def trendingShows(self, traktList=None): """ Display the new show page which collects a tvdb id, folder, and extra options and posts them to addNewShow """ if not traktList: traktList = "" traktList = traktList.lower() if traktList == "trending": page_title = _("Trending Shows") elif traktList == "popular": page_title = _("Popular Shows") elif traktList == "anticipated": page_title = _("Most Anticipated Shows") elif traktList == "collected": page_title = _("Most Collected Shows") elif traktList == "watched": page_title = _("Most Watched Shows") elif traktList == "played": page_title = _("Most Played Shows") elif traktList == "recommended": page_title = _("Recommended Shows") elif traktList == "newshow": page_title = _("New Shows") elif traktList == "newseason": page_title = _("Season Premieres") else: page_title = _("Most Anticipated Shows") t = PageTemplate(rh=self, filename="addShows_trendingShows.mako") return t.render(title=page_title, header=page_title, enable_anime_options=False, traktList=traktList, controller="addShows", action="trendingShows")
def index(self): t = PageTemplate(rh=self, filename="config.mako") try: import getpass sc_user = getpass.getuser() except Exception: sc_user = os.getuid() try: import locale sc_locale = locale.getdefaultlocale() except Exception: sc_locale = 'Unknown', 'Unknown' try: import ssl ssl_version = ssl.OPENSSL_VERSION except Exception: ssl_version = 'Unknown' sc_version = '' if settings.VERSION_NOTIFY: updater = UpdateManager() if updater: updater.need_update() sc_version = updater.get_current_version() return t.render(submenu=self.ConfigMenu(), title=_('SickChill Configuration'), header=_('SickChill Configuration'), topmenu="config", sc_user=sc_user, sc_locale=sc_locale, ssl_version=ssl_version, sc_version=sc_version)
def failedDownloads(self, limit=100, toRemove=None): failed_db_con = db.DBConnection('failed.db') if limit == "0": sql_results = failed_db_con.select("SELECT * FROM failed") else: sql_results = failed_db_con.select("SELECT * FROM failed LIMIT ?", [limit]) toRemove = toRemove.split("|") if toRemove else [] for release in toRemove: failed_db_con.action("DELETE FROM failed WHERE failed.release = ?", [release]) if toRemove: return self.redirect('/manage/failedDownloads/') t = PageTemplate(rh=self, filename="manage_failedDownloads.mako") return t.render(limit=limit, failedResults=sql_results, title=_('Failed Downloads'), header=_('Failed Downloads'), topmenu='manage', controller="manage", action="failedDownloads")
def favoriteShows(self): """ Fetches data from IMDB to show a list of popular shows. """ t = PageTemplate(rh=self, filename="addShows_favoriteShows.mako") e = None if self.get_body_argument("submit", None): tvdb_user = self.get_body_argument("tvdb_user") tvdb_user_key = filters.unhide( settings.TVDB_USER_KEY, self.get_body_argument("tvdb_user_key")) if tvdb_user and tvdb_user_key: if tvdb_user != settings.TVDB_USER or tvdb_user_key != settings.TVDB_USER_KEY: favorites.test_user_key(tvdb_user, tvdb_user_key, 1) try: favorite_shows = favorites.fetch_indexer_favorites() except Exception as e: logger.exception(traceback.format_exc()) logger.warning( _("Could not get favorite shows: {0}").format(str(e))) favorite_shows = None return t.render( title=_("Favorite Shows"), header=_("Favorite Shows"), favorite_shows=favorite_shows, favorites_exception=e, topmenu="home", controller="addShows", action="popularShows", )
def index(self, *args_, **kwargs_): t = PageTemplate(rh=self, filename="config_anime.mako") return t.render(submenu=self.ConfigMenu(), title=_('Config - Anime'), header=_('Anime'), topmenu='config', controller="config", action="anime")
def index(self, *args_, **kwargs_): t = PageTemplate(rh=self, filename="addShows.mako") return t.render(title=_("Add Shows"), header=_("Add Shows"), topmenu="home", controller="addShows", action="index")
def popularShows(self): """ Fetches data from IMDB to show a list of popular shows. """ t = PageTemplate(rh=self, filename="addShows_popularShows.mako") try: popular_shows = imdb_popular.fetch_popular_shows() imdb_exception = None except Exception as error: logger.warning("Could not get popular shows: {0}".format( str(error))) logger.debug(traceback.format_exc()) popular_shows = None imdb_exception = error return t.render( title=_("Popular Shows"), header=_("Popular Shows"), popular_shows=popular_shows, imdb_exception=imdb_exception, imdb_url=imdb_popular.imdb_url, topmenu="home", controller="addShows", action="popularShows", )
def index(self, *args, **kwargs): t = PageTemplate(rh=self, filename="manage.mako") return t.render(title=_('Mass Update'), header=_('Mass Update'), topmenu='manage', controller="manage", action="index")
def favoriteShows(self, tvdb_user=None, tvdb_user_key=None, submit=False): """ Fetches data from IMDB to show a list of popular shows. """ t = PageTemplate(rh=self, filename="addShows_favoriteShows.mako") e = None tvdb_user_key = filters.unhide(sickbeard.TVDB_USER_KEY, tvdb_user_key) if submit and tvdb_user and tvdb_user_key: if tvdb_user != sickbeard.TVDB_USER and tvdb_user_key != sickbeard.TVDB_USER: favorites.test_user_key(tvdb_user, tvdb_user_key, 1) try: favorite_shows = favorites.fetch_indexer_favorites() except Exception as e: logger.log(traceback.format_exc(), logger.ERROR) logger.log( _("Could not get favorite shows: {0}").format(ex(e)), logger.WARNING) favorite_shows = None return t.render(title=_("Favorite Shows"), header=_("Favorite Shows"), favorite_shows=favorite_shows, favorites_exception=e, topmenu="home", controller="addShows", action="popularShows")
def index(self, *args_, **kwargs_): t = PageTemplate(rh=self, filename="home_postprocess.mako") return t.render(title=_('Post Processing'), header=_('Post Processing'), topmenu='home', controller="home", action="postProcess")
def existingShows(self): """ Prints out the page to add existing shows from a root dir """ t = PageTemplate(rh=self, filename="addShows_addExistingShow.mako") return t.render(enable_anime_options=False, title=_('Existing Show'), header=_('Existing Show'), topmenu="home", controller="addShows", action="addExistingShow")
def newShow(self, show_to_add=None, other_shows=None, search_string=None): """ Display the new show page which collects a tvdb id, folder, and extra options and posts them to addNewShow """ t = PageTemplate(rh=self, filename="addShows_newShow.mako") indexer, show_dir, indexer_id, show_name = self.split_extra_show( show_to_add) if indexer_id and indexer and show_name: use_provided_info = True else: use_provided_info = False # use the given show_dir for the indexer search if available if not show_dir: if search_string: default_show_name = search_string else: default_show_name = "" elif not show_name: default_show_name = re.sub( r" \(\d{4}\)", "", os.path.basename(os.path.normpath(show_dir)).replace(".", " ")) else: default_show_name = show_name # carry a list of other dirs if given if not other_shows: other_shows = [] elif not isinstance(other_shows, list): other_shows = [other_shows] provided_indexer_id = int(indexer_id or 0) provided_indexer_name = show_name provided_indexer = int(indexer or settings.INDEXER_DEFAULT) return t.render( enable_anime_options=True, use_provided_info=use_provided_info, default_show_name=default_show_name, other_shows=other_shows, provided_show_dir=show_dir, provided_indexer_id=provided_indexer_id, provided_indexer_name=provided_indexer_name, provided_indexer=provided_indexer, whitelist=[], blacklist=[], groups=[], title=_("New Show"), header=_("New Show"), topmenu="home", controller="addShows", action="newShow", )
def subtitleMissed(self, whichSubs=None): t = PageTemplate(rh=self, filename="manage_subtitleMissed.mako") if not whichSubs: return t.render( whichSubs=whichSubs, title=_("Episode Overview"), header=_("Episode Overview"), topmenu="manage", show_names=None, ep_counts=None, sorted_show_ids=None, controller="manage", action="subtitleMissed", ) main_db_con = db.DBConnection() status_results = main_db_con.select( "SELECT show_name, tv_shows.indexer_id as indexer_id, tv_episodes.subtitles subtitles " + "FROM tv_episodes, tv_shows " + "WHERE tv_shows.subtitles = 1 AND (tv_episodes.status LIKE '%4' OR tv_episodes.status LIKE '%6') AND tv_episodes.season != 0 " + "AND tv_episodes.location != '' AND tv_episodes.showid = tv_shows.indexer_id ORDER BY show_name" ) ep_counts = {} show_names = {} sorted_show_ids = [] for cur_status_result in status_results: if whichSubs == "all": if not frozenset( subtitle_module.wanted_languages()).difference( cur_status_result["subtitles"].split(",")): continue elif whichSubs in cur_status_result["subtitles"]: continue cur_indexer_id = int(cur_status_result["indexer_id"]) if cur_indexer_id not in ep_counts: ep_counts[cur_indexer_id] = 1 else: ep_counts[cur_indexer_id] += 1 show_names[cur_indexer_id] = cur_status_result["show_name"] if cur_indexer_id not in sorted_show_ids: sorted_show_ids.append(cur_indexer_id) return t.render( whichSubs=whichSubs, show_names=show_names, ep_counts=ep_counts, sorted_show_ids=sorted_show_ids, title=_("Missing Subtitles"), header=_("Missing Subtitles"), topmenu="manage", controller="manage", action="subtitleMissed", )
def index(self): t = PageTemplate(rh=self, filename="config_general.mako") return t.render(title=_('Config - General'), header=_('General Configuration'), topmenu='config', submenu=self.ConfigMenu(), controller="config", action="index")
def index(self, *args_, **kwargs_): t = PageTemplate(rh=self, filename="config_notifications.mako") return t.render(submenu=self.ConfigMenu(), title=_('Config - Notifications'), header=_('Notifications'), topmenu='config', controller="config", action="notifications")
def episodeStatuses(self, whichStatus=None): if whichStatus: status_list = [int(whichStatus)] if status_list[0] == SNATCHED: status_list = Quality.SNATCHED + Quality.SNATCHED_PROPER + Quality.SNATCHED_BEST else: status_list = [] t = PageTemplate(rh=self, filename="manage_episodeStatuses.mako") # if we have no status then this is as far as we need to go if not status_list: return t.render( title=_("Episode Overview"), header=_("Episode Overview"), topmenu="manage", show_names=None, whichStatus=whichStatus, ep_counts=None, sorted_show_ids=None, controller="manage", action="episodeStatuses", ) main_db_con = db.DBConnection() status_results = main_db_con.select( "SELECT show_name, tv_shows.indexer_id AS indexer_id FROM tv_episodes, tv_shows WHERE tv_episodes.status IN ({0}) AND season != 0 AND " "tv_episodes.showid = tv_shows.indexer_id ORDER BY show_name". format(",".join(["?"] * len(status_list))), status_list, ) ep_counts = {} show_names = {} sorted_show_ids = [] for cur_status_result in status_results: cur_indexer_id = int(cur_status_result["indexer_id"]) if cur_indexer_id not in ep_counts: ep_counts[cur_indexer_id] = 1 else: ep_counts[cur_indexer_id] += 1 show_names[cur_indexer_id] = cur_status_result["show_name"] if cur_indexer_id not in sorted_show_ids: sorted_show_ids.append(cur_indexer_id) return t.render( title=_("Episode Overview"), header=_("Episode Overview"), topmenu="manage", whichStatus=whichStatus, show_names=show_names, ep_counts=ep_counts, sorted_show_ids=sorted_show_ids, controller="manage", action="episodeStatuses", )
def index(self, *args_, **kwargs_): t = PageTemplate(rh=self, filename="config_backuprestore.mako") return t.render(submenu=self.ConfigMenu(), title=_('Config - Backup/Restore'), header=_('Backup/Restore'), topmenu='config', controller="config", action="backupRestore")
def index(self, *args_, **kwargs_): t = PageTemplate(rh=self, filename="config_providers.mako") return t.render(submenu=self.ConfigMenu(), title=_("Config - Providers"), header=_("Search Providers"), topmenu="config", controller="config", action="providers")
def index(self, *args_, **kwargs_): t = PageTemplate(rh=self, filename="config_postProcessing.mako") return t.render(submenu=self.ConfigMenu(), title=_('Config - Post Processing'), header=_('Post Processing'), topmenu='config', controller="config", action="postProcessing")
def index(self, *args_, **kwargs_): t = PageTemplate(rh=self, filename="config_search.mako") return t.render(submenu=self.ConfigMenu(), title=_('Config - Episode Search'), header=_('Search Settings'), topmenu='config', controller="config", action="search")
def index(self): t = PageTemplate(rh=self, filename="config_shares.mako") return t.render(title=_('Config - Shares'), header=_('Windows Shares Configuration'), topmenu='config', submenu=self.ConfigMenu(), controller="config", action="shares")
def backlogOverview(self): t = PageTemplate(rh=self, filename="manage_backlogOverview.mako") showCounts = {} showCats = {} showSQLResults = {} main_db_con = db.DBConnection() for curShow in sickbeard.showList: epCounts = { Overview.SKIPPED: 0, Overview.WANTED: 0, Overview.QUAL: 0, Overview.GOOD: 0, Overview.UNAIRED: 0, Overview.SNATCHED: 0, Overview.SNATCHED_PROPER: 0, Overview.SNATCHED_BEST: 0 } epCats = {} sql_results = main_db_con.select( "SELECT status, season, episode, name, airdate FROM tv_episodes WHERE tv_episodes.season IS NOT NULL " "AND tv_episodes.showid IN (SELECT tv_shows.indexer_id FROM tv_shows WHERE tv_shows.indexer_id = ? " "AND paused = 0) ORDER BY tv_episodes.season DESC, tv_episodes.episode DESC", [curShow.indexerid]) for curResult in sql_results: curEpCat = curShow.getOverview( curResult[b"status"], backlog=sickbeard.BACKLOG_MISSING_ONLY) if curEpCat: epCats['{ep}'.format( ep=episode_num(curResult[b'season'], curResult[b'episode']))] = curEpCat epCounts[curEpCat] += 1 showCounts[curShow.indexerid] = epCounts showCats[curShow.indexerid] = epCats showSQLResults[curShow.indexerid] = sql_results return t.render(showCounts=showCounts, showCats=showCats, showSQLResults=showSQLResults, controller='manage', action='backlogOverview', title=_('Backlog Overview'), header=_('Backlog Overview'), topmenu='manage')
def index(self, *args_, **kwargs_): t = PageTemplate(rh=self, filename="manage_manageSearches.mako") # t.backlogPI = sickbeard.backlogSearchScheduler.action.getProgressIndicator() return t.render( backlogPaused=sickbeard.searchQueueScheduler.action. is_backlog_paused(), backlogRunning=sickbeard.searchQueueScheduler.action. is_backlog_in_progress(), dailySearchStatus=sickbeard.dailySearchScheduler.action.amActive, findPropersStatus=sickbeard.properFinderScheduler.action.amActive, queueLength=sickbeard.searchQueueScheduler.action.queue_length(), subtitlesFinderStatus=sickbeard.subtitlesFinderScheduler.action. amActive, title=_('Manage Searches'), header=_('Manage Searches'), topmenu='manage', controller="manage", action="manageSearches")
def index(self, *args_, **kwargs_): t = PageTemplate(rh=self, filename="manage_manageSearches.mako") # t.backlogPI = oldbeard.backlogSearchScheduler.action.getProgressIndicator() return t.render( backlogPaused=settings.searchQueueScheduler.action.is_backlog_paused(), backlogRunning=settings.searchQueueScheduler.action.is_backlog_in_progress(), dailySearchStatus=settings.dailySearchScheduler.action.amActive, findPropersStatus=settings.properFinderScheduler.action.amActive, subtitlesFinderStatus=settings.subtitlesFinderScheduler.action.amActive, autoPostProcessorStatus=settings.autoPostProcessorScheduler.action.amActive, queueLength=settings.searchQueueScheduler.action.queue_length(), processing_queue=settings.postProcessorTaskScheduler.action.queue_length(), title=_("Manage Searches"), header=_("Manage Searches"), topmenu="manage", controller="manage", action="manageSearches", )
def index(self): t = PageTemplate(rh=self, filename="config.mako") try: import getpass sc_user = getpass.getuser() except Exception: sc_user = os.getuid() try: import locale sc_locale = locale.getdefaultlocale() except Exception: sc_locale = "Unknown", "Unknown" try: import ssl ssl_version = ssl.OPENSSL_VERSION except Exception: ssl_version = "Unknown" sc_version = "" if settings.VERSION_NOTIFY or settings.BRANCH == "pip": updater = UpdateManager() if updater: if settings.BRANCH == "pip": sc_version = updater.updater.get_clean_version() else: updater.need_update() sc_version = updater.get_current_version() return t.render( submenu=self.ConfigMenu(), title=_("SickChill Configuration"), header=_("SickChill Configuration"), topmenu="config", sc_user=sc_user, sc_locale=sc_locale, ssl_version=ssl_version, sc_version=sc_version, )
def getTrendingShows(self, traktList=None): """ 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() if traktList == "trending": page_url = "shows/trending" elif traktList == "popular": page_url = "shows/popular" elif traktList == "anticipated": page_url = "shows/anticipated" elif traktList == "collected": page_url = "shows/collected" elif traktList == "watched": page_url = "shows/watched" elif traktList == "played": page_url = "shows/played" elif traktList == "recommended": page_url = "recommendations/shows" elif traktList == "newshow": page_url = 'calendars/all/shows/new/{0}/30'.format( datetime.date.today().strftime("%Y-%m-%d")) elif traktList == "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) except Exception as e: logger.log("Could not get trending shows: {0}".format(ex(e)), logger.WARNING) return t.render(black_list=black_list, trending_shows=trending_shows)
def popularShows(self): """ Fetches data from IMDB to show a list of popular shows. """ t = PageTemplate(rh=self, filename="addShows_popularShows.mako") e = None try: popular_shows = imdb_popular.fetch_popular_shows() except Exception as e: logger.warning("Could not get popular shows: {0}".format(str(e))) popular_shows = None return t.render(title=_("Popular Shows"), header=_("Popular Shows"), popular_shows=popular_shows, imdb_exception=e, topmenu="home", controller="addShows", action="popularShows")
def index(self): t = PageTemplate(rh=self, filename="config.mako") try: # noinspection PyUnresolvedReferences import pwd sr_user = pwd.getpwuid(os.getuid()).pw_name except ImportError: try: import getpass sr_user = getpass.getuser() except StandardError: sr_user = '******' try: import locale sr_locale = locale.getdefaultlocale() except StandardError: sr_locale = 'Unknown', 'Unknown' try: import ssl ssl_version = ssl.OPENSSL_VERSION except StandardError: ssl_version = 'Unknown' sr_version = '' if sickbeard.VERSION_NOTIFY: updater = CheckVersion().updater if updater: updater.need_update() sr_version = updater.get_cur_version() return t.render(submenu=self.ConfigMenu(), title=_('SickChill Configuration'), header=_('SickChill Configuration'), topmenu="config", sr_user=sr_user, sr_locale=sr_locale, ssl_version=ssl_version, sr_version=sr_version)
def massAddTable(self, rootDir=None): t = PageTemplate(rh=self, filename="home_massAddTable.mako") if not rootDir: return _("No folders selected.") elif not isinstance(rootDir, list): root_dirs = [rootDir] else: root_dirs = rootDir root_dirs = [unquote_plus(xhtml_unescape(x)) for x in root_dirs] if settings.ROOT_DIRS: default_index = int(settings.ROOT_DIRS.split("|")[0]) else: default_index = 0 if len(root_dirs) > default_index: tmp = root_dirs[default_index] if tmp in root_dirs: root_dirs.remove(tmp) root_dirs.insert(0, tmp) dir_list = [] main_db_con = db.DBConnection() for root_dir in root_dirs: # noinspection PyBroadException try: file_list = os.listdir(root_dir) except Exception: continue for cur_file in file_list: # noinspection PyBroadException try: cur_path = os.path.normpath( os.path.join(root_dir, cur_file)) if not os.path.isdir(cur_path): continue # ignore Synology folders if cur_file.lower() in ["#recycle", "@eadir"]: continue except Exception: continue cur_dir = { "dir": cur_path, "existing_info": (None, None, None), "display_dir": "<b>" + os.path.dirname(cur_path) + os.sep + "</b>" + os.path.basename(cur_path), } # 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]) if dirResults: cur_dir["added_already"] = True else: cur_dir["added_already"] = False dir_list.append(cur_dir) indexer_id = show_name = indexer = None for cur_provider in settings.metadata_provider_dict.values(): if not (indexer_id and show_name): (indexer_id, show_name, indexer) = cur_provider.retrieveShowMetadata(cur_path) if all((indexer_id, show_name, indexer)): break if all((indexer_id, show_name, indexer)): cur_dir["existing_info"] = (indexer_id, show_name, indexer) if indexer_id and Show.find(settings.showList, indexer_id): cur_dir["added_already"] = True return t.render(dirList=dir_list)
def massEdit(self, toEdit=None): t = PageTemplate(rh=self, filename="manage_massEdit.mako") if not toEdit: return self.redirect("/manage/") showIDs = toEdit.split("|") showList = [] showNames = [] for curID in showIDs: curID = int(curID) show_obj = Show.find(sickbeard.showList, curID) if show_obj: showList.append(show_obj) showNames.append(show_obj.name) season_folders_all_same = True last_season_folders = None paused_all_same = True last_paused = None default_ep_status_all_same = True last_default_ep_status = None anime_all_same = True last_anime = None sports_all_same = True last_sports = None quality_all_same = True last_quality = None subtitles_all_same = True last_subtitles = None scene_all_same = True last_scene = None air_by_date_all_same = True last_air_by_date = None root_dir_list = [] for curShow in showList: cur_root_dir = self.__gooey_path(curShow._location, 'dirname') if cur_root_dir and cur_root_dir != curShow._location and cur_root_dir not in root_dir_list: root_dir_list.append(cur_root_dir) # if we know they're not all the same then no point even bothering if paused_all_same: # if we had a value already and this value is different then they're not all the same if last_paused not in (None, curShow.paused): paused_all_same = False else: last_paused = curShow.paused if default_ep_status_all_same: if last_default_ep_status not in (None, curShow.default_ep_status): default_ep_status_all_same = False else: last_default_ep_status = curShow.default_ep_status if anime_all_same: # if we had a value already and this value is different then they're not all the same if last_anime not in (None, curShow.is_anime): anime_all_same = False else: last_anime = curShow.anime if season_folders_all_same: if last_season_folders not in (None, curShow.season_folders): season_folders_all_same = False else: last_season_folders = curShow.season_folders if quality_all_same: if last_quality not in (None, curShow.quality): quality_all_same = False else: last_quality = curShow.quality if subtitles_all_same: if last_subtitles not in (None, curShow.subtitles): subtitles_all_same = False else: last_subtitles = curShow.subtitles if scene_all_same: if last_scene not in (None, curShow.scene): scene_all_same = False else: last_scene = curShow.scene if sports_all_same: if last_sports not in (None, curShow.sports): sports_all_same = False else: last_sports = curShow.sports if air_by_date_all_same: if last_air_by_date not in (None, curShow.air_by_date): air_by_date_all_same = False else: last_air_by_date = curShow.air_by_date default_ep_status_value = last_default_ep_status if default_ep_status_all_same else None paused_value = last_paused if paused_all_same else None anime_value = last_anime if anime_all_same else None season_folders_value = last_season_folders if season_folders_all_same else None quality_value = last_quality if quality_all_same else None subtitles_value = last_subtitles if subtitles_all_same else None scene_value = last_scene if scene_all_same else None sports_value = last_sports if sports_all_same else None air_by_date_value = last_air_by_date if air_by_date_all_same else None return t.render(showList=toEdit, showNames=showNames, default_ep_status_value=default_ep_status_value, paused_value=paused_value, anime_value=anime_value, season_folders_value=season_folders_value, quality_value=quality_value, subtitles_value=subtitles_value, scene_value=scene_value, sports_value=sports_value, air_by_date_value=air_by_date_value, root_dir_list=root_dir_list, title=_('Mass Edit'), header=_('Mass Edit'), controller='manage', action='massEdit', topmenu='manage')