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


Python YouTubePlayer.getInfo方法代码示例

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


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

示例1: test_getInfo_should_use_cache_when_possible

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_getInfo_should_use_cache_when_possible(self):
        sys.modules["__main__"].cache.get.return_value = '["something"]'
        player = YouTubePlayer()

        player.getInfo({"videoid": "some_id"})

        sys.modules["__main__"].cache.get.assert_called_with("videoidcachesome_id")
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:9,代码来源:TestYouTubePlayer.py

示例2: test_getInfo_should_call_fetchPage_with_correct_url

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_getInfo_should_call_fetchPage_with_correct_url(self):
        sys.modules["__main__"].cache.get.return_value = {}
        sys.modules["__main__"].core._fetchPage.return_value = {"status": 303, "content": "something"}
        player = YouTubePlayer()

        player.getInfo({"videoid": "some_id"})

        sys.modules["__main__"].core._fetchPage.assert_called_with({"api": "true", "link": player.urls["video_info"] % ("some_id")})
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:10,代码来源:TestYouTubePlayer.py

示例3: test_getInfo_should_save_video_info_in_cache

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_getInfo_should_save_video_info_in_cache(self):
        sys.modules["__main__"].cache.get.return_value = {}
        sys.modules["__main__"].core._fetchPage.return_value = {"status": 200, "content": "something"}
        sys.modules["__main__"].core.getVideoInfo.return_value = [{"videoid": "some_id"}]
        player = YouTubePlayer()

        player.getInfo({"videoid": "some_id"})

        sys.modules["__main__"].cache.set.assert_called_with('videoidcachesome_id', "{'videoid': 'some_id'}")
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:11,代码来源:TestYouTubePlayer.py

示例4: test_getInfo_should_call_core_getVideoInfo_to_parse_youtube_xml

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_getInfo_should_call_core_getVideoInfo_to_parse_youtube_xml(self):
        sys.modules["__main__"].cache.get.return_value = {}
        sys.modules["__main__"].core._fetchPage.return_value = {"status": 200, "content": "something"}
        sys.modules["__main__"].core.getVideoInfo.return_value = [{"videoid": "some_id"}]
        player = YouTubePlayer()

        player.getInfo({"videoid": "some_id"})

        sys.modules["__main__"].core.getVideoInfo.assert_called_with("something", {"videoid": "some_id"})
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:11,代码来源:TestYouTubePlayer.py

示例5: test_buildVideoObject_should_use_local_file_for_playback_if_found

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_buildVideoObject_should_use_local_file_for_playback_if_found(self):
        sys.modules["__main__"].subtitles.getLocalFileSource.return_value = "somePath/someTitle.mp4"
        params = {"videoid": "some_id"}
        player = YouTubePlayer()
        player.getInfo = Mock()
        video = {"videoid": "some_id", "Title": "someTitle"}
        player.getInfo.return_value = (video, 200)

        (video, status) = player.buildVideoObject(params)

        assert(video["video_url"] == "somePath/someTitle.mp4")
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:13,代码来源:TestYouTubePlayer.py

示例6: test_buildVideoObject_should_get_video_information_from_getInfo

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_buildVideoObject_should_get_video_information_from_getInfo(self):
        sys.modules["__main__"].settings.getSetting.return_value = ""
        player = YouTubePlayer()
        player.getInfo = Mock()
        player.getInfo.return_value = ({}, 303)
        player.extractVideoLinksFromYoutube = Mock()
        player.extractVideoLinksFromYoutube.return_value = ({}, {})

        player.buildVideoObject({})

        player.getInfo.assert_called_with({})
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:13,代码来源:TestYouTubePlayer.py

示例7: test_buildVideoObject_should_use_pre_defined_error_messages_on_missing_url

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_buildVideoObject_should_use_pre_defined_error_messages_on_missing_url(self):
        sys.modules["__main__"].settings.getSetting.return_value = ""
        player = YouTubePlayer()
        player.getInfo = Mock()
        player.getInfo.return_value = ({}, 303)
        player.getLocalFileSource = Mock(return_value="")
        player.extractVideoLinksFromYoutube = Mock(return_value = ({}, {}))

        player.buildVideoObject({})

        player.getInfo.assert_called_with({})
        sys.modules["__main__"].language.assert_called_with(30618)
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:14,代码来源:TestYouTubePlayer.py

示例8: test_buildVideoObject_should_check_for_local_file_before_scraping

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_buildVideoObject_should_check_for_local_file_before_scraping(self):
        sys.modules["__main__"].subtitles.getLocalFileSource.return_value = "somePath/someTitle.mp4"
        sys.modules["__main__"].settings.getSetting.return_value = "1"
        params = {"videoid": "some_id"}
        player = YouTubePlayer()
        player.getInfo = Mock()
        video = {"videoid": "some_id", "Title": "someTitle"}
        player.getInfo.return_value = (video, 200)

        (video, status) = player.buildVideoObject(params)

        sys.modules["__main__"].subtitles.getLocalFileSource.assert_called_with(params, video)
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:14,代码来源:TestYouTubePlayer.py

示例9: test_buildVideoObject_should_not_scrape_webpage_if_local_file_is_found

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_buildVideoObject_should_not_scrape_webpage_if_local_file_is_found(self):
        sys.modules["__main__"].subtitles.getLocalFileSource.return_value = "somePath/someTitle.mp4"
        params = {"videoid": "some_id"}
        player = YouTubePlayer()
        player.getInfo = Mock()
        player.extractVideoLinksFromYoutube = Mock()
        video = {"videoid": "some_id", "Title": "someTitle"}
        player.getInfo.return_value = (video, 200)

        player.buildVideoObject(params)

        assert(player.extractVideoLinksFromYoutube.call_count == 0)
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:14,代码来源:TestYouTubePlayer.py

示例10: test_getInfo_should_fail_correctly_if_api_is_unavailable

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_getInfo_should_fail_correctly_if_api_is_unavailable(self):
        sys.modules["__main__"].cache.get.return_value = {}
        sys.modules["__main__"].core._fetchPage.return_value = {"status": 200, "content": "something"}
        sys.modules["__main__"].core.getVideoInfo.return_value = []
        sys.modules["__main__"].language.return_value = "some_string"
        player = YouTubePlayer()

        (video, status) = player.getInfo({"videoid": "some_id"})

        sys.modules["__main__"].common.log.assert_called_with("- Couldn't parse API output, YouTube doesn't seem to know this video id?")
        sys.modules["__main__"].language.assert_called_with(30608)
        assert(video["apierror"] == "some_string")
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:14,代码来源:TestYouTubePlayer.py

示例11: test_buildVideoObject_with_hls

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_buildVideoObject_with_hls(self):
        sys.modules["__main__"].core._fetchPage.return_value = {"status": 200, "content": self.readTestInput("live-video-hls-page-S_pMsJw-_oA.html", False)}
        sys.modules["__main__"].subtitles.getLocalFileSource.return_value = ""
        sys.modules["__main__"].common.parseDOM.return_value = []
        params = {"videoid": "some_id"}
        player = YouTubePlayer()
        player.getInfo = Mock()
        video = {"videoid": "some_id", "Title": "someTitle"}
        player.getInfo.return_value = (video, 200)

        (video, status) = player.buildVideoObject(params)
        
        assert(video["video_url"] == "http://www.youtube.com/api/manifest/hls_variant/id/S_pMsJw-_oA.2/sparams/cp%2Cid%2Cip%2Cipbits%2Cmaudio%2Cplaylist_type%2Cpmbypass%2Csource%2Cexpire/expire/1364700604/playlist_type/DVR/ipbits/8/upn/Ftpj_wWBeuQ/signature/4B46E966BDE27C0772BA90DE72F0B083F7C44E5A.6F1348A5EE63E4167F1E03C1DE268DABA3EB836E/fexp/932000%2C906383%2C902000%2C919512%2C929903%2C931202%2C900821%2C900823%2C931203%2C931401%2C908529%2C919373%2C930803%2C906836%2C920201%2C929602%2C930101%2C930603%2C900824%2C910223/ip/205.178.10.177/key/yt1/maudio/1/sver/3/cp/U0hVSVdLTl9FTkNONV9PRVJHOmtkY0VJTkJQay02/pmbypass/yes/source/yt_live_broadcast/file/index.m3u8")
开发者ID:1c0n,项目名称:youtube-xbmc-plugin,代码行数:15,代码来源:TestYouTubePlayer.py

示例12: test_buildVideoObject_should_call_getVideoLinks_if_local_file_not_found

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_buildVideoObject_should_call_getVideoLinks_if_local_file_not_found(self):
        sys.modules["__main__"].subtitles.getLocalFileSource.return_value = ""
        sys.modules["__main__"].settings.getSetting.return_value = "1"
        params = {"videoid": "some_id"}
        player = YouTubePlayer()
        player.getInfo = Mock()
        player.extractVideoLinksFromYoutube = Mock()
        player.extractVideoLinksFromYoutube.return_value = ({}, {})
        video = {"videoid": "some_id", "Title": "someTitle"}
        player.getInfo.return_value = (video, 200)

        player.buildVideoObject(params)

        player.extractVideoLinksFromYoutube.assert_any_call(video, params)
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:16,代码来源:TestYouTubePlayer.py

示例13: test_buildVideoObject_should_call_selectVideoQuality_if_local_file_not_found_and_remote_links_found

# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import getInfo [as 别名]
    def test_buildVideoObject_should_call_selectVideoQuality_if_local_file_not_found_and_remote_links_found(self):
        sys.modules["__main__"].subtitles.getLocalFileSource.return_value = ""
        params = {"videoid": "some_id"}
        video = {"videoid": "some_id", "Title": "someTitle"}

        player = YouTubePlayer()
        player.getInfo = Mock()
        player.getInfo.return_value = (video, 200)

        player.extractVideoLinksFromYoutube = Mock()
        player.extractVideoLinksFromYoutube.return_value = ({22: "720p"}, {})
        player.selectVideoQuality = Mock()

        player.buildVideoObject(params)

        player.selectVideoQuality.assert_called_with(params,{22: "720p"})
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:18,代码来源:TestYouTubePlayer.py


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