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


Python YouTubeSubtitleControl.saveSubtitle方法代码示例

本文整理汇总了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"
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:11,代码来源:TestYouTubeSubtitleControl.py

示例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")
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:12,代码来源:TestYouTubeSubtitleControl.py

示例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)
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:17,代码来源:TestYouTubeSubtitleControl.py


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