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


Python Language.fromalpha3b方法代码示例

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


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

示例1: test_converter_alpha3b

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
 def test_converter_alpha3b(self):
     self.assertEqual(Language('fra').alpha3b, 'fre')
     self.assertEqual(Language.fromalpha3b('fre'), Language('fra'))
     self.assertEqual(Language.fromcode('fre', 'alpha3b'), Language('fra'))
     self.assertRaises(LanguageReverseError, lambda: Language.fromalpha3b('zzz'))
     self.assertRaises(LanguageConvertError, lambda: Language('aaa').alpha3b)
     self.assertEqual(len(language_converters['alpha3b'].codes), 418)
开发者ID:Diaoul,项目名称:babelfish,代码行数:9,代码来源:tests.py

示例2: test_converter_alpha3b

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
 def test_converter_alpha3b(self):
     self.assertEqual(Language('fra').alpha3b, 'fre')
     self.assertEqual(Language.fromalpha3b('fre'), Language('fra'))
     self.assertEqual(Language.fromcode('fre', 'alpha3b'), Language('fra'))
     with self.assertRaises(LanguageReverseError):
         Language.fromalpha3b('zzz')
     with self.assertRaises(LanguageConvertError):
         Language('aaa').alpha3b
     self.assertEqual(len(get_language_converter('alpha3b').codes), 418)
开发者ID:nvbn,项目名称:babelfish,代码行数:11,代码来源:tests.py

示例3: getEmbeddedLanguages

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
def getEmbeddedLanguages(video_path):
    embedded_subtitle_languages = set()
    try:
        with open(video_path, 'rb') as f:
            mkv = MKV(f)
            if mkv.subtitle_tracks:
                for st in mkv.subtitle_tracks:
                    if st.language:
                        try:
                            embedded_subtitle_languages.add(Language.fromalpha3b(st.language))
                        except BabelfishError:
                            logger.log('Embedded subtitle track is not a valid language', logger.DEBUG)
                            embedded_subtitle_languages.add(Language('und'))
                    elif st.name:
                        try:
                            embedded_subtitle_languages.add(Language.fromname(st.name))
                        except BabelfishError:
                            logger.log('Embedded subtitle track is not a valid language', logger.DEBUG)
                            embedded_subtitle_languages.add(Language('und'))
                    else:
                        embedded_subtitle_languages.add(Language('und'))
            else:
                logger.log('MKV has no subtitle track', logger.DEBUG)
    except MalformedMKVError:
        logger.log('MKV seems to be malformed, ignoring embedded subtitles', logger.WARNING)

    return embedded_subtitle_languages
开发者ID:TCRakt,项目名称:SickRage,代码行数:29,代码来源:subtitles.py

示例4: subtitlesLanguages

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
def subtitlesLanguages(video_path):
    """Return a list detected subtitles for the given video file"""
    resultList = []
    embedded_subtitle_languages = set()

    # Serch for embedded subtitles
    if not sickbeard.EMBEDDED_SUBTITLES_ALL:
        if video_path.endswith('mkv'):
            try:
                with open(video_path.encode(sickbeard.SYS_ENCODING), 'rb') as f:
                    mkv = MKV(f)
                if mkv.subtitle_tracks:
                    for st in mkv.subtitle_tracks:
                        if st.language:
                            try:
                                embedded_subtitle_languages.add(Language.fromalpha3b(st.language))
                            except BabelfishError:
                                logger.log('Embedded subtitle track is not a valid language', logger.DEBUG)
                                embedded_subtitle_languages.add(Language('und'))
                        elif st.name:
                            try:
                                embedded_subtitle_languages.add(Language.fromname(st.name))
                            except BabelfishError:
                                logger.log('Embedded subtitle track is not a valid language', logger.DEBUG)
                                embedded_subtitle_languages.add(Language('und'))
                        else:
                            embedded_subtitle_languages.add(Language('und'))
                else:
                    logger.log('MKV has no subtitle track', logger.DEBUG)
            except MalformedMKVError:
                logger.log('MKV seems to be malformed, ignoring embedded subtitles', logger.WARNING)

    # Search subtitles in the absolute path
    if sickbeard.SUBTITLES_DIR and ek(os.path.exists, sickbeard.SUBTITLES_DIR):
        video_path = ek(os.path.join, sickbeard.SUBTITLES_DIR, ek(os.path.basename, video_path))
    # Search subtitles in the relative path
    elif sickbeard.SUBTITLES_DIR:
        video_path = ek(os.path.join, ek(os.path.dirname, video_path), sickbeard.SUBTITLES_DIR, ek(os.path.basename, video_path))

    external_subtitle_languages = subliminal.video.scan_subtitle_languages(video_path)
    subtitle_languages = external_subtitle_languages.union(embedded_subtitle_languages)

    if (len(subtitle_languages) is 1 and len(wantedLanguages()) is 1) and Language('und') in subtitle_languages:
        subtitle_languages.remove(Language('und'))
        subtitle_languages.add(fromietf(wantedLanguages()[0]))

    for language in subtitle_languages:
        if hasattr(language, 'opensubtitles') and language.opensubtitles:
            resultList.append(language.opensubtitles)
        elif hasattr(language, 'alpha3') and language.alpha3:
            resultList.append(language.alpha3)
        elif hasattr(language, 'alpha2') and language.alpha2:
            resultList.append(language.alpha2)

    defaultLang = wantedLanguages()

    if ('pob' in defaultLang or 'pb' in defaultLang) and ('pt' not in defaultLang and 'por' not in defaultLang):
            resultList = [x if not x in ['por', 'pt'] else u'pob' for x in resultList]

    return sorted(resultList)
开发者ID:WebSpider,项目名称:SickRage,代码行数:62,代码来源:subtitles.py

示例5: _get_embedded_subtitles

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
def _get_embedded_subtitles(dirname, filename):
    """
    Based on subliminal.video.scan_video(...) but only keep the check for embedded subtitles
    """
    log.debug("Checking for embedded subtitle")
    embedded_subtitle_languages = set()
    try:
        path = os.path.join(dirname, filename)
        if filename.endswith('.mkv'):
            with open(path, 'rb') as f:
                mkv = MKV(f)

            # subtitle tracks
            if mkv.subtitle_tracks:
                for st in mkv.subtitle_tracks:
                    if st.language:
                        try:
                            embedded_subtitle_languages.add(Language.fromalpha3b(st.language))
                        except BabelfishError:
                            log.error('Embedded subtitle track language %r is not a valid language', st.language)
                            embedded_subtitle_languages.add(Language('und'))
                    elif st.name:
                        try:
                            embedded_subtitle_languages.add(Language.fromname(st.name))
                        except BabelfishError:
                            log.debug('Embedded subtitle track name %r is not a valid language', st.name)
                            embedded_subtitle_languages.add(Language('und'))
                    else:
                        embedded_subtitle_languages.add(Language('und'))
                log.debug('Found embedded subtitles %r with enzyme', embedded_subtitle_languages)
            else:
                log.debug('MKV has no subtitle track')
    except:
        log.exception('Parsing video metadata with enzyme failed')
    return embedded_subtitle_languages
开发者ID:sdtechz,项目名称:Auto-Subliminal,代码行数:37,代码来源:diskscanner.py

示例6: getEmbeddedLanguages

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
def getEmbeddedLanguages(video_path):
    embedded_subtitle_languages = set()
    try:
        with ek(io.open, video_path, 'rb') as f:
            mkv = MKV(f)
            if mkv.subtitle_tracks:
                for st in mkv.subtitle_tracks:
                    if st.language:
                        try:
                            embedded_subtitle_languages.add(Language.fromalpha3b(st.language))
                        except BabelfishError:
                            logging.debug('Embedded subtitle track is not a valid language')
                            embedded_subtitle_languages.add(Language('und'))
                    elif st.name:
                        try:
                            embedded_subtitle_languages.add(Language.fromname(st.name))
                        except BabelfishError:
                            logging.debug('Embedded subtitle track is not a valid language')
                            embedded_subtitle_languages.add(Language('und'))
                    else:
                        embedded_subtitle_languages.add(Language('und'))
            else:
                logging.debug('MKV has no subtitle track')
    except MalformedMKVError:
        logging.info('MKV seems to be malformed ( %s ), ignoring embedded subtitles' % video_path)

    return embedded_subtitle_languages
开发者ID:coderbone,项目名称:SickRage,代码行数:29,代码来源:subtitles.py

示例7: getAlpha3TCode

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
def getAlpha3TCode(code):  # We need to make sure that language codes are alpha3T
    """
        :param    code: Alpha2, Alpha3, or Alpha3b code.
        :type     code: C{str}

        :return: Alpha3t language code (ISO 639-2/T) as C{str}
    """
    lang = 'und'
    code = code.strip().lower()

    if len(code) == 3:
        try:
            lang = Language(code).alpha3t
        except:
            try:
                lang = Language.fromalpha3b(code).alpha3t
            except:
                try:
                    lang = Language.fromalpha3t(code).alpha3t
                except:
                    pass

    elif len(code) == 2:
        lang = Language.fromalpha2(code).alpha3t

    return lang
开发者ID:phtagn,项目名称:sickbeard_mp4_automator,代码行数:28,代码来源:languagecode.py

示例8: has_subtitle

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
    def has_subtitle(self, language):
        """ Returns true if the video has already
        a subtitle for a specific language. """
        has_subtitle = False

        # Look for embedded subtitle in mkv video
        if Video.is_mkv(self.signature):
            with open(self.filename, 'rb') as file_handler:
                mkv_video = enzyme.MKV(file_handler)

            for sub in mkv_video.subtitle_tracks:
                try:
                    if sub.language and \
                            Language.fromalpha3b(sub.language) == language:
                        has_subtitle = True
                        break
                    elif sub.name and \
                            Language.fromname(sub.name) == language:
                        has_subtitle = True
                        break
                except BabelfishError:
                    LOG.error(
                        "Embedded subtitle track"
                        "language {} is not a valid language"
                        .format(sub.language))

        # Look for external subtitle
        dir_name = os.path.dirname(self.filename)
        base_name, _ = os.path.splitext(os.path.basename(self.filename))

        search_subtitle = os.path.join(
            dir_name, "{}.{}.*".format(base_name, language.alpha2))
        existing_subtitles = [
            sub_file for sub_file in glob.glob(search_subtitle)
            if os.path.splitext(sub_file)[1] in Subtitle.EXTENSIONS
        ]

        if existing_subtitles:
            has_subtitle = True

        return has_subtitle
开发者ID:shamsan,项目名称:sublime,代码行数:43,代码来源:core.py

示例9: get_embedded_subtitles

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
def get_embedded_subtitles(dirname, filename, log_scan=False):
    """Get the embedded subtitle languages for a video file.

    Based on subliminal.video.scan_video(...) but only keep the check for embedded subtitles.
    """
    log.debug('Checking for embedded subtitle(s)')

    embedded_subtitle_languages = set()
    path = os.path.join(dirname, filename)
    try:
        if filename.endswith('.mkv'):
            with open(path, mode='rb') as f:
                mkv = MKV(f)

            # subtitle tracks
            if mkv.subtitle_tracks:
                for st in mkv.subtitle_tracks:
                    if st.language:
                        try:
                            embedded_subtitle_languages.add(Language.fromalpha3b(st.language))
                        except BabelfishError:
                            log_scan and log.error('Embedded subtitle track language %r is not a valid language',
                                                   st.language)
                    elif st.name:
                        try:
                            embedded_subtitle_languages.add(Language.fromname(st.name))
                        except BabelfishError:
                            log_scan and log.error('Embedded subtitle track name %r is not a valid language', st.name)
                    else:
                        log_scan and log.error('Embedded subtitle track language %r is not a valid language',
                                               st.language)
                log_scan and log.debug('Found embedded subtitles %r with enzyme', embedded_subtitle_languages)
            else:
                log_scan and log.debug('MKV has no subtitle track')
        else:
            log_scan and log.debug('Check is only supported for MKV containers, skipping')
    except Exception:
        log_scan and log.error('Parsing video metadata with enzyme failed')

    return [Subtitle(EMBEDDED, text_type(language), path) for language in embedded_subtitle_languages if
            language != Language('und')]
开发者ID:h3llrais3r,项目名称:Auto-Subliminal,代码行数:43,代码来源:filesystem.py

示例10: scan_video

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
def scan_video(path, subtitles=True, embedded_subtitles=True, subtitles_dir=None):
    """Scan a video and its subtitle languages from a video `path`.

    :param str path: existing path to the video.
    :param bool subtitles: scan for subtitles with the same name.
    :param bool embedded_subtitles: scan for embedded subtitles.
    :param str subtitles_dir: directory to search for subtitles.
    :return: the scanned video.
    :rtype: :class:`Video`

    """
    # check for non-existing path
    if not os.path.exists(path):
        raise ValueError('Path does not exist')

    # check video extension
    if not path.endswith(VIDEO_EXTENSIONS):
        raise ValueError('%s is not a valid video extension' % os.path.splitext(path)[1])

    dirpath, filename = os.path.split(path)
    logger.info('Scanning video %r in %r', filename, dirpath)

    # guess
    video = Video.fromguess(path, guessit(path))

    # size and hashes
    video.size = os.path.getsize(path)
    if video.size > 10485760:
        logger.debug('Size is %d', video.size)
        video.hashes['opensubtitles'] = hash_opensubtitles(path)
        video.hashes['thesubdb'] = hash_thesubdb(path)
        video.hashes['napiprojekt'] = hash_napiprojekt(path)
        logger.debug('Computed hashes %r', video.hashes)
    else:
        logger.warning('Size is lower than 10MB: hashes not computed')

    # external subtitles
    if subtitles:
        video.subtitle_languages |= set(search_external_subtitles(path, directory=subtitles_dir).values())

    # video metadata with enzyme
    try:
        if filename.endswith('.mkv'):
            with open(path, 'rb') as f:
                mkv = MKV(f)

            # main video track
            if mkv.video_tracks:
                video_track = mkv.video_tracks[0]

                # resolution
                if video_track.height in (480, 720, 1080):
                    if video_track.interlaced:
                        video.resolution = '%di' % video_track.height
                    else:
                        video.resolution = '%dp' % video_track.height
                    logger.debug('Found resolution %s with enzyme', video.resolution)

                # video codec
                if video_track.codec_id == 'V_MPEG4/ISO/AVC':
                    video.video_codec = 'h264'
                    logger.debug('Found video_codec %s with enzyme', video.video_codec)
                elif video_track.codec_id == 'V_MPEG4/ISO/SP':
                    video.video_codec = 'DivX'
                    logger.debug('Found video_codec %s with enzyme', video.video_codec)
                elif video_track.codec_id == 'V_MPEG4/ISO/ASP':
                    video.video_codec = 'XviD'
                    logger.debug('Found video_codec %s with enzyme', video.video_codec)
            else:
                logger.warning('MKV has no video track')

            # main audio track
            if mkv.audio_tracks:
                audio_track = mkv.audio_tracks[0]
                # audio codec
                if audio_track.codec_id == 'A_AC3':
                    video.audio_codec = 'AC3'
                    logger.debug('Found audio_codec %s with enzyme', video.audio_codec)
                elif audio_track.codec_id == 'A_DTS':
                    video.audio_codec = 'DTS'
                    logger.debug('Found audio_codec %s with enzyme', video.audio_codec)
                elif audio_track.codec_id == 'A_AAC':
                    video.audio_codec = 'AAC'
                    logger.debug('Found audio_codec %s with enzyme', video.audio_codec)
            else:
                logger.warning('MKV has no audio track')

            # subtitle tracks
            if mkv.subtitle_tracks:
                if embedded_subtitles:
                    embedded_subtitle_languages = set()
                    for st in mkv.subtitle_tracks:
                        if st.language:
                            try:
                                embedded_subtitle_languages.add(Language.fromalpha3b(st.language))
                            except BabelfishError:
                                logger.error('Embedded subtitle track language %r is not a valid language', st.language)
                                embedded_subtitle_languages.add(Language('und'))
                        elif st.name:
                            try:
#.........这里部分代码省略.........
开发者ID:Hydrog3n,项目名称:SickRage,代码行数:103,代码来源:video.py

示例11: refine

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
def refine(video, embedded_subtitles=True, **kwargs):
    """Refine a video by searching its metadata.

    Several :class:`~subliminal.video.Video` attributes can be found:

      * :attr:`~subliminal.video.Video.resolution`
      * :attr:`~subliminal.video.Video.video_codec`
      * :attr:`~subliminal.video.Video.audio_codec`
      * :attr:`~subliminal.video.Video.subtitle_languages`

    :param bool embedded_subtitles: search for embedded subtitles.

    """
    # skip non existing videos
    if not video.exists:
        return

    # check extensions
    extension = os.path.splitext(video.name)[1]
    if extension == '.mkv':
        with open(video.name, 'rb') as f:
            mkv = MKV(f)

        # main video track
        if mkv.video_tracks:
            video_track = mkv.video_tracks[0]

            # resolution
            if video_track.height in (480, 720, 1080):
                if video_track.interlaced:
                    video.resolution = '%di' % video_track.height
                else:
                    video.resolution = '%dp' % video_track.height
                logger.debug('Found resolution %s', video.resolution)

            # video codec
            if video_track.codec_id == 'V_MPEG4/ISO/AVC':
                video.video_codec = 'H.264'
                logger.debug('Found video_codec %s', video.video_codec)
            elif video_track.codec_id == 'V_MPEG4/ISO/SP':
                video.video_codec = 'DivX'
                logger.debug('Found video_codec %s', video.video_codec)
            elif video_track.codec_id == 'V_MPEG4/ISO/ASP':
                video.video_codec = 'Xvid'
                logger.debug('Found video_codec %s', video.video_codec)
        else:
            logger.warning('MKV has no video track')

        # main audio track
        if mkv.audio_tracks:
            audio_track = mkv.audio_tracks[0]
            # audio codec
            if audio_track.codec_id == 'A_AC3':
                video.audio_codec = 'Dolby Digital'
                logger.debug('Found audio_codec %s', video.audio_codec)
            elif audio_track.codec_id == 'A_DTS':
                video.audio_codec = 'DTS'
                logger.debug('Found audio_codec %s', video.audio_codec)
            elif audio_track.codec_id == 'A_AAC':
                video.audio_codec = 'AAC'
                logger.debug('Found audio_codec %s', video.audio_codec)
        else:
            logger.warning('MKV has no audio track')

        # subtitle tracks
        if mkv.subtitle_tracks:
            if embedded_subtitles:
                embedded_subtitle_languages = set()
                for st in mkv.subtitle_tracks:
                    if st.language:
                        try:
                            embedded_subtitle_languages.add(Language.fromalpha3b(st.language))
                        except BabelfishError:
                            logger.error('Embedded subtitle track language %r is not a valid language', st.language)
                            embedded_subtitle_languages.add(Language('und'))
                    elif st.name:
                        try:
                            embedded_subtitle_languages.add(Language.fromname(st.name))
                        except BabelfishError:
                            logger.debug('Embedded subtitle track name %r is not a valid language', st.name)
                            embedded_subtitle_languages.add(Language('und'))
                    else:
                        embedded_subtitle_languages.add(Language('und'))
                logger.debug('Found embedded subtitle %r', embedded_subtitle_languages)
                video.subtitle_languages |= embedded_subtitle_languages
        else:
            logger.debug('MKV has no subtitle track')
    else:
        logger.debug('Unsupported video extension %s', extension)
开发者ID:h3llrais3r,项目名称:Auto-Subliminal,代码行数:91,代码来源:metadata.py

示例12: fromalpha3b

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
    def fromalpha3b(cls, s):
        if s in repl_map:
            s = repl_map[s]
            return Language(*Language_.fromietf(s).__getstate__())

        return Language(*Language_.fromalpha3b(s).__getstate__())
开发者ID:pannal,项目名称:Sub-Zero.bundle,代码行数:8,代码来源:language.py

示例13: scan_video

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3b [as 别名]
def scan_video(path, subtitles=True, embedded_subtitles=True, subtitles_dir=None):
    """Scan a video and its subtitle languages from a video `path`.

    :param str path: existing path to the video.
    :param bool subtitles: scan for subtitles with the same name.
    :param bool embedded_subtitles: scan for embedded subtitles.
    :param str subtitles_dir: directory to search for subtitles.
    :return: the scanned video.
    :rtype: :class:`Video`

    """
    # check for non-existing path
    if not os.path.exists(path):
        raise ValueError("Path does not exist")

    # check video extension
    if not path.endswith(VIDEO_EXTENSIONS):
        raise ValueError("%s is not a valid video extension" % os.path.splitext(path)[1])

    dirpath, filename = os.path.split(path)
    logger.info("Scanning video %r in %r", filename, dirpath)

    # guess
    video = Video.fromguess(path, guess_file_info(path))

    # size and hashes
    video.size = os.path.getsize(path)
    if video.size > 10485760:
        logger.debug("Size is %d", video.size)
        video.hashes["opensubtitles"] = hash_opensubtitles(path)
        video.hashes["thesubdb"] = hash_thesubdb(path)
        video.hashes["napiprojekt"] = hash_napiprojekt(path)
        logger.debug("Computed hashes %r", video.hashes)
    else:
        logger.warning("Size is lower than 10MB: hashes not computed")

    # external subtitles
    if subtitles:
        video.subtitle_languages |= set(search_external_subtitles(path, directory=subtitles_dir).values())

    # video metadata with enzyme
    try:
        if filename.endswith(".mkv"):
            with open(path, "rb") as f:
                mkv = MKV(f)

            # main video track
            if mkv.video_tracks:
                video_track = mkv.video_tracks[0]

                # resolution
                if video_track.height in (480, 720, 1080):
                    if video_track.interlaced:
                        video.resolution = "%di" % video_track.height
                    else:
                        video.resolution = "%dp" % video_track.height
                    logger.debug("Found resolution %s with enzyme", video.resolution)

                # video codec
                if video_track.codec_id == "V_MPEG4/ISO/AVC":
                    video.video_codec = "h264"
                    logger.debug("Found video_codec %s with enzyme", video.video_codec)
                elif video_track.codec_id == "V_MPEG4/ISO/SP":
                    video.video_codec = "DivX"
                    logger.debug("Found video_codec %s with enzyme", video.video_codec)
                elif video_track.codec_id == "V_MPEG4/ISO/ASP":
                    video.video_codec = "XviD"
                    logger.debug("Found video_codec %s with enzyme", video.video_codec)
            else:
                logger.warning("MKV has no video track")

            # main audio track
            if mkv.audio_tracks:
                audio_track = mkv.audio_tracks[0]
                # audio codec
                if audio_track.codec_id == "A_AC3":
                    video.audio_codec = "AC3"
                    logger.debug("Found audio_codec %s with enzyme", video.audio_codec)
                elif audio_track.codec_id == "A_DTS":
                    video.audio_codec = "DTS"
                    logger.debug("Found audio_codec %s with enzyme", video.audio_codec)
                elif audio_track.codec_id == "A_AAC":
                    video.audio_codec = "AAC"
                    logger.debug("Found audio_codec %s with enzyme", video.audio_codec)
            else:
                logger.warning("MKV has no audio track")

            # subtitle tracks
            if mkv.subtitle_tracks:
                if embedded_subtitles:
                    embedded_subtitle_languages = set()
                    for st in mkv.subtitle_tracks:
                        if st.language:
                            try:
                                embedded_subtitle_languages.add(Language.fromalpha3b(st.language))
                            except BabelfishError:
                                logger.error("Embedded subtitle track language %r is not a valid language", st.language)
                                embedded_subtitle_languages.add(Language("und"))
                        elif st.name:
                            try:
#.........这里部分代码省略.........
开发者ID:lastdevonearth,项目名称:SickRage,代码行数:103,代码来源:video.py


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