Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 16 additions & 11 deletions dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ alabaster==0.7.12
# via sphinx
astroid==2.11.2
# via pylint
atomicwrites==1.4.0
# via pytest
attrs==21.4.0
# via
# -c requirements.txt
Expand All @@ -20,16 +18,18 @@ black==22.3.0
# via -r dev-requirements.in
bleach==4.1.0
# via readme-renderer
boto3==1.21.28
boto3==1.24.26
# via -r dev-requirements.in
botocore==1.24.28
botocore==1.27.26
# via
# boto3
# s3transfer
certifi==2021.10.8
# via
# -c requirements.txt
# requests
cffi==1.15.1
# via cryptography
cfgv==3.3.1
# via pre-commit
charset-normalizer==2.0.12
Expand All @@ -47,16 +47,13 @@ codacy-coverage==1.3.11
colorama==0.4.4
# via
# -c requirements.txt
# click
# pylint
# pytest
# sphinx
# tqdm
# twine
coverage[toml]==6.2
# via
# -r dev-requirements.in
# pytest-cov
cryptography==37.0.4
# via secretstorage
dill==0.3.4
# via pylint
distlib==0.3.4
Expand Down Expand Up @@ -92,6 +89,10 @@ isort==5.10.1
# via
# -r dev-requirements.in
# pylint
jeepney==0.8.0
# via
# keyring
# secretstorage
jinja2==3.0.3
# via
# -c requirements.txt
Expand Down Expand Up @@ -146,14 +147,16 @@ py==1.11.0
# via
# pytest
# pytest-forked
pycparser==2.21
# via cffi
pygments==2.11.2
# via
# -c requirements.txt
# readme-renderer
# sphinx
pylint==2.13.2
# via -r dev-requirements.in
pyparsing==3.0.7
pyparsing==2.4.7
# via
# -c requirements.txt
# packaging
Expand Down Expand Up @@ -197,8 +200,10 @@ requests-toolbelt==0.9.1
# via twine
rfc3986==1.5.0
# via twine
s3transfer==0.5.2
s3transfer==0.6.0
# via boto3
secretstorage==3.3.2
# via keyring
six==1.16.0
# via
# -c requirements.txt
Expand Down
6 changes: 4 additions & 2 deletions flexget/components/managed_lists/lists/entry_list/db.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _entry_query(self, session, entry):
or_(
EntryListEntry.title == entry['title'],
and_(
EntryListEntry.original_url,
EntryListEntry.original_url.isnot(None),
EntryListEntry.original_url == entry['original_url'],
),
),
Expand Down Expand Up @@ -157,7 +157,9 @@ def add(self, entry):
if stored_entry:
# Refresh all the fields if we already have this entry
logger.debug('refreshing entry {}', entry)
stored_entry.entry = entry
new_entry = Entry(stored_entry.entry)
new_entry.update(entry)
stored_entry.entry = new_entry
else:
logger.debug('adding entry {} to list {}', entry, self._db_list(session).name)
stored_entry = EntryListEntry(entry=entry, entry_list_id=self._db_list(session).id)
Expand Down
16 changes: 10 additions & 6 deletions flexget/components/managed_lists/lists/radarr_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def request_delete_json(url, headers):
def request_post_json(url, headers, data):
"""Makes a POST request and returns the JSON response"""
try:
response = requests.post(url, headers=headers, data=data, timeout=10)
response = requests.post(url, headers=headers, json=data, timeout=10)
if response.status_code == 201:
return response.json()
else:
Expand Down Expand Up @@ -123,7 +123,7 @@ def __init__(self, api_key, base_url, port=None):
if parsed_base_url.port:
port = int(parsed_base_url.port)

self.api_url = "%s://%s:%s%s/api/" % (
self.api_url = "%s://%s:%s%s/api/v3/" % (
parsed_base_url.scheme,
parsed_base_url.netloc,
port,
Expand All @@ -132,7 +132,7 @@ def __init__(self, api_key, base_url, port=None):

def get_profiles(self):
"""Gets all profiles"""
request_url = self.api_url + "profile"
request_url = self.api_url + "qualityProfile"
headers = self._default_headers()
return request_get_json(request_url, headers)

Expand All @@ -147,7 +147,7 @@ def add_tag(self, label):
request_url = self.api_url + "tag"
headers = self._default_headers()
data = {"label": label}
return request_post_json(request_url, headers, json.dumps(data))
return request_post_json(request_url, headers, data)

def get_movies(self):
"""Gets all movies"""
Expand Down Expand Up @@ -220,7 +220,7 @@ def add_movie(
data["addOptions"] = add_options

try:
json_response = request_post_json(request_url, headers, json.dumps(data))
json_response = request_post_json(request_url, headers, data)
except RadarrRequestError as ex:
spec_ex = spec_exception_from_response_ex(ex)
if spec_ex:
Expand Down Expand Up @@ -395,6 +395,7 @@ def add(self, entry):
if result:
root_folders = self.service.get_root_folders()
root_folder_path = root_folders[0]["path"]
add_options = {'searchForMovie': True } if self.config.get('search') else None

try:
self.service.add_movie(
Expand All @@ -406,6 +407,7 @@ def add(self, entry):
result["tmdbId"],
root_folder_path,
monitored=self.config.get('monitored', False),
add_options=add_options,
tags=self.get_tag_ids(entry),
)
logger.verbose('Added movie {} to Radarr list', result['title'])
Expand Down Expand Up @@ -528,7 +530,7 @@ def _get_movie_entries(self):

# Check if we should add quality requirement
if self.config.get("include_data"):
movie_profile_id = movie["profileId"]
movie_profile_id = movie["qualityProfileId"]
for profile in profiles:
profile_id = profile["id"]
if profile_id == movie_profile_id:
Expand All @@ -544,6 +546,7 @@ def _get_movie_entries(self):
title=movie["title"],
url="",
radarr_id=movie["id"],
radarr_added=movie['added'],
movie_name=movie["title"],
movie_year=movie["year"],
)
Expand Down Expand Up @@ -619,6 +622,7 @@ class RadarrList:
"api_key": {"type": "string"},
"only_monitored": {"type": "boolean", "default": True},
"include_data": {"type": "boolean", "default": False},
"search": {"type": "boolean", "default": False},
"only_use_cutoff_quality": {"type": "boolean", "default": False},
"monitored": {"type": "boolean", "default": True},
"profile_id": {"type": "integer", "default": 1},
Expand Down
24 changes: 18 additions & 6 deletions flexget/components/managed_lists/lists/sonarr_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

SERIES_ENDPOINT = 'series'
LOOKUP_ENDPOINT = 'series/lookup'
PROFILE_ENDPOINT = 'profile'
PROFILE_ENDPOINT = 'qualityProfile'
ROOTFOLDER_ENDPOINT = 'Rootfolder'
DELETE_ENDPOINT = 'series/{}'

Expand All @@ -32,10 +32,11 @@ class SonarrSet(MutableSet):
'include_ended': {'type': 'boolean', 'default': True},
'only_monitored': {'type': 'boolean', 'default': True},
'include_data': {'type': 'boolean', 'default': False},
'search_missing_episodes': {'type': 'boolean', 'default': True},
'search_missing_episodes': {'type': 'string', 'enum': ['all', 'first_season', 'no']},
'ignore_episodes_without_files': {'type': 'boolean', 'default': False},
'ignore_episodes_with_files': {'type': 'boolean', 'default': False},
'profile_id': {'type': 'integer', 'default': 1},
'language_id': {'type': 'integer', 'default': 1},
'season_folder': {'type': 'boolean', 'default': False},
'monitored': {'type': 'boolean', 'default': True},
'root_folder_path': {'type': 'string'},
Expand All @@ -61,7 +62,7 @@ def _sonarr_request(self, endpoint, term=None, method='get', data=None):
base_url = self.config['base_url']
port = self.config['port']
base_path = self.config['base_path']
url = '{}:{}{}/api/{}'.format(base_url, port, base_path, endpoint)
url = '{}:{}{}/api/v3/{}'.format(base_url, port, base_path, endpoint)
headers = {'X-Api-Key': self.config['api_key']}
if term:
url += '?term={}'.format(term)
Expand Down Expand Up @@ -147,7 +148,7 @@ def list_entries(self, filters=True):
# Checks if to retrieve ended shows
if show['status'] == 'ended' and not self.config.get('include_ended'):
continue
profile = profiles_dict.get(show['profileId'])
profile = profiles_dict.get(show['qualityProfileId'])
if profile:
fg_qualities, fg_cutoff = self.quality_requirement_builder(profile)

Expand All @@ -158,9 +159,10 @@ def list_entries(self, filters=True):
tvdb_id=show.get('tvdbId'),
tvrage_id=show.get('tvRageId'),
tvmaze_id=show.get('tvMazeId'),
imdb_id=show.get('imdbid'),
imdb_id=show.get('imdbId'),
slug=show.get('titleSlug'),
sonarr_id=show.get('id'),
sonarr_added=show.get('added'),
)
if len(fg_qualities) > 1:
entry['configure_series_qualities'] = fg_qualities
Expand Down Expand Up @@ -207,6 +209,7 @@ def add_show(self, entry):
# Setting defaults for Sonarr
show['profileId'] = self.config.get('profile_id')
show['qualityProfileId'] = self.config.get('profile_id')
show['languageProfileId'] = self.config.get('language_id')
show['seasonFolder'] = self.config.get('season_folder')
show['monitored'] = self.config.get('monitored')
show['seriesType'] = self.config.get('series_type')
Expand All @@ -215,9 +218,18 @@ def add_show(self, entry):
show['addOptions'] = {
"ignoreEpisodesWithFiles": self.config.get('ignore_episodes_with_files'),
"ignoreEpisodesWithoutFiles": self.config.get('ignore_episodes_without_files'),
"searchForMissingEpisodes": self.config.get('search_missing_episodes'),
}

if self.config.get('searchForMissingEpisodes') == 'no':
show['addOptions']['searchForMissingEpisodes'] = False
elif self.config.get('searchForMissingEpisodes'):
show['addOptions']['searchForMissingEpisodes'] = True

if self.config.get('searchForMissingEpisodes') == 'first_season' and len(show['seasons']) > 1:
for season in show['seasons']:
if season['seasonNumber'] > 1:
season['monitored'] = False

logger.debug('adding show {} to sonarr', show)
returned_show = self._sonarr_request(SERIES_ENDPOINT, method='post', data=show)
return returned_show
Expand Down
Loading