當前位置: 首頁>>代碼示例>>Python>>正文


Python YouTubeSubtitleControl.downloadSubtitle方法代碼示例

本文整理匯總了Python中YouTubeSubtitleControl.YouTubeSubtitleControl.downloadSubtitle方法的典型用法代碼示例。如果您正苦於以下問題:Python YouTubeSubtitleControl.downloadSubtitle方法的具體用法?Python YouTubeSubtitleControl.downloadSubtitle怎麽用?Python YouTubeSubtitleControl.downloadSubtitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在YouTubeSubtitleControl.YouTubeSubtitleControl的用法示例。


在下文中一共展示了YouTubeSubtitleControl.downloadSubtitle方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_downloadSubtitle_should_call_transformSubtitleToSSA

# 需要導入模塊: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 別名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import downloadSubtitle [as 別名]
    def test_downloadSubtitle_should_call_transformSubtitleToSSA(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 = ("", "style")

        player.downloadSubtitle()

        player.transformAnnotationToSSA.assert_called_with("nothingness")
開發者ID:Liorfru,項目名稱:youtube-xbmc-plugin,代碼行數:15,代碼來源:TestYouTubeSubtitleControl.py

示例2: test_addSubtitles_should_call_xbmcs_setSubtitles

# 需要導入模塊: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 別名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import downloadSubtitle [as 別名]
    def test_addSubtitles_should_call_xbmcs_setSubtitles(self):
        sys.modules["__main__"].settings.getSetting.return_value = "testDownloadPath"
        sys.modules["__main__"].xbmcvfs.exists.return_value = True
        sys.modules["__main__"].common.makeUTF8.return_value = "testTitle"
        player = YouTubeSubtitleControl()
        player.getSubtitleFileName = Mock(return_value="testTitle-[testid].ssa")
        player.downloadSubtitle = Mock()
        player.downloadSubtitle.return_value = True

        player.addSubtitles({"videoid": "testid", "Title": "testTitle"})

        sys.modules["__main__"].xbmcvfs.exists.assert_called_with('testDownloadPath/testTitle-[testid].ssa')
        sys.modules["__main__"].xbmc.Player().setSubtitles.assert_called_with('testDownloadPath/testTitle-[testid].ssa')
開發者ID:Liorfru,項目名稱:youtube-xbmc-plugin,代碼行數:15,代碼來源:TestYouTubeSubtitleControl.py

示例3: test_addSubtitles_should_check_if_subtitle_exists_locally_before_calling_downloadSubtitle

# 需要導入模塊: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 別名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import downloadSubtitle [as 別名]
    def test_addSubtitles_should_check_if_subtitle_exists_locally_before_calling_downloadSubtitle(self):
        player = YouTubeSubtitleControl()

        settings = [False, True]
        sys.modules["__main__"].settings.getSetting.return_value = "testDownloadPath"
        sys.modules["__main__"].xbmcvfs.exists.side_effect = lambda x: settings.pop()
        sys.modules["__main__"].common.makeUTF8.return_value = "testTitle"
        player.downloadSubtitle = Mock()
        player.getSubtitleFileName = Mock(return_value="testTitle-[testid].ssa")
        player.downloadSubtitle.return_value = False

        player.addSubtitles({"videoid": "testid", "Title": "testTitle"})

        sys.modules["__main__"].xbmcvfs.exists.assert_called_with('testDownloadPath/testTitle-[testid].ssa')
        assert(player.downloadSubtitle.call_count == 0)
開發者ID:Liorfru,項目名稱:youtube-xbmc-plugin,代碼行數:17,代碼來源:TestYouTubeSubtitleControl.py

示例4: test_downloadSubtitle_should_exit_gracefully_if_subtitles_and_annotations_are_disabled

# 需要導入模塊: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 別名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import downloadSubtitle [as 別名]
    def test_downloadSubtitle_should_exit_gracefully_if_subtitles_and_annotations_are_disabled(self):
        player = YouTubeSubtitleControl()

        subtitlessettings = ["false", "0", "false"]

        def popSetting(self, *args, **kwargs):
            val = subtitlessettings.pop()
            return val

        sys.modules["__main__"].settings.getSetting = Mock()
        sys.modules["__main__"].settings.getSetting.side_effect = popSetting

        result = player.downloadSubtitle()

        assert(result == False)
開發者ID:Liorfru,項目名稱:youtube-xbmc-plugin,代碼行數:17,代碼來源:TestYouTubeSubtitleControl.py

示例5: test_addSubtitles_should_sleep_for_1_second_if_player_isnt_ready

# 需要導入模塊: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 別名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import downloadSubtitle [as 別名]
    def test_addSubtitles_should_sleep_for_1_second_if_player_isnt_ready(self):
        sys.modules["__main__"].settings.getSetting.return_value = "testDownloadPath"
        sys.modules["__main__"].xbmcvfs.exists.return_value = True
        sys.modules["__main__"].xbmc.Player().isPlaying.side_effect = [False, True] 
        sys.modules["__main__"].common.makeUTF8.return_value = "testTitle"
        patcher = patch("time.sleep")
        patcher.start()
        sleep = Mock()
        import time
        time.sleep = sleep
        player = YouTubeSubtitleControl()
        player.getSubtitleFileName = Mock(return_value="testTitle-[testid].ssa")
        player.downloadSubtitle = Mock()
        player.downloadSubtitle.return_value = True

        player.addSubtitles({"videoid": "testid", "Title": "testTitle"})

        patcher.stop()
        sleep.assert_any_call(1)
開發者ID:Liorfru,項目名稱:youtube-xbmc-plugin,代碼行數:21,代碼來源:TestYouTubeSubtitleControl.py


注:本文中的YouTubeSubtitleControl.YouTubeSubtitleControl.downloadSubtitle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。