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


Python Livestreamer.set_logoutput方法代码示例

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


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

示例1: main

# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_logoutput [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)
开发者ID:spiegedj,项目名称:TwitchViewer,代码行数:36,代码来源:LivestreamerPlayer.py

示例2: init_gstream

# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_logoutput [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()
开发者ID:mroNNorm,项目名称:TwitchLive,代码行数:47,代码来源:TwitchLive.py

示例3: main

# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_logoutput [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)
开发者ID:492580195,项目名称:livestreamer,代码行数:45,代码来源:gst-player.py

示例4: main

# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_logoutput [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)
开发者ID:barretod,项目名称:livestreamer,代码行数:44,代码来源:gst-player.py

示例5: check_online

# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_logoutput [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
开发者ID:mroNNorm,项目名称:TwitchLive,代码行数:26,代码来源:TwitchLive.py

示例6: __init__

# 需要导入模块: from livestreamer import Livestreamer [as 别名]
# 或者: from livestreamer.Livestreamer import set_logoutput [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':
#.........这里部分代码省略.........
开发者ID:jamesdanylik,项目名称:saltydoctor,代码行数:103,代码来源:SaltyDoctor.py


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