diff --git a/qodana.yaml b/qodana.yaml new file mode 100644 index 0000000000..84e3e499b9 --- /dev/null +++ b/qodana.yaml @@ -0,0 +1,29 @@ +#-------------------------------------------------------------------------------# +# Qodana analysis is configured by qodana.yaml file # +# https://www.jetbrains.com/help/qodana/qodana-yaml.html # +#-------------------------------------------------------------------------------# +version: "1.0" + +#Specify inspection profile for code analysis +profile: + name: qodana.starter + +#Enable inspections +#include: +# - name: + +#Disable inspections +#exclude: +# - name: +# paths: +# - + +#Execute shell command before Qodana execution (Applied in CI/CD pipeline) +#bootstrap: sh ./prepare-qodana.sh + +#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline) +#plugins: +# - id: #(plugin id can be found at https://plugins.jetbrains.com) + +#Specify Qodana linter for analysis (Applied in CI/CD pipeline) +linter: jetbrains/qodana-python:latest diff --git a/sickchill/gui/slick/views/addShows_popularShows.mako b/sickchill/gui/slick/views/addShows_popularShows.mako index c56fa6d4a5..5ba74deb8f 100644 --- a/sickchill/gui/slick/views/addShows_popularShows.mako +++ b/sickchill/gui/slick/views/addShows_popularShows.mako @@ -45,7 +45,6 @@
- <% imdb_tt = {show.imdb_id for show in settings.showList if show.imdb_id} %>
% if not popular_shows: @@ -56,18 +55,6 @@
% else: % for current_result in popular_shows: - % if not current_result.getID(): - <% continue %> - % endif - - <% current_imdb_id = 'tt' + current_result.getID() %> - % if current_imdb_id in imdb_tt: - <% continue %> - % endif - - <% current_result.setdefault('rating', '0.0') %> - <% current_result.setdefault('votes', '0') %> -
diff --git a/sickchill/gui/slick/views/config_providers.mako b/sickchill/gui/slick/views/config_providers.mako index f4ffa88432..642fed3cb4 100644 --- a/sickchill/gui/slick/views/config_providers.mako +++ b/sickchill/gui/slick/views/config_providers.mako @@ -18,13 +18,13 @@ } }); % if settings.USE_NZBS: - % for curNewznabProvider in settings.newznab_provider_list: - $(this).addProvider('${curNewznabProvider.get_id()}', '${curNewznabProvider.name}', '${curNewznabProvider.url}', '${curNewznabProvider.key}', '${curNewznabProvider.catIDs}', ${int(curNewznabProvider.default)}); + % for provider in settings.newznab_provider_list: + $(this).addProvider('${provider.get_id()}', '${provider.name}', '${provider.url}', '${provider.key}', '${provider.categories}', ${int(provider.default)}); % endfor % endif % if settings.USE_TORRENTS: - % for curTorrentRssProvider in settings.torrent_rss_provider_list: - $(this).addTorrentRssProvider('${curTorrentRssProvider.get_id()}', '${curTorrentRssProvider.name}', '${curTorrentRssProvider.url}', '${curTorrentRssProvider.cookies}', '${curTorrentRssProvider.titleTAG}'); + % for provider in settings.torrent_rss_provider_list: + $(this).addTorrentRssProvider('${provider.get_id()}', '${provider.name}', '${provider.url}', '${provider.cookies}', '${provider.titleTAG}'); % endfor % endif }); @@ -57,7 +57,7 @@ % if not settings.USE_NZBS or not settings.USE_TORRENTS:
NZB/${_('Torrent and NZB providers can be toggled in ')} - Search Settings
+ Search Settings % else:
% endif @@ -73,32 +73,22 @@
    - % for curProvider in providers.sorted_provider_list(): + % for provider in providers.sorted_provider_list(only_enabled=True): <% - if curProvider.provider_type == GenericProvider.NZB and not settings.USE_NZBS: - continue # noinspection - elif curProvider.provider_type == GenericProvider.TORRENT and not settings.USE_TORRENTS: - continue - - curName = curProvider.get_id() - if hasattr(curProvider, 'custom_url'): - curURL = curProvider.custom_url or curProvider.url + if provider.has_option('custom_url'): + provider_url = provider.custom_url or provider.url else: - curURL = curProvider.url + provider_url = provider.url %> -
  • - - - ${curProvider.name} +
  • + + + ${provider.name} - - ${('*', '')[curProvider.can_backlog]} - ${('!', '')[curProvider.can_daily]} + + ${('*', '')[provider.can_backlog]} ${('!', '')[provider.can_daily]} - +
  • % endfor
@@ -128,40 +118,32 @@
<% - provider_config_list = [] - for curProvider in providers.sorted_provider_list(): - if curProvider.provider_type == GenericProvider.NZB and not (settings.USE_NZBS and curProvider.is_enabled): - continue - elif curProvider.provider_type == GenericProvider.TORRENT and not (settings.USE_TORRENTS and curProvider.is_enabled): - continue - provider_config_list.append(curProvider) + provider_config_list = providers.sorted_provider_list(only_enabled = True) %> - % if provider_config_list: + % if any(provider.is_enabled for provider in provider_config_list): % else: - + % endif
- % for curNewznabProvider in settings.newznab_provider_list: -
- % if curNewznabProvider.default and curNewznabProvider.needs_auth: + % for provider in settings.newznab_provider_list: +
+ % if provider.default and provider.needs_auth:
- +
@@ -170,52 +152,42 @@
- +
% endif - % if hasattr(curNewznabProvider, 'enable_daily'): + % if provider.has_option('enable_daily'):
- - - % if not curNewznabProvider.can_daily: + + + % if not provider.can_daily:

${_('Daily search is currently not working on this provider')}

% endif
% endif - % if hasattr(curNewznabProvider, 'enable_backlog'): -
+ % if provider.has_option('enable_backlog'): +
- - - % if not curNewznabProvider.can_backlog: + + + % if not provider.can_backlog:

${_('Backlog search is currently not working on this provider')}

% endif
% endif - % if hasattr(curNewznabProvider, 'search_mode'): + % if provider.has_option('search_mode'):
@@ -228,33 +200,30 @@
- - + +
- - + +
% endif - % if hasattr(curNewznabProvider, 'search_fallback'): + % if provider.has_option('search_fallback'):
- - + +
% endif @@ -262,73 +231,61 @@
% endfor - % for curNzbProvider in [curProvider for curProvider in providers.sorted_provider_list() if curProvider.provider_type == GenericProvider.NZB and curProvider not in settings.newznab_provider_list]: -
- % if hasattr(curNzbProvider, 'username'): + % for provider in [provider for provider in providers.sorted_provider_list() if provider.provider_type == GenericProvider.NZB and provider not in settings.newznab_provider_list]: +
+ % if provider.has_option('username'):
- +
% endif - % if hasattr(curNzbProvider, 'api_key'): + % if provider.has_option('api_key'):
- +
% endif - % if hasattr(curNzbProvider, 'enable_daily'): + % if provider.has_option('enable_daily'):
- - - % if not curNzbProvider.can_daily: + + + % if not provider.can_daily:

${_('Daily search is currently not working on this provider')}

% endif
% endif - % if hasattr(curNzbProvider, 'enable_backlog'): + % if provider.has_option('enable_backlog'):
- - - % if not curNzbProvider.can_backlog: + + + % if not provider.can_backlog:

${_('Backlog search is currently not working on this provider')}

% endif
% endif - % if hasattr(curNzbProvider, 'search_mode'): + % if provider.has_option('search_mode'):
@@ -341,33 +298,30 @@
- - + +
- - + +
% endif - % if hasattr(curNzbProvider, 'search_fallback'): + % if provider.has_option('search_fallback'):
- - + +
% endif @@ -375,109 +329,88 @@
% endfor - % for curTorrentProvider in [curProvider for curProvider in providers.sorted_provider_list() if curProvider.provider_type == GenericProvider.TORRENT]: -
+ % for provider in [provider for provider in providers.sorted_provider_list() if provider.provider_type == GenericProvider.TORRENT]: +
- % if hasattr(curTorrentProvider, 'custom_url'): + % if provider.has_option('custom_url'):
- - + +
% endif - % if hasattr(curTorrentProvider, 'api_key'): + % if provider.has_option('api_key'):
- +
% endif - % if hasattr(curTorrentProvider, 'digest'): + % if provider.has_option('digest'):
- +
% endif - % if hasattr(curTorrentProvider, 'hash'): + % if provider.has_option('hash'):
- +
% endif - % if hasattr(curTorrentProvider, 'username'): + % if provider.has_option('username'):
- +
% endif - % if hasattr(curTorrentProvider, 'password'): + % if provider.has_option('password'):
- +
% endif - % if hasattr(curTorrentProvider, 'passkey'): + % if provider.has_option('passkey'):
- +
% endif - % if curTorrentProvider.enable_cookies: + % if provider.enable_cookies:
@@ -485,16 +418,12 @@
- +
-
% endif - % if hasattr(curTorrentProvider, 'pin'): + % if provider.has_option('pin'):
- +
% endif - % if hasattr(curTorrentProvider, 'ratio'): + % if provider.has_option('ratio'):
- +
- +
- +
% endif - % if hasattr(curTorrentProvider, 'minseed'): + % if provider.has_option('minseed'):
- +
- +
% endif - % if hasattr(curTorrentProvider, 'minleech'): + % if provider.has_option('minleech'):
- +
- +
% endif - % if hasattr(curTorrentProvider, 'confirmed'): + % if provider.has_option('confirmed'):
- - + +
% endif - % if hasattr(curTorrentProvider, 'ranked'): + % if provider.has_option('ranked'):
- - + +
% endif - % if hasattr(curTorrentProvider, 'engrelease'): + % if provider.has_option('engrelease'):
- - + +
% endif - % if hasattr(curTorrentProvider, 'onlyspasearch'): + % if provider.has_option('onlyspasearch'):
- - + +
% endif - % if hasattr(curTorrentProvider, 'sorting'): + % if provider.has_option('sorting'):
- % for curAction in ('last', 'seeders', 'leechers'): - + % endfor
% endif - % if hasattr(curTorrentProvider, 'freeleech'): + % if provider.has_option('freeleech'):
- - + +
% endif - % if hasattr(curTorrentProvider, 'enable_daily'): + % if provider.has_option('enable_daily'):
- - - % if not curTorrentProvider.can_daily: + + + % if not provider.can_daily:

${_('Daily search is currently not working on this provider')}

% endif
% endif - % if hasattr(curTorrentProvider, 'enable_backlog'): + % if provider.has_option('enable_backlog'):
- + - - % if not curTorrentProvider.can_backlog: + + % if not provider.can_backlog:

${_('Backlog search is currently not working on this provider')}

% endif
% endif - % if hasattr(curTorrentProvider, 'search_mode'): + % if provider.has_option('search_mode'):
@@ -701,62 +606,57 @@
- - + +
- - + +
% endif - % if hasattr(curTorrentProvider, 'search_fallback'): + % if provider.has_option('search_fallback'):
- - + +
% endif - % if hasattr(curTorrentProvider, 'cat') and curTorrentProvider.get_id() == 'tntvillage': + % if provider.has_option('cat'):
- + % for i in provider.category_dict.values(): + % endfor
% endif - % if hasattr(curTorrentProvider, 'subtitle') and curTorrentProvider.get_id() == 'tntvillage': + % if provider.has_option('subtitle'):
- - + +
% endif @@ -801,8 +701,7 @@
- +
@@ -811,8 +710,7 @@
- +
@@ -822,9 +720,7 @@
- +
diff --git a/sickchill/gui/slick/views/home.mako b/sickchill/gui/slick/views/home.mako index dedcb07290..788b0b1b93 100644 --- a/sickchill/gui/slick/views/home.mako +++ b/sickchill/gui/slick/views/home.mako @@ -10,48 +10,48 @@ <%include file="/inc_home_menu.mako" /> - % if settings.ANIME_SPLIT_HOME: - % if settings.ANIME_SPLIT_HOME_IN_TABS: - -
- -
    - % for curShowlist in sortedShowLists: - % if curShowlist[1]: -
  • ${curShowlist[0]}
  • - % endif - % endfor -
- -
- % endif - % for curShowlist in sortedShowLists: - % if curShowlist[1]: - <% curListType = curShowlist[0] %> -
-
-
- % if not settings.ANIME_SPLIT_HOME_IN_TABS: -

${(_('Shows'), _('Anime'))[curListType == "Anime"]}

- % endif - % if settings.HOME_LAYOUT == 'poster': -
- % endif -
-
- <%include file="/inc_home_show_list.mako" args="curListType=curListType, myShowList=curShowlist[1]" /> -
-
-
-
-
- % endif - % endfor - % if settings.ANIME_SPLIT_HOME_IN_TABS: -
-
- % endif - % else: + % if settings.ANIME_SPLIT_HOME: + % if settings.ANIME_SPLIT_HOME_IN_TABS: + +
+ +
    + % for curShowlist in sortedShowLists: + % if curShowlist[1]: +
  • ${curShowlist[0]}
  • + % endif + % endfor +
+ +
+ % endif + % for curShowlist in sortedShowLists: + % if curShowlist[1]: + <% curListType = curShowlist[0] %> +
+
+
+ % if not settings.ANIME_SPLIT_HOME_IN_TABS: +

${(_('Shows'), _('Anime'))[curListType == "Anime"]}

+ % endif + % if settings.HOME_LAYOUT == 'poster': +
+ % endif +
+
+ <%include file="/inc_home_show_list.mako" args="curListType=curListType, myShowList=curShowlist[1]" /> +
+
+
+
+
+ % endif + % endfor + % if settings.ANIME_SPLIT_HOME_IN_TABS: +
+
+ % endif + % else:
@@ -61,7 +61,7 @@ % for curShowlist in sortedShowLists:
- <%include file="/inc_home_show_list.mako" args="curListType=curShowlist[0], myShowList=curShowlist[1]" /> + <%include file="/inc_home_show_list.mako" args="curListType=curShowlist[0], myShowList=curShowlist[1]" />
% endfor diff --git a/sickchill/gui/slick/views/home_massAddTable.mako b/sickchill/gui/slick/views/home_massAddTable.mako index e40fff4ceb..4074d034ae 100644 --- a/sickchill/gui/slick/views/home_massAddTable.mako +++ b/sickchill/gui/slick/views/home_massAddTable.mako @@ -6,19 +6,16 @@ - - - - - + + + + + - % for curDir in dirList: + % for curDir in filter(lambda x: x["added_already"], dirList): <% - if curDir['added_already']: - continue - indexer = 0 show_id = curDir['dir'] if curDir['existing_info'][0]: diff --git a/sickchill/gui/slick/views/inc_home_show_list_poster.mako b/sickchill/gui/slick/views/inc_home_show_list_poster.mako index 32a6e796ac..f5cd44cd11 100644 --- a/sickchill/gui/slick/views/inc_home_show_list_poster.mako +++ b/sickchill/gui/slick/views/inc_home_show_list_poster.mako @@ -1,6 +1,7 @@ <%! from sickchill import settings import calendar + from sickchill.oldbeard.filters import filter_shows_being_removed from sickchill.oldbeard import scdatetime, network_timezones from sickchill.helper.common import pretty_file_size import os @@ -45,23 +46,20 @@ % endfor - % for curShow in myShowList: - <% - if settings.showQueueScheduler.action.is_in_remove_queue(curShow) or settings.showQueueScheduler.action.is_being_removed(curShow): - continue - - cur_airs_next = '' - cur_snatched = 0 - cur_downloaded = 0 - cur_total = 0 - download_stat_tip = '' - display_status = curShow.status - - if display_status: - if re.search(r'(?i)(?:new|returning)\s*series', curShow.status): - display_status = 'Continuing' - elif re.search(r'(?i)(?:nded)', curShow.status): - display_status = 'Ended' + % for curShow in filter_shows_being_removed(myShowList): + <% + cur_airs_next = '' + cur_snatched = 0 + cur_downloaded = 0 + cur_total = 0 + download_stat_tip = '' + display_status = curShow.status + + if display_status: + if re.search(r'(?i)(?:new|returning)\s*series', curShow.status): + display_status = 'Continuing' + elif re.search(r'(?i)(?:nded)', curShow.status): + display_status = 'Ended' if curShow.paused: display_status = _(display_status) + ' ' + _('Paused') @@ -95,8 +93,8 @@ if cur_airs_next: data_date = calendar.timegm(scdatetime.scdatetime.convert_to_setting(network_timezones.parse_date_time(cur_airs_next, curShow.airs, curShow.network)).timetuple()) -## elif cur_airs_prev: -## data_date = calendar.timegm(scdatetime.scdatetime.convert_to_setting(network_timezones.parse_date_time(cur_airs_prev, curShow.airs, curShow.network)).timetuple()) + # elif cur_airs_prev: + # data_date = calendar.timegm(scdatetime.scdatetime.convert_to_setting(network_timezones.parse_date_time(cur_airs_prev, curShow.airs, curShow.network)).timetuple()) elif display_status: if display_status.startswith('Continuing'): data_date = '5000000000.0' diff --git a/sickchill/oldbeard/config.py b/sickchill/oldbeard/config.py index 3e671c1988..b697470bb5 100644 --- a/sickchill/oldbeard/config.py +++ b/sickchill/oldbeard/config.py @@ -907,7 +907,7 @@ def __init__(self, config_obj): 1: "Custom naming", 2: "Sync backup number with version number", 3: "Rename omgwtfnzb variables", - 4: "Add newznab catIDs", + 4: "Add newznab categories", 5: "Metadata update", 6: "Convert from XBMC to new KODI variables", 7: "Use version 2 for password encryption", @@ -1071,7 +1071,7 @@ def _migrate_v3(self): settings.OMGWTFNZBS_USERNAME = check_setting_str(self.config_obj, "omgwtfnzbs", "omgwtfnzbs_uid") settings.OMGWTFNZBS_APIKEY = check_setting_str(self.config_obj, "omgwtfnzbs", "omgwtfnzbs_key") - # Migration v4: Add default newznab catIDs + # Migration v4: Add default newznab categories def _migrate_v4(self): """Update newznab providers so that the category IDs can be set independently via the config""" @@ -1092,11 +1092,11 @@ def _migrate_v4(self): key = "0" if name == "NZBs.org": - catIDs = "5030,5040,5060,5070,5090" + categories = "5030,5040,5060,5070,5090" else: - catIDs = "5030,5040,5060" + categories = "5030,5040,5060" - cur_provider_data_list = [name, url, key, catIDs, enabled] + cur_provider_data_list = [name, url, key, categories, enabled] new_newznab_data.append("|".join(cur_provider_data_list)) settings.NEWZNAB_DATA = "!!!".join(new_newznab_data) diff --git a/sickchill/oldbeard/filters.py b/sickchill/oldbeard/filters.py index e36dc8be67..937fc14a2f 100644 --- a/sickchill/oldbeard/filters.py +++ b/sickchill/oldbeard/filters.py @@ -1,3 +1,6 @@ +from sickchill import settings + + def hide(value): return "hidden_value" if value else "" @@ -28,3 +31,11 @@ def selected(condition: bool) -> str: if condition: return "selected" return "" + + +def filter_shows_being_removed(show_list): + return { + show + for show in show_list + if not (settings.showQueueScheduler.action.is_in_remove_queue(show) or settings.showQueueScheduler.action.is_being_removed(show)) + } diff --git a/sickchill/oldbeard/providers/__init__.py b/sickchill/oldbeard/providers/__init__.py index cf72465330..e1c4a8deaa 100644 --- a/sickchill/oldbeard/providers/__init__.py +++ b/sickchill/oldbeard/providers/__init__.py @@ -132,26 +132,36 @@ ] -def sorted_provider_list(randomize=False) -> List[Union[TorrentProvider, NZBProvider, TorrentRssProvider, NZBProvider, GenericProvider]]: - initialList = settings.providerList + settings.newznab_provider_list + settings.torrent_rss_provider_list - provider_dict = {x.get_id(): x for x in initialList} +def sorted_provider_list(randomize=False, only_enabled=False) -> List[Union[TorrentProvider, NZBProvider, TorrentRssProvider, NZBProvider, GenericProvider]]: + provider_types = List[Union[GenericProvider, TorrentProvider, NZBProvider, TorrentRssProvider]] + initial_list: provider_types = settings.providerList + settings.newznab_provider_list + settings.torrent_rss_provider_list - new_provider_list = [] + provider_dict = {x.get_id(): x for x in initial_list} + + new_provider_list: provider_types = [] # add all modules in the priority list, in order - for current_module in settings.PROVIDER_ORDER: - if current_module in provider_dict: - new_provider_list.append(provider_dict[current_module]) + for provider_id in settings.PROVIDER_ORDER: + if provider_id in provider_dict: + new_provider_list.append(provider_dict[provider_id]) # add all enabled providers first - for current_module in provider_dict: - if provider_dict[current_module] not in new_provider_list and provider_dict[current_module].is_enabled: - new_provider_list.append(provider_dict[current_module]) + for module in provider_dict.values(): + if module not in new_provider_list and module.is_active: + new_provider_list.append(module) # add any modules that are missing from that list - for current_module in provider_dict: - if provider_dict[current_module] not in new_provider_list: - new_provider_list.append(provider_dict[current_module]) + for module in provider_dict.values(): + if module not in new_provider_list: + new_provider_list.append(module) + + if only_enabled: + new_provider_list = [ + module + for module in new_provider_list + if (module.provider_type == GenericProvider.TORRENT and settings.USE_TORRENTS) + or (module.provider_type == GenericProvider.NZB and settings.USE_NZBS) + ] if randomize: shuffle(new_provider_list) diff --git a/sickchill/oldbeard/providers/eztv.py b/sickchill/oldbeard/providers/eztv.py index fd7e73dd08..7186f8d0f0 100644 --- a/sickchill/oldbeard/providers/eztv.py +++ b/sickchill/oldbeard/providers/eztv.py @@ -35,11 +35,11 @@ def search(self, search_strings, episode_object=None): logger.debug(_("Search Mode: {mode}").format(mode=mode)) if mode != "RSS": - if not (self.show and self.show.imdb_id): + if not (episode_object and episode_object.show and episode_object.show.imdb_id): continue - search_params["imdb_id"] = self.show.imdb_id.strip("tt") - logger.debug("Search string: {}".format(self.show.imdb_id)) + search_params["imdb_id"] = episode_object.show.imdb_id.strip("tt") + logger.debug("Search string: {}".format(episode_object.show.imdb_id)) else: search_params.pop("imdb_id") diff --git a/sickchill/oldbeard/providers/newznab.py b/sickchill/oldbeard/providers/newznab.py index e7d416ead7..04fe62e59e 100644 --- a/sickchill/oldbeard/providers/newznab.py +++ b/sickchill/oldbeard/providers/newznab.py @@ -17,7 +17,7 @@ class NewznabProvider(NZBProvider, tvcache.RSSTorrentMixin): Tested with: newznab, nzedb, spotweb, torznab """ - def __init__(self, name, url, key="0", catIDs="5030,5040", search_mode="episode", search_fallback=False, enable_daily=True, enable_backlog=False): + def __init__(self, name, url, key="0", categories="5030,5040", search_mode="episode", search_fallback=False, enable_daily=True, enable_backlog=False): super().__init__(name) self.url = url @@ -32,7 +32,7 @@ def __init__(self, name, url, key="0", catIDs="5030,5040", search_mode="episode" self.needs_auth = self.key != "0" self.public = not self.needs_auth - self.catIDs = catIDs if catIDs else "5030,5040" + self.categories = categories if categories else "5030,5040" self.default = False @@ -49,7 +49,7 @@ def config_string(self): """ Generates a '|' delimited string of instance attributes, for saving to config.ini """ - return f"{self.name}|{self.url}|{self.key}|{self.catIDs}|{self.enabled:d}|{self.search_mode}|{self.search_fallback:d}|{self.enable_daily:d}|{self.enable_backlog:d}" + return f"{self.name}|{self.url}|{self.key}|{self.categories}|{self.enabled:d}|{self.search_mode}|{self.search_fallback:d}|{self.enable_daily:d}|{self.enable_backlog:d}" @staticmethod def providers_list(data): @@ -83,8 +83,8 @@ def providers_list(data): providers_dict[default.name].search_fallback = default.search_fallback providers_dict[default.name].enable_daily = default.enable_daily providers_dict[default.name].enable_backlog = default.enable_backlog - providers_dict[default.name].catIDs = ( - ",".join([x for x in providers_dict[default.name].catIDs.split(",") if 5000 <= try_int(x) <= 5999]) or default.catIDs + providers_dict[default.name].categories = ( + ",".join([x for x in providers_dict[default.name].categories.split(",") if 5000 <= try_int(x) <= 5999]) or default.categories ) return [x for x in providers_list if x] @@ -175,7 +175,7 @@ def get_newznab_categories(self, just_caps=False): @staticmethod def _get_default_providers(): - # name|url|key|catIDs|enabled|search_mode|search_fallback|enable_daily|enable_backlog + # name|url|key|categories|enabled|search_mode|search_fallback|enable_daily|enable_backlog return ( "NZB.Cat|https://nzb.cat/||5030,5040,5010|0|episode|1|1|1!!!" + "NZBFinder.ws|https://nzbfinder.ws/||5030,5040,5010,5045|0|episode|1|1|1!!!" @@ -248,7 +248,7 @@ def _make_provider(config): name, url, key=key, - catIDs=category_ids, + categories=category_ids, search_mode=search_mode, search_fallback=search_fallback, enable_daily=enable_daily, @@ -279,7 +279,7 @@ def search(self, search_strings, episode_object=None): "t": ("search", "tvsearch")[bool(self.use_tv_search)], "limit": 100, "offset": 0, - "cat": self.catIDs.strip(", ") or "5030,5040", + "cat": self.categories.strip(", ") or "5030,5040", "maxage": settings.USENET_RETENTION, } diff --git a/sickchill/providers/GenericProvider.py b/sickchill/providers/GenericProvider.py index a832c42130..ac57e960d4 100644 --- a/sickchill/providers/GenericProvider.py +++ b/sickchill/providers/GenericProvider.py @@ -50,10 +50,10 @@ def __init__(self, name): self.anime_only = False self.bt_cache_urls = [ - # 'http://torcache.net/torrent/{torrent_hash}.torrent', - # 'http://torrentproject.se/torrent/{torrent_hash}.torrent', - "http://thetorrent.org/torrent/{torrent_hash}.torrent", - # 'http://btdig.com/torrent/{torrent_hash}.torrent', + # "http://torcache.net/torrent/{torrent_hash}.torrent", + # "http://torrentproject.se/torrent/{torrent_hash}.torrent", + # "http://thetorrent.org/torrent/{torrent_hash}.torrent", + # "http://btdig.com/torrent/{torrent_hash}.torrent", ("https://torrage.info/download?h={torrent_hash}", "https://torrage.info/torrent.php?h={torrent_hash}"), "https://itorrents.org/torrent/{torrent_hash}.torrent?title={torrent_name}", ] @@ -387,7 +387,7 @@ def make_id(name): if not name: return "" - return re.sub(r"[^\w\d_]", "_", str(name).strip().lower()) + return re.sub(r"[^\w_]", "_", str(name).strip().lower()) def search_rss(self, episodes): return self.cache.find_needed_episodes(episodes) @@ -499,7 +499,7 @@ def _get_title_and_url(self, item): @staticmethod def hash_from_magnet(magnet): try: - torrent_hash = re.findall(r"urn:btih:([\w]{32,40})", magnet)[0].upper() + torrent_hash = re.findall(r"urn:btih:(\w{32,40})", magnet)[0].upper() if len(torrent_hash) == 32: torrent_hash = b16encode(b32decode(torrent_hash)).upper() return torrent_hash @@ -557,7 +557,7 @@ def _verify_download(self, filename): def add_cookies_from_ui(self): """ Adds the cookies configured from UI to the providers requests session - :return: A tuple with the the (success result, and a descriptive message in str) + :return: A tuple with the result (success result, and a descriptive message in str) """ # This is the generic attribute used to manually add cookies for provider authentication @@ -606,31 +606,35 @@ def valid_url(url): def invalid_url(cls, url): return not cls.valid_url(url) + def __store_original_urls(self): + if not self.__original_url: + # make sure we keep a clean copy of the original base url, in case they reset the custom url + self.__original_url = self.url + + if not self.__original_urls: + # make sure we keep a clean copy of the original urls, in case they reset the custom url + self.__original_urls = copy.deepcopy(self.urls) + + def __restore_original_urls(self): + # custom_url removed/reset, set urls back to defaults + if hasattr(self, "__original_urls"): + self.urls = copy.deepcopy(self.__original_urls) + if hasattr(self, "__original_url"): + self.url = self.__original_url + def check_and_update_urls(self): - if hasattr(self, "custom_url") and self.custom_url: - if self.invalid_url(self.custom_url): - logger.warning(_("Invalid custom url: {0}").format(self.custom_url)) - return False - - if not (hasattr(self, "custom_url"), hasattr(self, "url") and hasattr(self, "urls")): - # if we don't have these attributes, we cant figure out how to update these magically - return False - - if not self.__original_url: - # make sure we keep a clean copy of the original base url, in case they reset the custom url - self.__original_url = self.url - - if not self.__original_urls: - # make sure we keep a clean copy of the original urls, in case they reset the custom url - self.__original_urls = copy.deepcopy(self.urls) - - for url in self.__original_urls: - # update each url in our urls to have the correct proxy url - self.urls[url] = urljoin(self.custom_url, self.__original_urls[url].split(self.__original_url)[1]) - else: - # custom_url removed/reset, set urls back to defaults - if hasattr(self, "__original_urls"): - self.urls = copy.deepcopy(self.__original_urls) - if hasattr(self, "__original_url"): - self.url = self.__original_url - return True + has_custom_url = False + custom_url_valid = True + if hasattr(self, "custom_url") and self.has_option("url") and self.has_option("urls"): + has_custom_url = bool(self.custom_url) + custom_url_valid = self.valid_url(self.custom_url) + if has_custom_url and custom_url_valid: + self.__store_original_urls() + + for url in self.__original_urls: + # update each url in our urls to have the correct proxy url + self.urls[url] = urljoin(self.custom_url, self.__original_urls[url].split(self.__original_url)[1]) + else: + self.__restore_original_urls() + + return (True, custom_url_valid)[has_custom_url] diff --git a/sickchill/show/History.py b/sickchill/show/History.py index 6ff1cfbac6..8ce3e5141c 100644 --- a/sickchill/show/History.py +++ b/sickchill/show/History.py @@ -12,6 +12,7 @@ if TYPE_CHECKING: from sickchill.tv import TVEpisode, TVShow from sickchill.oldbeard.subtitles import Scores + from sickchill.providers.GenericProvider import GenericProvider from sickchill.helper.common import remove_extension, try_int from sickchill.helper.exceptions import EpisodeNotFoundException @@ -35,15 +36,15 @@ def remove(self, items): """ query = "" + params = [] for item in items: if query: query += " OR " - query += "(date IN ({0}) AND showid = {1} " "AND season = {2} AND episode = {3})".format( - ",".join(item["dates"]), item["show_id"], item["season"], item["episode"] - ) + query += "(date IN (?) AND showid = ? AND season = ? AND episode = ?)" + params.extend([",".join(item["dates"]), item["show_id"], item["season"], item["episode"]]) - self.db.action("DELETE FROM history WHERE " + query) + self.db.action("DELETE FROM history WHERE " + query, params) def clear(self): """ @@ -76,7 +77,7 @@ def get(self, limit: int = 100, action: str = None): "SELECT action, date, episode, provider, h.quality, resource, season, show_name, showid " "FROM history h, tv_shows s " "WHERE h.showid = s.indexer_id " - ) + ) # DataSource: sickchill.db replacements = ",".join(["?"] * len(actions)) filter_sql = f"AND action IN ({replacements})" order_sql = "ORDER BY date DESC " @@ -119,7 +120,7 @@ def trim(self): if settings.USE_FAILED_DOWNLOADS: self.failed_db.action("DELETE FROM history WHERE date < ?", [back_thirty_days]) - def _logHistoryItem(self, action: int, showid: int, season: int, episode: int, quality: int, resource: str, provider, version=-1): + def _log_history_item(self, action: int, showid: int, season: int, episode: int, quality: int, resource: str, provider, version=-1): """ Insert a history item in DB @@ -132,6 +133,7 @@ def _logHistoryItem(self, action: int, showid: int, season: int, episode: int, q :param provider: provider used :param version: tracked version of file (defaults to -1) """ + # DataSource: sickchill.db return self.db.action( "INSERT INTO history (action, date, showid, season, episode, quality, resource, provider, version) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)", [action, datetime.today().strftime(self.date_format), showid, season, episode, quality, resource, provider, version], @@ -143,15 +145,15 @@ def log_snatch(self, result: SearchResult): :param result: search result object """ - providerClass = result.provider + provider_class: "GenericProvider" = result.provider show: "TVShow" = result.episodes[0].show - if providerClass: - provider = providerClass.name + if provider_class: + provider = provider_class.name else: provider = "unknown" for episode in result.episodes: - self._logHistoryItem( + self._log_history_item( Quality.compositeStatus(SNATCHED, result.quality), episode.show.indexerid, episode.season, @@ -186,7 +188,7 @@ def log_download(self, episode: "TVEpisode", filename: str, quality: int, group: :param group: Release group :param version: Version of file (defaults to -1) """ - self._logHistoryItem(episode.status, episode.show.indexerid, episode.season, episode.episode, quality, filename, group or -1, version) + self._log_history_item(episode.status, episode.show.indexerid, episode.season, episode.episode, quality, filename, group or -1, version) def log_subtitle(self, show: int, season: int, episode: int, status: int, subtitle: subliminal.subtitle.Subtitle, scores: "Scores"): """ @@ -197,14 +199,14 @@ def log_subtitle(self, show: int, season: int, episode: int, status: int, subtit :param episode: Show episode :param status: Status of download :param subtitle: Result object - # :param scores: Scores named tuple + :param scores: Scores named tuple """ if settings.SUBTITLES_HISTORY: logger.debug( f"[{subtitle.provider_name}] Subtitle score for {subtitle.id} is: {scores.res}/{scores.percent}% (min={scores.min}/{scores.min_percent})" ) status, quality = Quality.splitCompositeStatus(status) - self._logHistoryItem( + self._log_history_item( Quality.compositeStatus(SUBTITLED, quality), show, season, episode, quality, subtitle.language.opensubtitles, subtitle.provider_name ) @@ -218,7 +220,7 @@ def log_failed(self, episode_object: "TVEpisode", release: str, provider: str = """ status, quality = Quality.splitCompositeStatus(episode_object.status) - self._logHistoryItem( + self._log_history_item( Quality.compositeStatus(FAILED, quality), episode_object.show.indexerid, episode_object.season, episode_object.episode, quality, release, provider ) diff --git a/sickchill/start.py b/sickchill/start.py index 1e74cb5368..a8b0d06141 100644 --- a/sickchill/start.py +++ b/sickchill/start.py @@ -776,59 +776,59 @@ def path_leaf(path): curProvider.enabled = (curProvider.can_daily or curProvider.can_backlog) and check_setting_bool( settings.CFG, curProvider.get_id().upper(), curProvider.get_id() ) - if hasattr(curProvider, "custom_url"): + if curProvider.has_option("custom_url"): curProvider.custom_url = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_custom_url"), "", censor_log=True) - if hasattr(curProvider, "api_key"): + if curProvider.has_option("api_key"): curProvider.api_key = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_api_key"), censor_log=True) - if hasattr(curProvider, "hash"): + if curProvider.has_option("hash"): curProvider.hash = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_hash"), censor_log=True) - if hasattr(curProvider, "digest"): + if curProvider.has_option("digest"): curProvider.digest = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_digest"), censor_log=True) - if hasattr(curProvider, "username"): + if curProvider.has_option("username"): curProvider.username = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_username"), censor_log=True) - if hasattr(curProvider, "password"): + if curProvider.has_option("password"): curProvider.password = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_password"), censor_log=True) - if hasattr(curProvider, "passkey"): + if curProvider.has_option("passkey"): curProvider.passkey = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_passkey"), censor_log=True) - if hasattr(curProvider, "pin"): + if curProvider.has_option("pin"): curProvider.pin = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_pin"), censor_log=True) - if hasattr(curProvider, "confirmed"): + if curProvider.has_option("confirmed"): curProvider.confirmed = check_setting_bool(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_confirmed"), True) - if hasattr(curProvider, "ranked"): + if curProvider.has_option("ranked"): curProvider.ranked = check_setting_bool(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_ranked"), True) - if hasattr(curProvider, "engrelease"): + if curProvider.has_option("engrelease"): curProvider.engrelease = check_setting_bool(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_engrelease")) - if hasattr(curProvider, "onlyspasearch"): + if curProvider.has_option("onlyspasearch"): curProvider.onlyspasearch = check_setting_bool(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_onlyspasearch")) - if hasattr(curProvider, "sorting"): + if curProvider.has_option("sorting"): curProvider.sorting = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_sorting"), "seeders") - if hasattr(curProvider, "options"): + if curProvider.has_option("options"): curProvider.options = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_options"), "") - if hasattr(curProvider, "ratio"): + if curProvider.has_option("ratio"): curProvider.ratio = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_ratio"), "") - if hasattr(curProvider, "minseed"): + if curProvider.has_option("minseed"): curProvider.minseed = check_setting_int(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_minseed"), 1, min_val=0) - if hasattr(curProvider, "minleech"): + if curProvider.has_option("minleech"): curProvider.minleech = check_setting_int(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_minleech"), 0, min_val=0) - if hasattr(curProvider, "freeleech"): + if curProvider.has_option("freeleech"): curProvider.freeleech = check_setting_bool(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_freeleech")) - if hasattr(curProvider, "search_mode"): + if curProvider.has_option("search_mode"): curProvider.search_mode = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_search_mode"), "episode") - if hasattr(curProvider, "search_fallback"): + if curProvider.has_option("search_fallback"): curProvider.search_fallback = check_setting_bool(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_search_fallback")) - if hasattr(curProvider, "enable_daily"): + if curProvider.has_option("enable_daily"): curProvider.enable_daily = curProvider.can_daily and check_setting_bool( settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_enable_daily"), True ) - if hasattr(curProvider, "enable_backlog"): + if curProvider.has_option("enable_backlog"): curProvider.enable_backlog = curProvider.can_backlog and check_setting_bool( settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_enable_backlog"), curProvider.can_backlog ) - if hasattr(curProvider, "cat"): + if curProvider.has_option("cat"): curProvider.cat = check_setting_int(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_cat"), 0) - if hasattr(curProvider, "subtitle"): + if curProvider.has_option("subtitle"): curProvider.subtitle = check_setting_bool(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_subtitle")) - if hasattr(curProvider, "cookies"): + if curProvider.has_option("cookies"): curProvider.cookies = check_setting_str(settings.CFG, curProvider.get_id().upper(), curProvider.get_id("_cookies"), censor_log=True) providers.check_enabled_providers() @@ -1092,55 +1092,55 @@ def save_config(): for curProvider in providers.sorted_provider_list(): new_config[curProvider.get_id().upper()] = {} new_config[curProvider.get_id().upper()][curProvider.get_id()] = int(curProvider.enabled) - if hasattr(curProvider, "custom_url"): + if curProvider.has_option("custom_url"): new_config[curProvider.get_id().upper()][curProvider.get_id("_custom_url")] = curProvider.custom_url - if hasattr(curProvider, "digest"): + if curProvider.has_option("digest"): new_config[curProvider.get_id().upper()][curProvider.get_id("_digest")] = curProvider.digest - if hasattr(curProvider, "hash"): + if curProvider.has_option("hash"): new_config[curProvider.get_id().upper()][curProvider.get_id("_hash")] = curProvider.hash - if hasattr(curProvider, "api_key"): + if curProvider.has_option("api_key"): new_config[curProvider.get_id().upper()][curProvider.get_id("_api_key")] = curProvider.api_key - if hasattr(curProvider, "username"): + if curProvider.has_option("username"): new_config[curProvider.get_id().upper()][curProvider.get_id("_username")] = curProvider.username - if hasattr(curProvider, "password"): + if curProvider.has_option("password"): new_config[curProvider.get_id().upper()][curProvider.get_id("_password")] = helpers.encrypt(curProvider.password, settings.ENCRYPTION_VERSION) - if hasattr(curProvider, "passkey"): + if curProvider.has_option("passkey"): new_config[curProvider.get_id().upper()][curProvider.get_id("_passkey")] = curProvider.passkey - if hasattr(curProvider, "pin"): + if curProvider.has_option("pin"): new_config[curProvider.get_id().upper()][curProvider.get_id("_pin")] = curProvider.pin - if hasattr(curProvider, "confirmed"): + if curProvider.has_option("confirmed"): new_config[curProvider.get_id().upper()][curProvider.get_id("_confirmed")] = int(curProvider.confirmed) - if hasattr(curProvider, "ranked"): + if curProvider.has_option("ranked"): new_config[curProvider.get_id().upper()][curProvider.get_id("_ranked")] = int(curProvider.ranked) - if hasattr(curProvider, "engrelease"): + if curProvider.has_option("engrelease"): new_config[curProvider.get_id().upper()][curProvider.get_id("_engrelease")] = int(curProvider.engrelease) - if hasattr(curProvider, "onlyspasearch"): + if curProvider.has_option("onlyspasearch"): new_config[curProvider.get_id().upper()][curProvider.get_id("_onlyspasearch")] = int(curProvider.onlyspasearch) - if hasattr(curProvider, "sorting"): + if curProvider.has_option("sorting"): new_config[curProvider.get_id().upper()][curProvider.get_id("_sorting")] = curProvider.sorting - if hasattr(curProvider, "ratio"): + if curProvider.has_option("ratio"): new_config[curProvider.get_id().upper()][curProvider.get_id("_ratio")] = curProvider.ratio - if hasattr(curProvider, "minseed"): + if curProvider.has_option("minseed"): new_config[curProvider.get_id().upper()][curProvider.get_id("_minseed")] = int(curProvider.minseed) - if hasattr(curProvider, "minleech"): + if curProvider.has_option("minleech"): new_config[curProvider.get_id().upper()][curProvider.get_id("_minleech")] = int(curProvider.minleech) - if hasattr(curProvider, "options"): + if curProvider.has_option("options"): new_config[curProvider.get_id().upper()][curProvider.get_id("_options")] = curProvider.options - if hasattr(curProvider, "freeleech"): + if curProvider.has_option("freeleech"): new_config[curProvider.get_id().upper()][curProvider.get_id("_freeleech")] = int(curProvider.freeleech) - if hasattr(curProvider, "search_mode"): + if curProvider.has_option("search_mode"): new_config[curProvider.get_id().upper()][curProvider.get_id("_search_mode")] = curProvider.search_mode - if hasattr(curProvider, "search_fallback"): + if curProvider.has_option("search_fallback"): new_config[curProvider.get_id().upper()][curProvider.get_id("_search_fallback")] = int(curProvider.search_fallback) - if hasattr(curProvider, "enable_daily"): + if curProvider.has_option("enable_daily"): new_config[curProvider.get_id().upper()][curProvider.get_id("_enable_daily")] = int(curProvider.enable_daily and curProvider.can_daily) - if hasattr(curProvider, "enable_backlog"): + if curProvider.has_option("enable_backlog"): new_config[curProvider.get_id().upper()][curProvider.get_id("_enable_backlog")] = int(curProvider.enable_backlog and curProvider.can_backlog) - if hasattr(curProvider, "cat"): + if curProvider.has_option("cat"): new_config[curProvider.get_id().upper()][curProvider.get_id("_cat")] = int(curProvider.cat) - if hasattr(curProvider, "subtitle"): + if curProvider.has_option("subtitle"): new_config[curProvider.get_id().upper()][curProvider.get_id("_subtitle")] = int(curProvider.subtitle) - if hasattr(curProvider, "cookies"): + if curProvider.has_option("cookies"): new_config[curProvider.get_id().upper()][curProvider.get_id("_cookies")] = curProvider.cookies new_config.update( diff --git a/sickchill/tv.py b/sickchill/tv.py index 4bd53a1ec3..e97cd986a5 100644 --- a/sickchill/tv.py +++ b/sickchill/tv.py @@ -950,7 +950,8 @@ def deleteShow(self, full=False): action = ("delete", "trash")[settings.TRASH_REMOVE_SHOW] # remove self from show list - settings.showList = [x for x in settings.showList if int(x.indexerid) != self.indexerid] + if self in settings.showList: + settings.showList.remove(self) # clear the cache image_cache_dir = os.path.join(settings.CACHE_DIR, "images") diff --git a/sickchill/views/config/providers.py b/sickchill/views/config/providers.py index c72db2c0b8..f36144ee1b 100644 --- a/sickchill/views/config/providers.py +++ b/sickchill/views/config/providers.py @@ -33,12 +33,12 @@ def canAddNewznabProvider(name): provider_dict = {x.get_id(): x for x in settings.newznab_provider_list} - current_id = GenericProvider.make_id(name) + provider_id = GenericProvider.make_id(name) - if current_id in provider_dict: + if provider_id in provider_dict: return json.dumps({"error": "Provider Name already exists as " + name}) else: - return json.dumps({"success": current_id}) + return json.dumps({"success": provider_id}) @staticmethod def getNewznabCategories(name, url, key): @@ -121,47 +121,49 @@ def saveProviders(self): torrent_rss_string = self.get_body_argument("torrent_rss_string", default="") provider_order = self.get_body_argument("provider_order", default="") + print(provider_order) + for current_newznab_string in newznab_string.split("!!!"): if not current_newznab_string: continue - current_name, current_url, current_key, current_cat = current_newznab_string.split("|") - current_url = config.clean_url(current_url) - current_id = GenericProvider.make_id(current_name) + name, url, key, categories = current_newznab_string.split("|") + url = config.clean_url(url) + provider_id = GenericProvider.make_id(name) # if it does not already exist then add it - if current_id not in newznab_provider_dict: - new_provider = NewznabProvider(current_name, current_url, key=current_key, catIDs=current_cat) + if provider_id not in newznab_provider_dict: + new_provider = NewznabProvider(name, url, key=key, categories=categories) settings.newznab_provider_list.append(new_provider) - newznab_provider_dict[current_id] = new_provider + newznab_provider_dict[provider_id] = new_provider # set all params - newznab_provider_dict[current_id].name = current_name - newznab_provider_dict[current_id].url = current_url - newznab_provider_dict[current_id].key = current_key - newznab_provider_dict[current_id].catIDs = current_cat + newznab_provider_dict[provider_id].name = name + newznab_provider_dict[provider_id].url = url + newznab_provider_dict[provider_id].key = key + newznab_provider_dict[provider_id].categories = categories # a 0 in the key spot indicates that no key is needed - newznab_provider_dict[current_id].needs_auth = current_key and current_key != "0" - newznab_provider_dict[current_id].search_mode = self.get_body_argument(current_id + "_search_mode", "episode") - newznab_provider_dict[current_id].search_fallback = config.checkbox_to_value( - self.get_body_argument(current_id + "search_fallback", 0), value_on=1, value_off=0 + newznab_provider_dict[provider_id].needs_auth = key and key != "0" + newznab_provider_dict[provider_id].search_mode = self.get_body_argument(provider_id + "_search_mode", "episode") + newznab_provider_dict[provider_id].search_fallback = config.checkbox_to_value( + self.get_body_argument(provider_id + "search_fallback", 0), value_on=1, value_off=0 ) - newznab_provider_dict[current_id].enable_daily = config.checkbox_to_value( - self.get_body_argument(current_id + "enable_daily", 0), value_on=1, value_off=0 + newznab_provider_dict[provider_id].enable_daily = config.checkbox_to_value( + self.get_body_argument(provider_id + "enable_daily", 0), value_on=1, value_off=0 ) - newznab_provider_dict[current_id].enable_backlog = config.checkbox_to_value( - self.get_body_argument(current_id + "enable_backlog", 0), value_on=1, value_off=0 + newznab_provider_dict[provider_id].enable_backlog = config.checkbox_to_value( + self.get_body_argument(provider_id + "enable_backlog", 0), value_on=1, value_off=0 ) # mark it finished - finished_names.append(current_id) + finished_names.append(provider_id) # delete anything that is in the list that was not processed just now if newznab_string: - for current_provider in settings.newznab_provider_list: - if current_provider.get_id() not in finished_names: - settings.newznab_provider_list.remove(current_provider) - del newznab_provider_dict[current_provider.get_id()] + for provider in settings.newznab_provider_list: + if provider.get_id() not in finished_names: + settings.newznab_provider_list.remove(provider) + del newznab_provider_dict[provider.get_id()] torrent_rss_provider_dict = {x.get_id(): x for x in settings.torrent_rss_provider_list} @@ -172,83 +174,84 @@ def saveProviders(self): if not current_torrent_rss_provider_string: continue - current_name, current_url, current_cookies, current_title_tag = current_torrent_rss_provider_string.split("|") - current_url = config.clean_url(current_url) - current_id = GenericProvider.make_id(current_name) + name, url, current_cookies, current_title_tag = current_torrent_rss_provider_string.split("|") + url = config.clean_url(url) + provider_id = GenericProvider.make_id(name) # if it does not already exist then create it - if current_id not in torrent_rss_provider_dict: - new_provider = TorrentRssProvider(current_name, current_url, current_cookies, current_title_tag) + if provider_id not in torrent_rss_provider_dict: + new_provider = TorrentRssProvider(name, url, current_cookies, current_title_tag) settings.torrent_rss_provider_list.append(new_provider) - torrent_rss_provider_dict[current_id] = new_provider + torrent_rss_provider_dict[provider_id] = new_provider # update values - torrent_rss_provider_dict[current_id].name = current_name - torrent_rss_provider_dict[current_id].url = current_url - torrent_rss_provider_dict[current_id].cookies = current_cookies - torrent_rss_provider_dict[current_id].current_title_tag = current_title_tag + torrent_rss_provider_dict[provider_id].name = name + torrent_rss_provider_dict[provider_id].url = url + torrent_rss_provider_dict[provider_id].cookies = current_cookies + torrent_rss_provider_dict[provider_id].current_title_tag = current_title_tag # mark it finished - finished_names.append(current_id) + finished_names.append(provider_id) # delete anything that is in the list that was not processed just now if torrent_rss_string: - for current_provider in settings.torrent_rss_provider_list: - if current_provider.get_id() not in finished_names: - settings.torrent_rss_provider_list.remove(current_provider) - del torrent_rss_provider_dict[current_provider.get_id()] + for provider in settings.torrent_rss_provider_list: + if provider.get_id() not in finished_names: + settings.torrent_rss_provider_list.remove(provider) + del torrent_rss_provider_dict[provider.get_id()] # do the enable/disable enabled_provider_list = [] disabled_provider_list = [] - for current_id, current_enabled in (current_provider_string.split(":") for current_provider_string in provider_order.split()): - current_enabled = bool(try_int(current_enabled)) - current_provider_object = [x for x in sickchill.oldbeard.providers.sorted_provider_list() if x.get_id() == current_id and hasattr(x, "enabled")] + for provider_id, enabled in (provider.split(":") for provider in provider_order.split()): + enabled = bool(try_int(enabled)) + + current_provider_object = [x for x in sickchill.oldbeard.providers.sorted_provider_list() if x.get_id() == provider_id and hasattr(x, "enabled")] if current_provider_object: - current_provider_object[0].enabled = current_enabled + current_provider_object[0].enabled = enabled - if current_enabled: - enabled_provider_list.append(current_id) + if enabled: + enabled_provider_list.append(provider_id) else: - disabled_provider_list.append(current_id) + disabled_provider_list.append(provider_id) - if current_id in newznab_provider_dict: - newznab_provider_dict[current_id].enabled = current_enabled - elif current_id in torrent_rss_provider_dict: - torrent_rss_provider_dict[current_id].enabled = current_enabled + if provider_id in newznab_provider_dict: + newznab_provider_dict[provider_id].enabled = enabled + elif provider_id in torrent_rss_provider_dict: + torrent_rss_provider_dict[provider_id].enabled = enabled # dynamically load provider settings - for current_provider in sickchill.oldbeard.providers.sorted_provider_list(): - current_provider.check_set_option(self, "custom_url") - current_provider.check_set_option(self, "cookies") - - current_provider.check_set_option(self, "minseed", 0, int) - current_provider.check_set_option(self, "minleech", 0, int) - current_provider.check_set_option(self, "cat", 0, int) - current_provider.check_set_option(self, "digest", None) - current_provider.check_set_option(self, "hash", None) - current_provider.check_set_option(self, "api_key", None, unhide=True) - current_provider.check_set_option(self, "username", None, unhide=True) - current_provider.check_set_option(self, "password", None, unhide=True) - current_provider.check_set_option(self, "passkey", None, unhide=True) - current_provider.check_set_option(self, "pin", None, unhide=True) - - current_provider.check_set_option(self, "confirmed", False, cast=config.checkbox_to_value) - current_provider.check_set_option(self, "ranked", False, cast=config.checkbox_to_value) - current_provider.check_set_option(self, "engrelease", False, cast=config.checkbox_to_value) - current_provider.check_set_option(self, "onlyspasearch", False, cast=config.checkbox_to_value) - current_provider.check_set_option(self, "freeleech", False, cast=config.checkbox_to_value) - current_provider.check_set_option(self, "search_fallback", False, cast=config.checkbox_to_value) - current_provider.check_set_option(self, "enable_daily", False, cast=config.checkbox_to_value) # fix can_daily - current_provider.check_set_option(self, "enable_backlog", False, cast=config.checkbox_to_value) # fix can_backlog - current_provider.check_set_option(self, "subtitle", False, cast=config.checkbox_to_value) - - current_provider.check_set_option(self, "sorting", "seeders") - current_provider.check_set_option(self, "search_mode", "episode") - - current_provider.check_set_option(self, "ratio", 0, cast=lambda x: max(try_int(x), -1)) + for provider in sickchill.oldbeard.providers.sorted_provider_list(): + provider.check_set_option(self, "custom_url") + provider.check_set_option(self, "cookies") + + provider.check_set_option(self, "minseed", 0, int) + provider.check_set_option(self, "minleech", 0, int) + provider.check_set_option(self, "cat", 0, int) + provider.check_set_option(self, "digest", None) + provider.check_set_option(self, "hash", None) + provider.check_set_option(self, "api_key", None, unhide=True) + provider.check_set_option(self, "username", None, unhide=True) + provider.check_set_option(self, "password", None, unhide=True) + provider.check_set_option(self, "passkey", None, unhide=True) + provider.check_set_option(self, "pin", None, unhide=True) + + provider.check_set_option(self, "confirmed", False, cast=config.checkbox_to_value) + provider.check_set_option(self, "ranked", False, cast=config.checkbox_to_value) + provider.check_set_option(self, "engrelease", False, cast=config.checkbox_to_value) + provider.check_set_option(self, "onlyspasearch", False, cast=config.checkbox_to_value) + provider.check_set_option(self, "freeleech", False, cast=config.checkbox_to_value) + provider.check_set_option(self, "search_fallback", False, cast=config.checkbox_to_value) + provider.check_set_option(self, "enable_daily", False, cast=config.checkbox_to_value) # fix can_daily + provider.check_set_option(self, "enable_backlog", False, cast=config.checkbox_to_value) # fix can_backlog + provider.check_set_option(self, "subtitle", False, cast=config.checkbox_to_value) + + provider.check_set_option(self, "sorting", "seeders") + provider.check_set_option(self, "search_mode", "episode") + + provider.check_set_option(self, "ratio", 0, cast=lambda x: max(try_int(x), -1)) settings.NEWZNAB_DATA = "!!!".join([x.config_string() for x in settings.newznab_provider_list]) settings.PROVIDER_ORDER = enabled_provider_list + disabled_provider_list diff --git a/sickchill/views/manage/add_shows.py b/sickchill/views/manage/add_shows.py index c34b8623b4..90c328188f 100644 --- a/sickchill/views/manage/add_shows.py +++ b/sickchill/views/manage/add_shows.py @@ -314,6 +314,16 @@ def popularShows(self): t = PageTemplate(rh=self, filename="addShows_popularShows.mako") try: popular_shows = imdb_popular.fetch_popular_shows() + + popular_shows = { + show + for show in popular_shows + if show.getID() and show.getID().strip("tt") not in {show.imdb_id.strip("tt") for show in settings.showList if show.imdb_id} + } + for show in popular_shows: + show.setdefault("rating", "0.0") + show.setdefault("votes", "0") + imdb_exception = None except Exception as error: logger.warning(f"Could not get popular shows: {error}")
${_('Directory')}${_('Show Name (tvshow.nfo)')} - ${_('Indexer')}
${_('Directory')}${_('Show Name (tvshow.nfo)')} + ${_('Indexer')}