class NineAnime(Plugin): _episode_info_url = "http://9anime.to/ajax/episode/info" _info_schema = validate.Schema({ "grabber": validate.url(), "params": { "id": validate.text, "token": validate.text, "options": validate.text, } }) _streams_schema = validate.Schema({ "token": validate.text, "error": None, "data": [{ "label": validate.text, "file": validate.url(), "type": "mp4" }] }) _user_agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) "\ "Chrome/36.0.1944.9 Safari/537.36" _url_re = re.compile(r"https?://9anime.to/watch/(?:[^.]+?\.)(\w+)/(\w+)") @classmethod def can_handle_url(cls, url): return cls._url_re.match(url) is not None def _get_streams(self): match = self._url_re.match(self.url) film_id, episode_id = match.groups() headers = {"Referer": self.url, "User-Agent": self._user_agent} # Get the info about the Episode, including the Grabber API URL info_res = http.get(self._episode_info_url, params=dict(update=0, film=film_id, id=episode_id), headers=headers) info = http.json(info_res, schema=self._info_schema) # Get the data about the streams from the Grabber API stream_list_res = http.get(info["grabber"], params=info["params"], headers=headers) stream_data = http.json(stream_list_res, schema=self._streams_schema) for stream in stream_data["data"]: yield stream["label"], HTTPStream(self.session, stream["file"])
class TV8(Plugin): """ Support for the live stream on www.tv8.com.tr """ url_re = re.compile(r"https?://www.tv8.com.tr/canli-yayin") player_config_re = re.compile( r""" configPlayer.source.media.push[ ]*\( [ ]*\{[ ]*'src':[ ]*"(.*?)", [ ]*type:[ ]*"application/x-mpegURL"[ ]*}[ ]*\); """, re.VERBOSE) player_config_schema = validate.Schema( validate.transform(player_config_re.search), validate.any(None, validate.all(validate.get(1), validate.url()))) @classmethod def can_handle_url(cls, url): return cls.url_re.match(url) is not None def _get_streams(self): res = http.get(self.url) stream_url = self.player_config_schema.validate(res.text) if stream_url: return HLSStream.parse_variant_playlist(self.session, stream_url)
class TV360(Plugin): url_re = re.compile(r"https?://(?:www.)?tv360.com.tr/CanliYayin") data_re = re.compile(r'''div.*?data-tp=(?P<q>["'])(?P<data>.*?)(?P=q)''', re.DOTALL) _js_to_json = partial(re.compile(r"""(\w+):(["']|\d+,|true|false)""").sub, r'"\1":\2') data_schema = validate.Schema( validate.transform(data_re.search), validate.any( None, validate.all( validate.get("data"), validate.transform(_js_to_json), validate.transform(lambda x: x.replace("'", '"')), validate.transform(parse_json), { "tp_type": "hls4", "tp_file": validate.url(), } ) ) ) @classmethod def can_handle_url(cls, url): return cls.url_re.match(url) is not None def _get_streams(self): res = http.get(self.url) data = self.data_schema.validate(res.text) if data: return HLSStream.parse_variant_playlist(self.session, data["tp_file"])
class LiveMe(Plugin): url_re = re.compile(r"https?://(www.)?liveme.com/media/play/(.*)") api_url = "http://live.ksmobile.net/live/queryinfo?userid=1&videoid={id}" api_schema = validate.Schema( validate.all( { "status": "200", "data": { "video_info": { "videosource": validate.any('', validate.url()), "hlsvideosource": validate.any('', validate.url()), } } }, validate.get("data"))) @classmethod def can_handle_url(cls, url): return cls.url_re.match(url) is not None def _make_stream(self, url): if url and url.endswith("flv"): return HTTPStream(self.session, url) elif url and url.endswith("m3u8"): return HLSStream(self.session, url) def _get_streams(self): url_params = dict(parse_qsl(urlparse(self.url).query)) video_id = url_params.get("videoid") if video_id: self.logger.debug("Found Video ID: {}", video_id) res = http.get(self.api_url.format(id=video_id)) data = http.json(res, schema=self.api_schema) hls = self._make_stream(data["video_info"]["hlsvideosource"]) video = self._make_stream(data["video_info"]["videosource"]) if hls: yield "live", hls if video: yield "live", video
class TVPlayer(Plugin): _user_agent = ( "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/43.0.2357.65 Safari/537.36") API_URL = "http://api.tvplayer.com/api/v2/stream/live" _url_re = re.compile( r"https?://(?:www.)?tvplayer.com/(:?watch/?|watch/(.+)?)") _stream_attrs_ = re.compile( r'var\s+(validate|platform|resourceId)\s+=\s*(.*?);', re.S) _stream_schema = validate.Schema({ "tvplayer": validate.Schema({ "status": u'200 OK', "response": validate.Schema( {"stream": validate.url(scheme=validate.any("http"))}) }) }) @classmethod def can_handle_url(cls, url): match = TVPlayer._url_re.match(url) return match is not None def _get_streams(self): # find the list of channels from the html in the page self.url = self.url.replace("https", "http") # https redirects to http res = http.get(self.url, headers={"User-Agent": TVPlayer._user_agent}) stream_attrs = dict( (k, v.strip('"')) for k, v in TVPlayer._stream_attrs_.findall(res.text)) # get the stream urls res = http.post(TVPlayer.API_URL, data=dict(id=stream_attrs["resourceId"], validate=stream_attrs["validate"], platform=stream_attrs["platform"])) stream_data = http.json(res, schema=TVPlayer._stream_schema) return HLSStream.parse_variant_playlist( self.session, stream_data["tvplayer"]["response"]["stream"], headers={'user-agent': TVPlayer._user_agent})
class Turkuvaz(Plugin): """ Plugin to support ATV/A2TV Live streams from www.atv.com.tr and www.a2tv.com.tr """ _url_re = re.compile( r"""https?://(?:www.)? (?: (atv|a2tv|ahaber|aspor|minikago|minikacocuk).com.tr/webtv/canli-yayin| (atvavrupa).tv/webtv/videoizle/atv_avrupa/canli_yayin )""", re.VERBOSE) _hls_url = "http://trkvz-live.ercdn.net/{channel}/{channel}.m3u8" _token_url = "http://videotoken.tmgrup.com.tr/webtv/secure" _token_schema = validate.Schema( validate.all({ "Success": True, "Url": validate.url(), }, validate.get("Url"))) @classmethod def can_handle_url(cls, url): return cls._url_re.match(url) is not None def _get_streams(self): url_m = self._url_re.match(self.url) domain = url_m.group(1) or url_m.group(2) # remap the domain to channel channel = { "atv": "atvhd", "ahaber": "ahaberhd", "aspor": "asporhd" }.get(domain, domain) hls_url = self._hls_url.format(channel=channel) # get the secure HLS URL res = http.get(self._token_url, params={"url": hls_url}) secure_hls_url = http.json(res, schema=self._token_schema) return HLSStream.parse_variant_playlist(self.session, secure_hls_url)
class CinerGroup(Plugin): """ Support for the live stream on www.showtv.com.tr """ url_re = re.compile( r"""https?://(?:www.)? (?: showtv.com.tr/canli-yayin/showtv| haberturk.com/canliyayin| showmax.com.tr/canliyayin| showturk.com.tr/canli-yayin/showturk| bloomberght.com/tv| haberturk.tv/canliyayin )/?""", re.VERBOSE) stream_re = re.compile( r"""div .*? data-ht=(?P<quote>["'])(?P<data>.*?)(?P=quote)""", re.DOTALL) stream_data_schema = validate.Schema( validate.transform(stream_re.search), validate.any( None, validate.all( validate.get("data"), validate.transform(unquote), validate.transform(lambda x: x.replace(""", '"')), validate.transform(json.loads), {"ht_stream_m3u8": validate.url()}, validate.get("ht_stream_m3u8")))) @classmethod def can_handle_url(cls, url): return cls.url_re.match(url) is not None def _get_streams(self): res = http.get(self.url) stream_url = self.stream_data_schema.validate(res.text) if stream_url: return HLSStream.parse_variant_playlist(self.session, stream_url)
class PowerApp(Plugin): url_re = re.compile(r"https?://(?:www.)?powerapp.com.tr/tv/(\w+)") api_url = "http://api.powergroup.com.tr/Channels/{}/?appRef=iPowerWeb&apiVersion=11" api_schema = validate.Schema( validate.all( { "errorCode": 0, "response": { "channel_stream_url": validate.url() } }, validate.get("response"))) @classmethod def can_handle_url(cls, url): return cls.url_re.match(url) is not None def _get_streams(self): channel = self.url_re.match(self.url).group(1) res = http.get(self.api_url.format(channel)) data = http.json(res, schema=self.api_schema) return HLSStream.parse_variant_playlist(self.session, data["channel_stream_url"])
"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): @classmethod
class Dogan(Plugin): """ Support for the live streams from Doğan Media Group channels """ url_re = re.compile( r""" https?://(?:www.)? (?:teve2.com.tr/(?:canli-yayin|filmler/.*|programlar/.*)| kanald.com.tr/.*| cnnturk.com/canli-yayin| dreamtv.com.tr/canli-yayin| dreamturk.com.tr/canli) """, re.VERBOSE) playerctrl_re = re.compile( r'''<div[^>]*?ng-controller=(?P<quote>["'])(?:Live)?PlayerCtrl(?P=quote).*?>''', re.DOTALL) data_id_re = re.compile( r'''data-id=(?P<quote>["'])(?P<id>\w+)(?P=quote)''') content_id_re = re.compile(r'"contentId", "(\w+)"') content_api = "/actions/content/media/{id}" alt_content_api = "/action/media/{id}" content_api_schema = validate.Schema({ "Id": validate.text, "Media": { "Link": { "DefaultServiceUrl": validate.url(), validate.optional("ServiceUrl"): validate.url(), "SecurePath": validate.text, } } }) @classmethod def can_handle_url(cls, url): return cls.url_re.match(url) is not None def _get_content_id(self): res = http.get(self.url) # find the PlayerCtrl div player_ctrl_m = self.playerctrl_re.search(res.text) if player_ctrl_m: # extract the content id from the player control data player_ctrl_div = player_ctrl_m.group(0) content_id_m = self.data_id_re.search(player_ctrl_div) if content_id_m: return content_id_m.group("id") # use the fall back regex content_id_m = self.content_id_re.search(res.text) return content_id_m and content_id_m.group(1) def _get_hls_url(self, content_id): # make the api url relative to the current domain if "cnnturk" in self.url: self.logger.debug("Using alternative content API url") api_url = urljoin(self.url, self.alt_content_api.format(id=content_id)) else: api_url = urljoin(self.url, self.content_api.format(id=content_id)) apires = http.get(api_url) stream_data = http.json(apires, schema=self.content_api_schema) d = stream_data["Media"]["Link"] return urljoin((d["ServiceUrl"] or d["DefaultServiceUrl"]), d["SecurePath"]) def _get_streams(self): content_id = self._get_content_id() if content_id: self.logger.debug(u"Loading content: {}", content_id) hls_url = self._get_hls_url(content_id) return HLSStream.parse_variant_playlist(self.session, hls_url) else: self.logger.error(u"Could not find the contentId for this stream")
from ACEStream.PluginsContainer.livestreamer.plugin.api import http, validate from ACEStream.PluginsContainer.livestreamer.stream import HLSStream COOKIE_PARAMS = ("devicetype=desktop&" "preferred-player-odm=hlslink&" "preferred-player-live=hlslink") _id_re = re.compile("/(?:program|direkte|serie/[^/]+)/([^/]+)") _url_re = re.compile("https?://(tv|radio).nrk.no/") _api_baseurl_re = re.compile('apiBaseUrl:\s*"(?P<baseurl>[^"]+)"') _schema = validate.Schema( validate.transform(_api_baseurl_re.search), validate.any( None, validate.all(validate.get("baseurl"), validate.url(scheme="http")))) _mediaelement_schema = validate.Schema( {"mediaUrl": validate.url(scheme="http", path=validate.endswith(".m3u8"))}) class NRK(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_streams(self): # Get the stream type from the url (tv/radio). stream_type = _url_re.match(self.url).group(1).upper() cookie = {"NRK_PLAYER_SETTINGS_{0}".format(stream_type): COOKIE_PARAMS}
class Dogus(Plugin): """ Support for live streams from Dogus sites include startv, ntv, ntvspor, and kralmuzik """ url_re = re.compile( r"""https?://(?:www.)? (?: startv.com.tr/canli-yayin| ntv.com.tr/canli-yayin/ntv| ntvspor.net/canli-yayin| kralmuzik.com.tr/tv/kral-tv| kralmuzik.com.tr/tv/kral-pop-tv )/?""", re.VERBOSE) mobile_url_re = re.compile( r"""(?P<q>[\"'])(?P<url>https?://[^'"]*?/live/hls/[^'"]*?\?token=) (?P<token>[^'"]*?)(?P=q)""", re.VERBOSE) desktop_url_re = re.compile( r"""(?P<q>[\"'])(?P<url>https?://[^'"]*?/live/hds/[^'"]*?\?token=) (?P<token>[^'"]*?)(?P=q)""", re.VERBOSE) token_re = re.compile(r"""token=(?P<q>[\"'])(?P<token>[^'"]*?)(?P=q)""") hds_schema = validate.Schema( validate.all( { "success": True, "xtra": { "url": validate.url(), "use_akamai": bool } }, validate.get("xtra"))) SWF_URL = "http://dygassets.akamaized.net/player2/plugins/flowplayer/flowplayer.httpstreaming-3.2.11.swf" @classmethod def can_handle_url(cls, url): return cls.url_re.match(url) is not None def _get_star_streams(self, desktop_url, mobile_url, token=""): if token: self.logger.debug("Opening stream with token: {}", token) if mobile_url: for _, s in HLSStream.parse_variant_playlist(self.session, mobile_url + token, headers={ "Referer": self.url }).items(): yield "live", s if desktop_url: # get the HDS stream URL res = http.get(desktop_url + token) stream_data = http.json(res, schema=self.hds_schema) for _, s in HDSStream.parse_manifest( self.session, stream_data["url"], pvswf=self.SWF_URL, is_akamai=stream_data["use_akamai"], headers={ "Referer": self.url }).items(): yield "live", s def _get_streams(self): res = http.get(self.url) mobile_url_m = self.mobile_url_re.search(res.text) desktop_url_m = self.desktop_url_re.search(res.text) desktop_url = desktop_url_m and desktop_url_m.group("url") mobile_url = mobile_url_m and mobile_url_m.group("url") token = (desktop_url_m and desktop_url_m.group("token")) or ( mobile_url_m and mobile_url_m.group("token")) if not token: # if no token is in the url, try to find it else where in the page token_m = self.token_re.search(res.text) token = token_m and token_m.group("token") return self._get_star_streams(desktop_url, mobile_url, token=token)
formats[int(s[0])] = "{0}p".format(h) return formats _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":
import re from ACEStream.PluginsContainer.livestreamer.plugin import Plugin from ACEStream.PluginsContainer.livestreamer.plugin.api import http, validate from ACEStream.PluginsContainer.livestreamer.stream import HLSStream _url_re = re.compile("http(s)?://(www\.)?openrec.tv/(live|movie)/[^/?&]+") _playlist_url_re = re.compile("data-file=\"(?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 OPENRECtv(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
#!/usr/bin/env python #-plugin-sig:j5IvF8YBcLoDm+PQagnwUnnyhIUaeWtb571lPo8bfkQ6gjvBdfOaKbEHp/GyEby4t6Kkj4C+ZyJ66jEdVSHvAFFCMjQkDcWRnwNrq0MkM00umifbqh2QzrftiDZbGiTzcqCue3gWenHU3E6NUmLxbbY/wYrpSM4Is0cf358kJ3PcDgyoIEibqxxV4feJCu0/95GWxQJ7OILfqTs15+nhGYkgDtWNHAD55jxq7BKIwFI/J5otPp094RW7gY3oThv8xagrn0OIVf9J75Nyha8rebWRoE9cHYaC6urzD3ji9H7P1v6DNaRTlkk5cmasUP8b1y/Y35eEUe9hiwtnw2HeRQ== import re from ACEStream.PluginsContainer.livestreamer.plugin import Plugin from ACEStream.PluginsContainer.livestreamer.plugin.api import http from ACEStream.PluginsContainer.livestreamer.stream import HLSStream from ACEStream.PluginsContainer.livestreamer.plugin.api import validate STREAM_INFO_URL = "http://dinamics.ccma.cat/pvideo/media.jsp?media=video&version=0s&idint={ident}&profile=pc&desplacament=0" _url_re = re.compile(r"http://(?:www.)?ccma.cat/tv3/directe/(.+?)/") _media_schema = validate.Schema({ "geo": validate.text, "url": validate.url(scheme=validate.any("http")) }) _channel_schema = validate.Schema({ "media": validate.any([_media_schema], _media_schema) }) class TV3Cat(Plugin): @classmethod def can_handle_url(self, url): match = _url_re.match(url) return match def _get_streams(self): match = _url_re.match(self.url) if match: ident = match.group(1)
API_URL = "http://veetle.com/index.php/stream/ajaxStreamLocation/{0}/flash" _url_re = re.compile( """ http(s)?://(\w+\.)?veetle.com (:? /.*(v|view)/ (?P<channel>[^/]+/[^/&?]+) )? """, re.VERBOSE) _schema = validate.Schema({ validate.optional("isLive"): bool, "payload": validate.any(int, validate.url(scheme="http")), "success": bool }) class Veetle(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_streams(self): self.url = http.resolve_url(self.url) match = _url_re.match(self.url) parsed = urlparse(self.url) if parsed.fragment:
from ACEStream.PluginsContainer.livestreamer.plugin.api import http, validate from ACEStream.PluginsContainer.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/[^/]+/(?P<broadcast_id>[\w\-\=]+)") _stream_schema = validate.Schema( validate.any( None, validate.union({ "hls_url": validate.all({"hls_url": validate.url(scheme="http")}, validate.get("hls_url")), }), validate.union({ "replay_url": validate.all({"replay_url": validate.url(scheme="http")}, validate.get("replay_url")), }), ), ) class Periscope(Plugin): @classmethod def can_handle_url(cls, url): return _url_re.match(url)
"http(s)?://(\w+\.)?(afreecatv.jp)/(?P<channel>[\w\-_]+)") _flashvars_re = re.compile('<param name="flashvars" value="([^"]+)" />') _flashvars_schema = validate.Schema( validate.transform(_flashvars_re.findall), validate.get(0), validate.transform(parse_query), validate.any({ "s": validate.text, "id": validate.text }, {})) _view_live_schema = validate.Schema( { "channel": { "strm": [{ "bps": validate.text, "purl": validate.url(scheme="rtmp") }] }, }, validate.get("channel"), validate.get("strm")) class AfreecaTV(Plugin): @classmethod def can_handle_url(cls, url): return _url_re.match(url) def _get_streams(self): flashvars = http.get(self.url, schema=_flashvars_schema) if not flashvars: return
"http(s)?://(\w+\.)?afreeca(tv)?.com/(?P<username>\w+)(/\d+)?") _channel_schema = validate.Schema( { "CHANNEL": { "RESULT": validate.transform(int), "BROAD_INFOS": [{ "list": [{ "nBroadNo": validate.text }] }] } }, validate.get("CHANNEL")) _stream_schema = validate.Schema({ validate.optional("view_url"): validate.url(scheme=validate.any("rtmp", "http")) }) class AfreecaTV(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_channel_info(self, username): headers = {"Referer": self.url} params = {"uid": username} res = http.get(CHANNEL_INFO_URL, params=params, headers=headers) return http.json(res, schema=_channel_schema)
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"): validate.text, validate.optional("reconnect_time"): validate.text, }, { "status": validate.transform(int),
class AdultSwim(Plugin): _user_agent = ( "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_3) AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/43.0.2357.65 Safari/537.36") API_URL = "http://www.adultswim.com/videos/api/v2/videos/{id}?fields=stream" _url_re = re.compile(r"http://www\.adultswim\.com/videos/streams/(.*)") _stream_data_re = re.compile(r".*AS_INITIAL_DATA = (\{.*?});.*", re.M | re.DOTALL) _page_data_schema = validate.Schema( {u"streams": { validate.text: { u"stream": validate.text } }}) _api_schema = validate.Schema({ u'status': u'ok', u'data': { u'stream': { u'assets': [{ u'url': validate.url() }] } } }) @classmethod def can_handle_url(cls, url): match = AdultSwim._url_re.match(url) return match is not None def _get_streams(self): # get the page res = http.get(self.url, headers={"User-Agent": self._user_agent}) # find the big blob of stream info in the page stream_data = self._stream_data_re.match(res.text) stream_name = AdultSwim._url_re.match( self.url).group(1) or "live-stream" if stream_data: # parse the stream info as json stream_info = parse_json(stream_data.group(1), schema=self._page_data_schema) # get the stream ID stream_id = stream_info[u"streams"][stream_name][u"stream"] if stream_id: api_url = self.API_URL.format(id=stream_id) res = http.get(api_url, headers={"User-Agent": self._user_agent}) stream_data = http.json(res, schema=self._api_schema) for asset in stream_data[u'data'][u'stream'][u'assets']: for n, s in HLSStream.parse_variant_playlist( self.session, asset[u"url"]).items(): yield n, s else: self.logger.error( "Couldn't find the stream ID for this stream: {}".format( stream_name)) else: self.logger.error( "Couldn't find the stream data for this stream: {}".format( stream_name))
from itertools import chain from ACEStream.PluginsContainer.livestreamer.compat import urlparse from ACEStream.PluginsContainer.livestreamer.plugin import Plugin from ACEStream.PluginsContainer.livestreamer.plugin.api import http, validate from ACEStream.PluginsContainer.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 }, }, ), "VTY":
_live_re = re.compile(""" \s*jwplayer\(\"player\"\)\.setup\({.*? \s*primary:\s+"([^"]+)".*? \s*file:\s+"([^"]+)" """, re.DOTALL) _live_schema = validate.Schema( validate.transform(_live_re.search), validate.any( None, validate.union({ "type": validate.get(1), "url": validate.all( validate.get(2), validate.url(scheme="http"), ), }) ) ) class SSH101(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_streams(self): res = http.get(self.url, schema=_live_schema) if not res: return
_url_re = re.compile("http(s)?://(\w+\.)?filmon.us") _live_export_re = re.compile( "<iframe src=\"(https://www.filmon.com/channel/export[^\"]+)\"") _live_json_re = re.compile("var startupChannel = (.+);") _replay_json_re = re.compile( "var standByVideo = encodeURIComponent\('(.+)'\);") _history_re = re.compile( "helpers.common.flash.flashplayerinstall\({url:'([^']+)',") _video_flashvars_re = re.compile( "<embed width=\"486\" height=\"326\" flashvars=\"([^\"]+)\"") _live_schema = validate.Schema({ "streams": [{ "name": validate.text, "quality": validate.text, "url": validate.url(scheme="rtmp") }] }) _schema = validate.Schema( validate.union({ "export_url": validate.all(validate.transform(_live_export_re.search), validate.any( None, validate.get(1), )), "video_flashvars": validate.all( validate.transform(_video_flashvars_re.search), validate.any( None,
{ "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({ "chunks": { validate.text: [{ "length": int, "url": validate.any(None, validate.url(scheme="http")), "upkeep": validate.any("pass", "fail", None) }] }, "restrictions": { validate.text: validate.text }, "start_offset": int, "end_offset": int, }) _viewer_info_schema = validate.Schema( {validate.optional("login"): validate.text}, validate.get("login")) _viewer_token_schema = validate.Schema( {validate.optional("token"): validate.text}, validate.get("token")) _quality_options_schema = validate.Schema( {
from ACEStream.PluginsContainer.livestreamer.compat import urljoin from ACEStream.PluginsContainer.livestreamer.plugin import Plugin from ACEStream.PluginsContainer.livestreamer.plugin.api import http, validate from ACEStream.PluginsContainer.livestreamer.plugin.api.utils import parse_json from ACEStream.PluginsContainer.livestreamer.stream import AkamaiHDStream, HLSStream _url_re = re.compile("http(s)?://(www\.)?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("playerUri"): validate.text, validate.optional("viewerPlusSwfUrl"): validate.url(scheme="http"), validate.optional("lsPlayerSwfUrl"): validate.text, 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"
"data": validate.any( None, { "channel": validate.any( None, { "id": validate.all(validate.text, validate.transform(int)), "vid": int }) }) }, validate.get("data")) _plu_schema = validate.Schema({ "urls": [{ "securityUrl": validate.url(scheme=validate.any("rtmp", "http")), "resolution": validate.text, "ext": validate.text }] }) _qq_schema = validate.Schema( {validate.optional("playurl"): validate.url(scheme="http")}, validate.get("playurl")) STREAM_WEIGHTS = {"middle": 540, "source": 1080} class Tga(Plugin): @classmethod def can_handle_url(self, url):
class Euronews(Plugin): _url_re = re.compile("http(?:s)?://(\w+)\.?euronews.com/(live|.*)") _re_vod = re.compile( r'<meta\s+property="og:video"\s+content="(http.*?)"\s*/>') _live_api_url = "http://fr.euronews.com/api/watchlive.json" _live_schema = validate.Schema({u"url": validate.url()}) _stream_api_schema = validate.Schema({ u'status': u'ok', u'primary': { validate.text: { validate.optional(u'hls'): validate.url(), validate.optional(u'rtsp'): validate.url(scheme="rtsp") } }, validate.optional(u'backup'): { validate.text: { validate.optional(u'hls'): validate.url(), validate.optional(u'rtsp'): validate.url(scheme="rtsp") } } }) @classmethod def can_handle_url(cls, url): return cls._url_re.match(url) def _get_vod_stream(self): """ Find the VOD video url :return: video url """ res = http.get(self.url) video_urls = self._re_vod.findall(res.text) if len(video_urls): return dict(vod=HTTPStream(self.session, video_urls[0])) def _get_live_streams(self, language): """ Get the live stream in a particular language :param language: :return: """ res = http.get(self._live_api_url) live_res = http.json(res, schema=self._live_schema) api_res = http.get(live_res[u"url"]) stream_data = http.json(api_res, schema=self._stream_api_schema) # find the stream in the requested language if language in stream_data[u'primary']: playlist_url = stream_data[u'primary'][language][u"hls"] return HLSStream.parse_variant_playlist(self.session, playlist_url) def _get_streams(self): """ Find the streams for euronews :return: """ match = self._url_re.match(self.url) language, path = match.groups() # remap domain to language (default to english) language = { "www": "en", "": "en", "arabic": "ar" }.get(language, language) if path == "live": return self._get_live_streams(language) else: return self._get_vod_stream()
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):
from time import time from ACEStream.PluginsContainer.livestreamer.plugin import Plugin, PluginError from ACEStream.PluginsContainer.livestreamer.plugin.api import http, validate from ACEStream.PluginsContainer.livestreamer.stream import RTMPStream, HLSStream SWF_URL = "http://play.streamingvideoprovider.com/player2.swf" API_URL = "http://player.webvideocore.net/index.php" _url_re = re.compile( "http(s)?://(\w+\.)?streamingvideoprovider.co.uk/(?P<channel>[^/&?]+)") _hls_re = re.compile("'(http://.+\.m3u8)'") _rtmp_schema = validate.Schema(validate.xml_findtext("./info/url"), validate.url(scheme="rtmp")) _hls_schema = validate.Schema( validate.transform(_hls_re.search), validate.any( None, validate.all( validate.get(1), validate.url(scheme="http", path=validate.endswith("m3u8"))))) class Streamingvideoprovider(Plugin): @classmethod def can_handle_url(self, url): return _url_re.match(url) def _get_hls_stream(self, channel_name):