diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6e8e072f79..7af07b011e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,7 @@ name: Build develop branch on: workflow_run: - workflows: [ "Python Packaging" ] + workflows: [Python Packaging] branches: | - develop type: diff --git a/sickchill/oldbeard/notifiers/nmj.py b/sickchill/oldbeard/notifiers/nmj.py index 42bc1d435a..46694f2ac9 100644 --- a/sickchill/oldbeard/notifiers/nmj.py +++ b/sickchill/oldbeard/notifiers/nmj.py @@ -1,5 +1,10 @@ import re -import telnetlib + +try: + import telnetlib +except (ImportError, ModuleNotFoundError): + telnetlib = None + import urllib.parse import urllib.request from xml.etree import ElementTree @@ -19,6 +24,9 @@ def notify_settings(host): """ # establish a terminal session to the PC + + if telnetlib is None: + logger.info("telnetlib was removed in python 3.13, use python 3.12, disable nmj, or update this script to use a new library") try: terminal = telnetlib.Telnet(host) except Exception: diff --git a/sickchill/oldbeard/providers/abnormal.py b/sickchill/oldbeard/providers/abnormal.py index d058481fbe..4b5123a930 100644 --- a/sickchill/oldbeard/providers/abnormal.py +++ b/sickchill/oldbeard/providers/abnormal.py @@ -58,7 +58,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/alpharatio.py b/sickchill/oldbeard/providers/alpharatio.py index c55752a8e8..3235f75f30 100644 --- a/sickchill/oldbeard/providers/alpharatio.py +++ b/sickchill/oldbeard/providers/alpharatio.py @@ -58,7 +58,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/archetorrent.py b/sickchill/oldbeard/providers/archetorrent.py index 604443829c..92e0c48c9a 100644 --- a/sickchill/oldbeard/providers/archetorrent.py +++ b/sickchill/oldbeard/providers/archetorrent.py @@ -59,7 +59,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/bitcannon.py b/sickchill/oldbeard/providers/bitcannon.py index 8f9b1a89b9..c029c8825c 100644 --- a/sickchill/oldbeard/providers/bitcannon.py +++ b/sickchill/oldbeard/providers/bitcannon.py @@ -17,7 +17,7 @@ def __init__(self): self.cache = tvcache.TVCache(self, search_params={"RSS": ["tv", "anime"]}) - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] url = "http://localhost:3000/" @@ -29,7 +29,7 @@ def search(self, search_strings, episode_object=None): search_params = {} - anime = episode_object and episode_object.show and episode_object.show.anime + anime = self.show and self.show.anime or False search_params["category"] = ("tv", "anime")[bool(anime)] if self.api_key: diff --git a/sickchill/oldbeard/providers/bjshare.py b/sickchill/oldbeard/providers/bjshare.py index c4977e1dfb..c45a0dca03 100644 --- a/sickchill/oldbeard/providers/bjshare.py +++ b/sickchill/oldbeard/providers/bjshare.py @@ -54,12 +54,11 @@ def __init__(self): # until they or the source from where they get that info fix it... self.absolute_numbering = ["One Piece", "Boruto: Naruto Next Generations"] - def search(self, search_strings, episode_object=None): + def search(self, search_strings): """ Search a provider and parse the results. :param search_strings: A dict with mode (key) and the search value (value) - :param episode_object: Information about the episode being searched (when not RSS) :returns: A list of search results (structure) """ @@ -67,9 +66,7 @@ def search(self, search_strings, episode_object=None): if not self.login(): return results - anime = False - if episode_object and episode_object.show: - anime = episode_object.show.anime == 1 + anime = self.show and self.show.anime == 1 or False search_params = {"order_by": "time", "order_way": "desc", "group_results": 0, "action": "basic", "searchsubmit": 1} diff --git a/sickchill/oldbeard/providers/btn.py b/sickchill/oldbeard/providers/btn.py index fce5af32f8..47cdb0a6af 100644 --- a/sickchill/oldbeard/providers/btn.py +++ b/sickchill/oldbeard/providers/btn.py @@ -47,7 +47,7 @@ def _check_auth_from_data(self, data): return True - def search(self, search_params, episode_object=None): + def search(self, search_params): self._check_auth() results = [] @@ -183,7 +183,7 @@ def get_season_search_strings(self, episode_object): search_params = {"category": "Season"} # Search for entire seasons: no need to do special things for air by date or sports shows - if episode_object.show.air_by_date or episode_object.show.sports: + if self.show.air_by_date or self.show.sports: # Search for the year of the air by date show search_params["name"] = str(episode_object.airdate).split("-")[0] else: @@ -199,7 +199,7 @@ def get_episode_search_strings(self, episode_object, add_string=""): search_params = {"category": "Episode"} # episode - if episode_object.show.air_by_date or episode_object.show.sports: + if self.show.air_by_date or self.show.sports: date_str = str(episode_object.airdate) # BTN uses dots in dates, we just search for the date since that diff --git a/sickchill/oldbeard/providers/cpasbien.py b/sickchill/oldbeard/providers/cpasbien.py index 2a4ec46bf6..e71a51eca8 100644 --- a/sickchill/oldbeard/providers/cpasbien.py +++ b/sickchill/oldbeard/providers/cpasbien.py @@ -10,7 +10,7 @@ class Provider(FrenchTorrentProvider): def __init__(self): super().__init__("Cpasbien", "https://www.cpasbien.ch") - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] for mode in search_strings: items = [] diff --git a/sickchill/oldbeard/providers/danishbits.py b/sickchill/oldbeard/providers/danishbits.py index b4f3c67ca6..998cd7df03 100644 --- a/sickchill/oldbeard/providers/danishbits.py +++ b/sickchill/oldbeard/providers/danishbits.py @@ -32,7 +32,7 @@ def __init__(self): # Cache self.cache = tvcache.TVCache(self, min_time=10) # Only poll Danishbits every 10 minutes max - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/demonoid.py b/sickchill/oldbeard/providers/demonoid.py index d1c54bccad..4cd9154869 100644 --- a/sickchill/oldbeard/providers/demonoid.py +++ b/sickchill/oldbeard/providers/demonoid.py @@ -30,7 +30,7 @@ def __init__(self): self.cache = DemonoidCache(self) - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] # https://demonoid.is/files/?category=12&quality=58&seeded=0&external=2&sort=seeders&order=desc&query=SEARCH_STRING search_params = { diff --git a/sickchill/oldbeard/providers/elitetorrent.py b/sickchill/oldbeard/providers/elitetorrent.py index 000cb722a5..5629f8f761 100644 --- a/sickchill/oldbeard/providers/elitetorrent.py +++ b/sickchill/oldbeard/providers/elitetorrent.py @@ -23,9 +23,9 @@ def __init__(self): self.url = self.urls["base_url"] - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] - lang_info = "" if not episode_object or not episode_object.show else episode_object.show.lang + lang_info = self.show and self.show.lang or "" """ Search query: diff --git a/sickchill/oldbeard/providers/eztv.py b/sickchill/oldbeard/providers/eztv.py index 36458edfad..87f09ab93d 100644 --- a/sickchill/oldbeard/providers/eztv.py +++ b/sickchill/oldbeard/providers/eztv.py @@ -25,7 +25,7 @@ def __init__(self): # Cache self.cache = tvcache.TVCache(self, min_time=30) # only poll ThePirateBay every 30 minutes max - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] search_params = {"imdb_id": None, "page": 1, "limit": 100} @@ -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 (episode_object and episode_object.show and episode_object.show.imdb_id): + if not (self.show and self.show.imdb_id): continue - search_params["imdb_id"] = episode_object.show.imdb_id.strip("tt") - logger.debug("Search string: {}".format(episode_object.show.imdb_id)) + search_params["imdb_id"] = self.show.imdb_id.strip("tt") + logger.debug("Search string: {}".format(self.show.imdb_id)) else: search_params.pop("imdb_id") diff --git a/sickchill/oldbeard/providers/filelist.py b/sickchill/oldbeard/providers/filelist.py index 8daebdd9aa..38639e4f01 100644 --- a/sickchill/oldbeard/providers/filelist.py +++ b/sickchill/oldbeard/providers/filelist.py @@ -53,7 +53,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/gimmepeers.py b/sickchill/oldbeard/providers/gimmepeers.py index 92cc580f84..1a2eba22a8 100644 --- a/sickchill/oldbeard/providers/gimmepeers.py +++ b/sickchill/oldbeard/providers/gimmepeers.py @@ -65,7 +65,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/hd4free.py b/sickchill/oldbeard/providers/hd4free.py index 4a75edd941..5a2717ccee 100644 --- a/sickchill/oldbeard/providers/hd4free.py +++ b/sickchill/oldbeard/providers/hd4free.py @@ -28,7 +28,7 @@ def _check_auth(self): logger.warning("Your authentication credentials for {0} are missing, check your config.".format(self.name)) return False - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self._check_auth: return results diff --git a/sickchill/oldbeard/providers/hdbits.py b/sickchill/oldbeard/providers/hdbits.py index be5f2caeef..2026baadd9 100644 --- a/sickchill/oldbeard/providers/hdbits.py +++ b/sickchill/oldbeard/providers/hdbits.py @@ -36,11 +36,11 @@ def _check_auth_from_data(parsed_json): return True def get_season_search_strings(self, episode_object): - season_search_string = [self.make_post_data_JSON(show=episode_object.show, season=episode_object)] + season_search_string = [self.make_post_data_JSON(show=self.show, season=episode_object)] return season_search_string def get_episode_search_strings(self, episode_object, add_string=""): - episode_search_string = [self.make_post_data_JSON(show=episode_object.show, episode=episode_object)] + episode_search_string = [self.make_post_data_JSON(show=self.show, episode=episode_object)] return episode_search_string def _get_title_and_url(self, item): @@ -49,11 +49,10 @@ def _get_title_and_url(self, item): return title, url - def search(self, search_params, episode_object=None): - # FIXME + def search(self, search_params): results = [] - logger.debug("Search string: {0}".format(search_params)) + logger.debug(f"Search string: {search_params}") self._check_auth() diff --git a/sickchill/oldbeard/providers/hdspace.py b/sickchill/oldbeard/providers/hdspace.py index f7401953b6..d4678aeb10 100644 --- a/sickchill/oldbeard/providers/hdspace.py +++ b/sickchill/oldbeard/providers/hdspace.py @@ -63,7 +63,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/hdtorrents.py b/sickchill/oldbeard/providers/hdtorrents.py index 74fe6ec8c0..d03523edbd 100644 --- a/sickchill/oldbeard/providers/hdtorrents.py +++ b/sickchill/oldbeard/providers/hdtorrents.py @@ -58,7 +58,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/hdtorrents_it.py b/sickchill/oldbeard/providers/hdtorrents_it.py index 0fe7694aac..6ea7c5ff68 100644 --- a/sickchill/oldbeard/providers/hdtorrents_it.py +++ b/sickchill/oldbeard/providers/hdtorrents_it.py @@ -58,7 +58,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/horriblesubs.py b/sickchill/oldbeard/providers/horriblesubs.py index 7c62b4c421..4d82b8e1be 100644 --- a/sickchill/oldbeard/providers/horriblesubs.py +++ b/sickchill/oldbeard/providers/horriblesubs.py @@ -24,7 +24,7 @@ def __init__(self): self.cache = tvcache.TVCache(self, min_time=15) # only poll HorribleSubs every 15 minutes max - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if self.show and not self.show.is_anime: return results diff --git a/sickchill/oldbeard/providers/hounddawgs.py b/sickchill/oldbeard/providers/hounddawgs.py index 2f33f520e7..507f863b42 100644 --- a/sickchill/oldbeard/providers/hounddawgs.py +++ b/sickchill/oldbeard/providers/hounddawgs.py @@ -65,7 +65,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/ilcorsaronero.py b/sickchill/oldbeard/providers/ilcorsaronero.py index 771811a395..f891f431ea 100644 --- a/sickchill/oldbeard/providers/ilcorsaronero.py +++ b/sickchill/oldbeard/providers/ilcorsaronero.py @@ -173,13 +173,13 @@ def _magnet_from_result(info_hash, title): hash=info_hash, title=quote_plus(title), trackers="http://tracker.tntvillage.scambioetico.org:2710/announce" ) - def search(self, search_params, episode_object=None): + def search(self, search_strings): results = [] - for mode in search_params: + for mode in search_strings: items = [] logger.debug(_("Search Mode: {mode}").format(mode=mode)) - for search_string in search_params[mode]: + for search_string in search_strings[mode]: if search_string == "": continue diff --git a/sickchill/oldbeard/providers/immortalseed.py b/sickchill/oldbeard/providers/immortalseed.py index b206ef1ec2..9adb4ff3bd 100644 --- a/sickchill/oldbeard/providers/immortalseed.py +++ b/sickchill/oldbeard/providers/immortalseed.py @@ -72,7 +72,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/iptorrents.py b/sickchill/oldbeard/providers/iptorrents.py index 66ec6d71e5..2a91e59e09 100644 --- a/sickchill/oldbeard/providers/iptorrents.py +++ b/sickchill/oldbeard/providers/iptorrents.py @@ -87,17 +87,17 @@ def login(self): return True - def search(self, search_params, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results freeleech = "&free=on" if self.freeleech else "" - for mode in search_params: + for mode in search_strings: items = [] logger.debug(_("Search Mode: {mode}").format(mode=mode)) - for search_string in search_params[mode]: + for search_string in search_strings[mode]: if mode != "RSS": logger.debug(_("Search String: {search_string}").format(search_string=search_string)) diff --git a/sickchill/oldbeard/providers/kat.py b/sickchill/oldbeard/providers/kat.py index 86ed40336f..d70ff7356d 100644 --- a/sickchill/oldbeard/providers/kat.py +++ b/sickchill/oldbeard/providers/kat.py @@ -37,14 +37,14 @@ def __init__(self): self.rows_selector = dict(class_=re.compile(r"even|odd"), id=re.compile(r"torrent_.*_torrents")) - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not (self.url and self.urls): self.find_domain() if not (self.url and self.urls): return results - anime = (self.show and self.show.anime) or (episode_object and episode_object.show and episode_object.show.anime) or False + anime = self.show and self.show.anime or False search_params = OrderedDict(field="seeders", sorder="desc", category=("tv", "anime")[anime]) for mode in search_strings: @@ -81,7 +81,7 @@ def search(self, search_strings, episode_object=None): return results # This will recurse a few times until all of the mirrors are exhausted if none of them work. - return self.search(search_strings, episode_object) + return self.search(search_strings) with BS4Parser(data) as html: labels = [cell.get_text() for cell in html.find(class_="firstr")("th")] diff --git a/sickchill/oldbeard/providers/limetorrents.py b/sickchill/oldbeard/providers/limetorrents.py index 28494da5ba..5e0dde6aa3 100644 --- a/sickchill/oldbeard/providers/limetorrents.py +++ b/sickchill/oldbeard/providers/limetorrents.py @@ -28,7 +28,7 @@ def __init__(self): self.cache = tvcache.TVCache(self, search_params={"RSS": ["rss"]}) - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] for mode in search_strings: items = [] diff --git a/sickchill/oldbeard/providers/magnetdl.py b/sickchill/oldbeard/providers/magnetdl.py index 7232d91c12..ce847b078b 100644 --- a/sickchill/oldbeard/providers/magnetdl.py +++ b/sickchill/oldbeard/providers/magnetdl.py @@ -24,7 +24,7 @@ def __init__(self): self.cache = tvcache.TVCache(self) - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] for mode in search_strings: diff --git a/sickchill/oldbeard/providers/morethantv.py b/sickchill/oldbeard/providers/morethantv.py index 9e0a429205..fc934f0ca0 100644 --- a/sickchill/oldbeard/providers/morethantv.py +++ b/sickchill/oldbeard/providers/morethantv.py @@ -69,7 +69,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/ncore.py b/sickchill/oldbeard/providers/ncore.py index 540113483f..5e942966db 100644 --- a/sickchill/oldbeard/providers/ncore.py +++ b/sickchill/oldbeard/providers/ncore.py @@ -48,7 +48,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/nebulance.py b/sickchill/oldbeard/providers/nebulance.py index 3e24ea477c..da79ea2365 100644 --- a/sickchill/oldbeard/providers/nebulance.py +++ b/sickchill/oldbeard/providers/nebulance.py @@ -61,7 +61,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/newpct.py b/sickchill/oldbeard/providers/newpct.py index 75fc344095..831ac9487b 100644 --- a/sickchill/oldbeard/providers/newpct.py +++ b/sickchill/oldbeard/providers/newpct.py @@ -19,7 +19,7 @@ def __init__(self): self.cache = tvcache.TVCache(self, min_time=20) - def search(self, search_strings, episode_object=None): + def search(self, search_strings): """ Search query: http://www.newpct.com/index.php?l=doSearch&q=fringe&category_=All&idioma_=1&bus_de_=All @@ -31,7 +31,7 @@ def search(self, search_strings, episode_object=None): results = [] # Only search if user conditions are true - lang_info = "" if not episode_object or not episode_object.show else episode_object.show.lang + lang_info = self.show and self.show.lang or "" search_params = {"l": "doSearch", "q": "", "category_": "All", "idioma_": 1, "bus_de_": "All"} diff --git a/sickchill/oldbeard/providers/newznab.py b/sickchill/oldbeard/providers/newznab.py index 04fe62e59e..9f3f7eab16 100644 --- a/sickchill/oldbeard/providers/newznab.py +++ b/sickchill/oldbeard/providers/newznab.py @@ -135,8 +135,7 @@ def get_newznab_categories(self, just_caps=False): """ Uses the newznab provider url and apikey to get the capabilities. Makes use of the default newznab caps param. e.a. http://yournewznab/api?t=caps&apikey=skdfiw7823sdkdsfjsfk - Returns a tuple with (succes or not, array with dicts [{'id': '5070', 'name': 'Anime'}, - {'id': '5080', 'name': 'Documentary'}, {'id': '5020', 'name': 'Foreign'}...etc}], error message) + Returns a tuple with (success or not, array with dicts [{'id': '5070', 'name': 'Anime'}], error message) """ return_categories = [] @@ -258,7 +257,7 @@ def _make_provider(config): return new_provider - def search(self, search_strings, episode_object=None): + def search(self, search_strings): """ Searches indexer using the params in search_strings, either for latest releases, or a string/id search Returns: list of results in dict form @@ -289,18 +288,15 @@ def search(self, search_strings, episode_object=None): if mode != "RSS": if self.use_tv_search: if "tvdbid" in str(self.cap_tv_search): - search_params["tvdbid"] = episode_object.show.indexerid - - if episode_object.show.air_by_date or episode_object.show.sports: - # date_str = str(episode_object.airdate) - # search_params['season'] = date_str.partition('-')[0] - # search_params['ep'] = date_str.partition('-')[2].replace('-', '/') - search_params["q"] = str(episode_object.airdate) - elif episode_object.show.is_anime: - search_params["ep"] = episode_object.absolute_number + search_params["tvdbid"] = self.show.indexerid + + if self.show.air_by_date or self.show.sports: + search_params["q"] = str(self.current_episode_object.airdate) + elif self.show.is_anime: + search_params["ep"] = self.current_episode_object.absolute_number else: - search_params["season"] = episode_object.scene_season - search_params["ep"] = episode_object.scene_episode + search_params["season"] = self.current_episode_object.scene_season + search_params["ep"] = self.current_episode_object.scene_episode if mode == "Season": search_params.pop("ep", "") diff --git a/sickchill/oldbeard/providers/norbits.py b/sickchill/oldbeard/providers/norbits.py index a6e2672f9f..6f629dd2d6 100644 --- a/sickchill/oldbeard/providers/norbits.py +++ b/sickchill/oldbeard/providers/norbits.py @@ -40,16 +40,16 @@ def _check_auth_from_data(parsed_json): return True - def search(self, search_params, episode_object=None): + def search(self, search_strings): """Do the actual searching and JSON parsing""" results = [] - for mode in search_params: + for mode in search_strings: items = [] logger.debug(_("Search Mode: {mode}").format(mode=mode)) - for search_string in search_params[mode]: + for search_string in search_strings[mode]: if mode != "RSS": logger.debug(_("Search String: {search_string}").format(search_string=search_string)) diff --git a/sickchill/oldbeard/providers/nyaa.py b/sickchill/oldbeard/providers/nyaa.py index 081b9267c3..bf9b873766 100644 --- a/sickchill/oldbeard/providers/nyaa.py +++ b/sickchill/oldbeard/providers/nyaa.py @@ -24,7 +24,7 @@ def __init__(self): self.size_units = ["BYTES", "KIB", "MIB", "GIB", "TIB", "PIB"] self.cache = tvcache.TVCache(self, min_time=20) # only poll Nyaa every 20 minutes max - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if self.show and not self.show.is_anime: return results diff --git a/sickchill/oldbeard/providers/omgwtfnzbs.py b/sickchill/oldbeard/providers/omgwtfnzbs.py index 3d2ef7ff2f..4bdb7d9c67 100644 --- a/sickchill/oldbeard/providers/omgwtfnzbs.py +++ b/sickchill/oldbeard/providers/omgwtfnzbs.py @@ -49,7 +49,7 @@ def _get_title_and_url(self, item): def _get_size(self, item): return try_int(item["sizebytes"], -1) - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self._check_auth(): return results diff --git a/sickchill/oldbeard/providers/pretome.py b/sickchill/oldbeard/providers/pretome.py index 539d5bfcfd..9f00dd5ec1 100644 --- a/sickchill/oldbeard/providers/pretome.py +++ b/sickchill/oldbeard/providers/pretome.py @@ -60,15 +60,15 @@ def login(self): return True - def search(self, search_params, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results - for mode in search_params: + for mode in search_strings: items = [] logger.debug(_("Search Mode: {mode}").format(mode=mode)) - for search_string in search_params[mode]: + for search_string in search_strings[mode]: if mode != "RSS": logger.debug(_("Search String: {search_string}").format(search_string=search_string)) diff --git a/sickchill/oldbeard/providers/rarbg.py b/sickchill/oldbeard/providers/rarbg.py index b4aaa24406..ebc4fadd73 100644 --- a/sickchill/oldbeard/providers/rarbg.py +++ b/sickchill/oldbeard/providers/rarbg.py @@ -45,7 +45,7 @@ def login(self): self.token_expires = datetime.datetime.now() + datetime.timedelta(minutes=14) if self.token else None return self.token is not None - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results @@ -60,9 +60,9 @@ def search(self, search_strings, episode_object=None): "token": self.token, } - if episode_object is not None: - ep_indexerid = episode_object.show.indexerid - ep_indexer = episode_object.idxr.slug + if self.show: + ep_indexerid = self.show.indexerid + ep_indexer = self.show.idxr.slug else: ep_indexerid = None ep_indexer = None diff --git a/sickchill/oldbeard/providers/scc.py b/sickchill/oldbeard/providers/scc.py index 349edac879..fad58eba92 100644 --- a/sickchill/oldbeard/providers/scc.py +++ b/sickchill/oldbeard/providers/scc.py @@ -61,7 +61,7 @@ def _isSection(section, text): title = r".+? \| {0}".format(section) return re.search(title, text, re.I) - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/scenetime.py b/sickchill/oldbeard/providers/scenetime.py index 72c48d5621..cbc56a7d3e 100644 --- a/sickchill/oldbeard/providers/scenetime.py +++ b/sickchill/oldbeard/providers/scenetime.py @@ -56,15 +56,15 @@ def login(self): logger.warning("Failed to login, check your cookies") return False - def search(self, search_params, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results - for mode in search_params: + for mode in search_strings: items = [] logger.debug(_("Search Mode: {mode}").format(mode=mode)) - for search_string in search_params[mode]: + for search_string in search_strings[mode]: if mode != "RSS": logger.debug(_("Search String: {search_string}").format(search_string=search_string)) diff --git a/sickchill/oldbeard/providers/skytorrents.py b/sickchill/oldbeard/providers/skytorrents.py index 5311ec59fb..d3a047f776 100644 --- a/sickchill/oldbeard/providers/skytorrents.py +++ b/sickchill/oldbeard/providers/skytorrents.py @@ -25,7 +25,7 @@ def __init__(self): self.cache = tvcache.TVCache(self, search_params={"RSS": [""]}) - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] for mode in search_strings: items = [] diff --git a/sickchill/oldbeard/providers/speedcd.py b/sickchill/oldbeard/providers/speedcd.py index c86d7b1459..47144834b3 100644 --- a/sickchill/oldbeard/providers/speedcd.py +++ b/sickchill/oldbeard/providers/speedcd.py @@ -69,7 +69,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/thepiratebay.py b/sickchill/oldbeard/providers/thepiratebay.py index 6e13bf5129..dd1f466f37 100644 --- a/sickchill/oldbeard/providers/thepiratebay.py +++ b/sickchill/oldbeard/providers/thepiratebay.py @@ -84,7 +84,7 @@ def make_magnet(self, name, info_hash): trackers = self.tracker_cache.get_trackers() return "magnet:?xt=urn:btih:{info_hash}&dn={name}{trackers}".format(name=name, info_hash=info_hash, trackers=trackers) + self._custom_trackers - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] search_params = {"cat": "208,205", "q": None} diff --git a/sickchill/oldbeard/providers/tntvillage.py b/sickchill/oldbeard/providers/tntvillage.py index 2df224f6b0..4997ec9804 100644 --- a/sickchill/oldbeard/providers/tntvillage.py +++ b/sickchill/oldbeard/providers/tntvillage.py @@ -242,17 +242,17 @@ def _is_season_pack(name): if int(episodes[0]["count"]) == len(parse_result.episode_numbers): return True - def search(self, search_params, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results self.categories = "cat=" + str(self.cat) - for mode in search_params: + for mode in search_strings: items = [] logger.debug(_("Search Mode: {mode}").format(mode=mode)) - for search_string in search_params[mode]: + for search_string in search_strings[mode]: if mode == "RSS": self.page = 2 diff --git a/sickchill/oldbeard/providers/tokyotoshokan.py b/sickchill/oldbeard/providers/tokyotoshokan.py index 334a268796..351aa08a96 100644 --- a/sickchill/oldbeard/providers/tokyotoshokan.py +++ b/sickchill/oldbeard/providers/tokyotoshokan.py @@ -22,7 +22,7 @@ def __init__(self): self.urls = {"search": self.url + "search.php", "rss": self.url + "rss.php"} self.cache = tvcache.TVCache(self, min_time=15) # only poll TokyoToshokan every 15 minutes max - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if self.show and not self.show.is_anime: return results diff --git a/sickchill/oldbeard/providers/torrent9.py b/sickchill/oldbeard/providers/torrent9.py index 9374fa2362..98d9f8fbe8 100644 --- a/sickchill/oldbeard/providers/torrent9.py +++ b/sickchill/oldbeard/providers/torrent9.py @@ -10,7 +10,7 @@ class Provider(FrenchTorrentProvider): def __init__(self): super().__init__("Torrent9", "https://www.torrent9.rs") - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] for mode in search_strings: items = [] diff --git a/sickchill/oldbeard/providers/torrent911.py b/sickchill/oldbeard/providers/torrent911.py index c2e78d5e70..d3bfb52203 100644 --- a/sickchill/oldbeard/providers/torrent911.py +++ b/sickchill/oldbeard/providers/torrent911.py @@ -10,7 +10,7 @@ class Provider(FrenchTorrentProvider): def __init__(self): super().__init__("Torrent911", "https://www.torrent911.ph") - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] for mode in search_strings: items = [] diff --git a/sickchill/oldbeard/providers/torrent_paradise.py b/sickchill/oldbeard/providers/torrent_paradise.py index f0e58b3d3c..162167fd2b 100644 --- a/sickchill/oldbeard/providers/torrent_paradise.py +++ b/sickchill/oldbeard/providers/torrent_paradise.py @@ -19,7 +19,7 @@ def __init__(self): self.cache = tvcache.TVCache(self) - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if "RSS" in search_strings: diff --git a/sickchill/oldbeard/providers/torrentbytes.py b/sickchill/oldbeard/providers/torrentbytes.py index 3d37c43225..1667c1df85 100644 --- a/sickchill/oldbeard/providers/torrentbytes.py +++ b/sickchill/oldbeard/providers/torrentbytes.py @@ -51,7 +51,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/torrentday.py b/sickchill/oldbeard/providers/torrentday.py index 92c1cd94fc..9c116a7319 100644 --- a/sickchill/oldbeard/providers/torrentday.py +++ b/sickchill/oldbeard/providers/torrentday.py @@ -77,7 +77,7 @@ def login(self): logger.info("You need to set your cookies to use torrentday") return False - def search(self, search_params, episode_object=None): + def search(self, search_strings): results = [] search_url = self.urls["search"] @@ -93,10 +93,10 @@ def search(self, search_params, episode_object=None): if not self.login(): return results - for mode in search_params: + for mode in search_strings: items = [] logger.debug(_("Search Mode: {mode}").format(mode=mode)) - for search_string in search_params[mode]: + for search_string in search_strings[mode]: if mode != "RSS": logger.debug(_("Search String: {search_string}").format(search_string=search_string)) diff --git a/sickchill/oldbeard/providers/torrentleech.py b/sickchill/oldbeard/providers/torrentleech.py index 2b28f18508..43cf484c59 100644 --- a/sickchill/oldbeard/providers/torrentleech.py +++ b/sickchill/oldbeard/providers/torrentleech.py @@ -56,7 +56,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/torrentproject.py b/sickchill/oldbeard/providers/torrentproject.py index 6cea1d4b5a..ba43a26d66 100644 --- a/sickchill/oldbeard/providers/torrentproject.py +++ b/sickchill/oldbeard/providers/torrentproject.py @@ -27,7 +27,7 @@ def __init__(self): # Cache self.cache = tvcache.TVCache(self, search_params={"RSS": ["0day"]}) - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] search_params = {"out": "json", "filter": 2101, "showmagnets": "on", "num": 50} diff --git a/sickchill/oldbeard/providers/torrentz.py b/sickchill/oldbeard/providers/torrentz.py index a74c25408b..8b4e2cd4f8 100644 --- a/sickchill/oldbeard/providers/torrentz.py +++ b/sickchill/oldbeard/providers/torrentz.py @@ -42,7 +42,7 @@ def _split_description(description): match = re.findall(r"[0-9]+", description) return int(match[0]) * 1024**2, int(match[1]), int(match[2]) - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] for mode in search_strings: diff --git a/sickchill/oldbeard/providers/tvchaosuk.py b/sickchill/oldbeard/providers/tvchaosuk.py index 2a658e2dbe..2835d15f43 100644 --- a/sickchill/oldbeard/providers/tvchaosuk.py +++ b/sickchill/oldbeard/providers/tvchaosuk.py @@ -47,7 +47,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self.login(): return results diff --git a/sickchill/oldbeard/providers/xthor.py b/sickchill/oldbeard/providers/xthor.py index e84a466d06..6e517e8247 100644 --- a/sickchill/oldbeard/providers/xthor.py +++ b/sickchill/oldbeard/providers/xthor.py @@ -25,7 +25,7 @@ def _check_auth(self): logger.warning("Your authentication credentials for {0} are missing, check your config.".format(self.name)) return False - def search(self, search_strings, episode_object=None): + def search(self, search_strings): results = [] if not self._check_auth: return results diff --git a/sickchill/oldbeard/providers/yggtorrent.py b/sickchill/oldbeard/providers/yggtorrent.py index 20262c2cc2..4144cc0760 100644 --- a/sickchill/oldbeard/providers/yggtorrent.py +++ b/sickchill/oldbeard/providers/yggtorrent.py @@ -82,7 +82,7 @@ def login(self): return True - def search(self, search_strings, episode_object=None): + def search(self, search_strings): self.login() results = [] diff --git a/sickchill/oldbeard/providers/zamunda.py b/sickchill/oldbeard/providers/zamunda.py index 36e608e18f..3e9e63eba2 100644 --- a/sickchill/oldbeard/providers/zamunda.py +++ b/sickchill/oldbeard/providers/zamunda.py @@ -66,7 +66,7 @@ def login(self): return True - def search(self, search_strings, ep_obj=None): + def search(self, search_strings): results = [] if not self.login(): diff --git a/sickchill/oldbeard/searchBacklog.py b/sickchill/oldbeard/searchBacklog.py index 49fa4e5ed4..1659184249 100644 --- a/sickchill/oldbeard/searchBacklog.py +++ b/sickchill/oldbeard/searchBacklog.py @@ -8,19 +8,19 @@ class BacklogSearchScheduler(scheduler.Scheduler): def forceSearch(self): - self.action._set_lastBacklog(1) + self.action.set_lastBacklog(1) self.lastRun = datetime.datetime.fromordinal(1) def nextRun(self): - if self.action._lastBacklog <= 1: + if self.action.lastBacklog <= 1: return datetime.date.today() else: - return datetime.date.fromordinal(self.action._lastBacklog + self.action.cycleTime) + return datetime.date.fromordinal(self.action.lastBacklog + self.action.cycleTime) class BacklogSearcher(object): def __init__(self): - self._lastBacklog = self._get_lastBacklog() + self.lastBacklog = self._get_lastBacklog() self.cycleTime = settings.BACKLOG_FREQUENCY / 60 / 24 self.lock = threading.Lock() self.amActive = False @@ -62,7 +62,7 @@ def searchBacklog(self, which_shows=None): curDate = datetime.date.today().toordinal() fromDate = datetime.date.min - if not (which_shows or curDate - self._lastBacklog >= self.cycleTime): + if not (which_shows or curDate - self.lastBacklog >= self.cycleTime): logger.info(f"Running limited backlog on missed episodes {settings.BACKLOG_DAYS} day(s) and older only") fromDate = datetime.date.today() - datetime.timedelta(days=settings.BACKLOG_DAYS) @@ -85,7 +85,7 @@ def searchBacklog(self, which_shows=None): # don't consider this an actual backlog search if we only did recent eps # or if we only did certain shows if fromDate == datetime.date.min and not which_shows: - self._set_lastBacklog(curDate) + self.set_lastBacklog(curDate) self.amActive = False self._reset_pi() @@ -105,8 +105,8 @@ def _get_lastBacklog(self): if lastBacklog > datetime.date.today().toordinal(): lastBacklog = 1 - self._lastBacklog = lastBacklog - return self._lastBacklog + self.lastBacklog = lastBacklog + return self.lastBacklog @staticmethod def _get_segments(show, fromDate): @@ -149,7 +149,7 @@ def _get_segments(show, fromDate): return wanted @staticmethod - def _set_lastBacklog(when): + def set_lastBacklog(when): logger.debug(f"Setting the last backlog in the DB to {when}") main_db_con = db.DBConnection() @@ -158,7 +158,7 @@ def _set_lastBacklog(when): if not sql_results: main_db_con.action("INSERT INTO info (last_backlog, last_indexer) VALUES (?,?)", [str(when), 0]) else: - main_db_con.action("UPDATE info SET last_backlog=" + str(when)) + main_db_con.action(f"UPDATE info SET last_backlog={when} WHERE 1") def run(self, force=False): try: diff --git a/sickchill/providers/GenericProvider.py b/sickchill/providers/GenericProvider.py index f8fcbdbc6b..9dd3e3e599 100644 --- a/sickchill/providers/GenericProvider.py +++ b/sickchill/providers/GenericProvider.py @@ -58,6 +58,9 @@ def __init__(self, name): "https://itorrents.org/torrent/{torrent_hash}.torrent?title={torrent_name}", ] self.cache = TVCache(self) + + self.current_episode_object = None + self.enable_backlog = False self.enable_daily = False self.enabled = False @@ -158,6 +161,8 @@ def find_search_results(self, show, episodes, search_mode, manual_search=False, elif search_mode == "episode": search_strings = self.get_episode_search_strings(episode) + self.current_episode_object = episode + for search_string in search_strings: items_list += self.search(search_string) @@ -283,11 +288,11 @@ def find_search_results(self, show, episodes, search_mode, manual_search=False, logger.debug(_("Found result {title} at {url}.").format(title=title, url=url)) - episode_object = [] + episode_objects = [] for current_episode in actual_episodes: - episode_object.append(show_object.getEpisode(actual_season, current_episode)) + episode_objects.append(show_object.getEpisode(actual_season, current_episode)) - result = self.get_result(episode_object) + result = self.get_result(episode_objects) result.show = show_object result.url = url result.name = title @@ -297,13 +302,13 @@ def find_search_results(self, show, episodes, search_mode, manual_search=False, result.content = None result.size = self._get_size(item) - if len(episode_object) == 1: - episode_number = episode_object[0].episode + if len(episode_objects) == 1: + episode_number = episode_objects[0].episode logger.debug("Single episode result.") - elif len(episode_object) > 1: + elif len(episode_objects) > 1: episode_number = MULTI_EP_RESULT logger.debug(f"Separating multi-episode result to check for later - result contains episodes: {parse_result.episode_numbers}") - elif len(episode_object) == 0: + elif len(episode_objects) == 0: episode_number = SEASON_RESULT logger.debug("Separating full season result to check for later") else: @@ -402,7 +407,7 @@ def _check_auth(self): def login(self): return True - def search(self, search_params, episode_object=None): + def search(self, strings): return [] def _get_result(self, episodes): diff --git a/sickchill/providers/torrent/TorrentProvider.py b/sickchill/providers/torrent/TorrentProvider.py index efc109a835..5cd895e8c5 100644 --- a/sickchill/providers/torrent/TorrentProvider.py +++ b/sickchill/providers/torrent/TorrentProvider.py @@ -32,10 +32,10 @@ def find_propers(self, search_date=None): if show: episode = show.getEpisode(result["season"], result["episode"]) + self.current_episode_object = episode for term in self.proper_strings: search_strings = self.get_episode_search_strings(episode, add_string=term) - for search_string in search_strings: for item in self.search(search_string): title, url = self._get_title_and_url(item) diff --git a/sickchill/tv.py b/sickchill/tv.py index c22f4de050..8d0cc766c1 100644 --- a/sickchill/tv.py +++ b/sickchill/tv.py @@ -749,7 +749,7 @@ def loadFromDB(self): self.default_ep_status = int(sql_results[0]["default_ep_status"] or SKIPPED) - if not self.imdb_id: + if sql_results[0]["imdb_id"] and not self.imdb_id: self.imdb_id = sql_results[0]["imdb_id"] if self.is_anime: diff --git a/tests/test_torrents.py b/tests/test_torrents.py index 32e54f2fc7..a05bc8aeef 100644 --- a/tests/test_torrents.py +++ b/tests/test_torrents.py @@ -39,8 +39,6 @@ def test_bitcannon(self): for search_strings in search_strings_list: provider.search(search_strings) # {'Episode': ['Italian Works S05E10']} - return True - @unittest.skip("Only run this manually") def test_search(self): """