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


Python Language.fromalpha3方法代码示例

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


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

示例1: __init__

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3 [as 别名]

#.........这里部分代码省略.........

        if not self.embedsubs and self.scodec not in valid_external_subcodecs:
            log.warning("Invalid external subtitle codec %s, defaulting to 'srt'." % self.scodec)
            self.scodec = 'srt'


        self.swl = config.get(section, 'subtitle-language').strip().lower()  # List of acceptable languages for subtitle streams to be carried over from the original file, separated by a comma. Blank for all
        if self.swl == '':
            self.swl = None
        else:
            self.swl = self.swl.replace(' ', '').split(',')

        self.adl = config.get(section, 'audio-default-language').strip().lower()  # What language to default an undefinied audio language tag to. If blank, it will remain undefined. This is useful for single language releases which tend to leave things tagged as und
        if self.adl == "" or len(self.adl) > 3:
            self.adl = None

        self.sdl = config.get(section, 'subtitle-default-language').strip().lower()  # What language to default an undefinied subtitle language tag to. If blank, it will remain undefined. This is useful for single language releases which tend to leave things tagged as und
        if self.sdl == ""or len(self.sdl) > 3:
            self.sdl = None
        # Prevent incompatible combination of settings
        if self.output_dir == "" and self.delete is False:
            log.error("You must specify an alternate output directory if you aren't going to delete the original file.")
            sys.exit()
        # Create output directory if it does not exist
        if self.output_dir is not None:
            if not os.path.isdir(self.output_dir):
                os.makedirs(self.output_dir)
        self.processMP4 = config.getboolean(section, "convert-mp4")  # Determine whether or not to reprocess mp4 files or just tag them
        self.fullpathguess = config.getboolean(section, "fullpathguess") # Guess using the full path or not
        self.tagfile = config.getboolean(section, "tagfile") # Tag files with metadata
        self.taglanguage = config.get(section, "tag-language").strip().lower() # Language to tag files
        if len(self.taglanguage) > 2:
            try:
                babel = Language.fromalpha3(self.taglanguage)
                self.taglanguage = babel.alpha2
            except:
                log.exception("Unable to set tag language, defaulting to English.")
                self.taglanguage = 'en'
        elif len(self.taglanguage) < 2:
            log.exception("Unable to set tag language, defaulting to English.")
            self.taglanguage = 'en'
        self.artwork = config.getboolean(section, "download-artwork") # Download and embed artwork

        #Read relevant CouchPotato section information
        section = "CouchPotato"
        self.CP = {}
        self.CP['host'] = config.get(section, "host")
        self.CP['port'] = config.get(section, "port")
        self.CP['username'] = config.get(section, "username")
        self.CP['password'] = config.get(section, "password")
        self.CP['apikey'] = config.get(section, "apikey")
        self.CP['delay'] = config.get(section, "delay")
        self.CP['method'] = config.get(section, "method")
        self.CP['web_root'] = config.get(section, "web_root")

        try:
            self.CP['delay'] = float(self.CP['delay'])
        except ValueError:
            self.CP['delay'] = 60
        try:
            self.CP['delete_failed'] = config.getboolean(section, "delete_failed")
        except (configparser.NoOptionError, ValueError):
            self.CP['delete_failed'] = False
        try:
            if config.getboolean(section, 'ssl'):
                self.CP['protocol'] = "https://"
开发者ID:gitaroomaan,项目名称:sickbeard_mp4_automator,代码行数:70,代码来源:readSettings.py

示例2: __init__

# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha3 [as 别名]

#.........这里部分代码省略.........
        )  # List of acceptable languages for subtitle streams to be carried over from the original file, separated by a comma. Blank for all
        if self.swl == "":
            self.swl = None
        else:
            self.swl = self.swl.replace(" ", "").split(",")

        self.adl = (
            config.get(section, "audio-default-language").strip().lower()
        )  # What language to default an undefinied audio language tag to. If blank, it will remain undefined. This is useful for single language releases which tend to leave things tagged as und
        if self.adl == "" or len(self.adl) > 3:
            self.adl = None

        self.sdl = (
            config.get(section, "subtitle-default-language").strip().lower()
        )  # What language to default an undefinied subtitle language tag to. If blank, it will remain undefined. This is useful for single language releases which tend to leave things tagged as und
        if self.sdl == "" or len(self.sdl) > 3:
            self.sdl = None
        # Prevent incompatible combination of settings
        if self.output_dir == "" and self.delete is False:
            log.error("You must specify an alternate output directory if you aren't going to delete the original file.")
            sys.exit()
        # Create output directory if it does not exist
        if self.output_dir is not None:
            if not os.path.isdir(self.output_dir):
                os.makedirs(self.output_dir)
        self.processMP4 = config.getboolean(
            section, "convert-mp4"
        )  # Determine whether or not to reprocess mp4 files or just tag them
        self.fullpathguess = config.getboolean(section, "fullpathguess")  # Guess using the full path or not
        self.tagfile = config.getboolean(section, "tagfile")  # Tag files with metadata
        self.taglanguage = config.get(section, "tag-language").strip().lower()  # Language to tag files
        if len(self.taglanguage) > 2:
            try:
                babel = Language.fromalpha3(self.taglanguage)
                self.taglanguage = babel.alpha2
            except:
                log.exception("Unable to set tag language, defaulting to English.")
                self.taglanguage = "en"
        elif len(self.taglanguage) < 2:
            log.exception("Unable to set tag language, defaulting to English.")
            self.taglanguage = "en"
        self.artwork = config.getboolean(section, "download-artwork")  # Download and embed artwork

        # Read relevant CouchPotato section information
        section = "CouchPotato"
        self.CP = {}
        self.CP["host"] = config.get(section, "host")
        self.CP["port"] = config.get(section, "port")
        self.CP["username"] = config.get(section, "username")
        self.CP["password"] = config.get(section, "password")
        self.CP["apikey"] = config.get(section, "apikey")
        self.CP["delay"] = config.get(section, "delay")
        self.CP["method"] = config.get(section, "method")
        self.CP["web_root"] = config.get(section, "web_root")

        try:
            self.CP["delay"] = float(self.CP["delay"])
        except ValueError:
            self.CP["delay"] = 60
        try:
            self.CP["delete_failed"] = config.getboolean(section, "delete_failed")
        except (configparser.NoOptionError, ValueError):
            self.CP["delete_failed"] = False
        try:
            if config.getboolean(section, "ssl"):
                self.CP["protocol"] = "https://"
开发者ID:dpkmon,项目名称:sickbeard_mp4_automator,代码行数:70,代码来源:readSettings.py


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