本文整理汇总了Python中livestreamer.Livestreamer.load_plugins方法的典型用法代码示例。如果您正苦于以下问题:Python Livestreamer.load_plugins方法的具体用法?Python Livestreamer.load_plugins怎么用?Python Livestreamer.load_plugins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类livestreamer.Livestreamer
的用法示例。
在下文中一共展示了Livestreamer.load_plugins方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestSession
# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import load_plugins [as 别名]
class TestSession(unittest.TestCase):
PluginPath = os.path.join(os.path.dirname(__file__), "plugins")
def setUp(self):
self.session = Livestreamer()
self.session.load_plugins(self.PluginPath)
def test_exceptions(self):
try:
self.session.resolve_url("invalid url")
self.assertTrue(False)
except NoPluginError:
self.assertTrue(True)
def test_load_plugins(self):
plugins = self.session.get_plugins()
self.assertTrue(plugins["testplugin"])
def test_builtin_plugins(self):
plugins = self.session.get_plugins()
self.assertTrue("justintv" in plugins)
def test_resolve_url(self):
plugins = self.session.get_plugins()
channel = self.session.resolve_url("http://test.se/channel")
self.assertTrue(isinstance(channel, Plugin))
self.assertTrue(isinstance(channel, plugins["testplugin"]))
def test_options(self):
self.session.set_option("test_option", "option")
self.assertEqual(self.session.get_option("test_option"), "option")
self.assertEqual(self.session.get_option("non_existing"), None)
self.assertEqual(self.session.get_plugin_option("testplugin", "a_option"), "default")
self.session.set_plugin_option("testplugin", "another_option", "test")
self.assertEqual(self.session.get_plugin_option("testplugin", "another_option"), "test")
self.assertEqual(self.session.get_plugin_option("non_existing", "non_existing"), None)
self.assertEqual(self.session.get_plugin_option("testplugin", "non_existing"), None)
def test_plugin(self):
channel = self.session.resolve_url("http://test.se/channel")
streams = channel.get_streams()
self.assertTrue("best" in streams)
self.assertTrue(streams["best"] is streams["1080p"])
self.assertTrue(isinstance(streams["rtmp"], RTMPStream))
self.assertTrue(isinstance(streams["http"], HTTPStream))
self.assertTrue(isinstance(streams["hls"], HLSStream))
self.assertTrue(isinstance(streams["akamaihd"], AkamaiHDStream))
示例2: get_streams
# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import load_plugins [as 别名]
def get_streams(self):
live = Livestreamer()
print self.url
live.set_option("http-ssl-verify", False)
streams = None
live.load_plugins(os.path.join(os.getcwd(), "plugins"))
try:
plugin = live.resolve_url(self.url)
streams = plugin.get_streams()
self.play_url = stream_to_url(streams.get("best"))
except NoPluginError:
print("No plugin can handle URL")
except PluginError as err:
print("{0}", err)
示例3: TestSession
# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import load_plugins [as 别名]
class TestSession(unittest.TestCase):
PluginPath = os.path.join(os.path.dirname(__file__), "plugins")
def setUp(self):
self.session = Livestreamer()
self.session.load_plugins(self.PluginPath)
def test_exceptions(self):
try:
self.session.resolve_url("invalid url")
self.assertTrue(False)
except NoPluginError:
self.assertTrue(True)
def test_load_plugins(self):
plugins = self.session.get_plugins()
self.assertTrue(plugins["testplugin"])
def test_builtin_plugins(self):
plugins = self.session.get_plugins()
self.assertTrue("twitch" in plugins)
def test_resolve_url(self):
plugins = self.session.get_plugins()
channel = self.session.resolve_url("http://test.se/channel")
self.assertTrue(isinstance(channel, Plugin))
self.assertTrue(isinstance(channel, plugins["testplugin"]))
def test_options(self):
self.session.set_option("test_option", "option")
self.assertEqual(self.session.get_option("test_option"), "option")
self.assertEqual(self.session.get_option("non_existing"), None)
self.assertEqual(self.session.get_plugin_option("testplugin", "a_option"), "default")
self.session.set_plugin_option("testplugin", "another_option", "test")
self.assertEqual(self.session.get_plugin_option("testplugin", "another_option"), "test")
self.assertEqual(self.session.get_plugin_option("non_existing", "non_existing"), None)
self.assertEqual(self.session.get_plugin_option("testplugin", "non_existing"), None)
def test_plugin(self):
channel = self.session.resolve_url("http://test.se/channel")
streams = channel.get_streams()
self.assertTrue("best" in streams)
self.assertTrue("worst" in streams)
self.assertTrue(streams["best"] is streams["1080p"])
self.assertTrue(streams["worst"] is streams["350k"])
self.assertTrue(isinstance(streams["rtmp"], RTMPStream))
self.assertTrue(isinstance(streams["http"], HTTPStream))
self.assertTrue(isinstance(streams["hls"], HLSStream))
self.assertTrue(isinstance(streams["akamaihd"], AkamaiHDStream))
def test_plugin_stream_types(self):
channel = self.session.resolve_url("http://test.se/channel")
streams = channel.get_streams(stream_types=["http", "rtmp"])
self.assertTrue(isinstance(streams["480p"], HTTPStream))
self.assertTrue(isinstance(streams["480p_rtmp"], RTMPStream))
streams = channel.get_streams(stream_types=["rtmp", "http"])
self.assertTrue(isinstance(streams["480p"], RTMPStream))
self.assertTrue(isinstance(streams["480p_http"], HTTPStream))
def test_plugin_stream_sorted_excludes(self):
channel = self.session.resolve_url("http://test.se/channel")
streams = channel.get_streams(sorting_excludes=["1080p", "3000k"])
self.assertTrue("best" in streams)
self.assertTrue("worst" in streams)
self.assertTrue(streams["best"] is streams["1500k"])
streams = channel.get_streams(sorting_excludes=[">=1080p", ">1500k"])
self.assertTrue(streams["best"] is streams["1500k"])
streams = channel.get_streams(sorting_excludes=lambda q: not q.endswith("p"))
self.assertTrue(streams["best"] is streams["3000k"])
def test_plugin_support(self):
channel = self.session.resolve_url("http://test.se/channel")
streams = channel.get_streams()
self.assertTrue("support" in streams)
self.assertTrue(isinstance(streams["support"], HTTPStream))