"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 }), validate.get("content") ), "videos": validate.all( validate.xml_findall("{http://www.w3.org/2001/SMIL20/Language}body/" "{http://www.w3.org/2001/SMIL20/Language}switch/" "{http://www.w3.org/2001/SMIL20/Language}video"), [ validate.all( validate.xml_element(attrib={ "src": validate.text, "system-bitrate": validate.all(
from livestreamer.plugin import Plugin from livestreamer.plugin.api import http, validate from livestreamer.stream import HTTPStream, RTMPStream from livestreamer.plugin.api.support_plugin import common_jwplayer as jwplayer BASE_VOD_URL = "https://www.connectcast.tv" SWF_URL = "https://www.connectcast.tv/jwplayer/jwplayer.flash.swf" _url_re = re.compile("http(s)?://(\w+\.)?connectcast.tv/") _smil_schema = validate.Schema( validate.union({ "base": validate.all(validate.xml_find("head/meta"), validate.get("base"), validate.url(scheme="rtmp")), "videos": validate.all(validate.xml_findall("body/video"), [validate.get("src")]) })) class ConnectCast(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_smil_streams(self, url): res = http.get(url, verify=False) smil = http.xml(res, schema=_smil_schema)
import re from livestreamer.plugin import Plugin from livestreamer.plugin.api import http, validate from livestreamer.stream import RTMPStream _url_re = re.compile("http(s)?://(\w+.)?beam.pro/(?P<channel>[^/]+)") CHANNEL_INFO = "https://beam.pro/api/v1/channels/{0}" CHANNEL_MANIFEST = "https://beam.pro/api/v1/channels/{0}/manifest.smil" _assets_schema = validate.Schema( validate.union({ "base": validate.all( validate.xml_find("./head/meta"), validate.get("base"), validate.url(scheme="rtmp") ), "videos": validate.all( validate.xml_findall(".//video"), [ validate.union({ "src": validate.all( validate.get("src"), validate.text ), "height": validate.all( validate.get("height"), validate.text, validate.transform(int) )
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}), validate.get("content")), "videos": validate.all( validate.xml_findall( "{http://www.w3.org/2001/SMIL20/Language}body/" "{http://www.w3.org/2001/SMIL20/Language}switch/" "{http://www.w3.org/2001/SMIL20/Language}video"), [ validate.all( validate.xml_element( attrib={ "src": validate.text,
def test_xml_find(self): el = Element("parent") el.append(Element("foo")) el.append(Element("bar")) assert validate(xml_find("bar"), el).tag == "bar"
JustinTVPluginBase = justintv_common.PluginBase JustinTVAPIBase = justintv_common.APIBase _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"),
_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"):
def test_xml_find(self): el = Element("parent") el.append(Element("foo")) el.append(Element("bar")) assert validate(xml_find("bar"), el).tag == "bar"