Skip to content

Commit

Permalink
root dirs, trakt, addshow, bdecode (#8718)
Browse files Browse the repository at this point in the history
* root dirs, trakt, addshow

* trakt

* KeyError: b'info'
  • Loading branch information
BKSteve authored Feb 18, 2024
1 parent 6fa4f33 commit 3bb209b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion sickchill/oldbeard/clients/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _get_torrent_hash(result):
raise

try:
info = torrent_bdecode[b"info"]
info = torrent_bdecode["info"]
except Exception:
logger.exception("Unable to find info field in torrent")
logger.info(f"Torrent bencoded data: {result.content!r}")
Expand Down
2 changes: 1 addition & 1 deletion sickchill/oldbeard/traktChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def _add_shows_to_trakt_watchlist(self):
trakt_data = []

for show in settings.showList or []:
if not self._is_in_show_watchlist(show.idxr.slug, str(show.indexerid), "0", "0"):
if not self._is_in_show_watchlist(show.idxr.slug, str(show.indexerid)):
logger.debug("Adding Show: Indexer {0} {1} - {2} to Watchlist".format(show.idxr.name, str(show.indexerid), show.name))
show_element = {"title": show.name, "year": show.startyear, "ids": {show.idxr.slug: show.indexerid}}

Expand Down
49 changes: 23 additions & 26 deletions sickchill/views/manage/add_shows.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ def index(self):
def sanitizeFileName(self):
return sanitize_filename(self.get_body_argument("name"))

def searchIndexersForShowName(self, search_term, lang=None, indexer=None, exact=False):
def searchIndexersForShowName(self):
self.set_header("Cache-Control", "max-age=0,no-cache,no-store")
self.set_header("Content-Type", "application/json")
search_terms = [self.get_body_argument("search_term")] # get_arguments to make this a list of terms, we can probably add advanced searching here.
search_term = self.get_body_argument("search_term")
search_terms = [search_term] # get_arguments to make this a list of terms, we can probably add advanced searching here.
lang = self.get_body_argument("lang", default=settings.INDEXER_DEFAULT_LANGUAGE)
indexer = int(self.get_body_argument("indexer", default=settings.INDEXER_DEFAULT))
exact = config.checkbox_to_value(self.get_body_argument("exact"))
Expand Down Expand Up @@ -110,7 +111,7 @@ def searchIndexersForShowName(self, search_term, lang=None, indexer=None, exact=
lang_id = sickchill.indexer.lang_dict()[lang]
return json.dumps({"results": final_results, "langid": lang_id, "success": len(final_results) > 0})

def massAddTable(self, rootDir=None):
def massAddTable(self):
t = PageTemplate(rh=self, filename="home_massAddTable.mako")
root_dirs = self.get_arguments("rootDir")
if not root_dirs:
Expand Down Expand Up @@ -156,9 +157,9 @@ def massAddTable(self, rootDir=None):
}

# see if the folder is in KODI already
dirResults = main_db_con.select("SELECT indexer_id FROM tv_shows WHERE location = ? LIMIT 1", [cur_path])
dir_results = main_db_con.select("SELECT indexer_id FROM tv_shows WHERE location = ? LIMIT 1", [cur_path])

if dirResults:
if dir_results:
cur_dir["added_already"] = True
else:
cur_dir["added_already"] = False
Expand Down Expand Up @@ -238,7 +239,7 @@ def trendingShows(self):
posts them to addNewShow
"""

traktList = self.get_argument("traktList", default="anticipated")
trakt_list = self.get_query_argument("traktList", default="anticipated").lower()

trakt_options = {
"anticipated": _("Most Anticipated Shows"),
Expand All @@ -253,53 +254,49 @@ def trendingShows(self):
if settings.TRAKT_ACCESS_TOKEN:
trakt_options["recommended"] = _("Recommended Shows")

traktList = traktList.lower()

t = PageTemplate(rh=self, filename="addShows_trendingShows.mako")
return t.render(
title=trakt_options[traktList],
header=trakt_options[traktList],
traktList=traktList,
title=trakt_options[trakt_list],
header=trakt_options[trakt_list],
traktList=trakt_list,
trakt_options=trakt_options,
controller="addShows",
action="trendingShows",
)

def getTrendingShows(self, traktList=None):
def getTrendingShows(self):
"""
Display the new show page which collects a tvdb id, folder, and extra options and posts them to addNewShow
"""
t = PageTemplate(rh=self, filename="trendingShows.mako")
if not traktList:
traktList = ""

traktList = traktList.lower()
trakt_list = self.get_query_argument("traktList", "").lower()

if traktList == "trending":
if trakt_list == "trending":
page_url = "shows/trending"
elif traktList == "popular":
elif trakt_list == "popular":
page_url = "shows/popular"
elif traktList == "anticipated":
elif trakt_list == "anticipated":
page_url = "shows/anticipated"
elif traktList == "collected":
elif trakt_list == "collected":
page_url = "shows/collected"
elif traktList == "watched":
elif trakt_list == "watched":
page_url = "shows/watched"
elif traktList == "played":
elif trakt_list == "played":
page_url = "shows/played"
elif traktList == "recommended":
elif trakt_list == "recommended":
page_url = "recommendations/shows"
elif traktList == "newshow":
elif trakt_list == "newshow":
page_url = "calendars/all/shows/new/{0}/30".format(datetime.date.today().strftime("%Y-%m-%d"))
elif traktList == "newseason":
elif trakt_list == "newseason":
page_url = "calendars/all/shows/premieres/{0}/30".format(datetime.date.today().strftime("%Y-%m-%d"))
else:
page_url = "shows/anticipated"

trending_shows = []
black_list = False
try:
trending_shows, black_list = trakt_trending.fetch_trending_shows(traktList, page_url)
trending_shows, black_list = trakt_trending.fetch_trending_shows(trakt_list, page_url)
except Exception as error:
logger.warning(f"Could not get trending shows: {error}")

Expand Down Expand Up @@ -458,7 +455,7 @@ def addNewShow(
provided then it forwards back to newShow, if not it goes to /home.
"""

indexerLang = self.get_argument("indexerLang", default=settings.INDEXER_DEFAULT_LANGUAGE)
indexerLang = self.get_body_argument("indexerLang", default=settings.INDEXER_DEFAULT_LANGUAGE)

# grab our list of other dirs if given
other_shows = self.get_arguments("other_shows")
Expand Down
2 changes: 1 addition & 1 deletion sickchill/views/server_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(self, options=None):
# video root
if settings.ROOT_DIRS:
root_dirs = settings.ROOT_DIRS.split("|")
self.video_root = root_dirs[int(root_dirs[0]) + 1]
self.video_root = root_dirs[int(root_dirs[0])]
else:
self.video_root = None

Expand Down

0 comments on commit 3bb209b

Please sign in to comment.