本文整理汇总了Python中YouTubeSubtitleControl.YouTubeSubtitleControl.transformAnnotationToSSA方法的典型用法代码示例。如果您正苦于以下问题:Python YouTubeSubtitleControl.transformAnnotationToSSA方法的具体用法?Python YouTubeSubtitleControl.transformAnnotationToSSA怎么用?Python YouTubeSubtitleControl.transformAnnotationToSSA使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YouTubeSubtitleControl.YouTubeSubtitleControl
的用法示例。
在下文中一共展示了YouTubeSubtitleControl.transformAnnotationToSSA方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_transformAnnotationToSSA_should_parse_youtube_annotations_xml
# 需要导入模块: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 别名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import transformAnnotationToSSA [as 别名]
def test_transformAnnotationToSSA_should_parse_youtube_annotations_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 TEXT"], ["TEXT"], ["popup"], ["popup"], ["0:00:06.5", "0:01:06.5"], [0], [0], [0], [0], [["snode"]], ["16777215"], ["26777215"], ["36777215"], ["46777215"]]
(result, style) = player.transformAnnotationToSSA(self.readTestInput("annotationsTest.xml", False).encode("utf-8"))
print repr(result)
assert(len(result.split("\r\n")) == 2)
示例2: test_transformAnnotationToSSA_should_call_replaceHTMLCodes_for_user_visible_text
# 需要导入模块: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 别名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import transformAnnotationToSSA [as 别名]
def test_transformAnnotationToSSA_should_call_replaceHTMLCodes_for_user_visible_text(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 TEXT"], ["TEXT"], ["bla"], ["bla2"], []]
result = player.transformAnnotationToSSA(self.readTestInput("annotationsTest.xml", False).encode("utf-8"))
print repr(result)
assert(sys.modules["__main__"].common.replaceHTMLCodes.call_count > 0)
示例3: test_downloadSubtitle_should_call_transformSubtitleToSSA
# 需要导入模块: from YouTubeSubtitleControl import YouTubeSubtitleControl [as 别名]
# 或者: from YouTubeSubtitleControl.YouTubeSubtitleControl import transformAnnotationToSSA [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")