本文整理汇总了Python中sickbeard.helpers.sanitizeSceneName函数的典型用法代码示例。如果您正苦于以下问题:Python sanitizeSceneName函数的具体用法?Python sanitizeSceneName怎么用?Python sanitizeSceneName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sanitizeSceneName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_season_search_strings
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 cur_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
示例2: test_formating
def test_formating(self):
self.loadFromDB()
show = sickbeard.helpers.findCertainShow(sickbeard.showList, 75978)
ep = show.getEpisode(7, 6)
ep.airdate = datetime.datetime.now()
print format(ep.episode, '02d')
print format(ep.scene_episode, '02d')
search_string = {'Episode':[]}
episode = ep.airdate
str(episode).replace('-', '|')
ep_string = sanitizeSceneName(show.name) + ' ' + \
str(episode).replace('-', '|') + '|' + \
sickbeard.helpers.custom_strftime('%b', episode)
search_string['Episode'].append(ep_string)
scene_ep_string = sanitizeSceneName(show.name) + ' ' + \
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep.scene_season,
'episodenumber': ep.scene_episode} + '|' + \
sickbeard.config.naming_ep_type[0] % {'seasonnumber': ep.scene_season,
'episodenumber': ep.scene_episode} + '|' + \
sickbeard.config.naming_ep_type[3] % {'seasonnumber': ep.scene_season,
'episodenumber': ep.scene_episode} + ' %s category:tv' % ''
scene_season_string = show.name + ' S%02d' % int(ep.scene_season) + ' -S%02d' % int(ep.scene_season) + 'E' + ' category:tv' #1) ShowName SXX -SXXE
print(
u'Searching "%s" for "%s" as "%s"' % (show.name, ep.prettyName(), ep.scene_prettyName()))
print('Scene episode search strings: %s' % (scene_ep_string))
print('Scene season search strings: %s' % (scene_season_string))
示例3: _get_episode_search_strings
def _get_episode_search_strings(self, ep_obj, add_string=''):
search_strings = []
if not ep_obj:
return []
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
if self.show.air_by_date:
ep_string = sanitizeSceneName(show_name) + ' ' + str(ep_obj.airdate).replace('-', '.')
elif self.show.sports:
ep_string = sanitizeSceneName(show_name) + ' ' + str(ep_obj.airdate).replace('-', '.') + '|' + \
ep_obj.airdate.strftime('%b')
elif self.show.anime:
ep_string = sanitizeSceneName(show_name) + ' %i' % int(ep_obj.scene_absolute_number)
else:
ep_string = sanitizeSceneName(show_name) + ' ' + \
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
'episodenumber': ep_obj.scene_episode}
if len(add_string):
ep_string += ' %s' % add_string
search_strings.append(ep_string)
return search_strings
示例4: _get_season_search_strings
def _get_season_search_strings(self, show, season=None):
search_string = []
if not (show and season):
return []
myDB = db.DBConnection()
if show.air_by_date:
(min_date, max_date) = self._get_airbydate_season_range(season)
sqlResults = myDB.select(
"SELECT DISTINCT airdate FROM tv_episodes WHERE showid = ? AND airdate >= ? AND airdate <= ? AND status = ?",
[show.tvdbid, min_date.toordinal(), max_date.toordinal(), WANTED],
)
else:
sqlResults = myDB.select(
"SELECT DISTINCT season FROM tv_episodes WHERE showid = ? AND season = ? AND status = ?",
[show.tvdbid, season, WANTED],
)
for sqlEp in sqlResults:
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
if show.air_by_date:
ep_string = (
sanitizeSceneName(show_name)
+ " "
+ str(datetime.date.fromordinal(sqlEp["airdate"])).replace("-", ".")
)
search_string.append(ep_string)
else:
ep_string = sanitizeSceneName(show_name) + " S%02d" % sqlEp["season"]
search_string.append(ep_string)
return search_string
示例5: _get_episode_search_strings
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
示例6: _get_episode_search_strings
def _get_episode_search_strings(self, ep_obj, add_string=""):
if not ep_obj:
return []
search_strings = []
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
if self.show.air_by_date:
ep_string = sanitizeSceneName(show_name) + " " + str(ep_obj.airdate).replace("-", "|")
elif self.show.sports:
ep_string = (
sanitizeSceneName(show_name)
+ " "
+ str(ep_obj.airdate).replace("-", "|")
+ "|"
+ ep_obj.airdate.strftime("%b")
)
elif self.show.anime:
ep_string = sanitizeSceneName(show_name) + " " + "%i" % int(ep_obj.scene_absolute_number)
else:
ep_string = (
sanitizeSceneName(show_name)
+ " "
+ sickbeard.config.naming_ep_type[2]
% {"seasonnumber": ep_obj.scene_season, "episodenumber": ep_obj.scene_episode}
)
if add_string:
ep_string += " %s" % add_string
search_strings.append(ep_string)
return [search_strings]
示例7: _get_episode_search_strings
def _get_episode_search_strings(self, show, season, episode, add_string=''):
search_string = {'Episode': []}
if not episode:
return []
if show.air_by_date:
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
ep_string = sanitizeSceneName(show_name) + ' ' + \
str(episode).replace('-', '|') + '|' + \
episode.strftime('%b')
search_string['Episode'].append(ep_string)
elif show.sports:
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
ep_string = sanitizeSceneName(show_name) + ' ' + \
str(episode).replace('-', '|') + '|' + \
episode.strftime('%b')
search_string['Episode'].append(ep_string)
else:
for show_name in set(show_name_helpers.allPossibleShowNames(show)):
ep_string = show_name_helpers.sanitizeSceneName(show_name) + ' ' + \
sickbeard.config.naming_ep_type[2] % {'seasonnumber': season,
'episodenumber': episode}
search_string['Episode'].append(re.sub('\s+', ' ', ep_string))
return [search_string]
示例8: _get_episode_search_strings
def _get_episode_search_strings(self, ep_obj, add_string=""):
search_string = {"Episode": []}
if not ep_obj:
return []
if self.show.air_by_date:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + " " + str(ep_obj.airdate).replace("-", "|")
search_string["Episode"].append(ep_string)
elif self.show.sports:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = (
sanitizeSceneName(show_name)
+ " "
+ str(ep_obj.airdate).replace("-", "|")
+ "|"
+ ep_obj.airdate.strftime("%b")
)
search_string["Episode"].append(ep_string)
else:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = (
show_name_helpers.sanitizeSceneName(show_name)
+ " "
+ sickbeard.config.naming_ep_type[2]
% {"seasonnumber": ep_obj.scene_season, "episodenumber": ep_obj.scene_episode}
)
search_string["Episode"].append(re.sub("\s+", " ", ep_string))
return [search_string]
示例9: _get_episode_search_strings
def _get_episode_search_strings(self, ep_obj, add_string=''):
search_string = {'Episode': []}
if not ep_obj:
return []
if self.show.air_by_date:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + '.' + \
str(ep_obj.airdate).replace('-', '|')
search_string['Episode'].append(ep_string)
elif self.show.sports:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + '.' + \
str(ep_obj.airdate).replace('-', '|') + '|' + \
ep_obj.airdate.strftime('%b')
search_string['Episode'].append(ep_string)
elif self.show.anime:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = sanitizeSceneName(show_name) + '.' + \
"%i" % int(ep_obj.scene_absolute_number)
search_string['Episode'].append(ep_string)
else:
for show_name in set(show_name_helpers.allPossibleShowNames(self.show)):
ep_string = show_name_helpers.sanitizeSceneName(show_name) + '.' + \
sickbeard.config.naming_ep_type[2] % {'seasonnumber': ep_obj.scene_season,
'episodenumber': ep_obj.scene_episode} + ' %s' % add_string
search_string['Episode'].append(re.sub('\s+', '.', ep_string))
return [search_string]
示例10: _get_episode_search_strings
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
示例11: _get_episode_search_strings
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
示例12: _get_episode_search_strings
def _get_episode_search_strings(self, show, season, episode, add_string=""):
if not episode:
return [{}]
search_params = {"category": "Episode"}
if show.indexer == 1:
search_params["tvdb"] = show.indexerid
elif show.indexer == 2:
search_params["tvrage"] = show.indexerid
else:
search_params["series"] = sanitizeSceneName(show.name)
if show.air_by_date:
date_str = str(episode)
# 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("-", ".")
if show.sports:
date_str = str(episode)
# 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("-", ".")
else:
# Do a general name search for the episode, formatted like SXXEYY
search_params["name"] = "S%02dE%02d" % (season, 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(show.indexerid)
for cur_exception in name_exceptions:
# don't add duplicates
if cur_exception == 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
示例13: _get_episode_search_strings
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
示例14: _get_season_search_strings
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
示例15: _get_episode_search_strings
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