本文整理汇总了Python中babelfish.Language.fromalpha2方法的典型用法代码示例。如果您正苦于以下问题:Python Language.fromalpha2方法的具体用法?Python Language.fromalpha2怎么用?Python Language.fromalpha2使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类babelfish.Language
的用法示例。
在下文中一共展示了Language.fromalpha2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_converter_alpha2
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
def test_converter_alpha2(self):
self.assertEqual(Language('eng').alpha2, 'en')
self.assertEqual(Language.fromalpha2('en'), Language('eng'))
self.assertEqual(Language.fromcode('en', 'alpha2'), Language('eng'))
self.assertRaises(LanguageReverseError, lambda: Language.fromalpha2('zz'))
self.assertRaises(LanguageConvertError, lambda: Language('aaa').alpha2)
self.assertEqual(len(language_converters['alpha2'].codes), 184)
示例2: query
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
def query(self, searchword=None):
params = {"searchword": searchword}
logger.info("Searching subtitles %r", params)
r = self.session.get("http://sub.makedie.me/sub/?", params=params, timeout=10)
r.raise_for_status()
# loop over
subtitles = []
try:
# BeautifulSoup gives you Unicode, damn it
soup = BeautifulSoup(r.content, "html5lib")
results = soup.find_all("div", attrs={"class": "subitem"})
for it in results:
releases = it.find("a", attrs={"class": "introtitle"})["title"].strip().split("/")
sid = re.search("/xml/sub/\d+/(\d+).xml", it.find("a", attrs={"class": "introtitle"})["href"]).group(1)
download_button = it.find("a", attrs={"id": "downsubbtn"})["onclick"].strip()
if re.search("location.href\s*=\s*", download_button):
link = "http://sub.makedie.me/" + re.search(
"location.href\s*=\s*['\"](.*?)['\"]", download_button
).group(1)
else:
logger.debug("No download link found")
continue
lang = ""
for li in it.find_all("li"):
if re.search("格式:", li.text.strip()):
subtype = re.search("格式:\s*([^\(]+)(?:\(\?\))*", li.text.strip()).group(1)
if re.search("语言:", li.text.strip()):
lang = re.search("语言:\s*([^\(]+)(?:\(\?\))*", li.text.strip()).group(1)
if re.search("下载次数:", li.text.strip()):
downloads = re.search("下载次数:\s*([^\(]+)(?:\(\?\))*", li.text.strip()).group(1)
downloads = re.search("(\d+).*", downloads).group(1)
if re.search("日期:", li.text.strip()):
upload_date = re.search("日期:\s*([^\(]+)(?:\(\?\))*", li.text.strip()).group(1)
if "简" in lang or "繁" in lang or "双语" in lang:
subtitle = MakeDieSubtitle(
Language.fromalpha2("zh"), releases, sid, link, subtype, downloads, upload_date
)
else:
subtitle = MakeDieSubtitle(
Language.fromalpha2("en"), releases, sid, link, subtype, downloads, upload_date
)
logger.debug("Found subtitle %r", subtitle)
subtitles.append(subtitle)
return subtitles
except:
logger.debug("No subtitle found")
return []
示例3: test_converter_alpha2
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
def test_converter_alpha2(self):
self.assertEqual(Language('eng').alpha2, 'en')
self.assertEqual(Language.fromalpha2('en'), Language('eng'))
self.assertEqual(Language.fromcode('en', 'alpha2'), Language('eng'))
with self.assertRaises(LanguageReverseError):
Language.fromalpha2('zz')
with self.assertRaises(LanguageConvertError):
Language('aaa').alpha2
self.assertEqual(len(get_language_converter('alpha2').codes), 184)
示例4: getAlpha3TCode
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [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
示例5: query
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
def query(self, title, season=None, episode=None):
# search for the url title
url_titles = self._search_url_titles(title)
# episode
if season and episode:
if 'series' not in url_titles:
logger.error('No URL title found for series %r', title)
return []
url_title = url_titles['series'][0]
logger.debug('Using series title %r', url_title)
url = self.server_url + 'cst/data/series/sb/{}/{}/{}/'.format(url_title, season, episode)
page_link = self.server_url + 'subtitle/series/{}/{}/{}/'.format(url_title, season, episode)
else:
if 'movie' not in url_titles:
logger.error('No URL title found for movie %r', title)
return []
url_title = url_titles['movie'][0]
logger.debug('Using movie title %r', url_title)
url = self.server_url + 'cst/data/movie/sb/{}/'.format(url_title)
page_link = self.server_url + 'subtitle/movie/{}/'.format(url_title)
# get the list of subtitles
logger.debug('Getting the list of subtitles')
r = self.session.get(url)
r.raise_for_status()
results = json.loads(r.text)
# loop over results
subtitles = {}
for language_code, language_data in results.items():
for quality_data in language_data.values():
for quality, subtitles_data in quality_data.items():
for subtitle_item in subtitles_data.values():
# read the item
language = Language.fromalpha2(language_code)
hearing_impaired = bool(subtitle_item['hearing_impaired'])
subtitle_id = subtitle_item['id']
subtitle_key = subtitle_item['key']
subtitle_version = subtitle_item['h_version']
downloaded = subtitle_item['downloaded']
release = subtitle_item['subtitle_version']
# add the release and increment downloaded count if we already have the subtitle
if subtitle_id in subtitles:
logger.debug('Found additional release %r for subtitle %d', release, subtitle_id)
bisect.insort_left(subtitles[subtitle_id].releases, release) # deterministic order
subtitles[subtitle_id].downloaded += downloaded
continue
# otherwise create it
subtitle = SubsCenterSubtitle(language, hearing_impaired, page_link, title, season, episode,
title, subtitle_id, subtitle_key, subtitle_version, downloaded,
[release])
logger.debug('Found subtitle %r', subtitle)
subtitles[subtitle_id] = subtitle
return subtitles.values()
示例6: query
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
def query(self, title, season=None, episode=None, year=None, filename=None, imdb_id=None):
# search for the IMDB ID if needed.
is_movie = not (season and episode)
imdb_id = imdb_id or self._search_imdb_id(title, year, is_movie)
if not imdb_id:
return {}
# search
logger.debug('Using IMDB ID %r', imdb_id)
url = 'http://json.{}/{}.json'.format(self.server_url, imdb_id)
page_link = 'http://{}/#/{}/{}'.format(self.server_url, 'movies' if is_movie else 'series', imdb_id)
# get the list of subtitles
logger.debug('Getting the list of subtitles')
r = self.session.get(url)
r.raise_for_status()
try:
results = r.json()
except ValueError:
return {}
# filter irrelevant results
if not is_movie:
results = results.get('subs', {}).get(str(season), {}).get(str(episode), [])
else:
results = results.get('subs', [])
# loop over results
subtitles = {}
for result in results:
language = Language.fromalpha2('he')
hearing_impaired = False
subtitle_id = result['id']
release = result['version']
# add the release and increment downloaded count if we already have the subtitle
if subtitle_id in subtitles:
logger.debug('Found additional release %r for subtitle %d', release, subtitle_id)
bisect.insort_left(subtitles[subtitle_id].releases, release) # deterministic order
subtitles[subtitle_id].downloaded += 1
continue
# otherwise create it
subtitle = WizdomSubtitle(language, hearing_impaired, page_link, title, season, episode, title, imdb_id,
subtitle_id, [release])
logger.debug('Found subtitle %r', subtitle)
subtitles[subtitle_id] = subtitle
return subtitles.values()
示例7: query
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
def query(self, series=None, season=None, episode=None, title=None):
# set the correct parameters depending on the kind
if series and season and episode:
url_series = self._search_url_title(series, 'series')
url = self.server + 'cinemast/data/series/sb/{}/{}/{}/'.format(url_series, season, episode)
page_link = self.server + 'subtitle/series/{}/{}/{}/'.format(url_series, season, episode)
elif title:
url_title = self._search_url_title(title, 'movie')
url = self.server + 'cinemast/data/movie/sb/{}/'.format(url_title)
page_link = self.server + 'subtitle/movie/{}/'.format(url_title)
else:
raise ValueError('One or more parameters are missing')
# get the list of subtitles
logger.debug('Getting the list of subtitles')
r = self.session.get(url)
r.raise_for_status()
results = json.loads(r.text)
# loop over results
subtitles = {}
for language_code, language_data in results.items():
for quality_data in language_data.values():
for quality, subtitles_data in quality_data.items():
for subtitle_item in subtitles_data.values():
# read the item
language = Language.fromalpha2(language_code)
hearing_impaired = bool(subtitle_item['hearing_impaired'])
subtitle_id = subtitle_item['id']
subtitle_key = subtitle_item['key']
downloaded = subtitle_item['downloaded']
release = subtitle_item['subtitle_version']
# add the release and increment downloaded count if we already have the subtitle
if subtitle_id in subtitles:
logger.debug('Found additional release %r for subtitle %d', release, subtitle_id)
bisect.insort_left(subtitles[subtitle_id].releases, release) # deterministic order
subtitles[subtitle_id].downloaded += downloaded
continue
# otherwise create it
subtitle = SubsCenterSubtitle(language, hearing_impaired, page_link, series, season, episode,
title, subtitle_id, subtitle_key, downloaded, [release])
logger.debug('Found subtitle %r', subtitle)
subtitles[subtitle_id] = subtitle
return subtitles.values()
示例8: query
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
def query(self, hash):
# make the query
params = {'action': 'search', 'hash': hash}
logger.info('Searching subtitles %r', params)
r = self.session.get(self.server_url, params=params, timeout=10)
# handle subtitles not found and errors
if r.status_code == 404:
logger.debug('No subtitles found')
return []
r.raise_for_status()
# loop over languages
subtitles = []
for language_code in r.text.split(','):
language = Language.fromalpha2(language_code)
subtitle = TheSubDBSubtitle(language, hash)
logger.info('Found subtitle %r', subtitle)
subtitles.append(subtitle)
return subtitles
示例9: query
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
def query(self, hash):
# shooter has many DNS mirrors, e.g. splayer[1-9], but one is enough
params = {"pathinfo": "temp", "format": "json", "filehash": hash}
logger.info("Searching subtitles %r", params)
r = self.session.get("https://www.shooter.cn/api/subapi.php", params=params, timeout=10)
r.raise_for_status()
# loop over, server always returns found or not
subtitles = []
try:
for it in r.json():
# It normally contains one File, but can contain multiple
link = it["Files"][0]["Link"]
subtype = it["Files"][0]["Ext"]
subtitle = ShooterSubtitle(Language.fromalpha2("zh"), hash, link, subtype)
logger.debug("Found subtitle %r", subtitle)
subtitles.append(subtitle)
return subtitles
except:
logger.debug("No subtitle found")
return []
示例10: generateOptions
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
#.........这里部分代码省略.........
# Attempt to set the dogpile cache
try:
subliminal.region.configure("dogpile.cache.memory")
except:
pass
try:
video = subliminal.scan_video(os.path.abspath(inputfile), subtitles=True, embedded_subtitles=True)
subtitles = subliminal.download_best_subtitles(
[video], languages, hearing_impaired=False, providers=self.subproviders
)
try:
subliminal.save_subtitles(video, subtitles[video])
except:
# Support for older versions of subliminal
subliminal.save_subtitles(subtitles)
self.log.info("Please update to the latest version of subliminal.")
except Exception as e:
self.log.info("Unable to download subtitles.", exc_info=True)
self.log.debug("Unable to download subtitles.", exc_info=True)
# External subtitle import
if self.embedsubs: # Don't bother if we're not embeddeding any subtitles
src = 1 # FFMPEG input source number
for dirName, subdirList, fileList in os.walk(input_dir):
for fname in fileList:
subname, subextension = os.path.splitext(fname)
# Watch for appropriate file extension
if subextension[1:] in valid_subtitle_extensions:
x, lang = os.path.splitext(subname)
lang = lang[1:]
# Using bablefish to convert a 2 language code to a 3 language code
if len(lang) is 2:
try:
babel = Language.fromalpha2(lang)
lang = babel.alpha3
except:
pass
# If subtitle file name and input video name are the same, proceed
if x == filename:
self.log.info("External %s subtitle file detected." % lang)
if self.swl is None or lang in self.swl:
self.log.info("Creating subtitle stream %s by importing %s." % (l, fname))
subtitle_settings.update(
{
l: {
"path": os.path.join(dirName, fname),
"source": src,
"map": 0,
"codec": "mov_text",
"language": lang,
}
}
)
self.log.debug("Path: %s." % os.path.join(dirName, fname))
self.log.debug("Source: %s." % src)
self.log.debug("Codec: mov_text.")
self.log.debug("Langauge: %s." % lang)
l = l + 1
src = src + 1
self.deletesubs.add(os.path.join(dirName, fname))
示例11: generateOptions
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
#.........这里部分代码省略.........
'codec': 'srt',
'language': s.language
}}
options = {
'format': 'srt',
'subtitle': ripsub,
}
input_dir, filename, input_extension = self.parseFile(inputfile)
output_dir = input_dir if self.output_dir is None else self.output_dir
outputfile = os.path.join(output_dir, filename + "." + s.language + ".srt")
i = 2
while os.path.isfile(outputfile):
outputfile = os.path.join(output_dir, filename + "." + s.language + "." + str(i) + ".srt")
i += i
print "Ripping " + s.language + " subtitle from file"
conv = Converter(self.FFMPEG_PATH, self.FFPROBE_PATH).convert(inputfile, outputfile, options, timeout=None)
for timecode in conv:
pass
try:
print outputfile + " created"
except:
print "File created"
# External subtitle import
# Attempt to download subtitles if they are missing using subliminal
languages = set()
if self.swl:
for alpha3 in self.swl:
languages.add(Language(alpha3))
elif self.sdl:
languages.add(Language(self.sdl))
else:
self.downloadsubs = False
if self.downloadsubs:
import subliminal
print "Attempting to download subtitles, please wait"
try:
subliminal.cache_region.configure('dogpile.cache.memory')
except:
pass
try:
video = subliminal.scan_video(os.path.abspath(inputfile), subtitles=True, embedded_subtitles=True, original=original)
subtitles = subliminal.download_best_subtitles([video], languages, hearing_impaired=False, providers=self.subproviders)
subliminal.save_subtitles(subtitles)
except Exception as e:
print e
print "Unable to download subtitle"
src = 1 # FFMPEG input source number
for dirName, subdirList, fileList in os.walk(input_dir):
for fname in fileList:
subname, subextension = os.path.splitext(fname)
# Watch for appropriate file extension
if subextension[1:] in valid_subtitle_extensions:
x, lang = os.path.splitext(subname)
lang = lang[1:]
# Using bablefish to convert a 2 language code to a 3 language code
if len(lang) is 2:
try:
babel = Language.fromalpha2(lang)
lang = babel.alpha3
except:
pass
# If subtitle file name and input video name are the same, proceed
if x == filename and self.embedsubs:
print "External subtitle file detected, language " + lang
if self.swl is None or lang in self.swl:
print "Importing %s subtitle stream" % (fname)
subtitle_settings.update({l: {
'path': os.path.join(dirName, fname),
'source': src,
'map': 0,
'codec': 'mov_text',
'language': lang,
}})
l = l + 1
src = src + 1
self.deletesubs.add(os.path.join(dirName, fname))
else:
print "Ignoring %s external subtitle stream due to language: %s" % (fname, lang)
# Collect all options
options = {
'format': self.output_format,
'video': {
'codec': vcodec,
'map': info.video.index,
'bitrate': info.format.bitrate
},
'audio': audio_settings,
'subtitle': subtitle_settings,
}
self.options = options
return options
示例12: generateOptions
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
#.........这里部分代码省略.........
try:
self.log.info("Ripping %s subtitle from source stream %s into external file." % (s.metadata['language'], s.index))
conv = Converter(self.FFMPEG_PATH, self.FFPROBE_PATH).convert(inputfile, outputfile, options, timeout=None)
for timecode in conv:
pass
self.log.info("%s created." % outputfile)
except:
self.log.exception("Unabled to create external subtitle file for stream %s." % (s.index))
# Attempt to download subtitles if they are missing using subliminal
languages = set()
if self.swl:
for alpha3 in self.swl:
languages.add(Language(alpha3))
elif self.sdl:
languages.add(Language(self.sdl))
else:
self.downloadsubs = False
if self.downloadsubs:
import subliminal
self.log.info("Attempting to download subtitles.")
try:
subliminal.cache_region.configure('dogpile.cache.memory')
except:
pass
try:
video = subliminal.scan_video(os.path.abspath(inputfile.decode(sys.getfilesystemencoding())), subtitles=True, embedded_subtitles=True, original=original)
subtitles = subliminal.download_best_subtitles([video], languages, hearing_impaired=False, providers=self.subproviders)
subliminal.save_subtitles(subtitles)
except Exception as e:
self.log.debug("Unable to download subtitles.", exc_info=True)
# External subtitle import
if self.embedsubs: #Don't bother if we're not embeddeding any subtitles
src = 1 # FFMPEG input source number
for dirName, subdirList, fileList in os.walk(input_dir):
for fname in fileList:
subname, subextension = os.path.splitext(fname)
# Watch for appropriate file extension
if subextension[1:] in valid_subtitle_extensions:
x, lang = os.path.splitext(subname)
lang = lang[1:]
# Using bablefish to convert a 2 language code to a 3 language code
if len(lang) is 2:
try:
babel = Language.fromalpha2(lang)
lang = babel.alpha3
except:
pass
# If subtitle file name and input video name are the same, proceed
if x == filename:
self.log.info("External %s subtitle file detected." % lang)
if self.swl is None or lang in self.swl:
self.log.info("Creating subtitle stream %s by importing %s." % (l, fname))
subtitle_settings.update({l: {
'path': os.path.join(dirName, fname),
'source': src,
'map': 0,
'codec': 'mov_text',
'language': lang,
}})
self.log.debug("Path: %s." % os.path.join(dirName, fname))
self.log.debug("Source: %s." % src)
self.log.debug("Codec: mov_text.")
self.log.debug("Langauge: %s." % lang)
l = l + 1
src = src + 1
self.deletesubs.add(os.path.join(dirName, fname))
else:
self.log.info("Ignoring %s external subtitle stream due to language %s." % (fname, lang))
# Collect all options
options = {
'format': self.output_format,
'video': {
'codec': vcodec,
'map': info.video.index,
'bitrate': vbitrate,
'level': self.h264_level
},
'audio': audio_settings,
'subtitle': subtitle_settings,
}
# Add width option
if vwidth: options['video']['width'] = vwidth
# Add pix_fmt
if self.pix_fmt: options['video']['pix_fmt'] = self.pix_fmt
self.options = options
return options
示例13: generateOptions
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
#.........这里部分代码省略.........
video = subliminal.scan_video(
os.path.abspath(inputfile), subtitles=True, embedded_subtitles=True
)
subtitles = subliminal.download_best_subtitles(
[video],
languages,
hearing_impaired=False,
providers=self.subproviders,
)
try:
subliminal.save_subtitles(video, subtitles[video])
except Exception:
# Support for older versions of subliminal
subliminal.save_subtitles(subtitles)
self.log.info("Please update to the latest version of subliminal.")
except Exception:
self.log.info("Unable to download subtitles.", exc_info=True)
self.log.debug("Unable to download subtitles.", exc_info=True)
# External subtitle import
if (
self.embedsubs and not self.embedonlyinternalsubs
): # Don't bother if we're not embeddeding subtitles and external subtitles
src = 1 # FFMPEG input source number
for dirName, subdirList, fileList in os.walk(input_dir):
for fname in fileList:
subname, subextension = os.path.splitext(fname)
# Watch for appropriate file extension
if subextension[1:] in valid_subtitle_extensions:
x, lang = os.path.splitext(subname)
lang = lang[1:]
# Using bablefish to convert a 2 language code to a 3 language code
if len(lang) is 2:
try:
babel = Language.fromalpha2(lang)
lang = babel.alpha3
except Exception:
pass
# If subtitle file name and input video name are the same, proceed
if x == filename:
self.log.info("External %s subtitle file detected." % lang)
if self.swl is None or lang in self.swl:
self.log.info(
"Creating subtitle stream %s by importing %s."
% (l, fname)
)
subtitle_settings.update(
{
l: {
"path": os.path.join(dirName, fname),
"source": src,
"map": 0,
"codec": "mov_text",
"language": lang,
}
}
)
self.log.debug(
"Path: %s." % os.path.join(dirName, fname)
)
self.log.debug("Source: %s." % src)
self.log.debug("Codec: mov_text.")
self.log.debug("Langauge: %s." % lang)
示例14: generateOptions
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
#.........这里部分代码省略.........
self.log.info("Attempting to download subtitles.")
# Attempt to set the dogpile cache
try:
subliminal.region.configure('dogpile.cache.memory')
except:
pass
try:
video = subliminal.scan_video(os.path.abspath(inputfile), subtitles=True, embedded_subtitles=True)
subtitles = subliminal.download_best_subtitles([video], languages, hearing_impaired=False, providers=self.subproviders)
try:
subliminal.save_subtitles(video, subtitles[video])
except:
# Support for older versions of subliminal
subliminal.save_subtitles(subtitles)
self.log.info("Please update to the latest version of subliminal.")
except Exception as e:
self.log.info("Unable to download subtitles.", exc_info=True)
self.log.debug("Unable to download subtitles.", exc_info=True)
# External subtitle import
if self.embedsubs and not self.embedonlyinternalsubs: # Don't bother if we're not embeddeding subtitles and external subtitles
src = 1 # FFMPEG input source number
for dirName, subdirList, fileList in os.walk(input_dir):
for fname in fileList:
subname, subextension = os.path.splitext(fname)
# Watch for appropriate file extension
if subextension[1:] in valid_subtitle_extensions:
x, lang = os.path.splitext(subname)
lang = lang[1:]
# Using bablefish to convert a 2 language code to a 3 language code
if len(lang) is 2:
try:
babel = Language.fromalpha2(lang)
lang = babel.alpha3
except:
pass
# If subtitle file name and input video name are the same, proceed
if x == filename:
self.log.info("External %s subtitle file detected." % lang)
if self.swl is None or lang in self.swl:
self.log.info("Creating subtitle stream %s by importing %s." % (l, fname))
subtitle_settings.update({l: {
'path': os.path.join(dirName, fname),
'source': src,
'map': 0,
'codec': 'mov_text',
'language': lang}})
self.log.debug("Path: %s." % os.path.join(dirName, fname))
self.log.debug("Source: %s." % src)
self.log.debug("Codec: mov_text.")
self.log.debug("Langauge: %s." % lang)
l = l + 1
src = src + 1
self.deletesubs.add(os.path.join(dirName, fname))
else:
self.log.info("Ignoring %s external subtitle stream due to language %s." % (fname, lang))
# Collect all options
options = {
示例15: autoFork
# 需要导入模块: from babelfish import Language [as 别名]
# 或者: from babelfish.Language import fromalpha2 [as 别名]
fork, fork_params = autoFork('SickBeard', 'tv')
if server_responding("http://127.0.0.1:5050"):
print "CouchPotato Running"
if server_responding("http://127.0.0.1:7073"):
print "SickBeard Running"
if server_responding("http://127.0.0.1:8181"):
print "HeadPhones Running"
if server_responding("http://127.0.0.1:8085"):
print "Gamez Running"
if server_responding("http://127.0.0.1:8090"):
print "Mylar Running"
from babelfish import Language
lan = 'pt'
lan = Language.fromalpha2(lan)
print lan.alpha3
vidName = "/volume1/Public/Movies/A Few Good Men/A Few Good Men(1992).mkv"
inputName = "in.the.name.of.ben.hur.2016.bdrip.x264-rusted.nzb"
guess = guessit.guessit(inputName)
if guess:
# Movie Title
title = None
if 'title' in guess:
title = guess['title']
# Movie Year
year = None
if 'year' in guess:
year = guess['year']
url = "http://www.omdbapi.com"
r = requests.get(url, params={'y': year, 't': title}, verify=False, timeout=(60, 300))