Skip to content

Commit

Permalink
refactor: try and complete the removal of episode_object parameter fr…
Browse files Browse the repository at this point in the history
…om all provider search methods, fixes newznab and other providers

Signed-off-by: miigotu <[email protected]>
  • Loading branch information
miigotu committed Feb 2, 2024
1 parent 06b7703 commit 05c2c8d
Show file tree
Hide file tree
Showing 62 changed files with 130 additions and 127 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Build develop branch

on:
workflow_run:
workflows: [ "Python Packaging" ]
workflows: [Python Packaging]
branches: |
- develop
type:
Expand Down
10 changes: 9 additions & 1 deletion sickchill/oldbeard/notifiers/nmj.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/abnormal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/alpharatio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/archetorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions sickchill/oldbeard/providers/bitcannon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand All @@ -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:
Expand Down
7 changes: 2 additions & 5 deletions sickchill/oldbeard/providers/bjshare.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,19 @@ 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)
"""
results = []
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}

Expand Down
6 changes: 3 additions & 3 deletions sickchill/oldbeard/providers/btn.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/cpasbien.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/danishbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/demonoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
4 changes: 2 additions & 2 deletions sickchill/oldbeard/providers/elitetorrent.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions sickchill/oldbeard/providers/eztv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand All @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/filelist.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/gimmepeers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/hd4free.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions sickchill/oldbeard/providers/hdbits.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/hdspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/hdtorrents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/hdtorrents_it.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/horriblesubs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/hounddawgs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions sickchill/oldbeard/providers/ilcorsaronero.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/immortalseed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions sickchill/oldbeard/providers/iptorrents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
6 changes: 3 additions & 3 deletions sickchill/oldbeard/providers/kat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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")]
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/limetorrents.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/magnetdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/morethantv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/providers/ncore.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading

0 comments on commit 05c2c8d

Please sign in to comment.