_embed_re = re.compile("<iframe src=\"(http://tv.aftonbladet.se[^\"]+)\"") _aptoma_id_re = re.compile("<div id=\"drvideo\".+data-aptomaId=\"([^\"]+)\"") _live_re = re.compile("data-isLive=\"true\"") _url_re = re.compile("http(s)?://(\w+.)?.aftonbladet.se") _video_schema = validate.Schema( { "formats": validate.all( { validate.text: { validate.text: validate.all( dict, validate.filter(lambda k,v: k in STREAM_FORMATS), { validate.text: [{ "address": validate.text, "filename": validate.text, "path": validate.text }] }, ) } }, validate.filter(lambda k,v: k in STREAM_TYPES) ) } ) class Aftonbladet(Plugin): @classmethod def can_handle_url(cls, url):
from livestreamer.plugin import Plugin from livestreamer.plugin.api import http, validate from livestreamer.stream import HDSStream, HLSStream CONFIG_API_URL = "http://www.majorleaguegaming.com/player/config.json" STREAM_API_URL = "http://streamapi.majorleaguegaming.com/service/streams/playback/{0}" STREAM_TYPES = { "hls": HLSStream.parse_variant_playlist, "hds": HDSStream.parse_manifest } _stream_id_re = re.compile( r"<meta content='.+/([\w_-]+).+' property='og:video'>") _url_re = re.compile("http(s)?://(\w+\.)?(majorleaguegaming\.com|mlg\.tv)") _config_schema = validate.Schema({"media": [{"channel": validate.text}]}) _stream_schema = validate.Schema( { "data": { "items": validate.all([{ "format": validate.text, "url": validate.text }], validate.filter(lambda s: s["format"] in STREAM_TYPES)) } }, validate.get("data", {}), validate.get("items", [])) class MLGTV(Plugin): @classmethod
import re from livestreamer.compat import urlparse from livestreamer.plugin import Plugin from livestreamer.plugin.api import http, validate from livestreamer.stream import RTMPStream, HTTPStream, HLSStream from livestreamer.utils import parse_json, rtmpparse, swfdecompress _url_re = re.compile("http(s)?://api.dmcloud.net/player/embed/[^/]+/[^/]+") _rtmp_re = re.compile(b"customURL[^h]+(https://.*?)\\\\") _info_re = re.compile("var info = (.*);") _schema = validate.Schema({ "mode": validate.text, validate.optional("mp4_url"): validate.url(scheme="http"), validate.optional("ios_url"): validate.url(scheme="http"), validate.optional("swf_url"): validate.url(scheme="http"), }) class DMCloud(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_rtmp_stream(self, swfurl): res = http.get(swfurl) swf = swfdecompress(res.content) match = _rtmp_re.search(swf)
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) ) }) ] ) }) ) class Beam(Plugin): @classmethod
import re from livestreamer.plugin import Plugin from livestreamer.plugin.api import http, validate from livestreamer.stream import HDSStream API_URL = "http://api.sh.nhk.fivecool.tv/api/cdn/?publicId=3bz2huey&playerId=7Dy" _url_re = re.compile("http(s)?://(\w+\.)?nhk.or.jp/nhkworld") _schema = validate.Schema({ "live-streams": [{ "streams": validate.all([{ "protocol": validate.text, "streamUrl": validate.text }], validate.filter(lambda s: s["protocol"] in ("http-flash", "http-hds"))) }] }) class NHKWorld(Plugin): @classmethod def can_handle_url(cls, url): return _url_re.match(url) def _get_streams(self): res = http.get(API_URL) data = http.json(res, schema=_schema)
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) for video in smil["videos"]:
SWF_URL = "http://euronews.com/media/player_live_1_14.swf" API_URL_LIVE = "http://euronews.hexaglobe.com/json/" _url_re = re.compile("http(s)?://(\w+\.)?euronews.com") _lang_re = re.compile("EN.lang\s+= \"([^\"]+)\";") _live_check_re = re.compile( "swfobject.embedSWF\(\"[^\"]+\", \"streaming-live-player\",") _video_re = re.compile( "{file: \"(?P<url>[^\"]+)\", label: \"(?P<name>[^\"]+)\"}") _live_schema = validate.Schema({ validate.any("primary", "secondary"): { validate.text: { "rtmp_flash": { validate.text: { "name": validate.text, "server": validate.url(scheme="rtmp") } } } } }) _schema = validate.Schema( validate.union({ "lang": validate.all(validate.transform(_lang_re.search), validate.get(1)), "live": validate.all(validate.transform(_live_check_re.search), validate.transform(bool)), "videos": validate.all(validate.transform(_video_re.findall), [(validate.url(scheme="http"), validate.text)])
int(ts[-6:-5] + "1") ) _url_re = re.compile(""" http(s)?://(\w+\.)?crunchyroll\. (?: com|de|es|fr|co.jp ) /[^/&?]+ /[^/&?]+-(?P<media_id>\d+) """, re.VERBOSE) _api_schema = validate.Schema({ "error": bool, validate.optional("code"): validate.text, validate.optional("message"): validate.text, validate.optional("data"): object, }) _media_schema = validate.Schema( { "stream_data": validate.any( None, { "streams": validate.all( [{ "quality": validate.text, "url": validate.url( scheme="http", path=validate.endswith(".m3u8") ) }],
(?: (/embed/|/channel/id/)(?P<channel_id>\d+) )? (?: /recorded/(?P<video_id>\d+) )? """, re.VERBOSE) _channel_id_re = re.compile("\"channelId\":(\d+)") HLS_PLAYLIST_URL = ("http://iphone-streaming.ustream.tv" "/uhls/{0}/streams/live/iphone/playlist.m3u8") RECORDED_URL = "http://tcdn.ustream.tv/video/{0}" RTMP_URL = "rtmp://r{0}-1-{1}-channel-live.ums.ustream.tv:1935/ustream" SWF_URL = "http://static-cdn1.ustream.tv/swf/live/viewer.rsl:505.swf" _module_info_schema = validate.Schema(list, validate.length(1), validate.get(0), dict) _amf3_array = validate.Schema( validate.any( validate.all( {int: object}, validate.transform(lambda a: list(a.values())), ), list)) _recorded_schema = validate.Schema({ validate.optional("stream"): validate.all(_amf3_array, [{ "name": validate.text, "streams": validate.all( _amf3_array, [{
) } _url_re = re.compile(""" http(s)?://(\w+\.)?zdf.de/zdfmediathek(\#)?/.+ /(live|video) /(?P<video_id>\d+) """, re.VERBOSE | re.IGNORECASE) _schema = validate.Schema( validate.xml_findall("video/formitaeten/formitaet"), [ validate.union({ "type": validate.get("basetype"), "quality": validate.xml_findtext("quality"), "url": validate.all( validate.xml_findtext("url"), validate.url() ) }) ] ) class zdf_mediathek(Plugin): @classmethod def can_handle_url(cls, url): return _url_re.match(url) @classmethod def stream_weight(cls, key):
)? (?: /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):
""" http(s)?:// (www\.)? (?: svtplay | svtflow | oppetarkiv ) .se """, re.VERBOSE) _video_schema = validate.Schema( { "video": { "videoReferences": validate.all([{ "url": validate.text, "playerType": validate.text }], validate.filter(lambda r: r["playerType"] in STREAM_TYPES)), } }, validate.get("video"), validate.get("videoReferences")) class SVTPlay(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_streams(self): res = http.get(self.url, params=dict(output="json")) videos = http.json(res, schema=_video_schema) streams = {}
""" import re from livestreamer.plugin import Plugin from livestreamer.plugin.api import http, validate from livestreamer.stream import HLSStream API_BASE = "http://gox.gomexp.com/cgi-bin" API_URL_APP = API_BASE + "/app_api.cgi" API_URL_LIVE = API_BASE + "/gox_live.cgi" _url_re = re.compile("http(s)?://(www\.)?gomexp.com") _entries_schema = validate.Schema( validate.xml_findall("./ENTRY/*/[@reftype='live'][@href]"), [validate.get("href")]) class GOMeXP(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_live_cubeid(self): res = http.get(API_URL_APP, params=dict(mode="get_live")) root = http.xml(res) return root.findtext("./cube/cubeid") def _get_streams(self): cubeid = self._get_live_cubeid()
_time_re = re.compile( """ (?: (?P<hours>\d+)h )? (?: (?P<minutes>\d+)m )? (?: (?P<seconds>\d+)s )? """, re.VERBOSE) _access_token_schema = validate.Schema( { "token": validate.text, "sig": validate.text }, validate.union((validate.get("sig"), validate.get("token")))) _token_schema = validate.Schema( { "chansub": { "restricted_bitrates": validate.all([validate.text], validate.filter(lambda n: not re.match( r"(.+_)?archives|live|chunked", n))) } }, validate.get("chansub")) _user_schema = validate.Schema( {validate.optional("display_name"): validate.text}, validate.get("display_name")) _video_schema = validate.Schema({
import re from livestreamer.plugin import Plugin from livestreamer.plugin.api import http, validate from livestreamer.stream import HLSStream STREAM_INFO_URL = "https://api.periscope.tv/api/v2/getAccessPublic" STATUS_GONE = 410 STATUS_UNAVAILABLE = (STATUS_GONE, ) _url_re = re.compile(r"http(s)?://(www\.)?periscope.tv/w/(?P<token>[\w\-\=]+)") _stream_schema = validate.Schema({"hls_url": validate.url(scheme="http")}, validate.get("hls_url")) class Periscope(Plugin): @classmethod def can_handle_url(cls, url): return _url_re.match(url) def _get_streams(self): match = _url_re.match(self.url) res = http.get(STREAM_INFO_URL, params=match.groupdict(), acceptable_status=STATUS_UNAVAILABLE) if res.status_code in STATUS_UNAVAILABLE: return playlist_url = http.json(res, schema=_stream_schema)
SHOW_STATUS_OFFLINE = 2 STREAM_WEIGHTS = {"low": 540, "middle": 720, "source": 1080} _url_re = re.compile( """ http(s)?://(www\.)?douyu.com /(?P<channel>[^/]+) """, re.VERBOSE) _json_re = re.compile(r"var\s*\$ROOM\s*=\s*({.+?});") _room_id_schema = validate.Schema( validate.all( validate.transform(_json_re.search), validate.any( None, validate.all(validate.get(1), validate.transform(parse_json), { "room_id": validate.any(validate.text, validate.transform(int)) })))) _room_schema = validate.Schema( { "data": validate.any(None, { "show_status": validate.all(validate.text, validate.transform(int)) }) }, validate.get("data")) _lapi_schema = validate.Schema(
(?P<domain>twitch.tv|justin.tv) / (?P<channel>[^/]+) (?: / (?P<video_type>[bc]) / (?P<video_id>\d+) )? """, re.VERBOSE) _access_token_schema = validate.Schema( { "token": validate.text, "sig": validate.text }, validate.union(( validate.get("sig"), validate.get("token") )) ) _token_schema = validate.Schema( { "chansub": { "restricted_bitrates": validate.all( [validate.text], validate.filter( lambda n: not re.match(r"(.+_)?archives|live|chunked", n) ) ) } },
import re from livestreamer.compat import urlparse from livestreamer.plugin import Plugin from livestreamer.plugin.api import StreamMapper, http, validate from livestreamer.stream import HLSStream, RTMPStream CHANNEL_URL = "http://www.mobileonline.tv/channel.php" _url_re = re.compile("http(s)?://(\w+\.)?(ilive.to|streamlive.to)/view/(?P<channel>\d+)") _link_re = re.compile("<p style=\"font-size:30px;\"><a href=(\S+) target=") _schema = validate.Schema( validate.transform(_link_re.findall), ) class StreamLive(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _create_hls_streams(self, url): try: streams = HLSStream.parse_variant_playlist(self.session, url) return streams.items() except IOError as err: self.logger.warning("Failed to extract HLS streams: {0}", err) def _create_rtmp_stream(self, url): parsed = urlparse(url) if parsed.query:
_content_id_re = re.compile("(?:data-videoid=\"|videostatus/\?id=)(\d+)") _url_id_re = re.compile(("https?://(?:www\.)?vgtv.no/" "(?:(?:#!/)?video/|(?:#!|\?)id=)(\d+)")) _video_schema = validate.Schema({ "status": 200, "formats": validate.all( dict, validate.filter(lambda k, v: k in STREAM_TYPES), { validate.text: validate.all( dict, validate.filter(lambda k, v: k in STREAM_FORMATS), { validate.text: [{ "bitrate": int, "paths": [{ "address": validate.text, "port": int, "path": validate.text, "filename": validate.text, "application": validate.text, }], }] }) }) }) class VGTV(Plugin): @classmethod
(?: (/embed/|/channel/id/)(?P<channel_id>\d+) )? (?: /recorded/(?P<video_id>\d+) )? """, re.VERBOSE) _channel_id_re = re.compile("\"cid\":(\d+)") HLS_PLAYLIST_URL = ("http://iphone-streaming.ustream.tv" "/uhls/{0}/streams/live/iphone/playlist.m3u8") RECORDED_URL = "http://tcdn.ustream.tv/video/{0}" RTMP_URL = "rtmp://r{0}.1.{1}.channel.live.ums.ustream.tv:80/ustream" SWF_URL = "http://static-cdn1.ustream.tv/swf/live/viewer.rsl:505.swf" _module_info_schema = validate.Schema(list, validate.length(1), validate.get(0), dict) _recorded_schema = validate.Schema({ validate.optional("stream"): [{ "name": validate.text, "streams": [{ "streamName": validate.text, "bitrate": float, }], validate.optional("url"): validate.text, }] }) _channel_schema = validate.Schema({ validate.optional("stream"): validate.any([{
from livestreamer.plugin.api import http, validate from livestreamer.stream import RTMPStream, HLSStream CHANNEL_INFO_URL = "http://live.afreecatv.com:8057/afreeca/player_live_api.php" ASSIGN_PATH = "/broad_stream_assign.html" CHANNEL_RESULT_ERROR = 0 CHANNEL_RESULT_OK = 1 # original, hd, sd quality = "original" _url_re = re.compile(r"http(s)?://afreeca.com/(?P<bid>\w+)(/\d+)?") _channel_schema = validate.Schema( { "CHANNEL": { "RESULT": validate.transform(int), "BNO": validate.text, "CDN": validate.text, "RMD": validate.text, } }, validate.get("CHANNEL")) _channel_aid_schema = validate.Schema( {"CHANNEL": { "RESULT": validate.transform(int), "AID": validate.text, }}, validate.get("CHANNEL")) _stream_schema = validate.Schema({ validate.optional("view_url"): validate.url(scheme=validate.any("rtmp", "http")) })
"medium": 2, "low": 1, } _url_re = re.compile( """ http(s)?://www\.gaminglive\.tv /\#/channels/(?P<channel>[^/]+) """, re.VERBOSE) _quality_re = re.compile("[^/]+-(?P<quality>[^/]+)") _channel_schema = validate.Schema( { validate.optional("state"): { "stream": { "qualities": [validate.text], "rootUrl": validate.url(scheme="rtmp") } } }, validate.get("state")) class GamingLive(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) @classmethod def stream_weight(cls, key): weight = QUALITY_WEIGHTS.get(key) if weight:
_quality_re = re.compile("(\d+p)$") _url_re = re.compile( """ http(s)?://(www\.)?hitbox.tv /(?P<channel>[^/]+) (?: /(?P<media_id>[^/]+) )? """, re.VERBOSE) _live_schema = validate.Schema( { "livestream": [{ "media_is_live": validate.all(validate.text, validate.transform(int), validate.transform(bool)), "media_id": validate.text }], }, validate.get("livestream"), validate.length(1), validate.get(0)) _player_schema = validate.Schema({ "clip": { "baseUrl": validate.any(None, validate.text), "bitrates": validate.all( validate.filter(lambda b: b.get("url") and b.get("label")), [{ "label": validate.text, "url": validate.text, }],
from livestreamer.stream import HTTPStream API_URL = "http://www.douyutv.com/api/client/room/{0}" _url_re = re.compile( """ http(s)?://(www\.)?douyutv.com /(?P<channel>[^/]+) """, re.VERBOSE) _room_schema = validate.Schema( { "data": validate.any( None, { "show_status": validate.all(validate.text, validate.transform(int)), "rtmp_url": validate.text, "rtmp_live": validate.text }) }, validate.get("data")) class Douyutv(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_streams(self): match = _url_re.match(self.url) channel = match.group("channel")
import re 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:
_config_schema = validate.Schema({ validate.optional("fmt_list"): validate.all(validate.text, validate.transform(parse_fmt_list)), validate.optional("url_encoded_fmt_stream_map"): validate.all(validate.text, validate.transform(parse_stream_map), [{ "itag": validate.all(validate.text, validate.transform(int)), "quality": validate.text, "url": validate.url(scheme="http"), validate.optional("s"): validate.text, validate.optional("stereo3d"): validate.all(validate.text, validate.transform(int), validate.transform(bool)), }]), validate.optional("adaptive_fmts"): validate.all(validate.text, validate.transform(parse_stream_map), [{ validate.optional("s"): validate.text, "type": validate.all(validate.text, validate.transform(lambda t: t.split(";")[0].split("/")), [validate.text, validate.text]), "url": validate.all(validate.url(scheme="http")) }]), validate.optional("hlsvp"): validate.text, validate.optional("live_playback"): validate.transform(bool), "status": validate.text })
tv(3|6|8|10)play | viasat4play | play.tv3 ) \. (?: dk|ee|lt|lv|no|se|com ) (/.+?/|/embed\?id=) (?P<stream_id>\d+) """, re.VERBOSE) _stream_schema = validate.Schema( { "streams": validate.all( {validate.text: validate.any(validate.text, int, None)}, validate.filter(lambda k, v: isinstance(v, validate.text))) }, validate.get("streams")) class Viasat(Plugin): @classmethod def can_handle_url(cls, url): return _url_re.match(url) def _get_swf_url(self): res = http.get(self.url) match = _swf_url_re.search(res.text) if not match: raise PluginError("Unable to find SWF URL in the HTML")
"360": 1, "low": 1 } _url_re = re.compile( """ http(s)?://(\w+\.)?gaminglive\.tv /(?P<type>channels|videos)/(?P<name>[^/]+) """, re.VERBOSE) _quality_re = re.compile("[^/]+-(?P<quality>[^/]+)") _channel_schema = validate.Schema( { validate.optional("state"): { "stream": { "qualities": [validate.text], "rootUrl": validate.url(scheme="rtmp") } } }, validate.get("state")) _vod_schema = validate.Schema( { "name": validate.text, "channel_slug": validate.text, "title": validate.text, "created_at": validate.transform(int) }, ) class GamingLive(Plugin):
import re from itertools import chain from livestreamer.compat import urlparse from livestreamer.plugin import Plugin from livestreamer.plugin.api import http, validate from livestreamer.stream import HLSStream, HTTPStream, RTMPStream SWF_URL = "http://www.arte.tv/player/v2/jwplayer6/mediaplayer.6.6.swf" _url_re = re.compile("http(s)?://(\w+\.)?arte.tv/") _json_re = re.compile("arte_vp_(?:live-)?url=(['\"])(.+?)\\1") _schema = validate.Schema( validate.transform(_json_re.search), validate.any(None, validate.all(validate.get(2), validate.url(scheme="http")))) _video_schema = validate.Schema({ "videoJsonPlayer": { "VSR": validate.any( [], { validate.text: { "height": int, "mediaType": validate.text, "url": validate.text, validate.optional("streamer"): validate.text }, }, ),
http(s)?://(\w+\.)? (?P<domain>vaughnlive|breakers|instagib|vapers).tv /(?P<channel>[^/&?]+) """, re.VERBOSE) _channel_not_found_re = re.compile("<title>Channel Not Found") def decode_token(token): return token.replace("0m0", "") _schema = validate.Schema( validate.transform(lambda s: s.split(";:mvnkey%")), validate.length(2), validate.union({ "server": validate.all(validate.get(0), validate.text), "token": validate.all(validate.get(1), validate.text, validate.transform(decode_token)) })) class VaughnLive(Plugin): @classmethod def can_handle_url(cls, url): return _url_re.match(url) def _get_streams(self): res = http.get(self.url) if _channel_not_found_re.search(res.text): return