blob: 21fc8ac14dc002188384ba29f932f6a0befcb0c2 (
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
|
from livestreamer.utils import urlopen
import os
import pbs
class StreamError(Exception):
pass
class Stream(object):
def open(self):
raise NotImplementedError
class RTMPStream(Stream):
def __init__(self, params):
self.params = params or {}
def open(self):
try:
rtmpdump = pbs.rtmpdump
except pbs.CommandNotFound:
raise StreamError("Unable to find 'rtmpdump' command")
self.params["flv"] = "-"
self.params["_bg"] = True
self.params["_err"] = open(os.devnull, "w")
stream = rtmpdump(**self.params)
return stream.process.stdout
class HTTPStream(Stream):
def __init__(self, url):
self.url = url
def open(self):
return urlopen(self.url)
|