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


Python YouTubePlayer.YouTubePlayer类代码示例

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


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

示例1: test_selectVideoQuality_should_limit_to_sd_if_user_has_selected_that_option

    def test_selectVideoQuality_should_limit_to_sd_if_user_has_selected_that_option(self):
        sys.modules["__main__"].settings.getSetting.return_value = "1"
        player = YouTubePlayer()

        url = player.selectVideoQuality({},{35: "SD", 22: "720p", 37: "1080p"})

        assert(url[:url.find("|")].strip() == "SD")
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:7,代码来源:TestYouTubePlayer.py

示例2: test_playVideo_should_call_getVideoObject

    def test_playVideo_should_call_getVideoObject(self):
        player = YouTubePlayer()
        player.buildVideoObject = Mock(return_value=[{"apierror": "some error"}, 303])

        player.playVideo()

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

示例3: test_selectVideoQuality_should_prefer_SD_if_asked_to

    def test_selectVideoQuality_should_prefer_SD_if_asked_to(self):
        sys.modules["__main__"].settings.getSetting.return_value = "2"
        player = YouTubePlayer()

        url = player.selectVideoQuality({"quality": "SD"},{37: "1080p", 22: "720p", 35: "SD"})

        assert(url[:url.find("|")].strip() == "SD")
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:7,代码来源:TestYouTubePlayer.py

示例4: test_selectVideoQuality_should_choose_highest_sd_quality_if_only_multiple_sd_qualities_are_available

    def test_selectVideoQuality_should_choose_highest_sd_quality_if_only_multiple_sd_qualities_are_available(self):
        sys.modules["__main__"].settings.getSetting.return_value = "1"
        player = YouTubePlayer()

        url = player.selectVideoQuality({},{5: "1", 33: "2", 18: "3", 26: "4", 43: "5", 34: "6", 78: "7", 44: "8", 59: "9", 35: "10"})

        assert(url[:url.find("|")].strip() == "10")
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:7,代码来源:TestYouTubePlayer.py

示例5: test_selectVideoQuality_should_limit_to_720p_if_user_has_selected_that_option

    def test_selectVideoQuality_should_limit_to_720p_if_user_has_selected_that_option(self):
        sys.modules["__main__"].settings.getSetting.return_value = "2"
        player = YouTubePlayer()

        url = player.selectVideoQuality({},{35: "SD", 22: "720p", 37: "1080p"})

        assert(url == "720p | Mozilla/5.0 (MOCK)")
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:7,代码来源:TestYouTubePlayer.py

示例6: test_getInfo_should_use_cache_when_possible

    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,代码行数:7,代码来源:TestYouTubePlayer.py

示例7: test_selectVideoQuality_should_add_user_agent_when_not_called_by_download_function

    def test_selectVideoQuality_should_add_user_agent_when_not_called_by_download_function(self):
        sys.modules["__main__"].settings.getSetting.return_value = "1"
        player = YouTubePlayer()

        url = player.selectVideoQuality({},{35: "SD", 22: "720p", 37: "1080p"})

        assert(url.find("| Mozilla/5.0 (MOCK)") > 0)
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:7,代码来源:TestYouTubePlayer.py

示例8: test_selectVideoQuality_should_not_add_user_agent_when_called_by_download_function

    def test_selectVideoQuality_should_not_add_user_agent_when_called_by_download_function(self):
        sys.modules["__main__"].settings.getSetting.return_value = "1"
        player = YouTubePlayer()

        url = player.selectVideoQuality({"action": "download"},{35: "SD", 22: "720p", 37: "1080p"})

        assert(url.find("|" + urllib.urlencode({'User-Agent':"Mozilla/5.0 (MOCK)"})) < 0)
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:7,代码来源:TestYouTubePlayer.py

示例9: test_selectVideoQuality_should_prefer_720p_if_asked_to

    def test_selectVideoQuality_should_prefer_720p_if_asked_to(self):
        sys.modules["__main__"].settings.getSetting.return_value = "2"
        player = YouTubePlayer()

        url = player.selectVideoQuality({"quality": "720p"},{37: "1080p", 22: "720p", 35: "SD"})

        assert(url == "720p | Mozilla/5.0 (MOCK)")
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:7,代码来源:TestYouTubePlayer.py

示例10: test_selectVideoQuality_should_call_userSelectsVideoQuality_if_user_selected_that_option

    def test_selectVideoQuality_should_call_userSelectsVideoQuality_if_user_selected_that_option(self):
        sys.modules["__main__"].settings.getSetting.return_value = "0"
        player = YouTubePlayer()
        player.userSelectsVideoQuality = Mock()

        player.selectVideoQuality({},{35: "SD", 22: "720p", 37: "1080p"})

        player.userSelectsVideoQuality.assert_called_with({}, {35: 'SD', 37: '1080p', 22: '720p'})
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:8,代码来源:TestYouTubePlayer.py

示例11: test_selectVideoQuality_should_prefer_h264_over_vp8_for_720p_as_appletv2_cant_handle_vp8_properly

    def test_selectVideoQuality_should_prefer_h264_over_vp8_for_720p_as_appletv2_cant_handle_vp8_properly(self):
        sys.modules["__main__"].settings.getSetting.return_value = "2"
        player = YouTubePlayer()

        url = player.selectVideoQuality({},{22: "h264", 45: "vp8"})

        print "url: " + repr(url)
        assert(url[:url.find("|")].strip() == "h264")
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:8,代码来源:TestYouTubePlayer.py

示例12: test__getVideoLinks_should_return_empty_dictionary_on_missing_map

    def test__getVideoLinks_should_return_empty_dictionary_on_missing_map(self):
        sys.modules["__main__"].core._fetchPage.return_value = {"status":303, "content": ""}
        sys.modules["__main__"].common.parseDOM.return_value = []

        player = YouTubePlayer()
        (result, status) = player.extractVideoLinksFromYoutube({},{"videoid":"123"})

        assert (result == {})
开发者ID:BlackSmith,项目名称:youtube-xbmc-plugin,代码行数:8,代码来源:TestYouTubePlayer.py

示例13: test_getInfo_should_call_fetchPage_with_correct_url

    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,代码行数:8,代码来源:TestYouTubePlayer.py

示例14: test_buildVideoLinks_should_try_scraping_first

    def test_buildVideoLinks_should_try_scraping_first(self):
        sys.modules["__main__"].core._fetchPage.return_value = {"status":303, "content": ""}
        sys.modules["__main__"].common.parseDOM.return_value = []

        player = YouTubePlayer()
        player.extractVideoLinksFromYoutube({},{"videoid":"123"})

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

示例15: test_getInfo_should_call_core_getVideoInfo_to_parse_youtube_xml

    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,代码行数:9,代码来源:TestYouTubePlayer.py


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