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


Python livestreamer.Livestreamer类代码示例

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


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

示例1: GetYoutubeFullLink

def GetYoutubeFullLink(url):
	from livestreamer import Livestreamer
	livestr = Livestreamer()
	channel = livestr.resolve_url(url)
	streams = channel.get_streams()
	stream = streams["best"]
	return stream.url
开发者ID:aw20x,项目名称:xbmc-pal,代码行数:7,代码来源:myResolver.py

示例2: TestPluginStream

class TestPluginStream(unittest.TestCase):
    def setUp(self):
        self.session = Livestreamer()

    def assertDictHas(self, a, b):
        for key, value in a.items():
            self.assertEqual(b[key], value)

    def _test_akamaihd(self, surl, host, streamname):
        channel = self.session.resolve_url(surl)
        streams = channel.get_streams()

        self.assertTrue("live" in streams)

        stream = streams["live"]
        self.assertTrue(isinstance(stream, AkamaiHDStream))
        self.assertEqual(stream.host, host)
        self.assertEqual(stream.streamname, streamname)

    def _test_hls(self, surl, url):
        channel = self.session.resolve_url(surl)
        streams = channel.get_streams()

        self.assertTrue("live" in streams)

        stream = streams["live"]
        self.assertTrue(isinstance(stream, HLSStream))
        self.assertEqual(stream.url, url)

    def _test_rtmp(self, surl, url, params):
        channel = self.session.resolve_url(surl)
        streams = channel.get_streams()

        self.assertTrue("live" in streams)

        stream = streams["live"]
        self.assertTrue(isinstance(stream, RTMPStream))
        self.assertEqual(stream.params["rtmp"], url)
        self.assertDictHas(params, stream.params)

    def test_plugin(self):
        self._test_rtmp("rtmp://hostname.se/stream",
                         "rtmp://hostname.se/stream", dict())

        self._test_rtmp("rtmp://hostname.se/stream live=1 num=47",
                        "rtmp://hostname.se/stream", dict(live=True, num=47))

        self._test_rtmp("rtmp://hostname.se/stream live=1 qarg='a \'string' noq=test",
                        "rtmp://hostname.se/stream", dict(live=True, qarg='a \'string', noq="test"))

        self._test_hls("hls://http://hostname.se/playlist.m3u8",
                       "http://hostname.se/playlist.m3u8")

        self._test_akamaihd("akamaihd://http://hostname.se/stream",
                            "http://hostname.se", "stream")
开发者ID:buttsKramer,项目名称:livestreamer,代码行数:55,代码来源:test_plugin_stream.py

示例3: _getLiveUrl

def _getLiveUrl(target):
    livestreamer = Livestreamer()
    streams = livestreamer.streams("http://www.twitch.tv/" + target)
    print(streams)
    if streams:
        # default
        # xx = streams.popitem()
        # return xx[1].url
        xx = streams.get('high')
        return xx.url
    return None
开发者ID:caorong,项目名称:sneak-streaming,代码行数:11,代码来源:fabfile.py

示例4: face_detect

def face_detect(x, y, width, height, stream_url):
    x = x*426/651
    y = y*240/398
    width = width*426/651
    height = height*240/398
    cascade_fn = "haarcascade_frontalface_alt.xml"
    nested_fn = "haarcascade_eye.xml"

    cascade = cv2.CascadeClassifier(cascade_fn)
    nested = cv2.CascadeClassifier(nested_fn)

    FFMPEG_BIN = 'C:/ffmpeg/bin/ffmpeg.exe'

    livestreamer = Livestreamer()
    plugin = livestreamer.resolve_url(stream_url)
    streams = plugin.get_streams()
    stream = streams.get("best")
    VIDEO_URL = stream.url
    print VIDEO_URL
    pipe = sp.Popen([FFMPEG_BIN, "-i", VIDEO_URL,
                     "-loglevel", "quiet",  # no text output
                     "-an",  # disable audio
                     "-f", "image2pipe",
                     "-pix_fmt", "bgr24",
                     "-vcodec", "rawvideo", "-"],
                    stdin=sp.PIPE, stdout=sp.PIPE)
    interval = 0
    while True:
        raw_image = pipe.stdout.read(426 * 240 * 3)  # read 432*240*3 bytes (= 1 frame)
        img = np.fromstring(raw_image, dtype='uint8').reshape((240, 426, 3))
        img = img[y:(y + height), x:(x + width)]
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        gray = cv2.equalizeHist(gray)

        rects = detect(gray, cascade)
        vis = img.copy()
        if rects:
            interval += 1
        draw_rects(vis, rects, (0, 255, 0))
        for x1, y1, x2, y2 in rects:
            roi = gray[y1:y2, x1:x2]
            vis_roi = vis[y1:y2, x1:x2]
            subrects = detect(roi.copy(), nested)
            draw_rects(vis_roi, subrects, (255, 0, 0))

        cv2.imwrite('./media/face', vis)
        if cv2.waitKey(5) == 27:
            break
    cv2.destroyAllWindows()
开发者ID:ramitarora,项目名称:crowdcams,代码行数:49,代码来源:tasks.py

示例5: open

    def open(self, url, quality):
        """Attempt to open stream from *url*.

        Exits with '-1' (using self.exit()) in case of error, including
        an error msg.
        """

        self.original_url = url
        try:
            self.livestreamer = Livestreamer()
            self._load_config()
            streams = self.livestreamer.streams(url)
        except NoPluginError:
            self.exit("Livestreamer is unable to handle the URL '{}'".
                      format(url))
        except PluginError as err:
            self.exit("Plugin error: {}".format(err))

        if quality not in streams:
            print("Unable to find '{}' stream on URL '{}'"
                  .format(quality, url), file=sys.stderr)
            self.exit("List of available streams: {}".
                      format(sorted(streams.keys())))

        self.stream = streams[quality]
        try:
            self.fd = self.stream.open()
        except StreamError as err:
            self.exit("Failed to open stream: {}".format(err))
开发者ID:dot-Sean,项目名称:livedumper,代码行数:29,代码来源:dumper.py

示例6: __init__

 def __init__(self):    
     self.gchoice = -1
     self.cchoice = -1    
     self.exit_now = False
     self.state = 'none'
     self.keybingings = {
         ord('q'):       self.quit,
         ord('f'):       self.get_favorites,
         ord('s'):       self.get_fav_games,
         ord('g'):       self.get_games,
         ord('n'):       self.get_next,
         ord('r'):       self.refresh,
         ord('p'):       self.get_previous            
     }
     
     self.games = []
     self.favs = []
     self.channels = []        
     self.twitch = Twitch(config.get('settings', 'twitchapiurl'), config.get('settings', 'channel'), config.get('settings', 'game'))
     self.livestreamer = Livestreamer()
     
     try:
         self.run()
     except Exception as e:
         print e.message
开发者ID:parurope,项目名称:twitchscript,代码行数:25,代码来源:twitchscript_Serialloser.py

示例7: stream_recording

def stream_recording():
 
    print("STARTING TO RECORD STREAM")

    session = Livestreamer()
    stream = session.streams('http://www.twitch.tv/' + channel)

    print("CONNECTED TO STREAM")
    stream = stream['source']
    fd = stream.open()
    print("CONNECTED!")
    f = open("stream.dat", 'wb')

    while True:
        data = fd.read(1024)
        f.write(data)
开发者ID:Vatyx,项目名称:StreamLighter,代码行数:16,代码来源:main2.py

示例8: start

def start(portNum):
	global LIVESTREAMER
	LIVESTREAMER = Livestreamer()
	LIVESTREAMER.set_option('hls-segment-threads', '3')
	LIVESTREAMER.set_option('hds-segment-threads', '3')
	LIVESTREAMER.set_option('stream-segment-threads', '3')

	global httpd
	#httpd = ThreadedHTTPServer(('', portNum), StreamHandler)
	httpd = StoppableHTTPServer(('', portNum), StreamHandler)
	try:
		#thread.start_new_thread(httpd.serve, ())
		t1 = threading.Thread(target = httpd.serve, args = ())
		t1.daemon = True
		t1.start()
		print "Livestreamer: Server Starts - {0}:{1}".format("localhost", portNum)
	except Exception as ex:
		print ex
开发者ID:orenma,项目名称:xbmc-israel,代码行数:18,代码来源:livestreamersrv.py

示例9: serveFile

 def serveFile(self, fURL, sendData):
     from livestreamer import Livestreamer, StreamError, PluginError, NoPluginError
     session = Livestreamer()
     if '|' in fURL:
             sp = fURL.split('|')
             fURL = sp[0]
             headers = dict(urlparse.parse_qsl(sp[1]))
             session.set_option("http-headers", headers)
             session.set_option("http-ssl-verify",False)
     try:
         streams = session.streams(fURL)
     except:
         traceback.print_exc(file=sys.stdout)
         self.send_response(403)
     self.send_response(200)
     #print "XBMCLocalProxy: Sending headers..."
     self.end_headers()
     
     if (sendData):
         #print "XBMCLocalProxy: Sending data..."
         fileout = self.wfile
         try:
             stream = streams["best"]
             try:
                 response = stream.open()
                 buf = 'INIT'
                 while (buf != None and len(buf) > 0):
                     buf = response.read(300 * 1024)
                     fileout.write(buf)
                     fileout.flush()
                 response.close()
                 fileout.close()
                 #print time.asctime(), "Closing connection"
             except socket.error, e:
                 #print time.asctime(), "Client Closed the connection."
                 try:
                     response.close()
                     fileout.close()
                 except Exception, e:
                     return
             except Exception, e:
                 traceback.print_exc(file=sys.stdout)
                 response.close()
                 fileout.close()
开发者ID:Alsocogi,项目名称:repository.catoal,代码行数:44,代码来源:livestreamerXBMCLocalProxy.py

示例10: get_stream

def get_stream(stream_url):
    # change to a stream that is actually online
    livestreamer = Livestreamer()
    stream = None
    try:
        plugin = livestreamer.resolve_url("http://www.twitch.tv/" + stream_url)
        plugin.set_option('oauth_token', 'xtlhyl6uapy6znsvuhy4zfk0jbt086')
        streams = plugin.get_streams()
        # It seems best isn't necessarily the best, twitch doesn't seem to consider 60
        # streams, so we should search for those first.
        if '1080p60' in streams:
            stream = streams['1080p60']
        elif '720p60' in streams:
            stream = streams['720p60']
        else:
            stream = streams['best']
    except Exception:
        pass
    return stream
开发者ID:atkaiser,项目名称:sc2livescores,代码行数:19,代码来源:update_state.py

示例11: stream_recording

def stream_recording():
    from livestreamer import Livestreamer
 
    print(": Starting to record stream")
 
    session = Livestreamer()
    stream = session.streams('http://www.twitch.tv/' + channel)
    print("Connecting to stream")
    stream = stream['source']
    fd = stream.open()
    print("Connected!")

    #lock = threading.Lock()
    f = open("stream.dat", 'wb')# with open("stream.dat", 'wb') as f:

    global front
    while True:
        data = fd.read(1024)
        f.write(data)
        front += len(data)
开发者ID:Vatyx,项目名称:StreamLighter,代码行数:20,代码来源:main.py

示例12: openStream

def openStream(url, quality):
    """Open a livestreamer URL and return the stream"""

    livestreamer = Livestreamer()
    setOptions(livestreamer)

    try:
        streams = livestreamer.streams(url)
    except NoPluginError:
        print("Unable to Find Plugin")
        abort(404)

    except PluginError as err:
        print("Plugin error: {0}".format(err))
        abort(404)

    if quality not in streams:
        print("Quality {0} not available in {1}".format(quality, url))
        abort(404)

    return streams[quality]
开发者ID:drjson,项目名称:livestreamer-host,代码行数:21,代码来源:lshost.py

示例13: __init__

class Application:
    def __init__(self, window, stream_list):
        self.window = window
        self.stream_list = stream_list
        self.livestreamer = Livestreamer()
    
    def refresh_key(self):
        self.stream_list.update_streamers()
        self.refresh_screen()

    def refresh_screen(self):
        self.window.screen.erase()
        self.window.draw_borders()
        self.window.draw_help()
        self.stream_list.draw_streamers()
        self.window.screen.refresh()

    def up_key(self, distance=1):
        self.stream_list.move_up(distance)
        self.refresh_screen()

    def down_key(self, distance=1):
        self.stream_list.move_down(distance)
        self.refresh_screen()

    def sort_key(self):
        self.stream_list.toggle_sort()
        self.refresh_screen()

    def sort_order_key(self):
        self.stream_list.toggle_sort_order()
        self.refresh_screen()

    def resize_event(self):
        self.window.resize_term()
        self.refresh_screen()

    def play_stream(self, livestreamer_config=None, quality="best"):
        url = self.stream_list.get_twitch_url()
        streams = self.livestreamer.streams(url)
        
        stream = streams[quality]

        call = []
        call.append('livestreamer')
        call.append('--quiet')
        if livestreamer_config is not None:
            call.append('--config')
            call.append(livestreamer_config)
        call.append(url)
        call.append(quality)

        subprocess.Popen(call)
开发者ID:robcross,项目名称:srl-cli,代码行数:53,代码来源:srl-cli.py

示例14: main

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,代码行数:34,代码来源:LivestreamerPlayer.py

示例15: __init__

    def __init__(self, filename, rc_module):
        """ Init and try to load a stream list, nothing about curses yet """

        self.db_was_read = False

        # Open the storage (create it if necessary
        try:
            f = shelve.open(filename, 'c')
        except Exception:
            raise ShelveError(
                'Database could not be opened, another livestreamer-curses instance might be already running. '
                'Please note that a database created with Python 2.x cannot be used with Python 3.x and vice versa.'
            )
        self.max_id = 0

        # Sort streams by view count
        try:
            self.streams = sorted(f['streams'], key=lambda s:s['seen'], reverse=True)
            for s in self.streams:
                # Max id, needed when adding a new stream
                self.max_id = max(self.max_id, s['id'])
                s['online'] = 2
        except:
            self.streams = []
        self.db_was_read = True
        self.filtered_streams = list(self.streams)
        self.filter = ''
        self.all_streams_offline = None
        self.show_offline_streams = False
        self.rc_module = rc_module

        if 'LIVESTREAMER_COMMANDS' in dir(self.rc_module):
            self.cmd_list = list(map(shlex.split, self.rc_module.LIVESTREAMER_COMMANDS))
        else:
            self.cmd_list = [['livestreamer']]
        self.cmd_index = 0
        self.cmd = self.cmd_list[self.cmd_index]

        if 'DEFAULT_RESOLUTION' in dir(self.rc_module):
            self.default_res = self.rc_module.DEFAULT_RESOLUTION
        else:
            self.default_res = DEFAULT_RESOLUTION_HARD

        self.store = f
        self.store.sync()

        self.no_streams = self.streams == []
        self.no_stream_shown = self.no_streams
        self.q = ProcessList(StreamPlayer().play)

        self.livestreamer = Livestreamer()
开发者ID:fletom,项目名称:livestreamer-curses,代码行数:51,代码来源:main.py


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