本文整理汇总了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')})
示例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)
示例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)
示例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({})