http(s)?://(www\.)? (?: tv4play.se/program/[^\?/]+ )? (?: fotbollskanalen.se/video )? .+(video_id|videoid)=(?P<video_id>\d+) """, re.VERBOSE) _asset_schema = validate.Schema( validate.xml_findall("items/item"), [ validate.all( validate.xml_findall("*"), validate.map(lambda e: (e.tag, e.text)), validate.transform(dict), { "base": validate.text, "bitrate": validate.all( validate.text, validate.transform(int) ), "url": validate.text } ) ] ) class TV4Play(Plugin): @classmethod
http(s)?://(\w+\.)?aliez.tv (?: /live/[^/]+ )? (?: /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
http(s)?://(\w+\.)?aliez.tv (?: /live/[^/]+ )? (?: /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") ) ) ) )
SWF_URL = "http://live.daserste.de/lib/br-player/swf/main.swf" STREAMING_TYPES = { "streamingUrlLive": ( "HDS", partial(HDSStream.parse_manifest, pvswf=SWF_URL) ), "streamingUrlIPhone": ( "HLS", HLSStream.parse_variant_playlist ) } _url_re = re.compile("http(s)?://live.daserste.de/(?P<channel>[^/?]+)?") _livestream_schema = validate.Schema( validate.xml_findall("video/*"), validate.filter(lambda e: e.tag in STREAMING_TYPES), validate.map(lambda e: (STREAMING_TYPES.get(e.tag), e.text)), validate.transform(dict), ) class ard_live(Plugin): @classmethod def can_handle_url(cls, url): return _url_re.match(url) def _get_streams(self): match = _url_re.match(self.url) channel = match.group("channel") res = http.get(STREAM_INFO_URL.format(channel)) urls = http.xml(res, schema=_livestream_schema) streams = {}
http(s)?://(\w+\.)?aliez.tv (?: /live/[^/]+ )? (?: /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):
def test_map(self): assert validate(map(lambda v: v[0]), [(1, 2), (3, 4)]) == [1, 3]
def test_map_dict(self): assert validate(map(lambda k, v: (v, k)), {"foo": "bar"}) == {"bar": "foo"}
"14": "block_time", "16": "reconnect_time", "20": "multibitrate", "73": "token" } BLOCKED_MSG_FORMAT = ( "You have crossed the free viewing limit. You have been blocked for " "{0} minutes. Try again in {1} minutes" ) BLOCK_TYPE_VIEWING_LIMIT = 1 BLOCK_TYPE_NO_SLOTS = 11 _url_re = re.compile("http(s)?://(\w+\.)?weeb.tv/channel/(?P<channel>[^/&?]+)") _schema = validate.Schema( dict, validate.map(lambda k, v: (PARAMS_KEY_MAP.get(k, k), v)), validate.any( { "status": validate.transform(int), "rtmp": validate.url(scheme="rtmp"), "playpath": validate.text, "multibitrate": validate.all( validate.transform(int), validate.transform(bool) ), "block_type": validate.transform(int), validate.optional("token"): validate.text, validate.optional("block_time"): validate.text, validate.optional("reconnect_time"): validate.text, }, {
from livestreamer.stream import HLSStream, HDSStream STREAM_INFO_URL = "http://live.daserste.de/{0}/livestream.xml" SWF_URL = "http://live.daserste.de/lib/br-player/swf/main.swf" STREAMING_TYPES = { "streamingUrlLive": ("HDS", partial(HDSStream.parse_manifest, pvswf=SWF_URL)), "streamingUrlIPhone": ("HLS", HLSStream.parse_variant_playlist) } _url_re = re.compile("http(s)?://live.daserste.de/(?P<channel>[^/?]+)?") _livestream_schema = validate.Schema( validate.xml_findall("video/*"), validate.filter(lambda e: e.tag in STREAMING_TYPES), validate.map(lambda e: (STREAMING_TYPES.get(e.tag), e.text)), validate.transform(dict), ) class ard_live(Plugin): @classmethod def can_handle_url(cls, url): return _url_re.match(url) def _get_streams(self): match = _url_re.match(self.url) channel = match.group("channel") res = http.get(STREAM_INFO_URL.format(channel)) urls = http.xml(res, schema=_livestream_schema)
_video_schema = validate.Schema( validate.union({ "archives": validate.all(validate.xml_findall("archive"), [ validate.union({ "length": validate.all( validate.xml_findtext("length"), validate.transform(int), ), "transcodes": validate.all( validate.xml_find("transcode_file_urls"), validate.xml_findall("*"), validate.map(lambda e: (e.tag.replace("transcode_", ""), e.text)), validate.transform(dict), ), "url": validate.xml_findtext("video_file_url") }), ]), validate.optional("restrictions"): validate.xml_findtext("archive_restrictions/restriction"), validate.optional("bracket_start"): validate.all(validate.xml_findtext("bracket_start"), validate.transform(int)), validate.optional("bracket_end"): validate.all(validate.xml_findtext("bracket_end"), validate.transform(int)) }))
_url_re = re.compile(r"http(s)?://([\w\.]+)?justin.tv/[^/]+(/[bc]/\d+)?") _video_schema = validate.Schema(validate.union({ "archives": validate.all( validate.xml_findall("archive"), [ validate.union({ "length": validate.all( validate.xml_findtext("length"), validate.transform(int), ), "transcodes": validate.all( validate.xml_find("transcode_file_urls"), validate.xml_findall("*"), validate.map( lambda e: (e.tag.replace("transcode_", ""), e.text) ), validate.transform(dict), ), "url": validate.xml_findtext("video_file_url") }), ] ), validate.optional("restrictions"): validate.xml_findtext( "archive_restrictions/restriction" ), validate.optional("bracket_start"): validate.all( validate.xml_findtext("bracket_start"), validate.transform(int) ), validate.optional("bracket_end"): validate.all(
def test_map_dict(self): assert validate(map(lambda k, v: (v, k)), {"foo": "bar"}) == { "bar": "foo" }
(?: /live/[^/]+ )? (?: /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)
"13": "block_type", "14": "block_time", "16": "reconnect_time", "20": "multibitrate", "73": "token" } BLOCKED_MSG_FORMAT = ( "You have crossed the free viewing limit. You have been blocked for " "{0} minutes. Try again in {1} minutes") BLOCK_TYPE_VIEWING_LIMIT = 1 BLOCK_TYPE_NO_SLOTS = 11 _url_re = re.compile( "http(s)?://(\w+\.)?weeb.tv/(channel|online)/(?P<channel>[^/&?]+)") _schema = validate.Schema( dict, validate.map(lambda k, v: (PARAMS_KEY_MAP.get(k, k), v)), validate.any( { "status": validate.transform(int), "rtmp": validate.url(scheme="rtmp"), "playpath": validate.text, "multibitrate": validate.all(validate.transform(int), validate.transform(bool)), "block_type": validate.transform(int), validate.optional("token"): validate.text, validate.optional("block_time"):
_url_re = re.compile( """ http(s)?://(www\.)? (?: tv4play.se/program/[^\?/]+ )? (?: fotbollskanalen.se/video )? .+(video_id|videoid)=(?P<video_id>\d+) """, re.VERBOSE) _asset_schema = validate.Schema(validate.xml_findall("items/item"), [ validate.all( validate.xml_findall("*"), validate.map(lambda e: (e.tag, e.text)), validate.transform(dict), { "base": validate.text, "bitrate": validate.all(validate.text, validate.transform(int)), "url": validate.text }) ]) class TV4Play(Plugin): @classmethod def can_handle_url(cls, url): return _url_re.match(url) def _get_streams(self): match = _url_re.match(self.url)