from livestreamer.plugin import Plugin from livestreamer.plugin.api import http, validate from livestreamer.stream import HLSStream _url_re = re.compile("http(s)?://chaturbate.com/[^/?&]+") _playlist_url_re = re.compile("html \+= \"src='(?P<url>[^']+)'\";") _schema = validate.Schema( validate.transform(_playlist_url_re.search), validate.any( None, validate.all( validate.get("url"), validate.url( scheme="http", path=validate.endswith(".m3u8") ) ) ) ) class Chaturbate(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_streams(self): playlist_url = http.get(self.url, schema=_schema) if not playlist_url: return
REDIRECT_SERVICE_URI = "https://lancer.streamup.com/api/redirect/{0}" _url_re = re.compile("http(s)?://(\w+\.)?streamup.com/(?P<channel>[^/?]+)") _flashvars_re = re.compile("flashvars\.(?P<var>\w+)\s?=\s?'(?P<value>[^']+)';") _swf_url_re = re.compile('swfobject.embedSWF\(\s*"(?P<player_url>[^"]+)",') _schema = validate.Schema( validate.union( { "vars": validate.all( validate.transform(_flashvars_re.findall), validate.transform(dict), {"owner": validate.text, validate.optional("token"): validate.text}, ), "swf": validate.all( validate.transform(_swf_url_re.search), validate.get("player_url"), validate.endswith(".swf") ), } ) ) _channel_details_schema = validate.Schema({"channel": {"live": bool, "slug": validate.text}}) class StreamupCom(Plugin): @classmethod def can_handle_url(cls, url): return _url_re.match(url) def _get_streams(self): res = http.get(self.url, schema=_schema)
_schema = validate.Schema( validate.union({ "urls": validate.all( validate.transform(_file_re.findall), validate.map(unquote), [validate.url()] ), "swf": validate.all( validate.transform(_swf_url_re.search), validate.any( None, validate.all( validate.get(1), validate.url( scheme="http", path=validate.endswith("swf") ) ) ) ) }) ) class Aliez(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_streams(self): res = http.get(self.url, schema=_schema)
_url_re = re.compile("http(s)?://new.livestream.com/") _stream_config_schema = validate.Schema({ "event": { "stream_info": validate.any( { "is_live": bool, "qualities": [{ "bitrate": int, "height": int }], validate.optional("play_url"): validate.url(scheme="http"), validate.optional("m3u8_url"): validate.url(scheme="http", path=validate.endswith(".m3u8")), }, None) }, validate.optional("viewerPlusSwfUrl"): validate.url(scheme="http"), validate.optional("hdPlayerSwfUrl"): validate.text }) _smil_schema = validate.Schema( validate.union({ "http_base": validate.all( validate.xml_find("{http://www.w3.org/2001/SMIL20/Language}head/" "{http://www.w3.org/2001/SMIL20/Language}meta" "[@name='httpBase']"), validate.xml_element(attrib={"content": validate.text}),
_swf_url_re = re.compile("swfobject.embedSWF\(\"([^\"]+)\",") _schema = validate.Schema( validate.union({ "urls": validate.all(validate.transform(_file_re.findall), validate.map(unquote), [validate.url()]), "swf": validate.all( validate.transform(_swf_url_re.search), validate.any( None, validate.all( validate.get(1), validate.url(scheme="http", path=validate.endswith("swf"))))) })) class Aliez(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_streams(self): res = http.get(self.url, schema=_schema) streams = {} for url in res["urls"]: parsed = urlparse(url) if parsed.scheme.startswith("rtmp"): params = {"rtmp": url, "pageUrl": self.url, "live": True}
def test_endswith(self): assert validate(endswith(u"åäö"), u"xyzåäö")
_url_re = re.compile("http(s)?://(\w+\.)?streamup.com/(?P<channel>[^/?]+)") _flashvars_re = re.compile("flashvars\.(?P<var>\w+)\s?=\s?'(?P<value>[^']+)';") _swf_url_re = re.compile("swfobject.embedSWF\(\s*\"(?P<player_url>[^\"]+)\",") _schema = validate.Schema( validate.union({ "vars": validate.all(validate.transform(_flashvars_re.findall), validate.transform(dict), { "owner": validate.text, validate.optional("token"): validate.text }), "swf": validate.all(validate.transform(_swf_url_re.search), validate.get("player_url"), validate.endswith(".swf")) })) _channel_details_schema = validate.Schema( {"channel": { "live": bool, "slug": validate.text }}) class StreamupCom(Plugin): @classmethod def can_handle_url(cls, url): return _url_re.match(url) def _get_streams(self):
_csrf_token_re = re.compile("<meta content=\"([^\"]+)\" name=\"csrf-token\"") _hls_playlist_re = re.compile("<source src=\"([^\"]+)\"") _url_re = re.compile("http(s)?://(\w+\.)?livestation.com") _csrf_token_schema = validate.Schema( validate.transform(_csrf_token_re.search), validate.any(None, validate.get(1)) ) _hls_playlist_schema = validate.Schema( validate.transform(_hls_playlist_re.search), validate.any( None, validate.all( validate.get(1), validate.url(scheme="http", path=validate.endswith(".m3u8")) ) ) ) _login_schema = validate.Schema({ "email": validate.text, validate.optional("errors"): validate.all( { "base": [validate.text] }, validate.get("base"), ) }) class Livestation(Plugin):
/video/\d+/[^/]+ )? """, re.VERBOSE, ) _file_re = re.compile('"?file"?:\s+[\'"]([^\'"]+)[\'"]') _swf_url_re = re.compile('swfobject.embedSWF\("([^"]+)",') _schema = validate.Schema( validate.union( { "urls": validate.all(validate.transform(_file_re.findall), validate.map(unquote), [validate.url()]), "swf": validate.all( validate.transform(_swf_url_re.search), validate.any( None, validate.all(validate.get(1), validate.url(scheme="http", path=validate.endswith("swf"))) ), ), } ) ) class Aliez(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_streams(self): res = http.get(self.url, schema=_schema) streams = {}