本文整理匯總了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({})