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


Python YouTubeSubtitleControl.transformSubtitleXMLtoSRT方法代码示例

本文整理汇总了Python中YouTubeSubtitleControl.YouTubeSubtitleControl.transformSubtitleXMLtoSRT方法的典型用法代码示例。如果您正苦于以下问题:Python YouTubeSubtitleControl.transformSubtitleXMLtoSRT方法的具体用法?Python YouTubeSubtitleControl.transformSubtitleXMLtoSRT怎么用?Python YouTubeSubtitleControl.transformSubtitleXMLtoSRT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在YouTubeSubtitleControl.YouTubeSubtitleControl的用法示例。


在下文中一共展示了YouTubeSubtitleControl.transformSubtitleXMLtoSRT方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_transformSubtitleXMLtoSRT_should_parse_youtube_subtitle_xml

# 需要导入模块: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 别名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import transformSubtitleXMLtoSRT [as 别名]
    def test_transformSubtitleXMLtoSRT_should_parse_youtube_subtitle_xml(self):
        player = YouTubeSubtitleControl()
        sys.modules["__main__"].common.replaceHTMLCodes = Mock()
        sys.modules["__main__"].common.replaceHTMLCodes.side_effect = lambda x: x.encode("ascii", 'ignore')
        sys.modules["__main__"].common.parseDOM.side_effect = [["content"] * 3, ["content"], ["00"], ["10"], ["content1"], ["20"], ["30"], ["content3"], ["40"], ["50"]]

        result = player.transformSubtitleXMLtoSRT(self.readTestInput("subtitleTest.xml", False))

        assert(len(result.split("\r\n")) == 4)
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:11,代码来源:TestYouTubeSubtitleControl.py

示例2: test_transformSubtitleXMLtoSRT_should_call_replaceHTMLCodes_for_user_visible_text

# 需要导入模块: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 别名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import transformSubtitleXMLtoSRT [as 别名]
    def test_transformSubtitleXMLtoSRT_should_call_replaceHTMLCodes_for_user_visible_text(self):
        sys.modules["__main__"].common.parseDOM.side_effect = [["content TEXT"] * 2, ["text"], ["14.017"], ["2.07"], ["text"], ["16.087"], ["2.996"]]
        player = YouTubeSubtitleControl()
        player.simpleReplaceHTMLCodes = Mock()
        player.simpleReplaceHTMLCodes.side_effect = lambda x: x.encode("ascii", 'ignore')

        result = player.transformSubtitleXMLtoSRT(self.readTestInput("subtitleTest.xml", False))

        print repr(result)

        assert(player.simpleReplaceHTMLCodes.call_count > 0)
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:13,代码来源:TestYouTubeSubtitleControl.py

示例3: test_transformSubtitleXMLtoSRT_should_correctly_recalculate_duration_time_for_text_elements

# 需要导入模块: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 别名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import transformSubtitleXMLtoSRT [as 别名]
    def test_transformSubtitleXMLtoSRT_should_correctly_recalculate_duration_time_for_text_elements(self):
        input = '<?xml version="1.0" encoding="utf-8" ?><transcript>\n\
                <text start="14.017" dur="2.07">first</text>\n\
                <text start="16.087" dur="2.996">second</text>\n\
                </transcript>'
        player = YouTubeSubtitleControl()
        sys.modules["__main__"].common.replaceHTMLCodes = Mock()
        sys.modules["__main__"].common.replaceHTMLCodes.side_effect = lambda x: x.encode("ascii", 'ignore')
        sys.modules["__main__"].common.parseDOM.side_effect = [["content TEXT"] * 2, ["text"], ["14.017"], ["2.07"], ["text"], ["16.087"], ["2.996"]]

        result = player.transformSubtitleXMLtoSRT(input).split("\r\n")

        assert(result[0].find("0:00:16.087,Default") > 0)
        assert(result[1].find("0:00:19.083,Default") > 0)
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:16,代码来源:TestYouTubeSubtitleControl.py

示例4: test_downloadSubtitle_should_call_transformSubtitleXMLtoSRT

# 需要导入模块: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 别名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import transformSubtitleXMLtoSRT [as 别名]
    def test_downloadSubtitle_should_call_transformSubtitleXMLtoSRT(self):
        player = YouTubeSubtitleControl()
        sys.modules["__main__"].core._fetchPage = Mock()
        sys.modules["__main__"].core._fetchPage.return_value = {"status": 200, "content": "nothingness"}

        subtitlesettings = ["true", "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.getTranscriptionUrl = Mock()
        player.getTranscriptionUrl.return_value = "something"
        player.transformSubtitleXMLtoSRT = Mock()
        player.transformSubtitleXMLtoSRT.return_value = ""

        player.downloadSubtitle()

        player.transformSubtitleXMLtoSRT.assert_called_with("nothingness")
开发者ID:Liorfru,项目名称:youtube-xbmc-plugin,代码行数:23,代码来源:TestYouTubeSubtitleControl.py


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