本文整理汇总了Python中livestreamer.Livestreamer.set_loglevel方法的典型用法代码示例。如果您正苦于以下问题:Python Livestreamer.set_loglevel方法的具体用法?Python Livestreamer.set_loglevel怎么用?Python Livestreamer.set_loglevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类livestreamer.Livestreamer
的用法示例。
在下文中一共展示了Livestreamer.set_loglevel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_loglevel [as 别名]
def main():
if len(sys.argv) < 3:
exit("Usage: {0} <url> <quality>".format(sys.argv[0]))
gi.require_version("Gst", "1.0")
gobject.threads_init()
gst.init(None)
url = sys.argv[1]
quality = sys.argv[2]
livestreamer = Livestreamer()
livestreamer.set_loglevel("info")
livestreamer.set_logoutput(sys.stdout)
try:
streams = livestreamer.streams(url)
except NoPluginError:
exit("Livestreamer is unable to handle the URL '{0}'".format(url))
except PluginError as err:
exit("Plugin error: {0}.".format(err))
if not streams:
exit("No streams found on URL '{0}'.".format(url))
if quality not in streams:
exit("Unable to find '{0}' stream on URL '{1}'".format(quality, url))
stream = streams[quality]
player = LivestreamerPlayer()
player.play(stream)
示例2: init_gstream
# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_loglevel [as 别名]
def init_gstream(self):
# if len(sys.argv) < 3:
# exit("Usage: {0} <url> <quality>".format(sys.argv[0]))
# Initialize and check GStreamer version
gi.require_version("Gst", "1.0")
gobject.threads_init()
gst.init(None)
# Collect arguments
url = "twitch.tv/" + self.stream_textbox.get_text()
# Create the Livestreamer session
livestreamer = Livestreamer()
# Enable logging
livestreamer.set_loglevel("info")
livestreamer.set_logoutput(sys.stdout)
# Attempt to fetch streams
try:
streams = livestreamer.streams(url)
except NoPluginError:
print("Livestreamer is unable to handle the URL '{0}'".format(url))
except PluginError as err:
print("Plugin error: {0}".format(err))
if not streams:
print("No streams found on URL '{0}'".format(url))
# Look for specified stream
elif self.quality not in streams:
print("Unable to find '{0}' stream on URL '{1}'".format(self.quality, url))
# We found the stream
else:
stream = streams[self.quality]
# Create the player and start playback
# player = LivestreamerPlayer()
win = PI()
win.play(stream)
win.connect("delete-event", gtk.main_quit)
win.show_all()
win.main()
示例3: main
# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_loglevel [as 别名]
def main():
if len(sys.argv) < 3:
exit("Usage: {0} <url> <quality>".format(sys.argv[0]))
# Initialize and check GStreamer version
gi.require_version("Gst", "1.0")
gobject.threads_init()
gst.init(None)
# Collect arguments
url = sys.argv[1]
quality = sys.argv[2]
# Create the Livestreamer session
livestreamer = Livestreamer()
# Enable logging
livestreamer.set_loglevel("info")
livestreamer.set_logoutput(sys.stdout)
# Attempt to fetch streams
try:
streams = livestreamer.streams(url)
except NoPluginError:
exit("Livestreamer is unable to handle the URL '{0}'".format(url))
except PluginError as err:
exit("Plugin error: {0}".format(err))
if not streams:
exit("No streams found on URL '{0}'".format(url))
# Look for specified stream
if quality not in streams:
exit("Unable to find '{0}' stream on URL '{1}'".format(quality, url))
# We found the stream
stream = streams[quality]
# Create the player and start playback
player = LivestreamerPlayer()
# Blocks until playback is done
player.play(stream)
示例4: main
# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_loglevel [as 别名]
def main():
if len(sys.argv) < 3:
exit("Usage: {0} <url> <quality>".format(sys.argv[0]))
# Collect arguments
url = sys.argv[1]
quality = sys.argv[2]
# Create the Livestreamer session
livestreamer = Livestreamer()
# Enable logging
livestreamer.set_loglevel("info")
livestreamer.set_logoutput(sys.stdout)
# Attempt to find a plugin for this URL
try:
plugin = livestreamer.resolve_url(url)
except NoPluginError:
exit("Livestreamer is unable to handle the URL '{0}'".format(url))
# Attempt to fetch streams
try:
streams = plugin.get_streams()
except PluginError as err:
exit("Plugin error: {0}".format(err))
if len(streams) == 0:
exit("No streams found on URL '{0}'".format(url))
# Look for specified stream
if quality not in streams:
exit("Unable to find '{0}' stream on URL '{1}'".format(quality, url))
# We found the stream
stream = streams[quality]
# Create the player and start playback
player = LivestreamerPlayer()
# Blocks until playback is done
player.play(stream)
示例5: check_online
# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_loglevel [as 别名]
def check_online(stream_name):
# Collect arguments
url = "twitch.tv/" + stream_name
# Create the Livestreamer session
livestreamer = Livestreamer()
# Enable logging
livestreamer.set_loglevel("info")
livestreamer.set_logoutput(sys.stdout)
# Attempt to fetch streams
try:
streams = livestreamer.streams(url)
except NoPluginError:
print("Livestreamer is unable to handle the URL '{0}'".format(url))
except PluginError as err:
print("Plugin error: {0}".format(err))
if not streams:
print("No streams found on URL '{0}'".format(url))
return False
else:
return True
示例6: Livestreamer
# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_loglevel [as 别名]
"""
Test Livestreamer Script for enigma2
Test commands:
cd /usr/lib/enigma2/python/Plugins/Extensions/GreekStreamTV
python testme.py
"""
import sys
sys.path.append('/usr/lib/enigma2/python/Plugins/Extensions/GreekStreamTV')
import os
import requests
from livestreamer import Livestreamer
url = 'http://www.dailymotion.com/video/xqjey2'
livestreamer = Livestreamer()
livestreamer.set_loglevel('debug')
channel = livestreamer.resolve_url(url)
streams = channel.get_streams()
print 'Streams:', streams.keys()
stream = streams['best']
print stream
fd = stream.open()
while True:
data = fd.read(1024)
if len(data) == 0:
break
else:
print 'Got Data! Livestreamer Works!'
break
if hasattr(fd, 'close'):
示例7: Livestreamer
# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_loglevel [as 别名]
"""
import sys
sys.path.append("/usr/lib/enigma2/python/Plugins/Extensions/GreekStreamTV")
import os
import requests
from livestreamer import Livestreamer
url = "http://www.dailymotion.com/video/xqjey2"
#url = "hds://http://btslive-lh.akamaihd.net/z/[email protected]/manifest.f4m"
#url = "http://www.youtube.com/watch?v=ZTf2EzTd1TE"
livestreamer = Livestreamer()
livestreamer.set_loglevel("debug")
channel = livestreamer.resolve_url(url)
streams = channel.get_streams()
print 'Streams:', streams.keys()
stream = streams["best"]
print stream
fd = stream.open()
while True:
data = fd.read(1024)
if len(data) == 0:
break
else:
示例8: __init__
# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_loglevel [as 别名]
class SaltyMainGUI:
def __init__(self, master):
self.master = master
self.frame = tk.Frame(self.master)
gobject.threads_init()
gst.init(None)
self.livestreamer = Livestreamer()
self.livestreamer.set_loglevel("info")
self.livestreamer.set_logoutput(sys.stdout)
self.fd = None
try:
self.streams = self.livestreamer.streams('http://www.twitch.tv/saltybet')
except NoPluginError:
exit("Livestreamer failed to handle the url.")
except PluginError as err:
exit("Livestreamer plugin error: {}".format(err))
if not self.streams:
exit("No streams found.")
if 'best' not in self.streams:
exit("Unable to select livestreamer quality.")
self.stream = self.streams['best']
try:
self.fd = self.stream.open()
except SteamError as err:
self.exit("Livestreamer failed to open stream.")
self.init_gui()
# self.login()
self.window_id = self.video.winfo_id()
self.player = gst.ElementFactory.make('playbin', None)
self.player.set_property('video-sink', None)
self.player.set_property('uri', 'appsrc://')
self.player.connect('source-setup', self.on_source_setup)
self.bus = self.player.get_bus()
self.bus.add_signal_watch()
self.bus.enable_sync_message_emission()
self.bus.connect('sync-message::element', self.on_sync_message, self.window_id)
self.bus.connect('message::eos', self.on_eos)
self.bus.connect('message::error', self.on_error)
self.player.set_state(gst.State.PLAYING)
def init_gui(self):
self.master.title('SaltyDoctor')
self.master.geometry('640x480')
self.video = tk.Frame(self.master, bg='black')
self.video.pack(side=tk.TOP, anchor=tk.N, expand=tk.YES, fill=tk.BOTH)
self.mute_btn = tk.Button(self.master, text='Mute', command=self.mute_stream)
self.mute_btn.pack()
self.frame.pack()
def shutdown(self):
self.player.set_state(gst.State.NULL)
self.master.destroy()
def mute_stream(self):
if self.player.get_property('mute'):
self.player.set_property('mute', False)
else:
self.player.set_property('mute', True)
def login(self):
self.login_window = tk.Toplevel(self.master)
self.app = SaltyLoginGUI(self.login_window)
def on_source_setup(self, element, source):
# print 'Source setup called.'
source.connect("need-data", self.on_source_need_data)
def on_source_need_data(self, source, length):
try:
data = self.fd.read(length)
except IOError as err:
exit('Failed to read data from stream.')
if not data:
source.emit('end-of-stream')
return
buf = gst.Buffer.new_wrapped(data)
source.emit('push-buffer', buf)
def on_sync_message(self, bus, message, window_id):
# print 'On sync message called: ' + message.get_structure().get_name()
if not message.get_structure() is None:
if message.get_structure().get_name() == 'prepare-window-handle':
#.........这里部分代码省略.........