本文整理汇总了Python中YouTubePlayer.YouTubePlayer.selectVideoQuality方法的典型用法代码示例。如果您正苦于以下问题:Python YouTubePlayer.selectVideoQuality方法的具体用法?Python YouTubePlayer.selectVideoQuality怎么用?Python YouTubePlayer.selectVideoQuality使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YouTubePlayer.YouTubePlayer
的用法示例。
在下文中一共展示了YouTubePlayer.selectVideoQuality方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_selectVideoQuality_should_call_userSelectsVideoQuality_if_user_selected_that_option
# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import selectVideoQuality [as 别名]
def test_selectVideoQuality_should_call_userSelectsVideoQuality_if_user_selected_that_option(self):
sys.modules["__main__"].settings.getSetting.return_value = "0"
player = YouTubePlayer()
player.userSelectsVideoQuality = Mock()
player.selectVideoQuality({},{35: "SD", 22: "720p", 37: "1080p"})
player.userSelectsVideoQuality.assert_called_with({}, {35: 'SD', 37: '1080p', 22: '720p'})
示例2: test_selectVideoQuality_should_not_add_user_agent_when_called_by_download_function
# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import selectVideoQuality [as 别名]
def test_selectVideoQuality_should_not_add_user_agent_when_called_by_download_function(self):
sys.modules["__main__"].settings.getSetting.return_value = "1"
player = YouTubePlayer()
url = player.selectVideoQuality({"action": "download"},{35: "SD", 22: "720p", 37: "1080p"})
assert(url.find("|" + urllib.urlencode({'User-Agent':"Mozilla/5.0 (MOCK)"})) < 0)
示例3: test_selectVideoQuality_should_choose_highest_sd_quality_if_only_multiple_sd_qualities_are_available
# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import selectVideoQuality [as 别名]
def test_selectVideoQuality_should_choose_highest_sd_quality_if_only_multiple_sd_qualities_are_available(self):
sys.modules["__main__"].settings.getSetting.return_value = "1"
player = YouTubePlayer()
url = player.selectVideoQuality({},{5: "1", 33: "2", 18: "3", 26: "4", 43: "5", 34: "6", 78: "7", 44: "8", 59: "9", 35: "10"})
assert(url[:url.find("|")].strip() == "10")
示例4: test_selectVideoQuality_should_limit_to_sd_if_user_has_selected_that_option
# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import selectVideoQuality [as 别名]
def test_selectVideoQuality_should_limit_to_sd_if_user_has_selected_that_option(self):
sys.modules["__main__"].settings.getSetting.return_value = "1"
player = YouTubePlayer()
url = player.selectVideoQuality({},{35: "SD", 22: "720p", 37: "1080p"})
assert(url[:url.find("|")].strip() == "SD")
示例5: test_selectVideoQuality_should_prefer_SD_if_asked_to
# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import selectVideoQuality [as 别名]
def test_selectVideoQuality_should_prefer_SD_if_asked_to(self):
sys.modules["__main__"].settings.getSetting.return_value = "2"
player = YouTubePlayer()
url = player.selectVideoQuality({"quality": "SD"},{37: "1080p", 22: "720p", 35: "SD"})
assert(url[:url.find("|")].strip() == "SD")
示例6: test_selectVideoQuality_should_add_user_agent_when_not_called_by_download_function
# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import selectVideoQuality [as 别名]
def test_selectVideoQuality_should_add_user_agent_when_not_called_by_download_function(self):
sys.modules["__main__"].settings.getSetting.return_value = "1"
player = YouTubePlayer()
url = player.selectVideoQuality({},{35: "SD", 22: "720p", 37: "1080p"})
assert(url.find("| Mozilla/5.0 (MOCK)") > 0)
示例7: test_selectVideoQuality_should_limit_to_720p_if_user_has_selected_that_option
# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import selectVideoQuality [as 别名]
def test_selectVideoQuality_should_limit_to_720p_if_user_has_selected_that_option(self):
sys.modules["__main__"].settings.getSetting.return_value = "2"
player = YouTubePlayer()
url = player.selectVideoQuality({},{35: "SD", 22: "720p", 37: "1080p"})
assert(url == "720p | Mozilla/5.0 (MOCK)")
示例8: test_selectVideoQuality_should_prefer_720p_if_asked_to
# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import selectVideoQuality [as 别名]
def test_selectVideoQuality_should_prefer_720p_if_asked_to(self):
sys.modules["__main__"].settings.getSetting.return_value = "2"
player = YouTubePlayer()
url = player.selectVideoQuality({"quality": "720p"},{37: "1080p", 22: "720p", 35: "SD"})
assert(url == "720p | Mozilla/5.0 (MOCK)")
示例9: test_selectVideoQuality_should_prefer_h264_over_vp8_for_720p_as_appletv2_cant_handle_vp8_properly
# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import selectVideoQuality [as 别名]
def test_selectVideoQuality_should_prefer_h264_over_vp8_for_720p_as_appletv2_cant_handle_vp8_properly(self):
sys.modules["__main__"].settings.getSetting.return_value = "2"
player = YouTubePlayer()
url = player.selectVideoQuality({},{22: "h264", 45: "vp8"})
print "url: " + repr(url)
assert(url[:url.find("|")].strip() == "h264")
示例10: test_buildVideoObject_should_call_selectVideoQuality_if_local_file_not_found_and_remote_links_found
# 需要导入模块: from YouTubePlayer import YouTubePlayer [as 别名]
# 或者: from YouTubePlayer.YouTubePlayer import selectVideoQuality [as 别名]
def test_buildVideoObject_should_call_selectVideoQuality_if_local_file_not_found_and_remote_links_found(self):
sys.modules["__main__"].subtitles.getLocalFileSource.return_value = ""
params = {"videoid": "some_id"}
video = {"videoid": "some_id", "Title": "someTitle"}
player = YouTubePlayer()
player.getInfo = Mock()
player.getInfo.return_value = (video, 200)
player.extractVideoLinksFromYoutube = Mock()
player.extractVideoLinksFromYoutube.return_value = ({22: "720p"}, {})
player.selectVideoQuality = Mock()
player.buildVideoObject(params)
player.selectVideoQuality.assert_called_with(params,{22: "720p"})