本文整理汇总了Python中sickbeard.helpers.mapIndexersToShow函数的典型用法代码示例。如果您正苦于以下问题:Python mapIndexersToShow函数的具体用法?Python mapIndexersToShow怎么用?Python mapIndexersToShow使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mapIndexersToShow函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _get_season_search_strings
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
示例2: _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:
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
示例3: _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
示例4: _get_season_search_strings
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
示例5: _retrieve_show_images_from_fanart
def _retrieve_show_images_from_fanart(self, show, type, thumb=False):
types = {
"poster": fanart.TYPE.TV.POSTER,
"banner": fanart.TYPE.TV.BANNER,
"poster_thumb": fanart.TYPE.TV.POSTER,
"banner_thumb": fanart.TYPE.TV.BANNER,
"fanart": fanart.TYPE.TV.BACKGROUND,
}
try:
indexerid = helpers.mapIndexersToShow(show)[1]
if indexerid:
request = fanartRequest(
apikey=sickbeard.FANART_API_KEY,
id=indexerid,
ws=fanart.WS.TV,
type=types[type],
sort=fanart.SORT.POPULAR,
limit=fanart.LIMIT.ONE,
)
resp = request.response()
url = resp[types[type]][0]["url"]
if thumb:
url = re.sub("/fanart/", "/preview/", url)
return url
except Exception as e:
pass
logger.log(u"Could not find any " + type + " images on Fanart.tv for " + show.name, logger.DEBUG)
示例6: _retrieve_show_images_from_fanart
def _retrieve_show_images_from_fanart(self, show, img_type, thumb=False):
types = {
'poster': fanart.TYPE.TV.POSTER,
'banner': fanart.TYPE.TV.BANNER,
'poster_thumb': fanart.TYPE.TV.POSTER,
'banner_thumb': fanart.TYPE.TV.BANNER,
'fanart': fanart.TYPE.TV.BACKGROUND,
}
try:
indexerid = helpers.mapIndexersToShow(show)[1]
if indexerid:
request = fanartRequest(
apikey=sickbeard.FANART_API_KEY,
id=indexerid,
ws=fanart.WS.TV,
type=types[img_type],
sort=fanart.SORT.POPULAR,
limit=fanart.LIMIT.ONE,
)
resp = request.response()
url = resp[types[img_type]][0]['url']
if thumb:
url = re.sub('/fanart/', '/preview/', url)
return url
except Exception:
pass
logger.log(u"Could not find any " + img_type + " images on Fanart.tv for " + show.name, logger.INFO)
示例7: _build_search_str
def _build_search_str(ep_obj, search_params):
if 1 == ep_obj.show.indexer:
search_params['series_id'] = ep_obj.show.indexerid
elif 2 == ep_obj.show.indexer:
tvdbid = mapIndexersToShow(ep_obj.show)[1]
if tvdbid:
search_params['series_id'] = tvdbid
return [search_params]
示例8: removeShowFromTraktLibrary
def removeShowFromTraktLibrary(self, show_obj):
data = {}
if self.findShow(show_obj.indexer, show_obj.indexerid):
# URL parameters
data['tvdb_id'] = helpers.mapIndexersToShow(show_obj)[1]
data['title'] = show_obj.name
data['year'] = show_obj.startyear
if len(data):
logger.log(u"Removing " + show_obj.name + " from trakt.tv library", logger.DEBUG)
TraktCall("show/unlibrary/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD,
data)
示例9: _get_season_search_strings
def _get_season_search_strings(self, ep_obj):
search_params = {"limit": 100}
search_params["season"] = "Season %02d" % ep_obj.scene_season
if ep_obj.show.indexer == 1:
search_params["series_id"] = ep_obj.show.indexerid
elif ep_obj.show.indexer == 2:
tvdbid = mapIndexersToShow(ep_obj.show)[1]
if tvdbid:
search_params["series_id"] = tvdbid
return [search_params]
示例10: removeShowFromTraktLibrary
def removeShowFromTraktLibrary(self, show_obj):
if self.findShow(show_obj.indexer, show_obj.indexerid):
# URL parameters
data = {'tvdb_id': helpers.mapIndexersToShow(show_obj)[1], 'title': show_obj.name,
'year': show_obj.startyear}
logger.log(u"Removing " + show_obj.name + " from trakt.tv library", logger.DEBUG)
try:
self.trakt_api.traktRequest("show/unlibrary/%APIKEY%", data, method='POST')
except (traktException, traktAuthException, traktServerBusy) as e:
logger.log(u"Could not connect to Trakt service: %s" % ex(e), logger.WARNING)
pass
示例11: _get_episode_search_strings
def _get_episode_search_strings(self, ep_obj):
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 if int(ep_obj.scene_absolute_number) > 0 else ep_obj.scene_episode)
else:
params['season'], params['ep'] = ep_obj.scene_season, 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([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 = params.copy()
cur_return['q'] = cur_exception
to_return.append(cur_return)
if ep_obj.show.anime:
# Experimental, add a searchstring without search explicitly for the episode!
# Remove the ?ep=e46 paramater and use add the episode number to the query paramater.
# Can be usefull for newznab indexers that do not have the episodes 100% parsed.
# Start with only applying the searchstring to anime shows
params['q'] = cur_exception
params_no_ep = params.copy()
params_no_ep['q'] = '%s.%02d' % (params_no_ep['q'], int(params_no_ep['ep']))
if 'ep' in params_no_ep:
params_no_ep.pop('ep')
to_return.append(params_no_ep)
return to_return
示例12: _get_episode_search_strings
def _get_episode_search_strings(self, ep_obj, add_string=''):
if not ep_obj:
return [{}]
search_params = {'limit': 100}
# Do a general name search for the episode, formatted like SXXEYY
search_params['episode'] = 'S%02dE%02d' % (ep_obj.scene_season, ep_obj.scene_episode)
if ep_obj.show.indexer == 1:
search_params['series_id'] = ep_obj.show.indexerid
elif ep_obj.show.indexer == 2:
tvdbid = mapIndexersToShow(ep_obj.show)[1]
if tvdbid:
search_params['series_id'] = tvdbid
return [search_params]
示例13: _season_strings
def _season_strings(self, ep_obj):
search_params = []
base_params = {}
# season
if ep_obj.show.air_by_date or ep_obj.show.is_sports:
date_str = str(ep_obj.airdate).split("-")[0]
base_params["season"] = date_str
base_params["q"] = date_str.replace("-", ".")
elif ep_obj.show.is_anime:
base_params["season"] = "%d" % ep_obj.scene_absolute_number
else:
base_params["season"] = str((ep_obj.season, ep_obj.scene_season)[bool(ep_obj.show.is_scene)])
# search
ids = helpers.mapIndexersToShow(ep_obj.show)
if ids[1]: # or ids[2]:
params = base_params.copy()
use_id = False
if ids[1] and self.supports_tvdbid():
params["tvdbid"] = ids[1]
use_id = True
if ids[2]:
params["rid"] = ids[2]
use_id = True
use_id and search_params.append(params)
# 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:
params = base_params.copy()
if "q" in params:
params["q"] = "%s.%s" % (cur_exception, params["q"])
search_params.append(params)
return [{"Season": search_params}]
示例14: _get_episode_search_strings
def _get_episode_search_strings(self, ep_obj, add_string=''):
to_return = []
params = {}
if not ep_obj:
return [params]
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('-', '/')
elif ep_obj.show.anime:
params['ep'] = "%i" % int(ep_obj.scene_absolute_number if int(ep_obj.scene_absolute_number) > 0 else ep_obj.scene_episode)
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
elif 'rid' in params:
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:
params['q'] = helpers.sanitizeSceneName(cur_exception)
if add_string:
params['q'] += ' ' + add_string
to_return.append(dict(params))
if ep_obj.show.anime:
paramsNoEp = params.copy()
paramsNoEp['q'] = paramsNoEp['q'] + " " + paramsNoEp['ep']
if "ep" in paramsNoEp:
paramsNoEp.pop("ep")
to_return.append(paramsNoEp)
return to_return
示例15: addShowToTraktLibrary
def addShowToTraktLibrary(self, show_obj):
"""
Sends a request to trakt indicating that the given show and all its episodes is part of our library.
show_obj: The TVShow object to add to trakt
"""
data = {}
if not self.findShow(show_obj.indexer, show_obj.indexerid):
# URL parameters
data['tvdb_id'] = helpers.mapIndexersToShow(show_obj)[1]
data['title'] = show_obj.name
data['year'] = show_obj.startyear
if len(data):
logger.log(u"Adding " + show_obj.name + " to trakt.tv library", logger.DEBUG)
TraktCall("show/library/%API%", sickbeard.TRAKT_API, sickbeard.TRAKT_USERNAME, sickbeard.TRAKT_PASSWORD,
data)