本文整理汇总了Python中sickbeard.tv.TVEpisode.from_filepath方法的典型用法代码示例。如果您正苦于以下问题:Python TVEpisode.from_filepath方法的具体用法?Python TVEpisode.from_filepath怎么用?Python TVEpisode.from_filepath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sickbeard.tv.TVEpisode
的用法示例。
在下文中一共展示了TVEpisode.from_filepath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: subtitles_download_in_pp
# 需要导入模块: from sickbeard.tv import TVEpisode [as 别名]
# 或者: from sickbeard.tv.TVEpisode import from_filepath [as 别名]
def subtitles_download_in_pp(): # pylint: disable=too-many-locals, too-many-branches, too-many-statements
"""Check for needed subtitles in the post process folder."""
from sickbeard.tv import TVEpisode
logger.info(u'Checking for needed subtitles in Post-Process folder')
# Check if PP folder is set
if not sickbeard.TV_DOWNLOAD_DIR or not os.path.isdir(sickbeard.TV_DOWNLOAD_DIR):
logger.warning(u'You must set a valid post-process folder in "Post Processing" settings')
return
# Search for all wanted languages
if not wanted_languages():
return
unpack_rar_files(sickbeard.TV_DOWNLOAD_DIR)
run_post_process = False
for root, _, files in os.walk(sickbeard.TV_DOWNLOAD_DIR, topdown=False):
for filename in sorted(files):
# Delete unwanted subtitles before downloading new ones
delete_unwanted_subtitles(root, filename)
if not isMediaFile(filename):
continue
filename = clear_non_release_groups(root, filename)
video_path = os.path.join(root, filename)
tv_episode = TVEpisode.from_filepath(video_path)
if not tv_episode:
logger.debug(u'%s cannot be parsed to an episode', filename)
continue
if not tv_episode.show.subtitles:
logger.debug(u'Subtitle disabled for show: %s. Running post-process to PP it', filename)
run_post_process = True
continue
# 'postpone' should not consider existing subtitles from db.
tv_episode.subtitles = []
downloaded_languages = download_subtitles(tv_episode, video_path=video_path,
subtitles=False, embedded_subtitles=False)
# Don't run post processor unless at least one file has all of the needed subtitles OR
# if user don't want to ignore embedded subtitles and wants to consider 'unknown' as wanted sub,
# and .mkv has one.
if not run_post_process and (
not needs_subtitles(downloaded_languages) or
processTV.has_matching_unknown_subtitles(video_path)):
run_post_process = True
if run_post_process:
logger.info(u'Starting post-process with default settings now that we found subtitles')
processTV.processDir(sickbeard.TV_DOWNLOAD_DIR)