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


Python helper.FakeYDL类代码示例

本文整理汇总了Python中test.helper.FakeYDL的典型用法代码示例。如果您正苦于以下问题:Python FakeYDL类的具体用法?Python FakeYDL怎么用?Python FakeYDL使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: test_youtube_playlist_noplaylist

 def test_youtube_playlist_noplaylist(self):
     dl = FakeYDL()
     dl.params['noplaylist'] = True
     ie = YoutubePlaylistIE(dl)
     result = ie.extract('https://www.youtube.com/watch?v=FXxLjLQi3Fg&list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re')
     self.assertEqual(result['_type'], 'url')
     self.assertEqual(YoutubeIE().extract_id(result['url']), 'FXxLjLQi3Fg')
开发者ID:AlexBu,项目名称:youtube-dl,代码行数:7,代码来源:test_youtube_lists.py

示例2: test_youtube_playlist_noplaylist

 def test_youtube_playlist_noplaylist(self):
     dl = FakeYDL()
     dl.params["noplaylist"] = True
     ie = YoutubePlaylistIE(dl)
     result = ie.extract("https://www.youtube.com/watch?v=FXxLjLQi3Fg&list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re")
     self.assertEqual(result["_type"], "url")
     self.assertEqual(YoutubeIE()._extract_id(result["url"]), "FXxLjLQi3Fg")
开发者ID:renuyarday,项目名称:youtube-dl,代码行数:7,代码来源:test_youtube_lists.py

示例3: test_youtube_flat_playlist_titles

 def test_youtube_flat_playlist_titles(self):
     dl = FakeYDL()
     dl.params['extract_flat'] = True
     ie = YoutubePlaylistIE(dl)
     result = ie.extract('https://www.youtube.com/playlist?list=PLwiyx1dc3P2JR9N8gQaQN_BCvlSlap7re')
     self.assertIsPlaylist(result)
     for entry in result['entries']:
         self.assertTrue(entry.get('title'))
开发者ID:AlexBu,项目名称:youtube-dl,代码行数:8,代码来源:test_youtube_lists.py

示例4: _get_ip

    def _get_ip(self, protocol):
        if self._SKIP_SOCKS_TEST:
            return '127.0.0.1'

        ydl = FakeYDL({
            'proxy': '%s://127.0.0.1:%d' % (protocol, self.port),
        })
        return ydl.urlopen('http://yt-dl.org/ip').read().decode('utf-8')
开发者ID:0wnrepo,项目名称:youtube-dl,代码行数:8,代码来源:test_socks.py

示例5: test_secondary_proxy_https

 def test_secondary_proxy_https(self):
     params = self._check_params(['secondary_proxy', 'secondary_server_ip'])
     if params is None:
         return
     ydl = FakeYDL()
     req = compat_urllib_request.Request('https://yt-dl.org/ip')
     req.add_header('Ytdl-request-proxy', params['secondary_proxy'])
     self.assertEqual(
         ydl.urlopen(req).read().decode('utf-8'),
         params['secondary_server_ip'])
开发者ID:0wnrepo,项目名称:youtube-dl,代码行数:10,代码来源:test_socks.py

示例6: test_proxy_https

 def test_proxy_https(self):
     params = self._check_params(['primary_proxy', 'primary_server_ip'])
     if params is None:
         return
     ydl = FakeYDL({
         'proxy': params['primary_proxy']
     })
     self.assertEqual(
         ydl.urlopen('https://yt-dl.org/ip').read().decode('utf-8'),
         params['primary_server_ip'])
开发者ID:0wnrepo,项目名称:youtube-dl,代码行数:10,代码来源:test_socks.py

示例7: test_InstagramUser

 def test_InstagramUser(self):
     dl = FakeYDL()
     ie = InstagramUserIE(dl)
     result = ie.extract("http://instagram.com/porsche")
     self.assertIsPlaylist(result)
     self.assertEqual(result["id"], "porsche")
     self.assertTrue(len(result["entries"]) >= 2)
     test_video = next(e for e in result["entries"] if e["id"] == "614605558512799803_462752227")
     dl.add_default_extra_info(test_video, ie, "(irrelevant URL)")
     dl.process_video_result(test_video, download=False)
     EXPECTED = {
         "id": "614605558512799803_462752227",
         "ext": "mp4",
         "title": "#Porsche Intelligent Performance.",
         "thumbnail": "re:^https?://.*\.jpg",
         "uploader": "Porsche",
         "uploader_id": "porsche",
         "timestamp": 1387486713,
         "upload_date": "20131219",
     }
     expect_info_dict(self, EXPECTED, test_video)
开发者ID:0m15,项目名称:youtube-dl,代码行数:21,代码来源:test_playlists.py

示例8: BaseTestSubtitles

class BaseTestSubtitles(unittest.TestCase):
    url = None
    IE = None

    def setUp(self):
        self.DL = FakeYDL()
        self.ie = self.IE()
        self.DL.add_info_extractor(self.ie)

    def getInfoDict(self):
        info_dict = self.DL.extract_info(self.url, download=False)
        return info_dict

    def getSubtitles(self):
        info_dict = self.getInfoDict()
        subtitles = info_dict['requested_subtitles']
        if not subtitles:
            return subtitles
        for sub_info in subtitles.values():
            if sub_info.get('data') is None:
                uf = self.DL.urlopen(sub_info['url'])
                sub_info['data'] = uf.read().decode('utf-8')
        return dict((l, sub_info['data']) for l, sub_info in subtitles.items())
开发者ID:bastik,项目名称:youtube-dl,代码行数:23,代码来源:test_subtitles.py

示例9: test_InstagramUser

 def test_InstagramUser(self):
     dl = FakeYDL()
     ie = InstagramUserIE(dl)
     result = ie.extract('http://instagram.com/porsche')
     self.assertIsPlaylist(result)
     self.assertEqual(result['id'], 'porsche')
     self.assertTrue(len(result['entries']) >= 2)
     test_video = next(
         e for e in result['entries']
         if e['id'] == '614605558512799803_462752227')
     dl.add_default_extra_info(test_video, ie, '(irrelevant URL)')
     dl.process_video_result(test_video, download=False)
     EXPECTED = {
         'id': '614605558512799803_462752227',
         'ext': 'mp4',
         'title': '#Porsche Intelligent Performance.',
         'thumbnail': 're:^https?://.*\.jpg',
         'uploader': 'Porsche',
         'uploader_id': 'porsche',
         'timestamp': 1387486713,
         'upload_date': '20131219',
     }
     expect_info_dict(self, EXPECTED, test_video)
开发者ID:668,项目名称:youtube-dl,代码行数:23,代码来源:test_playlists.py

示例10: TestDailymotionSubtitles

class TestDailymotionSubtitles(unittest.TestCase):
    def setUp(self):
        self.DL = FakeYDL()
        self.url = 'http://www.dailymotion.com/video/xczg00'
    def getInfoDict(self):
        IE = DailymotionIE(self.DL)
        info_dict = IE.extract(self.url)
        return info_dict
    def getSubtitles(self):
        info_dict = self.getInfoDict()
        return info_dict['subtitles']
    def test_no_writesubtitles(self):
        subtitles = self.getSubtitles()
        self.assertEqual(subtitles, None)
    def test_subtitles(self):
        self.DL.params['writesubtitles'] = True
        subtitles = self.getSubtitles()
        self.assertEqual(md5(subtitles['en']), '976553874490cba125086bbfea3ff76f')
    def test_subtitles_lang(self):
        self.DL.params['writesubtitles'] = True
        self.DL.params['subtitleslangs'] = ['fr']
        subtitles = self.getSubtitles()
        self.assertEqual(md5(subtitles['fr']), '594564ec7d588942e384e920e5341792')
    def test_allsubtitles(self):
        self.DL.params['writesubtitles'] = True
        self.DL.params['allsubtitles'] = True
        subtitles = self.getSubtitles()
        self.assertEqual(len(subtitles.keys()), 5)
    def test_list_subtitles(self):
        self.DL.expect_warning(u'Automatic Captions not supported by this server')
        self.DL.params['listsubtitles'] = True
        info_dict = self.getInfoDict()
        self.assertEqual(info_dict, None)
    def test_automatic_captions(self):
        self.DL.expect_warning(u'Automatic Captions not supported by this server')
        self.DL.params['writeautomaticsub'] = True
        self.DL.params['subtitleslang'] = ['en']
        subtitles = self.getSubtitles()
        self.assertTrue(len(subtitles.keys()) == 0)
    def test_nosubtitles(self):
        self.DL.expect_warning(u'video doesn\'t have subtitles')
        self.url = 'http://www.dailymotion.com/video/x12u166_le-zapping-tele-star-du-08-aout-2013_tv'
        self.DL.params['writesubtitles'] = True
        self.DL.params['allsubtitles'] = True
        subtitles = self.getSubtitles()
        self.assertEqual(len(subtitles), 0)
    def test_multiple_langs(self):
        self.DL.params['writesubtitles'] = True
        langs = ['es', 'fr', 'de']
        self.DL.params['subtitleslangs'] = langs
        subtitles = self.getSubtitles()
        for lang in langs:
            self.assertTrue(subtitles.get(lang) is not None, u'Subtitles for \'%s\' not extracted' % lang)
开发者ID:CBGoodBuddy,项目名称:youtube-dl,代码行数:53,代码来源:test_dailymotion_subtitles.py

示例11: setUp

 def setUp(self):
     self.DL = FakeYDL()
     self.ie = self.IE()
     self.DL.add_info_extractor(self.ie)
开发者ID:bastik,项目名称:youtube-dl,代码行数:4,代码来源:test_subtitles.py

示例12: setUp

 def setUp(self):
     self.DL = FakeYDL()
     self.url = 'QRS8MkLhQmM'
开发者ID:CBGoodBuddy,项目名称:youtube-dl,代码行数:3,代码来源:test_youtube_subtitles.py

示例13: TestYoutubeSubtitles

class TestYoutubeSubtitles(unittest.TestCase):
    def setUp(self):
        self.DL = FakeYDL()
        self.url = 'QRS8MkLhQmM'

    def getInfoDict(self):
        IE = YoutubeIE(self.DL)
        info_dict = IE.extract(self.url)
        return info_dict

    def getSubtitles(self):
        info_dict = self.getInfoDict()
        return info_dict[0]['subtitles']

    def test_youtube_no_writesubtitles(self):
        self.DL.params['writesubtitles'] = False
        subtitles = self.getSubtitles()
        self.assertEqual(subtitles, None)

    def test_youtube_subtitles(self):
        self.DL.params['writesubtitles'] = True
        subtitles = self.getSubtitles()
        self.assertEqual(md5(subtitles['en']), '4cd9278a35ba2305f47354ee13472260')

    def test_youtube_subtitles_lang(self):
        self.DL.params['writesubtitles'] = True
        self.DL.params['subtitleslangs'] = ['it']
        subtitles = self.getSubtitles()
        self.assertEqual(md5(subtitles['it']), '164a51f16f260476a05b50fe4c2f161d')

    def test_youtube_allsubtitles(self):
        self.DL.params['writesubtitles'] = True
        self.DL.params['allsubtitles'] = True
        subtitles = self.getSubtitles()
        self.assertEqual(len(subtitles.keys()), 13)

    def test_youtube_subtitles_sbv_format(self):
        self.DL.params['writesubtitles'] = True
        self.DL.params['subtitlesformat'] = 'sbv'
        subtitles = self.getSubtitles()
        self.assertEqual(md5(subtitles['en']), '13aeaa0c245a8bed9a451cb643e3ad8b')

    def test_youtube_subtitles_vtt_format(self):
        self.DL.params['writesubtitles'] = True
        self.DL.params['subtitlesformat'] = 'vtt'
        subtitles = self.getSubtitles()
        self.assertEqual(md5(subtitles['en']), '356cdc577fde0c6783b9b822e7206ff7')

    def test_youtube_list_subtitles(self):
        self.DL.expect_warning(u'Video doesn\'t have automatic captions')
        self.DL.params['listsubtitles'] = True
        info_dict = self.getInfoDict()
        self.assertEqual(info_dict, None)

    def test_youtube_automatic_captions(self):
        self.url = '8YoUxe5ncPo'
        self.DL.params['writeautomaticsub'] = True
        self.DL.params['subtitleslangs'] = ['it']
        subtitles = self.getSubtitles()
        self.assertTrue(subtitles['it'] is not None)

    def test_youtube_nosubtitles(self):
        self.DL.expect_warning(u'video doesn\'t have subtitles')
        self.url = 'sAjKT8FhjI8'
        self.DL.params['writesubtitles'] = True
        self.DL.params['allsubtitles'] = True
        subtitles = self.getSubtitles()
        self.assertEqual(len(subtitles), 0)

    def test_youtube_multiple_langs(self):
        self.url = 'QRS8MkLhQmM'
        self.DL.params['writesubtitles'] = True
        langs = ['it', 'fr', 'de']
        self.DL.params['subtitleslangs'] = langs
        subtitles = self.getSubtitles()
        for lang in langs:
            self.assertTrue(subtitles.get(lang) is not None, u'Subtitles for \'%s\' not extracted' % lang)
开发者ID:CBGoodBuddy,项目名称:youtube-dl,代码行数:77,代码来源:test_youtube_subtitles.py


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