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


Python YouTubeSubtitleControl.getSubtitleUrl方法代码示例

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


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

示例1: test_getSubtitleUrl_should_call_fetchPage_with_correct_url

# 需要导入模块: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 别名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import getSubtitleUrl [as 别名]
    def test_getSubtitleUrl_should_call_fetchPage_with_correct_url(self):
        player = YouTubeSubtitleControl()
        sys.modules["__main__"].core._fetchPage = Mock()
        sys.modules["__main__"].core._fetchPage.return_value = {"status": 303, "content": ""}

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

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

示例2: test_getSubtitleUrl_should_fall_back_to_english_if_proper_language_code_is_not_found

# 需要导入模块: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 别名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import getSubtitleUrl [as 别名]
    def test_getSubtitleUrl_should_fall_back_to_english_if_proper_language_code_is_not_found(self):
        player = YouTubeSubtitleControl()
        sys.modules["__main__"].core._fetchPage = Mock()
        sys.modules["__main__"].core._fetchPage.return_value = {"status": 200, "content": self.readTestInput("timedtextDirectoryTest.xml", False)}
        sys.modules["__main__"].core.getVideoIdStatusFromCache = Mock()
        sys.modules["__main__"].settings.getSetting = Mock()
        sys.modules["__main__"].settings.getSetting.return_value = "2"
        sys.modules["__main__"].common.parseDOM.side_effect = [["en"], ["english"], ["english"]]

        url = player.getSubtitleUrl({"videoid": "some_id"})

        assert(url.find("lang=en") > 0)
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:14,代码来源:TestYouTubeSubtitleControl.py

示例3: test_getSubtitleUrl_should_find_url_with_proper_language_code

# 需要导入模块: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 别名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import getSubtitleUrl [as 别名]
    def test_getSubtitleUrl_should_find_url_with_proper_language_code(self):
        player = YouTubeSubtitleControl()
        sys.modules["__main__"].core._fetchPage = Mock()
        sys.modules["__main__"].core._fetchPage.return_value = {"status": 200, "content": self.readTestInput("timedtextDirectoryTest.xml", False)}
        sys.modules["__main__"].settings.getSetting = Mock()
        sys.modules["__main__"].settings.getSetting.return_value = "3"
        sys.modules["__main__"].common.parseDOM.side_effect = [["de"], ["german"], ["deutch"]]
        sys.modules["__main__"].core.getVideoIdStatusFromCache = Mock()

        url = player.getSubtitleUrl({"videoid": "some_id"})
        print repr(url)

        assert(url.find("lang=de") > 0)
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:15,代码来源:TestYouTubeSubtitleControl.py

示例4: test_downloadSubtitle_should_call_getSubtitleUrl

# 需要导入模块: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 别名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import getSubtitleUrl [as 别名]
    def test_downloadSubtitle_should_call_getSubtitleUrl(self):
        player = YouTubeSubtitleControl()
        sys.modules["__main__"].core._fetchPage = Mock()
        sys.modules["__main__"].core._fetchPage.return_value = {"status": 200, "content": "nothingness"}

        subtitlesettings = ["false", "2", "true"]

        sys.modules["__main__"].settings.getSetting = Mock()
        sys.modules["__main__"].settings.getSetting.side_effect = lambda x: subtitlesettings.pop()
        player.transformAnnotationToSSA = Mock()
        player.transformAnnotationToSSA.return_value = ("", "style")
        player.getSubtitleUrl = Mock()
        player.getSubtitleUrl.return_value = ""

        player.downloadSubtitle()

        player.getSubtitleUrl.assert_called_with({})
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:19,代码来源:TestYouTubeSubtitleControl.py


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