diff --git a/CHANGES.md b/CHANGES.md index beec02c..369bab9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,6 +1,8 @@ -### 0.21.47 (2020-09-xx xx:xx:00 UTC) +### 0.21.47 (2020-09-17 16:10:00 UTC) * Change add warning to logs for enabled providers where `cf_clearance` cookie is missing +* Fix backlog search in season search mode +* Fix don't search if subtitles disabled ### 0.21.46 (2020-09-16 20:00:00 UTC) diff --git a/sickbeard/search.py b/sickbeard/search.py index 8f02f72..c1b05e3 100644 --- a/sickbeard/search.py +++ b/sickbeard/search.py @@ -737,14 +737,6 @@ def search_providers( orig_thread_name = threading.currentThread().name - use_quality_list = None - if any([ep_obj_list]): - old_status = old_status or failed_history.find_old_status(ep_obj_list[0]) or ep_obj_list[0].status - if old_status: - status, quality = Quality.splitCompositeStatus(old_status) - use_quality_list = (status not in ( - common.WANTED, common.FAILED, common.UNAIRED, common.SKIPPED, common.IGNORED, common.UNKNOWN)) - provider_list = [x for x in sickbeard.providers.sortedProviderList() if x.is_active() and getattr(x, 'enable_backlog', None) and (not torrent_only or GenericProvider.TORRENT == x.providerType) and @@ -975,14 +967,28 @@ def search_providers( # of all the single ep results narrow it down to the best one for each episode final_results += set(itervalues(multi_results)) - quality_list = use_quality_list and (None, best_qualities)[any(best_qualities)] or None - for cur_search_result in found_results[provider_id]: + + for cur_search_result in found_results[provider_id]: # type: int if cur_search_result in (MULTI_EP_RESULT, SEASON_RESULT): continue if 0 == len(found_results[provider_id][cur_search_result]): continue + use_quality_list = None + if 0 < len(found_results[provider_id][cur_search_result]) and \ + any([found_results[provider_id][cur_search_result][0].ep_obj_list]): + old_status = old_status or \ + failed_history.find_old_status( + found_results[provider_id][cur_search_result][0].ep_obj_list[0]) or \ + found_results[provider_id][cur_search_result][0].ep_obj_list[0].status + if old_status: + status, quality = Quality.splitCompositeStatus(old_status) + use_quality_list = (status not in ( + common.WANTED, common.FAILED, common.UNAIRED, common.SKIPPED, common.IGNORED, common.UNKNOWN)) + + quality_list = use_quality_list and (None, best_qualities)[any(best_qualities)] or None + best_result = pick_best_result(found_results[provider_id][cur_search_result], show_obj, quality_list, filter_rls=orig_thread_name) diff --git a/sickbeard/show_queue.py b/sickbeard/show_queue.py index 5e75417..97f93bf 100644 --- a/sickbeard/show_queue.py +++ b/sickbeard/show_queue.py @@ -336,11 +336,12 @@ class ShowQueue(generic_queue.GenericQueue): :return: :rtype: QueueItemSubtitle """ - queue_item_obj = QueueItemSubtitle(show_obj) + if sickbeard.USE_SUBTITLES: + queue_item_obj = QueueItemSubtitle(show_obj) - self.add_item(queue_item_obj) + self.add_item(queue_item_obj) - return queue_item_obj + return queue_item_obj def addShow(self, tvid, prodid, show_dir, default_status=None, quality=None, flatten_folders=None, lang='en', subtitles=None, anime=None, scene=None, paused=None, blacklist=None, whitelist=None, @@ -986,6 +987,9 @@ class QueueItemSubtitle(ShowQueueItem): def run(self): ShowQueueItem.run(self) + if not sickbeard.USE_SUBTITLES: + self.finish() + return logger.log('Downloading subtitles for %s' % self.show_obj.name) diff --git a/sickbeard/tv.py b/sickbeard/tv.py index 248d333..4990798 100644 --- a/sickbeard/tv.py +++ b/sickbeard/tv.py @@ -761,7 +761,7 @@ class TVShow(TVShowBase): # store the reference in the show if None is not ep_obj: - if self.subtitles: + if sickbeard.USE_SUBTITLES and self.subtitles: try: ep_obj.refresh_subtitles() except (BaseException, Exception): @@ -2067,7 +2067,8 @@ class TVEpisode(TVEpisodeBase): def refresh_subtitles(self): """Look for subtitles files and refresh the subtitles property""" - self.subtitles = subtitles.subtitles_languages(self.location) + if sickbeard.USE_SUBTITLES: + self.subtitles = subtitles.subtitles_languages(self.location) def download_subtitles(self, force=False): """ @@ -2077,6 +2078,9 @@ class TVEpisode(TVEpisodeBase): :return: :rtype: """ + if not sickbeard.USE_SUBTITLES: + return + # TODO: Add support for force option if not ek.ek(os.path.isfile, self.location): logger.log('%s: Episode file doesn\'t exist, can\'t download subtitles for episode %sx%s' % diff --git a/sickbeard/webapi.py b/sickbeard/webapi.py index 7654e52..2ccae8e 100644 --- a/sickbeard/webapi.py +++ b/sickbeard/webapi.py @@ -1448,6 +1448,9 @@ class CMD_SickGearSubtitleSearch(ApiCall): def run(self): """ search episode subtitles """ + if not sickbeard.USE_SUBTITLES: + return _responds(RESULT_FAILURE, msg='Subtitle search is disabled in SickGear') + show_obj = helpers.find_show_by_id({self.tvid: self.prodid}) if not show_obj: return _responds(RESULT_FAILURE, msg="Show not found") diff --git a/sickbeard/webserve.py b/sickbeard/webserve.py index 775902a..8984978 100644 --- a/sickbeard/webserve.py +++ b/sickbeard/webserve.py @@ -2747,9 +2747,10 @@ class Home(MainHandler): return self._generic_message('Error', 'Unable to find the specified show') # search and download subtitles - sickbeard.showQueueScheduler.action.download_subtitles(show_obj) + if sickbeard.USE_SUBTITLES: + sickbeard.showQueueScheduler.action.download_subtitles(show_obj) - helpers.cpu_sleep() + helpers.cpu_sleep() self.redirect('/home/view-show?tvid_prodid=%s' % show_obj.tvid_prodid) @@ -3159,6 +3160,9 @@ class Home(MainHandler): def search_episode_subtitles(self, tvid_prodid=None, season=None, episode=None): + if not sickbeard.USE_SUBTITLES: + return json.dumps({'result': 'falure'}) + # retrieve the episode object and fail if we can't get one ep_obj = self._get_episode(tvid_prodid, season, episode) if isinstance(ep_obj, str): @@ -4995,38 +4999,39 @@ class Manage(MainHandler): def download_subtitle_missed(self, **kwargs): - to_download = {} + if sickbeard.USE_SUBTITLES: + to_download = {} - # make a list of all shows and their associated args - for arg in kwargs: - tvid_prodid, what = arg.split('-') + # make a list of all shows and their associated args + for arg in kwargs: + tvid_prodid, what = arg.split('-') - # we don't care about unchecked checkboxes - if kwargs[arg] != 'on': - continue + # we don't care about unchecked checkboxes + if kwargs[arg] != 'on': + continue - if tvid_prodid not in to_download: - to_download[tvid_prodid] = [] + if tvid_prodid not in to_download: + to_download[tvid_prodid] = [] - to_download[tvid_prodid].append(what) + to_download[tvid_prodid].append(what) - for cur_tvid_prodid in to_download: - # get a list of all the eps we want to download subtitles if 'all' is selected - if 'all' in to_download[cur_tvid_prodid]: - my_db = db.DBConnection() - sql_result = my_db.select( - 'SELECT season, episode' - ' FROM tv_episodes' - ' WHERE indexer = ? AND showid = ?' - ' AND season != 0 AND status LIKE \'%4\'', - TVidProdid(cur_tvid_prodid).list) - to_download[cur_tvid_prodid] = map_list(lambda x: '%sx%s' % (x['season'], x['episode']), sql_result) + for cur_tvid_prodid in to_download: + # get a list of all the eps we want to download subtitles if 'all' is selected + if 'all' in to_download[cur_tvid_prodid]: + my_db = db.DBConnection() + sql_result = my_db.select( + 'SELECT season, episode' + ' FROM tv_episodes' + ' WHERE indexer = ? AND showid = ?' + ' AND season != 0 AND status LIKE \'%4\'', + TVidProdid(cur_tvid_prodid).list) + to_download[cur_tvid_prodid] = map_list(lambda x: '%sx%s' % (x['season'], x['episode']), sql_result) - for epResult in to_download[cur_tvid_prodid]: - season, episode = epResult.split('x') + for epResult in to_download[cur_tvid_prodid]: + season, episode = epResult.split('x') - show_obj = helpers.find_show_by_id(cur_tvid_prodid) - _ = show_obj.get_episode(int(season), int(episode)).download_subtitles() + show_obj = helpers.find_show_by_id(cur_tvid_prodid) + _ = show_obj.get_episode(int(season), int(episode)).download_subtitles() self.redirect('/manage/subtitle-missed/') @@ -5441,7 +5446,7 @@ class Manage(MainHandler): sickbeard.showQueueScheduler.action.renameShowEpisodes(show_obj) renames.append(show_obj.name) - if cur_tvid_prodid in to_subtitle: + if sickbeard.USE_SUBTITLES and cur_tvid_prodid in to_subtitle: sickbeard.showQueueScheduler.action.download_subtitles(show_obj) subs.append(show_obj.name)