blob: 03949f21e3a902018aa56092e79f6a5ba4f44d0d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
from livestreamer.utils import urlopen
import os
import pbs
class StreamError(Exception):
pass
class Stream(object):
def open(self):
raise NotImplementedError
class StreamProcess(Stream):
def __init__(self, params):
self.params = params or {}
def cmdline(self):
return str(self.cmd.bake(**self.params))
def open(self):
stream = self.cmd(**self.params)
return stream.process.stdout
class RTMPStream(StreamProcess):
def __init__(self, params):
StreamProcess.__init__(self, params)
self.params["flv"] = "-"
self.params["_bg"] = True
self.params["_err"] = open(os.devnull, "w")
try:
self.cmd = pbs.rtmpdump
except pbs.CommandNotFound:
raise StreamError("Unable to find 'rtmpdump' command")
class HTTPStream(Stream):
def __init__(self, url):
self.url = url
def open(self):
return urlopen(self.url)
|