本文整理汇总了Python中sickrage.helper.common.episode_num函数的典型用法代码示例。如果您正苦于以下问题:Python episode_num函数的具体用法?Python episode_num怎么用?Python episode_num使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了episode_num函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: refresh_subtitles
def refresh_subtitles(episode_info, existing_subtitles):
video = get_video(episode_info['location'])
if not video:
logger.log(u'Exception caught in subliminal.scan_video, subtitles couldn\'t be refreshed', logger.DEBUG)
return existing_subtitles, None
current_subtitles = get_subtitles(video)
if existing_subtitles == current_subtitles:
logger.log(u'No changed subtitles for {} {}'.format
(episode_info['show_name'], episode_num(episode_info['season'], episode_info['episode']) or
episode_num(episode_info['season'], episode_info['episode'], numbering='absolute')), logger.DEBUG)
return existing_subtitles, None
else:
return current_subtitles, True
开发者ID:pedro2d10,项目名称:SickRage-FR,代码行数:13,代码来源:subtitles.py
示例2: refresh_subtitles
def refresh_subtitles(episode):
video = get_video(episode.location)
if not video:
logger.log("Exception caught in subliminal.scan_video, subtitles couldn't be refreshed", logger.DEBUG)
return episode.subtitles, None
current_subtitles = get_subtitles(video)
if episode.subtitles == current_subtitles:
logger.log('No changed subtitles for {0} {1}'.format
(episode.show.name, episode_num(episode.season, episode.episode) or
episode_num(episode.season, episode.episode, numbering='absolute')), logger.DEBUG)
return episode.subtitles, None
else:
return current_subtitles, True
开发者ID:Elettronik,项目名称:SickRage,代码行数:13,代码来源:subtitles.py
示例3: download_subtitles
def download_subtitles(video_path, show_name, season, episode, episode_name, show_indexerid, release_name, status,
existing_subtitles): # pylint: disable=too-many-locals, too-many-branches, too-many-statements
"""Download missing subtitles for the given episode.
Checks whether subtitles are needed or not
:param video_path: the video path
:type video_path: str
:param show_name: the show name
:type show_name: str
:param season: the season number
:type season: int
:param episode: the episode number
:type episode: int
:param episode_name: the episode name
:type episode_name: str
:param show_indexerid: the show indexerid
:type show_indexerid: int
:param release_name: the release name
:type release_name: str
:param status: the show status
:type status: int
:param existing_subtitles: list of existing subtitles (opensubtitles codes)
:type existing_subtitles: list of str
:return: a sorted list of the opensubtitles codes for the downloaded subtitles
:rtype: list of str
"""
ep_num = episode_num(season, episode) or episode_num(season, episode, numbering='absolute')
languages = get_needed_languages(existing_subtitles)
if not languages:
logger.debug(u'Episode already has all needed subtitles, skipping %s %s', show_name, ep_num)
return []
logger.debug(u'Checking subtitle candidates for %s %s (%s)', show_name, ep_num, os.path.basename(video_path))
subtitles_dir = get_subtitles_dir(video_path)
found_subtitles = download_best_subs(video_path, subtitles_dir, release_name, languages)
for subtitle in found_subtitles:
if sickbeard.SUBTITLES_EXTRA_SCRIPTS and isMediaFile(video_path):
subtitle_path = compute_subtitle_path(subtitle, video_path, subtitles_dir)
run_subs_extra_scripts(video_path=video_path, subtitle_path=subtitle_path,
subtitle_language=subtitle.language, show_name=show_name, season=season,
episode=episode, episode_name=episode_name, show_indexerid=show_indexerid)
if sickbeard.SUBTITLES_HISTORY:
logger.debug(u'history.logSubtitle %s, %s', subtitle.provider_name, subtitle.language.opensubtitles)
history.logSubtitle(show_indexerid, season, episode, status, subtitle)
return sorted({subtitle.language.opensubtitles for subtitle in found_subtitles})
开发者ID:Eiber,项目名称:SickRage-Medusa,代码行数:50,代码来源:subtitles.py
示例4: _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'] = "{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
开发者ID:KraXed112,项目名称:SickRage,代码行数:34,代码来源:btn.py
示例5: remove_episode_trakt_collection
def remove_episode_trakt_collection(self):
if sickbeard.TRAKT_SYNC_REMOVE and sickbeard.TRAKT_SYNC and sickbeard.USE_TRAKT:
main_db_con = db.DBConnection()
sql_selection = 'select tv_shows.indexer, tv_shows.startyear, showid, show_name, season, episode, tv_episodes.status, tv_episodes.location from tv_episodes,tv_shows where tv_shows.indexer_id = tv_episodes.showid'
episodes = main_db_con.select(sql_selection)
if episodes:
trakt_data = []
for cur_episode in episodes:
trakt_id = sickbeard.indexerApi(cur_episode["indexer"]).config['trakt_id']
if self._check_list(trakt_id, cur_episode["showid"], cur_episode["season"], cur_episode["episode"], List='Collection'):
if cur_episode["location"] == '':
logger.log(u"Removing Episode {show} {ep} from collection".format
(show=cur_episode["show_name"],
ep=episode_num(cur_episode["season"], cur_episode["episode"])),
logger.DEBUG)
trakt_data.append((cur_episode["showid"], cur_episode["indexer"], cur_episode["show_name"], cur_episode["startyear"], cur_episode["season"], cur_episode["episode"]))
if trakt_data:
try:
data = self.trakt_bulk_data_generate(trakt_data)
self.trakt_api.traktRequest("sync/collection/remove", data, method='POST')
self._get_show_collection()
except traktException as e:
logger.log(u"Could not connect to Trakt. Error: {}".format(ex(e)), logger.WARNING)
开发者ID:Thraxis,项目名称:pymedusa,代码行数:28,代码来源:traktChecker.py
示例6: addEpisodeToTraktWatchList
def addEpisodeToTraktWatchList(self):
if sickbeard.TRAKT_SYNC_WATCHLIST and sickbeard.USE_TRAKT:
logger.log("WATCHLIST::ADD::START - Look for Episodes to Add to Trakt Watchlist", logger.DEBUG)
main_db_con = db.DBConnection()
sql_selection = 'select tv_shows.indexer, tv_shows.startyear, showid, show_name, season, episode from tv_episodes,tv_shows where tv_shows.indexer_id = tv_episodes.showid and tv_episodes.status in (' + ','.join([str(x) for x in Quality.SNATCHED + Quality.SNATCHED_PROPER + [WANTED]]) + ')'
episodes = main_db_con.select(sql_selection)
if episodes is not None:
trakt_data = []
for cur_episode in episodes:
trakt_id = sickbeard.indexerApi(cur_episode[b"indexer"]).config['trakt_id']
if not self._checkInList(trakt_id, str(cur_episode[b"showid"]), str(cur_episode[b"season"]), str(cur_episode[b"episode"])):
logger.log("Adding Episode {show} {ep} to watchlist".format
(show=cur_episode[b"show_name"],
ep=episode_num(cur_episode[b"season"], cur_episode[b"episode"])),
logger.DEBUG)
trakt_data.append((cur_episode[b"showid"], cur_episode[b"indexer"], cur_episode[b"show_name"], cur_episode[b"startyear"], cur_episode[b"season"],
cur_episode[b"episode"]))
if trakt_data:
try:
data = self.trakt_bulk_data_generate(trakt_data)
self.trakt_api.traktRequest("sync/watchlist", data, method='POST')
self._getEpisodeWatchlist()
except traktException as e:
logger.log("Could not connect to Trakt service. Error {0}".format(ex(e)), logger.WARNING)
logger.log("WATCHLIST::ADD::FINISH - Look for Episodes to Add to Trakt Watchlist", logger.DEBUG)
开发者ID:Zelgadis87,项目名称:SickRage,代码行数:31,代码来源:traktChecker.py
示例7: addEpisodeToTraktCollection
def addEpisodeToTraktCollection(self):
if sickbeard.TRAKT_SYNC and sickbeard.USE_TRAKT:
logger.log(u"COLLECTION::ADD::START - Look for Episodes to Add to Trakt Collection", logger.DEBUG)
main_db_con = db.DBConnection()
sql_selection = 'select tv_shows.indexer, tv_shows.startyear, showid, show_name, season, episode from tv_episodes,tv_shows where tv_shows.indexer_id = tv_episodes.showid and tv_episodes.status in (' + ','.join([str(x) for x in Quality.DOWNLOADED + Quality.ARCHIVED]) + ')'
episodes = main_db_con.select(sql_selection)
if episodes is not None:
trakt_data = []
for cur_episode in episodes:
trakt_id = sickbeard.indexerApi(cur_episode["indexer"]).config['trakt_id']
if not self._checkInList(trakt_id, str(cur_episode["showid"]), str(cur_episode["season"]), str(cur_episode["episode"]), List='Collection'):
logger.log(u"Adding Episode {show} {ep} to collection".format
(show=cur_episode["show_name"],
ep=episode_num(cur_episode["season"], cur_episode["episode"])),
logger.DEBUG)
trakt_data.append((cur_episode["showid"], cur_episode["indexer"], cur_episode["show_name"], cur_episode["startyear"], cur_episode["season"], cur_episode["episode"]))
if trakt_data:
try:
data = self.trakt_bulk_data_generate(trakt_data)
self.trakt_api.traktRequest("sync/collection", data, method='POST')
self._getShowCollection()
except traktException as e:
logger.log(u"Could not connect to Trakt service. Error: {0}".format(ex(e)), logger.WARNING)
logger.log(u"COLLECTION::ADD::FINISH - Look for Episodes to Add to Trakt Collection", logger.DEBUG)
开发者ID:lucianot54,项目名称:SickRage,代码行数:30,代码来源:traktChecker.py
示例8: removeEpisodeFromTraktWatchList
def removeEpisodeFromTraktWatchList(self):
if sickbeard.TRAKT_SYNC_WATCHLIST and sickbeard.USE_TRAKT:
logger.log(u"WATCHLIST::REMOVE::START - Look for Episodes to Remove from Trakt Watchlist", logger.DEBUG)
main_db_con = db.DBConnection()
sql_selection = 'select tv_shows.indexer, tv_shows.startyear, showid, show_name, season, episode, tv_episodes.status from tv_episodes,tv_shows where tv_shows.indexer_id = tv_episodes.showid'
episodes = main_db_con.select(sql_selection)
if episodes is not None:
trakt_data = []
for cur_episode in episodes:
trakt_id = sickbeard.indexerApi(cur_episode["indexer"]).config['trakt_id']
if self._checkInList(trakt_id, str(cur_episode["showid"]), str(cur_episode["season"]), str(cur_episode["episode"])):
if cur_episode["status"] not in Quality.SNATCHED + Quality.SNATCHED_PROPER + [UNKNOWN] + [WANTED]:
logger.log(u"Removing Episode {show} {ep} from watchlist".format
(show=cur_episode["show_name"],
ep=episode_num(cur_episode["season"], cur_episode["episode"])),
logger.DEBUG)
trakt_data.append((cur_episode["showid"], cur_episode["indexer"], cur_episode["show_name"], cur_episode["startyear"], cur_episode["season"], cur_episode["episode"]))
if trakt_data:
try:
data = self.trakt_bulk_data_generate(trakt_data)
self.trakt_api.traktRequest("sync/watchlist/remove", data, method='POST')
self._getEpisodeWatchlist()
except traktException as e:
logger.log(u"Could not connect to Trakt service. Error: {0}".format(ex(e)), logger.WARNING)
logger.log(u"WATCHLIST::REMOVE::FINISH - Look for Episodes to Remove from Trakt Watchlist", logger.DEBUG)
开发者ID:lucianot54,项目名称:SickRage,代码行数:31,代码来源:traktChecker.py
示例9: removeEpisodeFromTraktCollection
def removeEpisodeFromTraktCollection(self):
if sickbeard.TRAKT_SYNC_REMOVE and sickbeard.TRAKT_SYNC and sickbeard.USE_TRAKT:
logger.log("COLLECTION::REMOVE::START - Look for Episodes to Remove From Trakt Collection", logger.DEBUG)
main_db_con = db.DBConnection()
sql_selection = 'select tv_shows.indexer, tv_shows.startyear, showid, show_name, season, episode, tv_episodes.status, tv_episodes.location from tv_episodes,tv_shows where tv_shows.indexer_id = tv_episodes.showid'
episodes = main_db_con.select(sql_selection)
if episodes is not None:
trakt_data = []
for cur_episode in episodes:
trakt_id = sickbeard.indexerApi(cur_episode[b"indexer"]).config[b'trakt_id']
if self._checkInList(trakt_id, str(cur_episode[b"showid"]), str(cur_episode[b"season"]), str(cur_episode[b"episode"]), List='Collection'):
if cur_episode[b"location"] == '':
logger.log("Removing Episode {show} {ep} from collection".format(
show=cur_episode[b"show_name"], ep=episode_num(cur_episode[b"season"], cur_episode[b"episode"])), logger.DEBUG
)
trakt_data.append((cur_episode[b"showid"], cur_episode[b"indexer"], cur_episode[b"show_name"], cur_episode[b"startyear"],
cur_episode[b"season"], cur_episode[b"episode"]))
if trakt_data:
try:
data = self.trakt_bulk_data_generate(trakt_data)
self.trakt_api.traktRequest("sync/collection/remove", data, method='POST')
self._getShowCollection()
except traktException as e:
logger.log("Could not connect to Trakt service. Error: {0}".format(ex(e)), logger.WARNING)
logger.log("COLLECTION::REMOVE::FINISH - Look for Episodes to Remove From Trakt Collection", logger.DEBUG)
开发者ID:Zelgadis87,项目名称:SickRage,代码行数:31,代码来源:traktChecker.py
示例10: refresh_subtitles
def refresh_subtitles(episode_info, existing_subtitles):
video = get_video(episode_info["location"])
if not video:
logger.log(u"Exception caught in subliminal.scan_video, subtitles couldn't be refreshed", logger.DEBUG)
return existing_subtitles, None
current_subtitles = get_subtitles(video)
if existing_subtitles == current_subtitles:
logger.log(
u"No changed subtitles for {0} {1}".format(
episode_info["show_name"],
episode_num(episode_info["season"], episode_info["episode"])
or episode_num(episode_info["season"], episode_info["episode"], numbering="absolute"),
),
logger.DEBUG,
)
return existing_subtitles, None
else:
return current_subtitles, True
开发者ID:Mhynlo,项目名称:rn-sickrage,代码行数:18,代码来源:subtitles.py
示例11: refresh_subtitles
def refresh_subtitles(episode_info, existing_subtitles):
try:
video = get_video(episode_info['location'].encode(sickbeard.SYS_ENCODING))
except UnicodeEncodeError as error:
logger.log(u'An error occurred while encoding \'{}\' with your current locale. '
'Rename the file or try a different locale. Error: {}'.format
(episode_info['location'], ex(error)), logger.WARNING)
return existing_subtitles, None
if not video:
logger.log(u'Exception caught in subliminal.scan_video, subtitles couldn\'t be refreshed', logger.DEBUG)
return existing_subtitles, None
current_subtitles = get_subtitles(video)
if existing_subtitles == current_subtitles:
logger.log(u'No changed subtitles for {} {}'.format
(episode_info['show_name'], episode_num(episode_info['season'], episode_info['episode']) or
episode_num(episode_info['season'], episode_info['episode'], numbering='absolute')), logger.DEBUG)
return existing_subtitles, None
else:
return current_subtitles, True
开发者ID:Hydrog3n,项目名称:SickRage,代码行数:20,代码来源:subtitles.py
示例12: backlogOverview
def backlogOverview(self):
t = PageTemplate(rh=self, filename='manage_backlogOverview.mako')
show_counts = {}
show_cats = {}
show_sql_results = {}
main_db_con = db.DBConnection()
for cur_show in sickbeard.showList:
ep_counts = {
Overview.SKIPPED: 0,
Overview.WANTED: 0,
Overview.QUAL: 0,
Overview.GOOD: 0,
Overview.UNAIRED: 0,
Overview.SNATCHED: 0,
Overview.SNATCHED_PROPER: 0,
Overview.SNATCHED_BEST: 0
}
ep_cats = {}
sql_results = main_db_con.select(
"""
SELECT status, season, episode, name, airdate
FROM tv_episodes
WHERE tv_episodes.season IS NOT NULL AND
tv_episodes.showid IN (SELECT tv_shows.indexer_id
FROM tv_shows
WHERE tv_shows.indexer_id = ? AND
paused = 0)
ORDER BY tv_episodes.season DESC, tv_episodes.episode DESC
""",
[cur_show.indexerid]
)
for cur_result in sql_results:
cur_ep_cat = cur_show.getOverview(cur_result[b'status'])
if cur_ep_cat:
ep_cats[u'{ep}'.format(ep=episode_num(cur_result[b'season'], cur_result[b'episode']))] = cur_ep_cat
ep_counts[cur_ep_cat] += 1
show_counts[cur_show.indexerid] = ep_counts
show_cats[cur_show.indexerid] = ep_cats
show_sql_results[cur_show.indexerid] = sql_results
return t.render(
showCounts=show_counts, showCats=show_cats,
showSQLResults=show_sql_results, controller='manage',
action='backlogOverview', title='Backlog Overview',
header='Backlog Overview', topmenu='manage')
开发者ID:Eiber,项目名称:SickRage-Medusa,代码行数:51,代码来源:handler.py
示例13: setEpisodeToWanted
def setEpisodeToWanted(show, s, e):
"""
Sets an episode to wanted, only if it is currently skipped
"""
epObj = show.getEpisode(s, e)
if epObj:
with epObj.lock:
if epObj.status != SKIPPED or epObj.airdate == datetime.date.fromordinal(1):
return
logger.log("Setting episode {show} {ep} to wanted".format
(show=show.name, ep=episode_num(s, e)))
# figure out what segment the episode is in and remember it so we can backlog it
epObj.status = WANTED
epObj.saveToDB()
cur_backlog_queue_item = search_queue.BacklogQueueItem(show, [epObj])
sickbeard.searchQueueScheduler.action.add_item(cur_backlog_queue_item)
logger.log("Starting backlog search for {show} {ep} because some episodes were set to wanted".format
(show=show.name, ep=episode_num(s, e)))
开发者ID:Zelgadis87,项目名称:SickRage,代码行数:23,代码来源:traktChecker.py
示例14: download_subtitles
def download_subtitles(subtitles_info): # pylint: disable=too-many-locals, too-many-branches, too-many-statements
existing_subtitles = subtitles_info['subtitles']
if not needs_subtitles(existing_subtitles):
logger.log(u'Episode already has all needed subtitles, skipping {} {}'.format
(subtitles_info['show_name'], episode_num(subtitles_info['season'], subtitles_info['episode']) or
episode_num(subtitles_info['season'], subtitles_info['episode'], numbering='absolute')), logger.DEBUG)
return existing_subtitles, None
# Check if we really need subtitles
languages = get_needed_languages(existing_subtitles)
if not languages:
logger.log(u'No subtitles needed for {} {}'.format
(subtitles_info['show_name'], episode_num(subtitles_info['season'], subtitles_info['episode']) or
episode_num(subtitles_info['season'], subtitles_info['episode'], numbering='absolute')), logger.DEBUG)
return existing_subtitles, None
subtitles_path = get_subtitles_path(subtitles_info['location'])
video_path = subtitles_info['location']
# Perfect match = hash score - hearing impaired score - resolution score (subtitle for 720p its the same for 1080p)
# Perfect match = 215 -1 -1 = 213
# No-perfect match = hash score - hearing impaired score - resolution score - release_group score
# No-perfect match = 215 -1 -1 -9 = 204
# From latest subliminal code:
# episode_scores = {'hash': 215, 'series': 108, 'year': 54, 'season': 18, 'episode': 18, 'release_group': 9,
# 'format': 4, 'audio_codec': 2, 'resolution': 1, 'hearing_impaired': 1, 'video_codec': 1}
user_score = 213 if sickbeard.SUBTITLES_PERFECT_MATCH else 204
video = get_video(video_path, subtitles_path=subtitles_path)
if not video:
logger.log(u'Exception caught in subliminal.scan_video for {} {}'.format
(subtitles_info['show_name'], episode_num(subtitles_info['season'], subtitles_info['episode']) or
episode_num(subtitles_info['season'], subtitles_info['episode'], numbering='absolute')), logger.DEBUG)
return existing_subtitles, None
providers = enabled_service_list()
provider_configs = {'addic7ed': {'username': sickbeard.ADDIC7ED_USER,
'password': sickbeard.ADDIC7ED_PASS},
'legendastv': {'username': sickbeard.LEGENDASTV_USER,
'password': sickbeard.LEGENDASTV_PASS},
'opensubtitles': {'username': sickbeard.OPENSUBTITLES_USER,
'password': sickbeard.OPENSUBTITLES_PASS}}
pool = ProviderPool(providers=providers, provider_configs=provider_configs)
try:
subtitles_list = pool.list_subtitles(video, languages)
for provider in providers:
if provider in pool.discarded_providers:
logger.log(u'Could not search in {} provider. Discarding for now'.format(provider), logger.DEBUG)
if not subtitles_list:
logger.log(u'No subtitles found for {} {}'.format
(subtitles_info['show_name'], episode_num(subtitles_info['season'], subtitles_info['episode']) or
episode_num(subtitles_info['season'], subtitles_info['episode'], numbering='absolute')), logger.DEBUG)
return existing_subtitles, None
for subtitle in subtitles_list:
score = subliminal.score.compute_score(subtitle, video, hearing_impaired=sickbeard.SUBTITLES_HEARING_IMPAIRED)
logger.log(u'[{}] Subtitle score for {} is: {} (min={})'.format
(subtitle.provider_name, subtitle.id, score, user_score), logger.DEBUG)
found_subtitles = pool.download_best_subtitles(subtitles_list, video, languages=languages,
hearing_impaired=sickbeard.SUBTITLES_HEARING_IMPAIRED,
min_score=user_score, only_one=not sickbeard.SUBTITLES_MULTI)
subliminal.save_subtitles(video, found_subtitles, directory=subtitles_path,
single=not sickbeard.SUBTITLES_MULTI)
except IOError as error:
if 'No space left on device' in ex(error):
logger.log(u'Not enough space on the drive to save subtitles', logger.WARNING)
else:
logger.log(traceback.format_exc(), logger.WARNING)
except Exception:
logger.log(u'Error occurred when downloading subtitles for: {}'.format(video_path))
logger.log(traceback.format_exc(), logger.ERROR)
return existing_subtitles, None
for subtitle in found_subtitles:
subtitle_path = subliminal.subtitle.get_subtitle_path(video.name,
None if not sickbeard.SUBTITLES_MULTI else
subtitle.language)
if subtitles_path is not None:
subtitle_path = os.path.join(subtitles_path, os.path.split(subtitle_path)[1])
sickbeard.helpers.chmodAsParent(subtitle_path)
sickbeard.helpers.fixSetGroupID(subtitle_path)
if sickbeard.SUBTITLES_HISTORY:
logger.log(u'history.logSubtitle {}, {}'.format
(subtitle.provider_name, subtitle.language.opensubtitles), logger.DEBUG)
history.logSubtitle(subtitles_info['show_indexerid'], subtitles_info['season'],
subtitles_info['episode'], subtitles_info['status'], subtitle)
if sickbeard.SUBTITLES_EXTRA_SCRIPTS and isMediaFile(video_path) and not sickbeard.EMBEDDED_SUBTITLES_ALL:
run_subs_extra_scripts(subtitles_info, subtitle, video, single=not sickbeard.SUBTITLES_MULTI)
#.........这里部分代码省略.........
开发者ID:pedro2d10,项目名称:SickRage-FR,代码行数:101,代码来源:subtitles.py
示例15: _ep_data
def _ep_data(self, ep_obj):
"""
Creates an elementTree XML structure for a MediaBrowser style episode.xml
and returns the resulting data object.
show_obj: a TVShow instance to create the NFO for
"""
eps_to_write = [ep_obj] + ep_obj.relatedEps
indexer_lang = ep_obj.show.lang
# There's gotta be a better way of doing this but we don't wanna
# change the language value elsewhere
l_indexer_api_params = sickbeard.indexerApi(ep_obj.show.indexer).api_params.copy()
if indexer_lang and not indexer_lang == sickbeard.INDEXER_DEFAULT_LANGUAGE:
l_indexer_api_params[b'language'] = indexer_lang
if ep_obj.show.dvdorder != 0:
l_indexer_api_params[b'dvdorder'] = True
try:
t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**l_indexer_api_params)
my_show = t[ep_obj.show.indexerid]
except sickbeard.indexer_shownotfound as e:
raise ShowNotFoundException(e.message)
except sickbeard.indexer_error:
logger.log(u'Unable to connect to {indexer} while creating meta files - skipping it.'.format
(indexer=sickbeard.indexerApi(ep_obj.show.indexer).name), logger.WARNING)
return
root_node = etree.Element('details')
movie = etree.SubElement(root_node, 'movie')
movie.attrib['isExtra'] = 'false'
movie.attrib['isSet'] = 'false'
movie.attrib['isTV'] = 'true'
# write an MediaBrowser XML containing info for all matching episodes
for ep_to_write in eps_to_write:
try:
my_ep = my_show[ep_to_write.season][ep_to_write.episode]
except (sickbeard.indexer_episodenotfound, sickbeard.indexer_seasonnotfound):
logger.log(u'Unable to find episode {ep_num} on {indexer}... '
u'has it been removed? Should I delete from db?'.format
(ep_num=episode_num(ep_to_write.season, ep_to_write.episode),
indexer=sickbeard.indexerApi(ep_obj.show.indexer).name))
return None
if ep_to_write == ep_obj:
# root (or single) episode
# default to today's date for specials if firstaired is not set
if ep_to_write.season == 0 and not getattr(my_ep, 'firstaired', None):
my_ep['firstaired'] = str(datetime.date.fromordinal(1))
if not (getattr(my_ep, 'episodename', None) and getattr(my_ep, 'firstaired', None)):
return None
episode = movie
if ep_to_write.name:
episode_name = etree.SubElement(episode, 'title')
episode_name.text = ep_to_write.name
season_number = etree.SubElement(episode, 'season')
season_number.text = str(ep_to_write.season)
episode_number = etree.SubElement(episode, 'episode')
episode_number.text = str(ep_to_write.episode)
if getattr(my_show, 'firstaired', None):
try:
year_text = str(datetime.datetime.strptime(my_show['firstaired'], dateFormat).year)
if year_text:
year = etree.SubElement(episode, 'year')
year.text = year_text
except Exception:
pass
if getattr(my_show, 'overview', None):
plot = etree.SubElement(episode, 'plot')
plot.text = my_show['overview']
if ep_to_write.description:
overview = etree.SubElement(episode, 'episodeplot')
overview.text = ep_to_write.description
if getattr(my_show, 'contentrating', None):
mpaa = etree.SubElement(episode, 'mpaa')
mpaa.text = my_show['contentrating']
if not ep_obj.relatedEps and getattr(my_ep, 'rating', None):
try:
rating = int((float(my_ep['rating']) * 10))
except ValueError:
rating = 0
#.........这里部分代码省略.........
开发者ID:bitzorro,项目名称:SickRage,代码行数:101,代码来源:mede8er.py
示例16: _ep_data
def _ep_data(self, ep_obj):
"""
Creates an elementTree XML structure for a MediaBrowser style episode.xml
and returns the resulting data object.
show_obj: a TVShow instance to create the NFO for
"""
eps_to_write = [ep_obj] + ep_obj.related_episodes
persons_dict = {
'Director': [],
'GuestStar': [],
'Writer': []
}
indexer_lang = ep_obj.show.lang
l_indexer_api_params = sickbeard.indexerApi(ep_obj.show.indexer).api_params.copy()
l_indexer_api_params[b'actors'] = True
if indexer_lang and not indexer_lang == sickbeard.INDEXER_DEFAULT_LANGUAGE:
l_indexer_api_params[b'language'] = indexer_lang
if ep_obj.show.dvdorder != 0:
l_indexer_api_params[b'dvdorder'] = True
try:
t = sickbeard.indexerApi(ep_obj.show.indexer).indexer(**l_indexer_api_params)
my_show = t[ep_obj.show.indexerid]
except sickbeard.indexer_shownotfound as e:
raise ShowNotFoundException(e.message)
except sickbeard.indexer_error:
logger.log(u'Unable to connect to {indexer} while creating meta files - skipping it.'.format
(indexer=sickbeard.indexerApi(ep_obj.show.indexer).name), logger.WARNING)
return
root_node = etree.Element('Item')
# write an MediaBrowser XML containing info for all matching episodes
for ep_to_write in eps_to_write:
try:
my_ep = my_show[ep_to_write.season][ep_to_write.episode]
except (sickbeard.indexer_episodenotfound, sickbeard.indexer_seasonnotfound):
logger.log(u'Unable to find episode {ep_num} on {indexer}... '
u'has it been removed? Should I delete from db?'.format
(ep_num=episode_num(ep_to_write.season, ep_to_write.episode),
indexer=sickbeard.indexerApi(ep_obj.show.indexer).name))
return None
if ep_to_write == ep_obj:
# root (or single) episode
# default to today's date for specials if firstaired is not set
if ep_to_write.season == 0 and not getattr(my_ep, 'firstaired', None):
my_ep['firstaired'] = str(datetime.date.fromordinal(1))
if not (getattr(my_ep, 'episodename', None) and getattr(my_ep, 'firstaired', None)):
return None
episode = root_node
if ep_to_write.name:
episode_name = etree.SubElement(episode, 'EpisodeName')
episode_name.text = ep_to_write.name
episode_number = etree.SubElement(episode, 'EpisodeNumber')
episode_number.text = str(ep_obj.episode)
if ep_obj.related_episodes:
episode_number_end = etree.SubElement(episode, 'EpisodeNumberEnd')
episode_number_end.text = str(ep_to_write.episode)
season_number = etree.SubElement(episode, 'SeasonNumber')
season_number.text = str(ep_to_write.season)
if not ep_obj.related_episodes and getattr(my_ep, 'absolute_number', None):
absolute_number = etree.SubElement(episode, 'absolute_number')
absolute_number.text = str(my_ep['absolute_number'])
if ep_to_write.airdate != datetime.date.fromordinal(1):
first_aired = etree.SubElement(episode, 'FirstAired')
first_aired.text = str(ep_to_write.airdate)
metadata_type = etree.SubElement(episode, 'Type')
metadata_type.text = 'Episode'
if ep_to_write.description:
overview = etree.SubElement(episode, 'Overview')
overview.text = ep_to_write.description
if not ep_obj.related_episodes:
if getattr(my_ep, 'rating', None):
rating = etree.SubElement(episode, 'Rating')
rating.text = my_ep['rating']
if getattr(my_show, 'imdb_id', None):
IMDB_ID = etree.SubElement(episode, 'IMDB_ID')
#.........这里部分代码省略.........
开发者ID:Thraxis,项目名称:pymedusa,代码行数:101,代码来源:mediabrowser.py
示例17: test_episode_num
def test_episode_num(self):
# Standard numbering
self.assertEqual(episode_num(0, 1), 'S00E01') # Seasons start at 0 for specials
self.assertEqual(episode_num(1, 1), 'S01E01')
# Absolute numbering
self.assertEqual(episode_num(1, numbering='absolute'), '001')
self.assertEqual(episode_num(0, 1, numbering='absolute'), '001')
self.assertEqual(episode_num(1, 0, numbering='absolute'), '001')
# Must have both season and episode for standard numbering
self.assertEqual(episode_num(0), None)
self.assertEqual(episode_num(1), None)
# Episode numbering starts at 1
self.assertEqual(episode_num(0, 0), None)
self.assertEqual(episode_num(1, 0), None)
# Absolute numbering starts at 1
self.assertEqual(episode_num(0, 0, numbering='absolute'), None)
# Absolute numbering can't have both season and episode
self.assertEqual(episode_num(1, 1, numbering='absolute'), None)
开发者ID:ratoaq2,项目名称:SickRageSickRage,代码行数:23,代码来源:common_tests.py
示例18: download_subtitles
def download_subtitles(episode, force_lang=None): # pylint: disable=too-many-locals, too-many-branches, too-many-statements
existing_subtitles = episode.subtitles
if not needs_subtitles(existing_subtitles, force_lang):
logger.log('Episode already has all needed subtitles, skipping {0} {1}'.format
(episode.show.name, episode_num(episode.season, episode.episode) or
episode_num(episode.season, episode.episode, numbering='absolute')), logger.DEBUG)
return existing_subtitles, None
if not force_lang:
languages = get_needed_languages(existing_subtitles)
else:
languages = {from_code(force_lang)}
if not languages:
logger.log('No subtitles needed for {0} {1}'.format
(episode.show.name, episode_num(episode.season, episode.episode) or
episode_num(episode.season, episode.episode, numbering='absolute')), logger.DEBUG)
return existing_subtitles, None
subtitles_path = get_subtitles_path(episode.location)
video_path = episode.location
# Perfect match = hash score - hearing impaired score - resolution score
# (subtitle for 720p is the same as for 1080p)
# Perfect match = 215 - 1 - 1 = 213
# Non-perfect match = series + year + season + episode
# Non-perfect match = 108 + 54 + 18 + 18 = 198
# From latest subliminal code:
# episode_scores = {'hash': 215, 'series': 108, 'year': 54, 'season': 18, 'episode': 18, 'release_group': 9,
# 'format': 4, 'audio_codec': 2, 'resolution': 1, 'hearing_impaired': 1, 'video_codec': 1}
user_score = 213 if sickbeard.SUBTITLES_PERFECT_MATCH else 198
video = get_video(video_path, subtitles_path=subtitles_path, episode=episode)
if not video:
logger.log('Exception caught in subliminal.scan_video for {0} {1}'.format
(episode.show.name, episode_num(episode.season, episode.episode) or
episode_num(episode.season, episode.episode, numbering='absolute')), logger.DEBUG)
return existing_subtitles, None
providers = enabled_service_list()
pool = SubtitleProviderPool()
try:
|
请发表评论