本文整理匯總了Python中YouTubeSubtitleControl.YouTubeSubtitleControl.saveSubtitle方法的典型用法代碼示例。如果您正苦於以下問題:Python YouTubeSubtitleControl.saveSubtitle方法的具體用法?Python YouTubeSubtitleControl.saveSubtitle怎麽用?Python YouTubeSubtitleControl.saveSubtitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類YouTubeSubtitleControl.YouTubeSubtitleControl
的用法示例。
在下文中一共展示了YouTubeSubtitleControl.saveSubtitle方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_saveSubtitle_should_call_openFile_with_correct_params
# 需要導入模塊: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 別名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import saveSubtitle [as 別名]
def test_saveSubtitle_should_call_openFile_with_correct_params(self):
sys.modules["__main__"].xbmc.translatePath.return_value = "tempFilePath"
sys.modules["__main__"].common.makeUTF8.return_value = "testTitle"
subtitles = YouTubeSubtitleControl()
subtitles.getSubtitleFileName = Mock(return_value="testTitle-[someVideoId].ssa")
subtitles.saveSubtitle("my_subtitle_stream", {"Title": "testTitle", "videoid": "someVideoId", "downloadPath": "downloadFilePath"})
sys.modules["__main__"].storage.openFile.assert_called_with("tempFilePath/testTitle-[someVideoId].ssa", "w") # was "wb"
示例2: test_saveSubtitle_should_call_xbmcvfs_translatePath
# 需要導入模塊: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 別名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import saveSubtitle [as 別名]
def test_saveSubtitle_should_call_xbmcvfs_translatePath(self):
sys.modules["__main__"].xbmc.translatePath.return_value = "tempFilePath"
sys.modules["__main__"].common.makeUTF8.return_value = "testTitle"
subtitles = YouTubeSubtitleControl()
subtitles.getSubtitleFileName = Mock()
subtitles.saveSubtitle("my_subtitle_stream", {"Title": "testTitle", "videoid": "someVideoId", "downloadPath": "downloadFilePath"})
sys.modules["__main__"].xbmc.translatePath.assert_called_with("somepath")
示例3: test_downloadSubtitle_should_call_saveSubtitle
# 需要導入模塊: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 別名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import saveSubtitle [as 別名]
def test_downloadSubtitle_should_call_saveSubtitle(self):
player = YouTubeSubtitleControl()
sys.modules["__main__"].core._fetchPage = Mock()
sys.modules["__main__"].core._fetchPage.return_value = {"status": 200, "content": "nothingness"}
subtitlesettings = ["false", "0", "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 = ("something", "style")
player.saveSubtitle = Mock()
result = player.downloadSubtitle()
assert(result == True)
assert(player.saveSubtitle.called)