当前位置: 首页>>代码示例>>Python>>正文


Python TVEpisode.from_filepath方法代码示例

本文整理汇总了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)
开发者ID:Thraxis,项目名称:pymedusa,代码行数:57,代码来源:subtitles.py


注:本文中的sickbeard.tv.TVEpisode.from_filepath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。