本文整理汇总了Python中youtube_dl.extractor.YoutubeIE.extract方法的典型用法代码示例。如果您正苦于以下问题:Python YoutubeIE.extract方法的具体用法?Python YoutubeIE.extract怎么用?Python YoutubeIE.extract使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类youtube_dl.extractor.YoutubeIE
的用法示例。
在下文中一共展示了YoutubeIE.extract方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_youtube_subtitles
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_subtitles(self):
DL = FakeYDL()
DL.params["writesubtitles"] = True
IE = YoutubeIE(DL)
info_dict = IE.extract("QRS8MkLhQmM")
sub = info_dict[0]["subtitles"][0]
self.assertEqual(md5(sub[2]), "4cd9278a35ba2305f47354ee13472260")
示例2: test_youtube_allsubtitles
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_allsubtitles(self):
DL = FakeDownloader()
DL.params['allsubtitles'] = True
IE = YoutubeIE(DL)
info_dict = IE.extract('QRS8MkLhQmM')
subtitles = info_dict[0]['subtitles']
self.assertEqual(len(subtitles), 13)
示例3: test_youtube_subtitles
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_subtitles(self):
DL = FakeDownloader()
DL.params['writesubtitles'] = True
IE = YoutubeIE(DL)
info_dict = IE.extract('QRS8MkLhQmM')
sub = info_dict[0]['subtitles'][0]
self.assertEqual(md5(sub[2]), '4cd9278a35ba2305f47354ee13472260')
示例4: download_and_convert
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def download_and_convert(issue):
downloader = get_downloader()
ie = YoutubeIE(downloader=downloader)
try:
info = ie.extract(issue.youtube_url)
except ExtractorError:
return False
tmp_dir = os.path.join(settings.TMP_DIR)
tmp_video_fn = mktemp(suffix="." + settings.YOUTUBE_EXT, dir=tmp_dir)
try:
downloader.download(tmp_video_fn, [x for x in info["formats"] if x["format_id"] == settings.YOUTUBE_FORMAT][0])
finally:
try:
os.remove(tmp_video_fn + ".part")
except FileNotFoundError:
pass
result_fn = mktemp(suffix=".mp3", dir=tmp_dir)
call([os.path.join(settings.BASE_DIR, "scripts", "extract-speedup-file.sh"),
tmp_video_fn, settings.YOUTUBE_EXT, settings.SPEEDUP, tmp_dir, result_fn])
with open(result_fn, "rb") as f:
issue.file.save("{0}.mp3".format(issue.youtube_id), File(f))
issue.length_audio = get_audio_length(issue.file.path)
issue.save()
os.remove(result_fn)
return True
示例5: test_youtube_no_subtitles
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_no_subtitles(self):
DL = FakeDownloader()
DL.params['writesubtitles'] = False
IE = YoutubeIE(DL)
info_dict = IE.extract('QRS8MkLhQmM')
subtitles = info_dict[0]['subtitles']
self.assertEqual(subtitles, None)
示例6: get_video_info
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def get_video_info(url):
downloader = get_downloader()
ie = YoutubeIE(downloader=downloader)
try:
return ie.extract(url)
except ExtractorError:
return None
示例7: test_youtube_allsubtitles
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_allsubtitles(self):
DL = FakeYDL()
DL.params["allsubtitles"] = True
IE = YoutubeIE(DL)
info_dict = IE.extract("QRS8MkLhQmM")
subtitles = info_dict[0]["subtitles"]
self.assertEqual(len(subtitles), 13)
示例8: test_youtube_no_subtitles
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_no_subtitles(self):
DL = FakeYDL()
DL.params["writesubtitles"] = False
IE = YoutubeIE(DL)
info_dict = IE.extract("QRS8MkLhQmM")
subtitles = info_dict[0]["subtitles"]
self.assertEqual(subtitles, None)
示例9: test_youtube_automatic_captions
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_automatic_captions(self):
DL = FakeYDL()
DL.params['writeautomaticsub'] = True
DL.params['subtitleslangs'] = ['it']
IE = YoutubeIE(DL)
info_dict = IE.extract('8YoUxe5ncPo')
sub = info_dict[0]['subtitles']['it']
self.assertTrue(sub is not None)
示例10: test_youtube_subtitles_it
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_subtitles_it(self):
DL = FakeDownloader()
DL.params['writesubtitles'] = True
DL.params['subtitleslang'] = 'it'
IE = YoutubeIE(DL)
info_dict = IE.extract('QRS8MkLhQmM')
sub = info_dict[0]['subtitles'][0]
self.assertEqual(md5(sub[2]), '164a51f16f260476a05b50fe4c2f161d')
示例11: test_youtube_automatic_captions
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_automatic_captions(self):
DL = FakeDownloader()
DL.params['writesubtitles'] = True
DL.params['subtitleslang'] = 'it'
IE = YoutubeIE(DL)
info_dict = IE.extract('8YoUxe5ncPo')
sub = info_dict[0]['subtitles'][0]
self.assertTrue(sub[2] is not None)
示例12: test_youtube_subtitles_format
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_subtitles_format(self):
DL = FakeDownloader()
DL.params['writesubtitles'] = True
DL.params['subtitlesformat'] = 'sbv'
IE = YoutubeIE(DL)
info_dict = IE.extract('QRS8MkLhQmM')
sub = info_dict[0]['subtitles'][0]
self.assertEqual(md5(sub[2]), '13aeaa0c245a8bed9a451cb643e3ad8b')
示例13: test_youtube_subtitles_vtt_format
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_subtitles_vtt_format(self):
DL = FakeYDL()
DL.params['writesubtitles'] = True
DL.params['subtitlesformat'] = 'vtt'
IE = YoutubeIE(DL)
info_dict = IE.extract('QRS8MkLhQmM')
sub = info_dict[0]['subtitles']['en']
self.assertEqual(md5(sub), '356cdc577fde0c6783b9b822e7206ff7')
示例14: test_youtube_subtitles_vtt_format
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_subtitles_vtt_format(self):
DL = FakeYDL()
DL.params["writesubtitles"] = True
DL.params["subtitlesformat"] = "vtt"
IE = YoutubeIE(DL)
info_dict = IE.extract("QRS8MkLhQmM")
sub = info_dict[0]["subtitles"][0]
self.assertEqual(md5(sub[2]), "356cdc577fde0c6783b9b822e7206ff7")
示例15: test_youtube_automatic_captions
# 需要导入模块: from youtube_dl.extractor import YoutubeIE [as 别名]
# 或者: from youtube_dl.extractor.YoutubeIE import extract [as 别名]
def test_youtube_automatic_captions(self):
DL = FakeYDL()
DL.params["writeautomaticsub"] = True
DL.params["subtitleslang"] = "it"
IE = YoutubeIE(DL)
info_dict = IE.extract("8YoUxe5ncPo")
sub = info_dict[0]["subtitles"][0]
self.assertTrue(sub[2] is not None)