本文整理汇总了Python中subliminal.videos.Video类的典型用法代码示例。如果您正苦于以下问题:Python Video类的具体用法?Python Video怎么用?Python Video使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Video类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getSubtitleLanguage
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
示例2: getSubtitleLanguage
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