def all_possible_show_names(show_id, season=-1, session=None): """ Figures out every possible variation of the name for a particular show. Includes TVDB name, TVRage name, country codes on the end, eg. "Show Name (AU)", and any scene exception names. show: a TVShow object that we should get the names of Returns: a list of all the possible show names :rtype: list[unicode] """ from sickrage.core.scene_exceptions import get_scene_exceptions show = find_show(show_id, session=session) show_names = get_scene_exceptions(show_id, season=season)[:] if not show_names: # if we dont have any season specific exceptions fallback to generic exceptions season = -1 show_names = get_scene_exceptions(show_id, season=season)[:] if season in [-1, 1]: show_names.append(show.name) show_names.append(strip_accents(show.name)) show_names.append(strip_accents(show.name).replace("'", " ")) if not show.is_anime: new_show_names = [] country_list = common.countryList country_list.update( dict(zip(common.countryList.values(), common.countryList.keys()))) for curName in set(show_names): if not curName: continue # if we have "Show Name Australia" or "Show Name (Australia)" this will add "Show Name (AU)" for # any countries defined in common.countryList # (and vice versa) for curCountry in country_list: if curName.endswith(' ' + curCountry): new_show_names.append( curName.replace(' ' + curCountry, ' (' + country_list[curCountry] + ')')) elif curName.endswith(' (' + curCountry + ')'): new_show_names.append( curName.replace(' (' + curCountry + ')', ' (' + country_list[curCountry] + ')')) # if we have "Show Name (2013)" this will strip the (2013) show year from the show name new_show_names.append( re.sub(r'\({}\)'.format(show.startyear), '', curName)) show_names += new_show_names return list(set(show_names))
def _get_episode_search_strings(ep_obj, add_string='', **kwargs): if not ep_obj: return [{}] to_return = [] search_params = {'category': 'Episode'} # episode if ep_obj.show.air_by_date or ep_obj.show.sports: date_str = str(ep_obj.airdate) # BTN uses dots in dates, we just search for the date since that # combined with the series identifier should result in just one episode search_params['name'] = date_str.replace('-', '.') elif ep_obj.show.anime: search_params['name'] = "%i" % int(ep_obj.scene_absolute_number) else: # Do a general name search for the episode, formatted like SXXEYY search_params['name'] = "S%02dE%02d" % (ep_obj.scene_season, ep_obj.scene_episode) # search if ep_obj.show.indexer == 1: search_params['tvdb'] = ep_obj.show.indexerid to_return.append(search_params) else: # add new query string for every exception name_exceptions = list( set(get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name])) for cur_exception in name_exceptions: search_params['series'] = sanitizeSceneName(cur_exception) to_return.append(search_params) return to_return
def buildNameCache(self, show=None): """Build internal name cache :param show: Specify show to build name cache for, if None, just do all shows """ if self.shouldUpdate(): if not show: retrieve_exceptions() for show in sickrage.showList: sickrage.LOGGER.info("Building internal name cache for all shows") self.buildNameCache(show) else: self.lastUpdate = datetime.datetime.fromtimestamp( int(time.mktime(datetime.datetime.today().timetuple())) ) sickrage.LOGGER.debug("Building internal name cache for [{}]".format(show.name)) self.clearCache(show.indexerid) for curSeason in [-1] + get_scene_seasons(show.indexerid): for name in list(set(get_scene_exceptions( show.indexerid, season=curSeason) + [show.name])): name = full_sanitizeSceneName(name) if name not in self.cache: self.cache[name] = int(show.indexerid) sickrage.LOGGER.debug("Internal name cache for [{}] set to: [{}]".format( show.name, [key for key, value in self.cache.items() if value == show.indexerid][0]))
def _get_season_search_strings(self, ep_obj): to_return = [] params = {} if not ep_obj: return to_return params['maxage'] = (datetime.datetime.now() - datetime.datetime.combine(ep_obj.airdate, datetime.datetime.min.time())).days + 1 params['tvdbid'] = ep_obj.show.indexerid # season if ep_obj.show.air_by_date or ep_obj.show.sports: date_str = str(ep_obj.airdate).split('-')[0] params['season'] = date_str params['q'] = date_str.replace('-', '.') else: params['season'] = str(ep_obj.scene_season) save_q = ' ' + params['q'] if 'q' in params else '' # add new query strings for exceptions name_exceptions = list( set([ep_obj.show.name] + get_scene_exceptions(ep_obj.show.indexerid))) for cur_exception in name_exceptions: params['q'] = sanitizeSceneName(cur_exception) + save_q to_return.append(dict(params)) return to_return
def build(self, show=None, force=False): """Build internal name cache :param show: Specify show to build name cache for, if None, just do all shows """ if not show: retrieve_exceptions() for show in sickrage.srCore.SHOWLIST: self.build(show) elif self.should_update(show): self.lastUpdate[show.name] = datetime.fromtimestamp( int(time.mktime(datetime.today().timetuple()))) sickrage.srCore.srLogger.debug( "Building internal name cache for [{}]".format(show.name)) self.clear(show.indexerid) for curSeason in [-1] + get_scene_seasons(show.indexerid): for name in list( set( get_scene_exceptions(show.indexerid, season=curSeason) + [show.name])): self.put(name, show.indexerid) sickrage.srCore.srLogger.debug( "Internal name cache for [{}] set to: [{}]".format( show.name, [ key for key, value in self.cache.items() if value == show.indexerid ][0]))
def _get_episode_search_strings(self, ep_obj, add_string=''): to_return = [] params = {} if not ep_obj: return to_return params['maxage'] = (datetime.datetime.now() - datetime.datetime.combine(ep_obj.airdate, datetime.datetime.min.time())).days + 1 params['tvdbid'] = ep_obj.show.indexerid if ep_obj.show.air_by_date or ep_obj.show.sports: date_str = str(ep_obj.airdate) params['season'] = date_str.partition('-')[0] params['ep'] = date_str.partition('-')[2].replace('-', '/') else: params['season'] = ep_obj.scene_season params['ep'] = ep_obj.scene_episode # add new query strings for exceptions name_exceptions = list( set([ep_obj.show.name] + get_scene_exceptions(ep_obj.show.indexerid))) for cur_exception in name_exceptions: params['q'] = sanitizeSceneName(cur_exception) if add_string: params['q'] += ' ' + add_string to_return.append(dict(params)) return to_return
def get_video(self, video_path, subtitles_path=None, subtitles=True, embedded_subtitles=None, episode_object=None): if not subtitles_path: subtitles_path = self.get_subtitles_path(video_path) try: video = subliminal.scan_video(video_path) except Exception as error: sickrage.app.log.debug('Exception: {}'.format(error)) else: if video.size > 10485760: video.hashes['itasa'] = hash_itasa(video_path) # external subtitles if subtitles: video.subtitle_languages |= set(subliminal.core.search_external_subtitles(video_path, directory=subtitles_path).values()) if embedded_subtitles is None: embedded_subtitles = bool( not sickrage.app.config.embedded_subtitles_all and video_path.endswith('.mkv')) subliminal.refine(video, episode_refiners=self.episode_refiners, embedded_subtitles=embedded_subtitles, release_name=episode_object.name, tv_episode=episode_object) from sickrage.core.scene_exceptions import get_scene_exceptions video.alternative_series = list(get_scene_exceptions(episode_object.show.indexer_id)) # remove format metadata video.format = "" return video
def _get_season_search_strings(ep_obj, **kwargs): search_params = [] current_params = {'category': 'Season'} # Search for entire seasons: no need to do special things for air by date or sports shows if ep_obj.show.air_by_date or ep_obj.show.sports: # Search for the year of the air by date show current_params['name'] = str(ep_obj.airdate).split('-')[0] elif ep_obj.show.is_anime: current_params['name'] = "%d" % ep_obj.scene_absolute_number else: current_params['name'] = 'Season ' + str(ep_obj.scene_season) # search if ep_obj.show.indexer == 1: current_params['tvdb'] = ep_obj.show.indexerid search_params.append(current_params) else: name_exceptions = list( set( get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name])) for name in name_exceptions: # Search by name if we don't have tvdb id current_params['series'] = sanitizeSceneName(name) search_params.append(current_params) return search_params
def build(self, show): """Build internal name cache :param show: Specify show to build name cache for, if None, just do all shows """ retrieve_exceptions() if self.should_update(show): self.last_update[show.name] = datetime.fromtimestamp( int(time.mktime(datetime.today().timetuple()))) self.clear(show.indexerid) show_names = [] for curSeason in [-1] + get_scene_seasons(show.indexerid): for name in list( set( get_scene_exceptions(show.indexerid, season=curSeason) + [show.name])): show_names.append(name) show_names.append(strip_accents(name)) show_names.append(strip_accents(name).replace("'", " ")) for show_name in set(show_names): self.clear(show_name) self.put(show_name, show.indexerid)
def get_video(video_path, subtitles_path=None, subtitles=True, embedded_subtitles=None, episode=None): if not subtitles_path: subtitles_path = get_subtitles_path(video_path) try: video = subliminal.scan_video(video_path) except Exception as error: sickrage.app.log.debug('Exception: {}'.format(error)) else: if video.size > 10485760: video.hashes['itasa'] = hash_itasa(video_path) # external subtitles if subtitles: video.subtitle_languages |= \ set(subliminal.core.search_external_subtitles(video_path, directory=subtitles_path).values()) if embedded_subtitles is None: embedded_subtitles = bool( not sickrage.app.config.embedded_subtitles_all and video_path.endswith('.mkv')) subliminal.refine(video, episode_refiners=episode_refiners, embedded_subtitles=embedded_subtitles, release_name=episode.name, tv_episode=episode) video.alternative_series = list(get_scene_exceptions(episode.show.indexerid)) # remove format metadata video.format = "" return video
def _get_season_search_strings(ep_obj, **kwargs): search_params = [] current_params = {'category': 'Season'} # Search for entire seasons: no need to do special things for air by date or sports shows if ep_obj.show.air_by_date or ep_obj.show.sports: # Search for the year of the air by date show current_params['name'] = str(ep_obj.airdate).split('-')[0] elif ep_obj.show.is_anime: current_params['name'] = "%d" % ep_obj.scene_absolute_number else: current_params['name'] = 'Season ' + str(ep_obj.scene_season) # search if ep_obj.show.indexer == 1: current_params['tvdb'] = ep_obj.show.indexerid search_params.append(current_params) else: name_exceptions = list( set(get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name])) for name in name_exceptions: # Search by name if we don't have tvdb id current_params['series'] = sanitizeSceneName(name) search_params.append(current_params) return search_params
def allPossibleShowNames(show, season=-1): """ Figures out every possible variation of the name for a particular show. Includes TVDB name, TVRage name, country codes on the end, eg. "Show Name (AU)", and any scene exception names. show: a TVShow object that we should get the names of Returns: a list of all the possible show names :rtype: list[unicode] """ show_names = get_scene_exceptions(show.indexerid, season=season)[:] if not show_names: # if we dont have any season specific exceptions fallback to generic exceptions season = -1 show_names = get_scene_exceptions(show.indexerid, season=season)[:] if season in [-1, 1]: show_names.append(show.name) show_names.append(strip_accents(show.name)) show_names.append(strip_accents(show.name).replace("'", " ")) if not show.is_anime: new_show_names = [] country_list = countryList country_list.update(dict(zip(countryList.values(), countryList.keys()))) for curName in set(show_names): if not curName: continue # if we have "Show Name Australia" or "Show Name (Australia)" this will add "Show Name (AU)" for # any countries defined in common.countryList # (and vice versa) for curCountry in country_list: if curName.endswith(' ' + curCountry): new_show_names.append(curName.replace(' ' + curCountry, ' (' + country_list[curCountry] + ')')) elif curName.endswith(' (' + curCountry + ')'): new_show_names.append(curName.replace(' (' + curCountry + ')', ' (' + country_list[curCountry] + ')')) # # if we have "Show Name (2013)" this will strip the (2013) show year from the show name # new_show_names.append(re.sub('\(\d{4}\)', '', curName)) show_names += new_show_names return list(set(show_names))
def _search_params(self, show_id, season, episode, mode, season_numbering=None, session=None): searches = [] show_object = find_show(show_id, session=session) episode_object = show_object.get_episode(season, episode) air_by_date = show_object.air_by_date sports = show_object.sports if not season_numbering and (air_by_date or sports): date_fmt = '%Y' if mode == 'Season' else '%Y.%m.%d' search_name = episode_object.airdate.strftime(date_fmt) else: search_name = '{type} {number}'.format( type='Season' if mode == 'Season' else '', number=episode_object.scene_season if mode == 'Season' and season else episode_num( episode_object.scene_season, episode_object.scene_episode), ).strip() params = { 'category': mode, 'name': search_name, } # Search if show_object.indexer == 1: params['tvdb'] = show_object.indexer_id params['series'] = show_object.name searches.append(params) for name in list( set( scene_exceptions.get_scene_exceptions( show_object.indexer_id))): series_params = params.copy() series_params['series'] = sanitize_scene_name(name) searches.append(series_params) # extend air by date searches to include season numbering if air_by_date and not season_numbering: searches.extend( self._search_params(show_id, season, episode, mode, season_numbering=True)) return searches
def build(self, show): """Build internal name cache :param show: Specify show to build name cache for, if None, just do all shows """ retrieve_exceptions() if self.should_update(show): self.last_update[show.name] = datetime.fromtimestamp(int(time.mktime(datetime.today().timetuple()))) self.clear(show.indexerid) for curSeason in [-1] + get_scene_seasons(show.indexerid): for name in list(set(get_scene_exceptions(show.indexerid, season=curSeason) + [show.name])): self.put(name, show.indexerid)
def _get_episode_search_strings(self, show_id, season, episode, add_string='', session=None): """ Get episode search strings. """ search_string = { 'Episode': [] } show_object = find_show(show_id, session=session) episode_object = show_object.get_episode(season, episode) for show_name in all_possible_show_names(show_id, episode_object.scene_season): episode_string = "{}{}".format(show_name, self.search_separator) episode_string_fallback = None if show_object.air_by_date: episode_string += str(episode_object.airdate).replace('-', ' ') elif show_object.sports: episode_string += str(episode_object.airdate).replace('-', ' ') episode_string += ('|', ' ')[len(self.proper_strings) > 1] episode_string += episode_object.airdate.strftime('%b') elif show_object.anime: # If the show name is a season scene exception, we want to use the indexer episode number. if (episode_object.scene_season > 1 and show_name in get_scene_exceptions(show_object.indexer_id, episode_object.scene_season)): # This is apparently a season exception, let's use the scene_episode instead of absolute ep = episode_object.scene_episode else: ep = episode_object.scene_absolute_number episode_string += '{episode:0>2}'.format(episode=ep) episode_string_fallback = episode_string + '{episode:0>3}'.format(episode=ep) else: episode_string += sickrage.app.naming_ep_type[2] % { 'seasonnumber': episode_object.scene_season, 'episodenumber': episode_object.scene_episode, } if add_string: episode_string += self.search_separator + add_string episode_string_fallback += self.search_separator + add_string search_string['Episode'].append(episode_string.strip()) if episode_string_fallback: search_string['Episode'].append(episode_string_fallback.strip()) return [search_string]
def get(self, *args, **kwargs): show = self.get_argument('show') groups = [] show_obj = find_show(int(show), session=self.db_session) if not show_obj: err_string = _("Unable to find the specified show: ") + str(show) return self._genericMessage(_("Error"), err_string) scene_exceptions = get_scene_exceptions(show_obj.indexer_id) if show_obj.is_anime: whitelist = show_obj.release_groups.whitelist blacklist = show_obj.release_groups.blacklist try: groups = get_release_groups_for_anime(show_obj.name) except AnidbAdbaConnectionException as e: sickrage.app.log.debug('Unable to get ReleaseGroups: {}'.format(e)) return self.render( "/home/edit_show.mako", show=show_obj, quality=show_obj.quality, scene_exceptions=scene_exceptions, groups=groups, whitelist=whitelist, blacklist=blacklist, title=_('Edit Show'), header=_('Edit Show'), controller='home', action="edit_show" ) else: return self.render( "/home/edit_show.mako", show=show_obj, quality=show_obj.quality, scene_exceptions=scene_exceptions, title=_('Edit Show'), header=_('Edit Show'), controller='home', action="edit_show" )
def _search_params(self, ep_obj, mode, season_numbering=None): if not ep_obj: return [] searches = [] season = 'Season' if mode == 'Season' else '' air_by_date = ep_obj.show.air_by_date sports = ep_obj.show.sports if not season_numbering and (air_by_date or sports): date_fmt = '%Y' if season else '%Y.%m.%d' search_name = ep_obj.airdate.strftime(date_fmt) else: search_name = '{type} {number}'.format( type=season, number=ep_obj.scene_season if season else episode_num( ep_obj.scene_season, ep_obj.scene_episode ), ).strip() params = { 'category': season or 'Episode', 'name': search_name, } # Search if ep_obj.show.indexer == 1: params['tvdb'] = ep_obj.show.indexerid searches.append(params) else: name_exceptions = list( set(scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name])) for name in name_exceptions: # Search by name if we don't have tvdb id params['series'] = sanitizeSceneName(name) searches.append(params) # extend air by date searches to include season numbering if air_by_date and not season_numbering: searches.extend( self._search_params(ep_obj, mode, season_numbering=True) ) return searches
def _search_params(self, ep_obj, mode, season_numbering=None): if not ep_obj: return [] searches = [] season = 'Season' if mode == 'Season' else '' air_by_date = ep_obj.show.air_by_date sports = ep_obj.show.sports if not season_numbering and (air_by_date or sports): date_fmt = '%Y' if season else '%Y.%m.%d' search_name = ep_obj.airdate.strftime(date_fmt) else: search_name = '{type} {number}'.format( type=season, number=ep_obj.season if season else episode_num( ep_obj.season, ep_obj.episode ), ).strip() params = { 'category': season or 'Episode', 'name': search_name, } # Search if ep_obj.show.indexer == 1: params['tvdb'] = ep_obj.show.indexerid searches.append(params) else: name_exceptions = list( set(scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name])) for name in name_exceptions: # Search by name if we don't have tvdb id params['series'] = sanitizeSceneName(name) searches.append(params) # extend air by date searches to include season numbering if air_by_date and not season_numbering: searches.extend( self._search_params(ep_obj, mode, season_numbering=True) ) return searches
def build(self, show): """Build internal name cache :param show: Specify show to build name cache for, if None, just do all shows """ retrieve_exceptions() if self.should_update(show): self.last_update[show.name] = datetime.fromtimestamp( int(time.mktime(datetime.today().timetuple()))) self.clear(show.indexerid) show_names = [] for curSeason in [-1] + get_scene_seasons(show.indexerid): for name in list( set( get_scene_exceptions(show.indexerid, season=curSeason) + [show.name])): show_names.append(name) # strip accents try: try: name.decode('ascii') except UnicodeEncodeError: pass show_names.append( unicodedata.normalize('NFKD', name).encode( 'ASCII', 'ignore')) show_names.append( unicodedata.normalize('NFKD', name).encode( 'ASCII', 'ignore').replace("'", " ")) except UnicodeDecodeError: pass for show_name in set(show_names): self.put(show_name, show.indexerid)
def build(self, show=None, force=False): """Build internal name cache :param show: Specify show to build name cache for, if None, just do all shows """ if not show: retrieve_exceptions() for show in sickrage.srCore.SHOWLIST: self.build(show) elif self.should_update(show): self.last_update[show.name] = datetime.fromtimestamp(int(time.mktime(datetime.today().timetuple()))) sickrage.srCore.srLogger.debug("Building internal name cache for [{}]".format(show.name)) self.clear(show.indexerid) for curSeason in [-1] + get_scene_seasons(show.indexerid): for name in list(set(get_scene_exceptions(show.indexerid, season=curSeason) + [show.name])): self.put(name, show.indexerid) sickrage.srCore.srLogger.debug("Internal name cache for [{}] set to: [{}]".format( show.name, [key for key, value in self.cache.items() if value == show.indexerid][0]))
def buildNameCache(self, show=None): """Build internal name cache :param show: Specify show to build name cache for, if None, just do all shows """ if self.shouldUpdate(): if not show: retrieve_exceptions() for show in sickrage.showList: sickrage.LOGGER.info( "Building internal name cache for all shows") self.buildNameCache(show) else: self.lastUpdate = datetime.datetime.fromtimestamp( int(time.mktime(datetime.datetime.today().timetuple()))) sickrage.LOGGER.debug( "Building internal name cache for [{}]".format(show.name)) self.clearCache(show.indexerid) for curSeason in [-1] + get_scene_seasons(show.indexerid): for name in list( set( get_scene_exceptions(show.indexerid, season=curSeason) + [show.name])): name = full_sanitizeSceneName(name) if name not in self.cache: self.cache[name] = int(show.indexerid) sickrage.LOGGER.debug( "Internal name cache for [{}] set to: [{}]".format( show.name, [ key for key, value in self.cache.items() if value == show.indexerid ][0]))
def test_sceneExceptionsBabylon5(self): self.assertEqual(sorted(get_scene_exceptions(70726)), ['Babylon 5', 'Babylon5'])
def test_sceneExceptionsEmpty(self): self.assertEqual(get_scene_exceptions(0), [])
def allPossibleShowNames(show, season=-1): """ Figures out every possible variation of the name for a particular show. Includes TVDB name, TVRage name, country codes on the end, eg. "Show Name (AU)", and any scene exception names. show: a TVShow object that we should get the names of Returns: a list of all the possible show names :rtype: list[unicode] """ show_names = get_scene_exceptions(show.indexerid, season=season)[:] if not show_names: # if we dont have any season specific exceptions fallback to generic exceptions season = -1 show_names = get_scene_exceptions(show.indexerid, season=season)[:] if season in [-1, 1]: show_names.append(show.name) try: # strip accents try: show.name.decode('ascii') except UnicodeEncodeError: pass show_names.append( unicodedata.normalize('NFKD', show.name).encode('ASCII', 'ignore')) show_names.append( unicodedata.normalize('NFKD', show.name).encode('ASCII', 'ignore').replace( "'", " ")) except UnicodeDecodeError: pass if not show.is_anime: new_show_names = [] country_list = countryList country_list.update(dict(zip(countryList.values(), countryList.keys()))) for curName in set(show_names): if not curName: continue # if we have "Show Name Australia" or "Show Name (Australia)" this will add "Show Name (AU)" for # any countries defined in common.countryList # (and vice versa) for curCountry in country_list: if curName.endswith(' ' + curCountry): new_show_names.append( curName.replace(' ' + curCountry, ' (' + country_list[curCountry] + ')')) elif curName.endswith(' (' + curCountry + ')'): new_show_names.append( curName.replace(' (' + curCountry + ')', ' (' + country_list[curCountry] + ')')) # # if we have "Show Name (2013)" this will strip the (2013) show year from the show name # new_show_names.append(re.sub('\(\d{4}\)', '', curName)) show_names += new_show_names return list(set(show_names))
def edit_show(show, any_qualities, best_qualities, exceptions_list, location=None, flatten_folders=None, paused=None, direct_call=None, air_by_date=None, sports=None, dvdorder=None, indexer_lang=None, subtitles=None, sub_use_sr_metadata=None, skip_downloaded=None, rls_ignore_words=None, rls_require_words=None, anime=None, blacklist=None, whitelist=None, scene=None, default_ep_status=None, quality_preset=None, search_delay=None, session=None): show_obj = find_show(int(show), session=session) if not show_obj: err_msg = _("Unable to find the specified show: ") + str(show) if direct_call: sickrage.app.alerts.error(_('Error'), err_msg) return False, err_msg show_obj.exceptions = get_scene_exceptions(show_obj.indexer_id) flatten_folders = not checkbox_to_value(flatten_folders) # UI inverts this value dvdorder = checkbox_to_value(dvdorder) skip_downloaded = checkbox_to_value(skip_downloaded) paused = checkbox_to_value(paused) air_by_date = checkbox_to_value(air_by_date) scene = checkbox_to_value(scene) sports = checkbox_to_value(sports) anime = checkbox_to_value(anime) subtitles = checkbox_to_value(subtitles) sub_use_sr_metadata = checkbox_to_value(sub_use_sr_metadata) if indexer_lang and indexer_lang in IndexerApi(show_obj.indexer).indexer().languages.keys(): indexer_lang = indexer_lang else: indexer_lang = show_obj.lang # if we changed the language then kick off an update if indexer_lang == show_obj.lang: do_update = False else: do_update = True if scene == show_obj.scene or anime == show_obj.anime: do_update_scene_numbering = False else: do_update_scene_numbering = True show_obj.paused = paused show_obj.scene = scene show_obj.anime = anime show_obj.sports = sports show_obj.subtitles = subtitles show_obj.sub_use_sr_metadata = sub_use_sr_metadata show_obj.air_by_date = air_by_date show_obj.default_ep_status = int(default_ep_status) show_obj.skip_downloaded = skip_downloaded # If directCall from mass_edit_update no scene exceptions handling or blackandwhite list handling if direct_call: do_update_exceptions = False else: if set(exceptions_list) == set(show_obj.exceptions): do_update_exceptions = False else: do_update_exceptions = True if anime: if whitelist: shortwhitelist = short_group_names(whitelist) show_obj.release_groups.set_white_keywords(shortwhitelist) else: show_obj.release_groups.set_white_keywords([]) if blacklist: shortblacklist = short_group_names(blacklist) show_obj.release_groups.set_black_keywords(shortblacklist) else: show_obj.release_groups.set_black_keywords([]) warnings, errors = [], [] new_quality = try_int(quality_preset, None) if not new_quality: new_quality = Quality.combine_qualities(list(map(int, any_qualities)), list(map(int, best_qualities))) show_obj.quality = new_quality # reversed for now if bool(show_obj.flatten_folders) != bool(flatten_folders): show_obj.flatten_folders = flatten_folders try: sickrage.app.show_queue.refresh_show(show_obj.indexer_id, True) except CantRefreshShowException as e: errors.append(_("Unable to refresh this show: {}").format(e)) if not direct_call: show_obj.lang = indexer_lang show_obj.dvdorder = dvdorder show_obj.rls_ignore_words = rls_ignore_words.strip() show_obj.rls_require_words = rls_require_words.strip() show_obj.search_delay = int(search_delay) # if we change location clear the db of episodes, change it, write to db, and rescan if os.path.normpath(show_obj.location) != os.path.normpath(location): sickrage.app.log.debug(os.path.normpath(show_obj.location) + " != " + os.path.normpath(location)) if not os.path.isdir(location) and not sickrage.app.config.create_missing_show_dirs: warnings.append("New location {} does not exist".format(location)) # don't bother if we're going to update anyway elif not do_update: # change it try: show_obj.location = location try: sickrage.app.show_queue.refresh_show(show_obj.indexer_id, True) except CantRefreshShowException as e: errors.append(_("Unable to refresh this show:{}").format(e)) # grab updated info from TVDB # showObj.loadEpisodesFromIndexer() # rescan the episodes in the new folder except NoNFOException: warnings.append( _("The folder at %s doesn't contain a tvshow.nfo - copy your files to that folder before " "you change the directory in SiCKRAGE.") % location) # force the update if do_update: try: sickrage.app.show_queue.update_show(show_obj.indexer_id, force=True) except CantUpdateShowException as e: errors.append(_("Unable to update show: {}").format(e)) if do_update_exceptions: try: update_scene_exceptions(show_obj.indexer_id, exceptions_list) except CantUpdateShowException: warnings.append(_("Unable to force an update on scene exceptions of the show.")) if do_update_scene_numbering: try: xem_refresh(show_obj.indexer_id, show_obj.indexer, True) except CantUpdateShowException: warnings.append(_("Unable to force an update on scene numbering of the show.")) if direct_call: return True if len(warnings) == 0 and len(errors) == 0 else False, json_encode({'warnings': warnings, 'errors': errors}) if len(warnings) > 0: sickrage.app.alerts.message( _('{num_warnings:d} warning{plural} while saving changes:').format(num_warnings=len(warnings), plural="" if len( warnings) == 1 else "s"), '<ul>' + '\n'.join(['<li>{0}</li>'.format(warning) for warning in warnings]) + "</ul>") if len(errors) > 0: sickrage.app.alerts.error( _('{num_errors:d} error{plural} while saving changes:').format(num_errors=len(errors), plural="" if len(errors) == 1 else "s"), '<ul>' + '\n'.join(['<li>{0}</li>'.format(error) for error in errors]) + "</ul>") return True, ""