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


Python Video.from_path方法代码示例

本文整理汇总了Python中subliminal.videos.Video.from_path方法的典型用法代码示例。如果您正苦于以下问题:Python Video.from_path方法的具体用法?Python Video.from_path怎么用?Python Video.from_path使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在subliminal.videos.Video的用法示例。


在下文中一共展示了Video.from_path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: getSubtitleLanguage

# 需要导入模块: from subliminal.videos import Video [as 别名]
# 或者: from subliminal.videos.Video import from_path [as 别名]
    def getSubtitleLanguage(self, group):
        detected_languages = {}

        # Subliminal scanner
        paths = None
        try:
            paths = group['files']['movie']
            scan_result = []
            for p in paths:
                if not group['is_dvd']:
                    video = Video.from_path(sp(p))
                    video_result = [(video, video.scan())]
                    scan_result.extend(video_result)

            for video, detected_subtitles in scan_result:
                for s in detected_subtitles:
                    if s.language and s.path not in paths:
                        detected_languages[s.path] = [s.language]
        except:
            log.debug('Failed parsing subtitle languages for %s: %s', (paths, traceback.format_exc()))

        # IDX
        for extra in group['files']['subtitle_extra']:
            try:
                if os.path.isfile(extra):
                    output = open(extra, 'r')
                    txt = output.read()
                    output.close()

                    idx_langs = re.findall('\nid: (\w+)', txt)

                    sub_file = '%s.sub' % os.path.splitext(extra)[0]
                    if len(idx_langs) > 0 and os.path.isfile(sub_file):
                        detected_languages[sub_file] = idx_langs
            except:
                log.error('Failed parsing subtitle idx for %s: %s', (extra, traceback.format_exc()))

        return detected_languages
开发者ID:Affix,项目名称:CouchPotatoServer,代码行数:40,代码来源:scanner.py

示例2: getSubtitleLanguage

# 需要导入模块: from subliminal.videos import Video [as 别名]
# 或者: from subliminal.videos.Video import from_path [as 别名]
    def getSubtitleLanguage(self, group):
        detected_languages = {}

        # Subliminal scanner
        try:
            paths = group["files"]["movie"]
            scan_result = []
            for p in paths:
                if not group["is_dvd"]:
                    video = Video.from_path(toUnicode(p))
                    video_result = [(video, video.scan())]
                    scan_result.extend(video_result)

            for video, detected_subtitles in scan_result:
                for s in detected_subtitles:
                    if s.language and s.path not in paths:
                        detected_languages[s.path] = [s.language]
        except:
            log.debug("Failed parsing subtitle languages for %s: %s", (paths, traceback.format_exc()))

        # IDX
        for extra in group["files"]["subtitle_extra"]:
            try:
                if os.path.isfile(extra):
                    output = open(extra, "r")
                    txt = output.read()
                    output.close()

                    idx_langs = re.findall("\nid: (\w+)", txt)

                    sub_file = "%s.sub" % os.path.splitext(extra)[0]
                    if len(idx_langs) > 0 and os.path.isfile(sub_file):
                        detected_languages[sub_file] = idx_langs
            except:
                log.error("Failed parsing subtitle idx for %s: %s", (extra, traceback.format_exc()))

        return detected_languages
开发者ID:hwuethrich,项目名称:CouchPotatoServer,代码行数:39,代码来源:main.py


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