def _season_strings(self, ep_obj, **kwargs): search_params = [] base_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.is_sports: # Search for the year of the air by date show base_params["name"] = str(ep_obj.airdate).split("-")[0] elif ep_obj.show.is_anime: base_params["name"] = "%s" % ep_obj.scene_absolute_number else: base_params["name"] = "Season %s" % (ep_obj.season, ep_obj.scene_season)[bool(ep_obj.show.is_scene)] if 1 == ep_obj.show.indexer: base_params["tvdb"] = ep_obj.show.indexerid search_params.append(base_params) # elif 2 == ep_obj.show.indexer: # current_params['tvrage'] = ep_obj.show.indexerid # search_params.append(current_params) else: name_exceptions = list( set( [ helpers.sanitizeSceneName(a) for a in scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name] ] ) ) for name in name_exceptions: series_param = {"series": name} series_param.update(base_params) search_params.append(series_param) return [dict({"Season": search_params})]
def allPossibleShowNames(show): """ 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 """ showNames = [show.name] showNames += [name for name in get_scene_exceptions(show.indexerid)] newShowNames = [] country_list = countryList country_list.update(dict(zip(countryList.values(), countryList.keys()))) # 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 curName in set(showNames): if not curName: continue for curCountry in country_list: if curName.endswith(' ' + curCountry): newShowNames.append(curName.replace(' ' + curCountry, ' (' + country_list[curCountry] + ')')) elif curName.endswith(' (' + curCountry + ')'): newShowNames.append(curName.replace(' (' + curCountry + ')', ' (' + country_list[curCountry] + ')')) showNames += newShowNames return showNames
def _get_season_search_strings(self, ep_obj): to_return = [] # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid, ep_obj.season) + [self.show.name] name_exceptions = set(name_exceptions) for cur_exception in name_exceptions: cur_params = {} # search if ep_obj.show.indexer == 2: cur_params["rid"] = ep_obj.show.indexerid else: cur_params["q"] = helpers.sanitizeSceneName(cur_exception) # season if ep_obj.show.air_by_date or ep_obj.show.sports: date_str = str(ep_obj.airdate).split("-")[0] cur_params["season"] = date_str if "q" in cur_params: cur_params["q"] += "." + date_str.replace("-", ".") else: cur_params["q"] = date_str.replace("-", ".") else: cur_params["season"] = str(ep_obj.scene_season) if not ("rid" in cur_params and to_return): to_return.append(cur_params) return to_return
def _get_episode_search_strings(self, ep_obj,french=None): params = {} global lang if not ep_obj: return [params] params['show_name'] = helpers.sanitizeSceneName(ep_obj.show.name).replace('.',' ').encode('utf-8') if ep_obj.show.air_by_date: params['date'] = str(ep_obj.airdate) else: params['season'] = ep_obj.season params['episode'] = ep_obj.episode to_return = [params] # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions(ep_obj.show.tvdbid) for name_exception in name_exceptions: # don't add duplicates if name_exception != ep_obj.show.name: # only change show name cur_return = params.copy() cur_return['show_name'] = helpers.sanitizeSceneName(name_exception) to_return.append(cur_return) logger.log(u"KAT _get_episode_search_strings for %s is returning %s" % (repr(ep_obj), repr(params)), logger.DEBUG) if french: lang='fr' else: lang = ep_obj.show.audio_lang return to_return
def _get_season_search_strings(self, show, season, episode): if not show: return [] search_params = [] name_exceptions = scene_exceptions.get_scene_exceptions(show.indexerid) + [show.name] for name in name_exceptions: current_params = {} if show.indexer == 1: current_params["tvdb"] = show.indexerid elif show.indexer == 2: current_params["tvrage"] = show.indexerid else: # Search by name if we don't have tvdb or tvrage id current_params["series"] = sanitizeSceneName(name) whole_season_params = current_params.copy() partial_season_params = current_params.copy() # Search for entire seasons: no need to do special things for air by date shows whole_season_params["category"] = "Season" whole_season_params["name"] = "Season " + str(season) search_params.append(whole_season_params) # Search for episodes in the season search_params.append(self._get_episode_search_strings(show, season, episode)[0]) return search_params
def _get_season_search_strings(self, ep_obj): to_return = [] # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid) + [self.show.name] for cur_exception in name_exceptions: cur_params = {} # search if ep_obj.show.indexer == 2: cur_params['rid'] = ep_obj.show.indexerid else: cur_params['q'] = helpers.sanitizeSceneName(cur_exception) # season if ep_obj.show.air_by_date or ep_obj.show.sports: date_str = str(ep_obj.airdate).split('-')[0] cur_params['season'] = date_str if 'q' in cur_params: cur_params['q'] += '.' + date_str.replace('-', '.') else: cur_params['q'] = date_str.replace('-', '.') else: cur_params['season'] = str(ep_obj.scene_season) if not ('rid' in cur_params and to_return): to_return.append(cur_params) return to_return
def _get_season_search_strings(self, ep_obj): search_params = [] name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid) + [self.show.name] for name in name_exceptions: current_params = {} if self.show.indexer == 1: current_params['tvdb'] = self.show.indexerid elif self.show.indexer == 2: current_params['tvrage'] = self.show.indexerid else: # Search by name if we don't have tvdb or tvrage id current_params['series'] = sanitizeSceneName(name) # Search for entire seasons: no need to do special things for air by date shows whole_season_params = current_params.copy() partial_season_params = current_params.copy() # Search for entire seasons: no need to do special things for air by date shows whole_season_params['category'] = 'Season' if ep_obj.show.air_by_date or ep_obj.show.sports: # Search for the year of the air by date show whole_season_params['name'] = str(ep_obj.airdate)[:7] else: whole_season_params['name'] = 'Season ' + str(ep_obj.scene_season) search_params.append(whole_season_params) return search_params
def _get_season_search_strings(self, ep_obj): """ Makes objects to pass to _doSearch for manual and backlog season pack searching Returns a list containing dicts of search parameters """ 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).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 '' name_exceptions = list(set([ep_obj.show.name] + scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid))) for cur_exception in name_exceptions: params['q'] = helpers.sanitizeSceneName(cur_exception) + save_q to_return.append(dict(params)) return to_return
def _get_season_search_strings(self, ep_obj): search_params = [] name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid) + [self.show.name] if not (ep_obj.show.air_by_date or ep_obj.show.sports): for name in name_exceptions: current_params = {} if self.show.indexer == 1: current_params["tvdb"] = self.show.indexerid elif self.show.indexer == 2: current_params["tvrage"] = self.show.indexerid else: # Search by name if we don't have tvdb or tvrage id current_params["series"] = sanitizeSceneName(name) # Search for entire seasons: no need to do special things for air by date shows whole_season_params = current_params.copy() whole_season_params["category"] = "Season" if not (ep_obj.show.air_by_date or ep_obj.show.sports): whole_season_params["name"] = "Season " + str(ep_obj.scene_season) elif ep_obj.show.air_by_date or ep_obj.show.sports: whole_season_params["name"] = self._get_episode_search_strings(ep_obj)[0]["name"] search_params.append(whole_season_params) return search_params
def buildNameCache(show=None): """Build internal name cache :param show: Specify show to build name cache for, if None, just do all shows """ with nameCacheLock: scene_exceptions.retrieve_exceptions() if not show: logging.info("Building internal name cache for all shows") for show in sickbeard.showList: buildNameCache(show) else: logging.debug("Building internal name cache for [{}]".format(show.name)) clearCache(show.indexerid) for curSeason in [-1] + scene_exceptions.get_scene_seasons(show.indexerid): for name in list(set(scene_exceptions.get_scene_exceptions(show.indexerid, season=curSeason) + [ show.name])): name = sickbeard.helpers.full_sanitizeSceneName(name) if name in nameCache: continue nameCache[name] = int(show.indexerid) logging.debug("Internal name cache for {} set to: [{}]".format(show.name, [key for key, value in nameCache.items() if value == show.indexerid]))
def _get_season_search_strings(self, show, season, episode, abd=False): if not show: return [{}] to_return = [] # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions(show.indexerid) + [show.name] for cur_exception in name_exceptions: cur_params = {} # search cur_params['q'] = helpers.sanitizeSceneName(cur_exception) # season cur_params['season'] = str(season) # episode cur_params['episode'] = self._get_episode_search_strings(show, season, episode, abd)[0]['ep'] to_return.append(cur_params) return to_return
def _get_season_search_strings(self, ep_obj): 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) elif ep_obj.show.indexer == 2: current_params['tvrage'] = ep_obj.show.indexerid search_params.append(current_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 or tvrage id current_params['series'] = sanitizeSceneName(name) search_params.append(current_params) return search_params
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] + scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid))) for cur_exception in name_exceptions: params['q'] = helpers.sanitizeSceneName(cur_exception) if add_string: params['q'] += ' ' + add_string to_return.append(dict(params)) return to_return
def _get_episode_search_strings(self, ep_obj, add_string=''): """ Makes objects to pass to search for manual and backlog season pack searching Returns a list containing dicts of search parameters """ 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 name_exceptions = list(set([ep_obj.show.name] + scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid))) for cur_exception in name_exceptions: params['q'] = helpers.sanitizeSceneName(cur_exception) if add_string: params['q'] += ' ' + add_string to_return.append(dict(params)) return to_return
def _get_season_search_strings(self, show, season, wantedEp, searchSeason=False): if not show: return [{}] to_return = [] # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions(show.indexerid) + [show.name] for cur_exception in name_exceptions: cur_params = {} # search cur_params['q'] = helpers.sanitizeSceneName(cur_exception) # air-by-date means &season=2010&q=2010.03, no other way to do it atm if show.air_by_date: cur_params['season'] = season.split('-')[0] if 'q' in cur_params: cur_params['q'] += '.' + season.replace('-', '.') else: cur_params['q'] = season.replace('-', '.') else: cur_params['season'] = str(season) to_return.append(cur_params) return to_return
def _get_season_search_strings(self, show, season, wantedEp, searchSeason=False): if not show: return [{}] to_return = [] # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions(show.tvdbid) + [show.name] for cur_exception in name_exceptions: cur_params = {} # search directly by tvrage id if show.tvrid: cur_params['rid'] = show.tvrid # if we can't then fall back on a very basic name search else: cur_params['q'] = helpers.sanitizeSceneName(cur_exception) # air-by-date means &season=2010&q=2010.03, no other way to do it atm if show.air_by_date: cur_params['season'] = season.split('-')[0] if 'q' in cur_params: cur_params['q'] += '.' + season.replace('-', '.') else: cur_params['q'] = season.replace('-', '.') else: cur_params['season'] = season # hack to only add a single result if it's a rageid search if not ('rid' in cur_params and to_return): to_return.append(cur_params) return to_return
def _get_season_search_strings(self, season, episode): search_params = [] name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid) + [self.show.name] for name in name_exceptions: current_params = {} if self.show.indexer == 1: current_params['tvdb'] = self.show.indexerid elif self.show.indexer == 2: current_params['tvrage'] = self.show.indexerid else: # Search by name if we don't have tvdb or tvrage id current_params['series'] = sanitizeSceneName(name) whole_season_params = current_params.copy() # Search for entire seasons: no need to do special things for air by date shows whole_season_params['category'] = 'Season' whole_season_params['name'] = 'Season ' + str(season) search_params.append(whole_season_params) # Search for episodes in the season search_params.append(self._get_episode_search_strings(season, episode)[0]) return search_params
def _get_season_search_strings(self, ep_obj): to_return = [] cur_params = {} # season if ep_obj.show.air_by_date or ep_obj.show.sports: date_str = str(ep_obj.airdate).split('-')[0] cur_params['season'] = date_str cur_params['q'] = date_str.replace('-', '.') elif ep_obj.show.is_anime: cur_params['season'] = "%d" % ep_obj.scene_absolute_number else: cur_params['season'] = str(ep_obj.scene_season) # search rid = helpers.mapIndexersToShow(ep_obj.show)[2] if rid: cur_return = cur_params.copy() cur_return['rid'] = rid to_return.append(cur_return) # add new query strings for exceptions name_exceptions = list( set(scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name])) for cur_exception in name_exceptions: if 'q' in cur_params: cur_params['q'] = helpers.sanitizeSceneName(cur_exception) + '.' + cur_params['q'] to_return.append(cur_params) return to_return
def _get_season_search_strings(self, ep_obj): to_return = [] # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid) + [self.show.name] for cur_exception in name_exceptions: cur_params = {} # search cur_params['q'] = helpers.sanitizeSceneName(cur_exception) # season if not (ep_obj.show.air_by_date or ep_obj.show.sports): cur_params['season'] = str(ep_obj.scene_season) to_return.append(cur_params) cur_params = {} if ep_obj.show.air_by_date or ep_obj.show.sports: cur_params['season'] = self._get_episode_search_strings(ep_obj)[0]['season'] #cur_params['episode'] = self._get_episode_search_strings(ep_obj)[0]['ep'] to_return.append(cur_params) return to_return
def _get_episode_search_strings(self, ep_obj, add_string=""): to_return = [] params = {} if not ep_obj: return [params] 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("-", "/") elif ep_obj.show.anime: params["ep"] = "%i" % int(ep_obj.scene_absolute_number) else: params["season"] = ep_obj.scene_season params["ep"] = ep_obj.scene_episode # search rid = helpers.mapIndexersToShow(ep_obj.show)[2] if rid: params["rid"] = rid to_return.append(params) else: # add new query strings for exceptions name_exceptions = list( set(scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name]) ) for cur_exception in name_exceptions: params["q"] = helpers.sanitizeSceneName(cur_exception) to_return.append(params) return to_return
def _get_season_search_strings(self, ep_obj): to_return = [] cur_params = {} # season if ep_obj.show.air_by_date or ep_obj.show.sports: date_str = str(ep_obj.airdate).split("-")[0] cur_params["season"] = date_str cur_params["q"] = date_str.replace("-", ".") elif ep_obj.show.is_anime: cur_params["season"] = "%d" % ep_obj.scene_absolute_number else: cur_params["season"] = str(ep_obj.scene_season) # search rid = helpers.mapIndexersToShow(ep_obj.show)[2] if rid: cur_params["rid"] = rid to_return.append(cur_params) else: # add new query strings for exceptions name_exceptions = list( set(scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name]) ) for cur_exception in name_exceptions: if "q" in cur_params: cur_params["q"] = helpers.sanitizeSceneName(cur_exception) + "." + cur_params["q"] to_return.append(cur_params) return to_return
def _get_episode_search_strings(self, ep_obj, add_string=''): to_return = [] params = {} if not ep_obj: return [params] 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('-', '/') elif ep_obj.show.anime: params['ep'] = "%i" % int(ep_obj.scene_absolute_number) else: params['season'] = ep_obj.scene_season params['ep'] = ep_obj.scene_episode # search rid = helpers.mapIndexersToShow(ep_obj.show)[2] if rid: cur_return = params.copy() cur_return['rid'] = rid to_return.append(cur_return) # add new query strings for exceptions name_exceptions = list( set(scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name])) for cur_exception in name_exceptions: params['q'] = helpers.sanitizeSceneName(cur_exception) to_return.append(params) return to_return
def _get_episode_search_strings(self, ep_obj, add_string=''): 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'] = "{0:d}".format(int(ep_obj.scene_absolute_number)) else: # Do a general name search for the episode, formatted like SXXEYY search_params['name'] = "{ep}".format(ep=episode_num(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(scene_exceptions.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 _get_episode_search_strings(self, ep_obj, add_string=""): 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(scene_exceptions.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 _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] + scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid))) for cur_exception in name_exceptions: params['q'] = helpers.sanitizeSceneName(cur_exception) + save_q to_return.append(dict(params)) return to_return
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 """ showNames = get_scene_exceptions(show.tvdbid, season=season) if not showNames: # if we dont have any season specific exceptions fallback to generic exceptions season = -1 showNames = get_scene_exceptions(show.tvdbid, season=season) if season in [-1, 1]: showNames.append(show.name) # if we have a tvrage name then use it if show.tvrname != "" and show.tvrname != None and season in [-1, 1]: showNames.append(show.tvrname) newShowNames = [] for curName in set(showNames): newShowNames.append(curName) newShowNames.append(curName.replace(' ', '')) showNames = newShowNames country_list = countryList country_list.update(dict(zip(countryList.values(), countryList.keys()))) # 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) # only for none anime if not show.is_anime: for curName in set(showNames): if not curName: continue for curCountry in country_list: if curName.endswith(' '+curCountry): newShowNames.append(curName.replace(' '+curCountry, ' ('+country_list[curCountry]+')')) elif curName.endswith(' ('+curCountry+')'): newShowNames.append(curName.replace(' ('+curCountry+')', ' ('+country_list[curCountry]+')')) showNames += newShowNames return showNames
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 """ showNames = get_scene_exceptions(show.indexerid, season=season)[:] if not showNames: # if we dont have any season specific exceptions fallback to generic exceptions season = -1 showNames = get_scene_exceptions(show.indexerid, season=season)[:] if season in [-1, 1]: showNames.append(show.name) if not show.is_anime: newShowNames = [] country_list = common.countryList country_list.update(dict(zip(common.countryList.values(), common.countryList.keys()))) for curName in set(showNames): 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): newShowNames.append(curName.replace(" " + curCountry, " (" + country_list[curCountry] + ")")) elif curName.endswith(" (" + curCountry + ")"): newShowNames.append(curName.replace(" (" + curCountry + ")", " (" + country_list[curCountry] + ")")) # if we have "Show Name (2013)" this will strip the (2013) show year from the show name # newShowNames.append(re.sub('\(\d{4}\)','',curName)) showNames += newShowNames return showNames
def _get_episode_search_strings(self, ep_obj, add_string=''): if not ep_obj: return [{}] search_params = {'category': 'Episode'} if self.show.indexer == 1: search_params['tvdb'] = self.show.indexerid elif self.show.indexer == 2: search_params['tvrage'] = self.show.indexerid else: search_params['series'] = sanitizeSceneName(self.show.name) if self.show.air_by_date: 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 self.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'] = ep_obj.airdate.strftime('%b') elif self.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) to_return = [search_params] # only do scene exceptions if we are searching by name if 'series' in search_params: # add new query string for every exception name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid) for cur_exception in name_exceptions: # don't add duplicates if cur_exception == self.show.name: continue # copy all other parameters before setting the show name for this exception cur_return = search_params.copy() cur_return['series'] = sanitizeSceneName(cur_exception) to_return.append(cur_return) return to_return
def _get_episode_search_strings(self, ep_obj, french=None): showNames = show_name_helpers.allPossibleShowNames(ep_obj.show) for show_name in showNames: ep_obj.show.sname=show_name params = {} if not ep_obj: return [params] # search directly by tvrage id if ep_obj.show.tvrid: params['rid'] = ep_obj.show.tvrid if ep_obj.show.audio_lang=="fr" or french: params['q'] = "french" else: params['q'] = helpers.sanitizeSceneName(ep_obj.show.sname) # if we can't then fall back on a very basic name search else: if ep_obj.show.audio_lang=="fr" or french: params['q'] = helpers.sanitizeSceneName(ep_obj.show.sname) + " french" else: params['q'] = helpers.sanitizeSceneName(ep_obj.show.sname) if ep_obj.show.air_by_date: 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 to_return = [params] # only do exceptions if we are searching by name if 'q' in params: # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions(ep_obj.show.tvdbid) for cur_exception in name_exceptions: # don't add duplicates if cur_exception == ep_obj.show.sname: continue cur_return = params.copy() cur_return['q'] = helpers.sanitizeSceneName(cur_exception) to_return.append(cur_return) return to_return
def _get_season_search_strings(self, show, season=None): if not show: return [{}] search_params = [] name_exceptions = scene_exceptions.get_scene_exceptions(show.tvdbid) + [show.name] for name in name_exceptions: current_params = {} if show.tvdbid: current_params['tvdb'] = show.tvdbid elif show.tvrid: current_params['tvrage'] = show.tvrid else: # Search by name if we don't have tvdb or tvrage id current_params['series'] = sanitizeSceneName(name) if season is not None: whole_season_params = current_params.copy() partial_season_params = current_params.copy() # Search for entire seasons: no need to do special things for air by date shows whole_season_params['category'] = 'Season' whole_season_params['name'] = 'Season ' + str(season) if whole_season_params not in search_params: search_params.append(whole_season_params) # Search for episodes in the season partial_season_params['category'] = 'Episode' if show.air_by_date: # Search for the year of the air by date show partial_season_params['name'] = str(season.split('-')[0]) + "%" else: # Search for any result which has Sxx in the name partial_season_params['name'] = "S" + str(season).zfill(2) + "%" if partial_season_params not in search_params: search_params.append(partial_season_params) else: if current_params not in search_params: search_params.append(current_params) return search_params
def _get_season_search_strings(self, show, season=None): if not show: return [{}] to_return = [] # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions( show.tvdbid) + [show.name] for cur_exception in name_exceptions: cur_params = {} # search directly by tvrage id if show.tvrid: cur_params['rid'] = show.tvrid # if we can't then fall back on a very basic name search else: if show.audio_lang == "fr": cur_params['q'] = helpers.sanitizeSceneName( cur_exception) + " french" else: cur_params['q'] = helpers.sanitizeSceneName(cur_exception) if season != None: # air-by-date means &season=2010&q=2010.03, no other way to do it atm if show.air_by_date: cur_params['season'] = season.split('-')[0] if 'q' in cur_params: cur_params['q'] += '.' + season.replace('-', '.') else: cur_params['q'] = season.replace('-', '.') else: cur_params['season'] = season # hack to only add a single result if it's a rageid search if not ('rid' in cur_params and to_return): to_return.append(cur_params) return to_return
def _get_episode_search_strings(self, ep_obj, add_string=''): params = {} if not ep_obj: return [params] # search params['q'] = helpers.sanitizeSceneName(self.show.name) if self.show.air_by_date: date_str = str(ep_obj.airdate) params['season'] = date_str.partition('-')[0] params['ep'] = date_str.partition('-')[2].replace('-', '/') elif self.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 to_return = [params] # only do exceptions if we are searching by name if 'q' in params: # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions( self.show.indexerid) for cur_exception in name_exceptions: # don't add duplicates if cur_exception == self.show.name: continue cur_return = params.copy() cur_return['q'] = helpers.sanitizeSceneName(cur_exception) to_return.append(cur_return) return to_return
def _episode_strings(self, ep_obj, **kwargs): if not ep_obj: return [{}] search_params = [] base_params = {'category': 'Episode'} # episode if ep_obj.show.air_by_date or ep_obj.show.is_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 base_params['name'] = date_str.replace('-', '.') elif ep_obj.show.is_anime: base_params['name'] = '%s' % ep_obj.scene_absolute_number else: # Do a general name search for the episode, formatted like SXXEYY season, episode = ((ep_obj.season, ep_obj.episode), (ep_obj.scene_season, ep_obj.scene_episode))[bool(ep_obj.show.is_scene)] base_params['name'] = 'S%02dE%02d' % (season, episode) # search if 1 == ep_obj.show.indexer: base_params['tvdb'] = ep_obj.show.indexerid search_params.append(base_params) # elif 2 == ep_obj.show.indexer: # search_params['tvrage'] = ep_obj.show.indexerid # to_return.append(search_params) else: # add new query string for every exception name_exceptions = list( set([helpers.sanitizeSceneName(a) for a in scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name]])) for name in name_exceptions: series_param = {'series': name} series_param.update(base_params) search_params.append(series_param) return [dict({'Episode': search_params})]
def allPossibleShowNames(show): """ 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 """ showNames = [show.name] showNames += [name for name in get_scene_exceptions(show.tvdbid)] # if we have a tvrage name then use it if show.tvrname != "" and show.tvrname != None: showNames.append(show.tvrname) newShowNames = [] country_list = countryList country_list.update(dict(zip(countryList.values(), countryList.keys()))) # 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 curName in set(showNames): if not curName: continue for curCountry in country_list: if curName.endswith(' ' + curCountry): newShowNames.append( curName.replace(' ' + curCountry, ' (' + country_list[curCountry] + ')')) elif curName.endswith(' (' + curCountry + ')'): newShowNames.append( curName.replace(' (' + curCountry + ')', ' (' + country_list[curCountry] + ')')) showNames += newShowNames return showNames
def _get_episode_search_strings(self, ep_obj): params = {} if not ep_obj: return [params] # search directly by tvrage id if ep_obj.show.tvrid: params['rid'] = ep_obj.show.tvrid # if we can't then fall back on a very basic name search else: params['q'] = helpers.sanitizeSceneName(ep_obj.show.name) if ep_obj.show.air_by_date: date_str = str(ep_obj.airdate) params['season'] = date_str.partition('-')[0] params['ep'] = date_str.partition('-')[2].replace('-', '/') else: params['season'] = ep_obj.season params['ep'] = ep_obj.episode to_return = [params] # only do exceptions if we are searching by name if 'q' in params: # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions(ep_obj.show.tvdbid) for cur_exception in name_exceptions: # don't add duplicates if cur_exception == ep_obj.show.name: continue cur_return = params.copy() cur_return['q'] = helpers.sanitizeSceneName(cur_exception) to_return.append(cur_return) return to_return
def _get_season_search_strings(self, ep_obj): to_return = [] cur_params = {} cur_params['maxage'] = ( datetime.datetime.now() - datetime.datetime.combine( ep_obj.airdate, datetime.datetime.min.time())).days + 1 # season if ep_obj.show.air_by_date or ep_obj.show.sports: date_str = str(ep_obj.airdate).split('-')[0] cur_params['season'] = date_str cur_params['q'] = date_str.replace('-', '.') elif ep_obj.show.is_anime: cur_params['season'] = "%d" % ep_obj.scene_absolute_number else: cur_params['season'] = str(ep_obj.scene_season) # search rid = helpers.mapIndexersToShow(ep_obj.show)[2] if rid: cur_params['rid'] = rid elif 'rid' in params: cur_params.pop('rid') # add new query strings for exceptions name_exceptions = list( set( scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name])) for cur_exception in name_exceptions: if 'q' in cur_params: cur_params['q'] = helpers.sanitizeSceneName( cur_exception) + '.' + cur_params['q'] else: cur_params['q'] = helpers.sanitizeSceneName(cur_exception) to_return.append(cur_params) return to_return
def _get_season_search_strings(self, ep_obj): to_return = [] cur_params = {} if not ep_obj: return to_return cur_params['maxage'] = (datetime.datetime.now() - datetime.datetime.combine(ep_obj.airdate, datetime.datetime.min.time())).days + 1 # season if ep_obj.show.air_by_date or ep_obj.show.sports: date_str = str(ep_obj.airdate).split('-')[0] cur_params['season'] = date_str cur_params['q'] = date_str.replace('-', '.') else: cur_params['season'] = str(ep_obj.scene_season) # search rid = helpers.mapIndexersToShow(ep_obj.show)[2] if rid: cur_params['rid'] = rid cur_params['attrs'] = "rageid" to_return.append(dict(cur_params)) if 'rid' in cur_params: cur_params.pop('rid') cur_params.pop('attrs') save_q = '' if 'q' in cur_params: save_q = ' ' + cur_params['q'] # add new query strings for exceptions name_exceptions = list( set([ep_obj.show.name] + scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid))) for cur_exception in name_exceptions: cur_params['q'] = helpers.sanitizeSceneName(cur_exception) + save_q to_return.append(dict(cur_params)) return to_return
def _get_episode_search_strings(self, ep_obj, add_string=''): 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) elif ep_obj.show.indexer == 2: search_params['tvrage'] = ep_obj.show.indexerid to_return.append(search_params) else: # add new query string for every exception name_exceptions = list( set( scene_exceptions.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 _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 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 # search rid = helpers.mapIndexersToShow(ep_obj.show)[2] if rid: params['rid'] = rid params['attrs'] = "rageid" to_return.append(dict(params)) if 'rid' in params: params.pop('rid') params.pop('attrs') # add new query strings for exceptions name_exceptions = list( set([ep_obj.show.name] + scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid))) for cur_exception in name_exceptions: params['q'] = helpers.sanitizeSceneName(cur_exception) if add_string: params['q'] += ' ' + add_string to_return.append(dict(params)) return to_return
def _get_season_search_strings(self, ep_obj): to_return = [] # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions(self.show.indexerid) + [self.show.name] for cur_exception in name_exceptions: cur_params = {} # search cur_params['q'] = helpers.sanitizeSceneName(cur_exception) # season cur_params['season'] = str(ep_obj.scene_season) # episode cur_params['episode'] = self._get_episode_search_strings(ep_obj)[0]['ep'] to_return.append(cur_params) return to_return
def _season_strings(self, ep_obj, **kwargs): search_params = [] base_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.is_sports: # Search for the year of the air by date show base_params['name'] = str(ep_obj.airdate).split('-')[0] elif ep_obj.show.is_anime: base_params['name'] = '%s' % ep_obj.scene_absolute_number else: base_params['name'] = 'Season %s' % ( ep_obj.season, ep_obj.scene_season)[bool(ep_obj.show.is_scene)] if 1 == ep_obj.show.indexer: base_params['tvdb'] = ep_obj.show.indexerid base_params['series'] = ep_obj.show.name search_params.append(base_params) # elif 2 == ep_obj.show.indexer: # current_params['tvrage'] = ep_obj.show.indexerid # search_params.append(current_params) # else: name_exceptions = list( set([ helpers.sanitizeSceneName(a) for a in scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name] ])) dedupe = [ep_obj.show.name.replace(' ', '.')] for name in name_exceptions: if name.replace(' ', '.') not in dedupe: dedupe += [name.replace(' ', '.')] series_param = base_params.copy() series_param['series'] = name search_params.append(series_param) return [dict(Season=search_params)]
def _get_season_search_strings(self, show, season=None): params = {} if not show: return params ShowRssId = self._getShowRssIdForShow(show.name) if ShowRssId: params['ShowRssId'] = ShowRssId return [params] if ATTEMPT_EXCEPTIONS_IF_NOT_KNOWN: for otherName in get_scene_exceptions(show.tvdbid): ShowRssId = self._getShowRssIdForShow(otherName) if ShowRssId: params['ShowRssId'] = ShowRssId return [params] logger.log( u"Show %s doesn't appear to be known to ShowRSS" % show.name, logger.MESSAGE) return []
def _get_season_search_strings(self, ep_obj): to_return = [] # add new query strings for exceptions name_exceptions = scene_exceptions.get_scene_exceptions( self.show.indexerid) + [self.show.name] for cur_exception in name_exceptions: cur_params = {} # search cur_params['q'] = helpers.sanitizeSceneName(cur_exception) # season if ep_obj.show.air_by_date or ep_obj.show.sports: cur_params['season'] = str(ep_obj.airdate)[:7] else: cur_params['season'] = str(ep_obj.scene_season) to_return.append(cur_params) return to_return
def _get_season_search_strings(self, ep_obj): search_params = [] name_exceptions = scene_exceptions.get_scene_exceptions( self.show.indexerid) + [self.show.name] for name in name_exceptions: current_params = {} if self.show.indexer == 1: current_params['tvdb'] = self.show.indexerid elif self.show.indexer == 2: current_params['tvrage'] = self.show.indexerid else: # Search by name if we don't have tvdb or tvrage id current_params['series'] = sanitizeSceneName(name) # Search for entire seasons: no need to do special things for air by date shows whole_season_params = current_params.copy() # Search for entire seasons: no need to do special things for air by date shows whole_season_params['category'] = 'Season' if ep_obj.show.air_by_date or ep_obj.show.sports: # Search for the year of the air by date show whole_season_params['name'] = str(ep_obj.airdate).split('-')[0] elif ep_obj.show.is_anime: whole_season_params[ 'name'] = "%d" % ep_obj.scene_absolute_number else: whole_season_params['name'] = 'Season ' + str( ep_obj.scene_season) if whole_season_params not in search_params: search_params.append(whole_season_params) return search_params
def _get_season_search_strings(self, ep_obj): to_return = [] cur_params = {} # season if ep_obj.show.air_by_date or ep_obj.show.sports: date_str = str(ep_obj.airdate).split('-')[0] cur_params['season'] = date_str cur_params['q'] = date_str.replace('-', '.') elif ep_obj.show.is_anime: cur_params['season'] = '%d' % ep_obj.scene_absolute_number else: cur_params['season'] = str(ep_obj.scene_season) # search rid = helpers.mapIndexersToShow(ep_obj.show)[2] if rid: cur_return = cur_params.copy() cur_return['rid'] = rid to_return.append(cur_return) # add new query strings for exceptions name_exceptions = list( set([ helpers.sanitizeSceneName(a) for a in scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name] ])) for cur_exception in name_exceptions: cur_return = cur_params.copy() if 'q' in cur_return: cur_return['q'] = cur_exception + '.' + cur_return['q'] to_return.append(cur_return) return to_return
def test_sceneExceptionsBlack_Lagoon(self): self.assertEqual( sorted(scene_exceptions.get_scene_exceptions(1, 79604)), ['Black-Lagoon'])
def test_scene_ex_babylon_5(self): """ Test scene exceptions for Babylon 5 """ self.assertEqual(sorted(scene_exceptions.get_scene_exceptions(70726)), ['Babylon 5', 'Babylon5'])
def parse(self, name): if not self.show: for showObj in sickbeard.showList: for showName in [ showObj.name ] + scene_exceptions.get_scene_exceptions(showObj.tvdbid): if showName in name: np = NameParser(show=showObj) return np.parse(name) name = self._unicodify(name) cached = name_parser_cache.get(name) if cached: return cached # break it into parts if there are any (dirname, file name, extension) dir_name, file_name = os.path.split(name) ext_match = re.match('(.*)\.\w{3,4}$', file_name) if ext_match and self.file_name: base_file_name = ext_match.group(1) else: base_file_name = file_name # use only the direct parent dir dir_name = os.path.basename(dir_name) # set up a result to use final_result = ParseResult(name) # try parsing the file name file_name_result = self._parse_string(base_file_name) # parse the dirname for extra info if needed dir_name_result = self._parse_string(dir_name) # build the ParseResult object final_result.air_date = self._combine_results(file_name_result, dir_name_result, 'air_date') if not final_result.air_date: final_result.season_number = self._combine_results( file_name_result, dir_name_result, 'season_number') final_result.episode_numbers = self._combine_results( file_name_result, dir_name_result, 'episode_numbers') final_result.ab_episode_numbers = self._combine_results( file_name_result, dir_name_result, 'ab_episode_numbers') # if the dirname has a release group/show name I believe it over the filename final_result.series_name = self._combine_results( dir_name_result, file_name_result, 'series_name') final_result.extra_info = self._combine_results( dir_name_result, file_name_result, 'extra_info') final_result.release_group = self._combine_results( dir_name_result, file_name_result, 'release_group') # Season name if self.show and self.show.seasons_name: if not final_result.episode_numbers: # Usually shows with season name get the absolute episode regex, this fix it final_result.episode_numbers = final_result.ab_episode_numbers final_result.series_name, final_result.season_number = getShowAndSeasonFromSeasonName( self.show, final_result.series_name) final_result.which_regex = [] if final_result == file_name_result: final_result.which_regex = file_name_result.which_regex elif final_result == dir_name_result: final_result.which_regex = dir_name_result.which_regex else: if file_name_result: final_result.which_regex += file_name_result.which_regex if dir_name_result: final_result.which_regex += dir_name_result.which_regex # if there's no useful info in it then raise an exception if final_result.season_number == None and not final_result.episode_numbers and final_result.air_date == None and not final_result.series_name: raise InvalidNameException("Unable to parse " + name) name_parser_cache.add(name, final_result) # return it return final_result
def test_sceneExceptionsBabylon5(self): self.assertEqual(sorted(scene_exceptions.get_scene_exceptions(70726)), ['Babylon 5', 'Babylon5'])
def test_sceneExceptionsEmpty(self): self.assertEqual(scene_exceptions.get_scene_exceptions(0), [])
def test_scene_ex_empty(self): """ Test empty scene exception """ self.assertEqual(scene_exceptions.get_scene_exceptions(0), [])
def allPossibleShowNames(show, season=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 """ showNames = [show.name] showNames += [name for name in get_scene_exceptions(show.tvdbid)] # if we have a tvrage name then use it if show.tvrname != "" and show.tvrname != None: showNames.append(show.tvrname) newShowNames = [] country_list = countryList country_list.update(dict(zip(countryList.values(), countryList.keys()))) # 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) # only for none anime if not show.anime: for curName in set(showNames): if not curName: continue for curCountry in country_list: if curName.endswith(' ' + curCountry): newShowNames.append( curName.replace(' ' + curCountry, ' (' + country_list[curCountry] + ')')) elif curName.endswith(' (' + curCountry + ')'): newShowNames.append( curName.replace(' (' + curCountry + ')', ' (' + country_list[curCountry] + ')')) showNames += newShowNames newShowNames = [] # Season Names if season != None and show.seasons_name: if season == "all": seasons = range(1, len(show.seasons_name) + 1) elif isinstance(season, int): seasons = [season] else: seasons = season for season in seasons: try: season_name = show.seasons_name[season] except: season_name = "" for showName in showNames: newShowNames.append(showName + season_name) showNames = newShowNames # If season is specified, return only the specified season name return showNames
def _episode_strings(self, ep_obj): search_params = [] base_params = {} if not ep_obj: return [base_params] ep_detail = None if ep_obj.show.air_by_date or ep_obj.show.is_sports: airdate = str(ep_obj.airdate).split('-') base_params['season'] = airdate[0] if ep_obj.show.air_by_date: base_params['ep'] = '/'.join(airdate[1:]) ep_detail = '+"%s.%s"' % (base_params['season'], '.'.join( airdate[1:])) elif ep_obj.show.is_anime: base_params['ep'] = '%i' % ( helpers.tryInt(ep_obj.scene_absolute_number) or helpers.tryInt(ep_obj.scene_episode)) ep_detail = '%02d' % helpers.tryInt(base_params['ep']) else: base_params['season'], base_params['ep'] = ( (ep_obj.season, ep_obj.episode), (ep_obj.scene_season, ep_obj.scene_episode))[ep_obj.show.is_scene] ep_detail = sickbeard.config.naming_ep_type[2] % { 'seasonnumber': helpers.tryInt(base_params['season'], 1), 'episodenumber': helpers.tryInt(base_params['ep'], 1) } # id search params = base_params.copy() use_id = False for i in sickbeard.indexerApi().all_indexers: if i in ep_obj.show.ids and 0 < ep_obj.show.ids[i][ 'id'] and i in self.caps: params[self.caps[i]] = ep_obj.show.ids[i]['id'] use_id = True use_id and search_params.append(params) # query search and exceptions name_exceptions = list( set([ helpers.sanitizeSceneName(a) for a in scene_exceptions.get_scene_exceptions(ep_obj.show.indexerid) + [ep_obj.show.name] ])) spacer = 'geek' in self.get_id() and ' ' or '.' if sickbeard.scene_exceptions.has_abs_episodes(ep_obj): search_params.append({ 'q': '%s%s%s' % (ep_obj.show.name, spacer, base_params['ep']) }) for cur_exception in name_exceptions: params = base_params.copy() cur_exception = cur_exception.replace('.', spacer) params['q'] = cur_exception search_params.append(params) if ep_detail: params = base_params.copy() params['q'] = '%s%s%s' % (cur_exception, spacer, ep_detail) 'season' in params and params.pop('season') 'ep' in params and params.pop('ep') search_params.append(params) return [{'Episode': search_params}]