def _get_live_streams(self): stream_id = _id_map[self.channel_path] if stream_id == "ruv": qualities_rtmp = ["720p", "480p", "360p", "240p"] for i, quality in enumerate(qualities_rtmp): yield quality, RTMPStream( self.session, { "rtmp": RTMP_LIVE_URL.format(stream_id, i + 1), "pageUrl": self.url, "live": True }) qualities_hls = ["240p", "360p", "480p", "720p"] for i, quality_hls in enumerate(qualities_hls): yield quality_hls, HLSStream(self.session, HLS_RUV_LIVE_URL.format(i + 1)) else: yield "audio", RTMPStream( self.session, { "rtmp": RTMP_LIVE_URL.format(stream_id, 1), "pageUrl": self.url, "live": True }) yield "audio", HLSStream(self.session, HLS_RADIO_LIVE_URL.format(stream_id))
def _create_hls_streams(self, bitrate): url = bitrate["url"] quality = self._get_quality(bitrate["label"]) if not url.startswith("http"): url = HLS_PLAYLIST_BASE.format(url) if bitrate["label"] == "Auto": 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) else: return quality, HLSStream(self.session, url)
def _get_streams(self): res = http.get(self.url) match = _info_re.search(res.text) if not match: return info = parse_json(match.group(1), schema=_schema) streams = defaultdict(list) stream_name = info["mode"] mp4_url = info.get("mp4_url") ios_url = info.get("ios_url") swf_url = info.get("swf_url") if mp4_url: stream = HTTPStream(self.session, mp4_url) streams[stream_name].append(stream) if ios_url: if urlparse(ios_url).path.endswith(".m3u8"): hls_streams = HLSStream.parse_variant_playlist( self.session, ios_url ) for name, stream in hls_streams.items(): streams[name].append(stream) if swf_url: stream = self._get_rtmp_streams(swf_url) if stream: streams[stream_name].append(stream) return streams
def _get_sarpurinn_streams(self): res = http.get(self.url) match = _rtmp_url_re.search(res.text) if not match: yield token = match.group("id") status = match.group("status") extension = match.group("ext") date = match.group("date") if not date: date = "" if extension == "mp3": key = "audio" else: key = "576p" # HLS on Sarpurinn is currently only available on videos yield key, HLSStream( self.session, HLS_SARPURINN_URL.format(status, date, token, extension)) yield key, RTMPStream( self.session, { "rtmp": RTMP_SARPURINN_URL.format(status, date, token, extension), "pageUrl": self.url, "live": True })
def _get_hls_streams(self, type="live"): self._authenticate() sig, token = self._access_token(type) if type == "live": url = self.usher.channel(self.channel, sig=sig, token=token) elif type == "video": url = self.usher.video(self.video_id, nauthsig=sig, nauth=token) try: streams = HLSStream.parse_variant_playlist(self.session, url) except IOError as err: err = str(err) if "404 Client Error" in err or "Failed to parse playlist" in err: return else: raise PluginError(err) try: token = parse_json(token, schema=_token_schema) for name in token["restricted_bitrates"]: if name not in streams: self.logger.warning( "The quality '{0}' is not available " "since it requires a subscription.", name) except PluginError: pass return streams
def _create_stream(self, stream, is_live): stream_name = "{0}p".format(stream["height"]) stream_type = stream["mediaType"] stream_url = stream["url"] if stream_type in ("hls", "mp4"): if urlparse(stream_url).path.endswith("m3u8"): try: streams = HLSStream.parse_variant_playlist( self.session, stream_url) # TODO: Replace with "yield from" when dropping Python 2. for stream in streams.items(): yield stream except IOError as err: self.logger.error("Failed to extract HLS streams: {0}", err) else: yield stream_name, HTTPStream(self.session, stream_url) elif stream_type == "rtmp": params = { "rtmp": stream["streamer"], "playpath": stream["url"], "swfVfy": SWF_URL, "pageUrl": self.url, } if is_live: params["live"] = True else: params["playpath"] = "mp4:{0}".format(params["playpath"]) stream = RTMPStream(self.session, params) yield stream_name, stream
def _get_streams(self): self.logger.debug("Fetching stream info") res = http.get(self.url) match = re.search("var info = (.*);", res.text) if not match: raise NoStreamsError(self.url) json = parse_json(match.group(1)) if not isinstance(json, dict): return ios_url = json.get("ios_url") swf_url = json.get("swf_url") streams = {} if ios_url: hls = HLSStream.parse_variant_playlist(self.session, ios_url) streams.update(hls) if swf_url: try: streams["live"] = self._get_rtmp_streams(swf_url) except NoStreamsError: pass return streams
def _get_hls_streams(self, type="live"): self._authenticate() sig, token = self._access_token(type) if type == "live": url = self.usher.select(self.channel, nauthsig=sig, nauth=token) elif type == "video": url = self.usher.vod(self.video_id, nauthsig=sig, nauth=token) try: streams = HLSStream.parse_variant_playlist(self.session, url) except IOError as err: err = str(err) if "404 Client Error" in err or "Failed to parse playlist" in err: return else: raise PluginError(err) try: token = parse_json(token, schema=_token_schema) for name in token["restricted_bitrates"]: if name not in streams: self.logger.warning("The quality '{0}' is not available " "since it requires a subscription.", name) except PluginError: pass return streams
def _get_streams(self): match = _url_re.match(self.url) channel = match.group("channel") channel = channel.replace("_", "-") playlist_url = PLAYLIST_URL.format(channel) return HLSStream.parse_variant_playlist(self.session, playlist_url)
def _get_streams(self): res = http.get(self.url) match = _info_re.search(res.text) if not match: return info = parse_json(match.group(1), schema=_schema) stream_name = info["mode"] mp4_url = info.get("mp4_url") ios_url = info.get("ios_url") swf_url = info.get("swf_url") if mp4_url: stream = HTTPStream(self.session, mp4_url) yield stream_name, stream if ios_url: if urlparse(ios_url).path.endswith(".m3u8"): streams = HLSStream.parse_variant_playlist(self.session, ios_url) # TODO: Replace with "yield from" when dropping Python 2. for stream in streams.items(): yield stream if swf_url: stream = self._get_rtmp_stream(swf_url) if stream: yield stream_name, stream
def _get_live_streams(self): self._authenticate() sig, token = self._access_token() url = self.usher.select(self.channel, password=self.options.get("password"), nauthsig=sig, nauth=token) try: streams = HLSStream.parse_variant_playlist(self.session, url) except IOError as err: err = str(err) if "404 Client Error" in err or "Failed to parse playlist" in err: return else: raise PluginError(err) try: token = parse_json(token, schema=_token_schema) for name in token["restricted_bitrates"]: if name not in streams: self.logger.warning("The quality '{0}' is not available " "since it requires a subscription.", name) except PluginError: pass return dict(starmap(self._check_stream_name, streams.items()))
def _get_streams(self): res = http.get(self.url) match = _info_re.search(res.text) if not match: return info = parse_json(match.group(1), schema=_schema) stream_name = info["mode"] mp4_url = info.get("mp4_url") ios_url = info.get("ios_url") swf_url = info.get("swf_url") if mp4_url: stream = HTTPStream(self.session, mp4_url) yield stream_name, stream if ios_url: if urlparse(ios_url).path.endswith(".m3u8"): streams = HLSStream.parse_variant_playlist( self.session, ios_url) # TODO: Replace with "yield from" when dropping Python 2. for stream in streams.items(): yield stream if swf_url: stream = self._get_rtmp_stream(swf_url) if stream: yield stream_name, stream
def _get_streams(self): info = self._get_stream_info() if not info: return stream_info = info["event"]["stream_info"] if not (stream_info and stream_info["is_live"]): # Stream is not live return streams = defaultdict(list) play_url = stream_info.get("play_url") if play_url: swfurl = info.get("viewerPlusSwfUrl") or info.get("hdPlayerSwfUrl") if not swfurl.startswith("http"): swfurl = "http://" + swfurl qualities = stream_info["qualities"] smil = self._parse_smil(play_url, swfurl) for bitrate, stream in smil.items(): name = "{0}k".format(bitrate / 1000) for quality in qualities: if quality["bitrate"] == bitrate: name = "{0}p".format(quality["height"]) streams[name].append(stream) m3u8_url = stream_info.get("m3u8_url") if m3u8_url: hls_streams = HLSStream.parse_variant_playlist(self.session, m3u8_url, namekey="pixels") for name, stream in hls_streams.items(): streams[name].append(stream) return streams
def _get_streams(self): info = self._get_stream_info() if not info: return stream_info = info["event"]["stream_info"] if not (stream_info and stream_info["is_live"]): # Stream is not live return play_url = stream_info.get("play_url") if play_url: swf_url = info.get("viewerPlusSwfUrl") or info.get("hdPlayerSwfUrl") if not swf_url.startswith("http"): swf_url = "http://" + swf_url qualities = stream_info["qualities"] for bitrate, stream in self._parse_smil(play_url, swf_url): name = "{0}k".format(bitrate / 1000) for quality in qualities: if quality["bitrate"] == bitrate: name = "{0}p".format(quality["height"]) yield name, stream m3u8_url = stream_info.get("m3u8_url") if m3u8_url: streams = HLSStream.parse_variant_playlist(self.session, m3u8_url, namekey="pixels") # TODO: Replace with "yield from" when dropping Python 2. for stream in streams.items(): yield stream
def _get_streams(self): channelid = self._get_channel_id(self.url) if not channelid: raise NoStreamsError(self.url) self.logger.debug("Fetching stream info") res = urlget(self.AMFURL.format(channelid)) try: packet = AMF0Packet.deserialize(BytesIO(res.content)) except (IOError, AMFError) as err: raise PluginError(("Failed to parse AMF packet: {0}").format(str(err))) result = None for message in packet.messages: if message.target_uri == "/1/onResult": result = message.value break if not result: raise PluginError("No result found in AMF packet") streams = {} if "liveHttpUrl" in result: try: hlsstreams = HLSStream.parse_variant_playlist(self.session, result["liveHttpUrl"]) streams.update(hlsstreams) except IOError as err: self.logger.warning("Failed to get variant playlist: {0}", err) if "streamName" in result: if "cdnUrl" in result: cdn = result["cdnUrl"] elif "fmsUrl" in result: cdn = result["fmsUrl"] else: self.logger.warning("Missing cdnUrl and fmsUrl from result") return streams if "videoCodec" in result and result["videoCodec"]["height"] > 0: streamname = "{0}p".format(int(result["videoCodec"]["height"])) else: streamname = "live" streams[streamname] = self._create_stream(cdn, result["streamName"]) if "streamVersions" in result: for version, info in result["streamVersions"].items(): if "streamVersionCdn" in info: for name, cdn in info["streamVersionCdn"].items(): if "cdnStreamUrl" in cdn and "cdnStreamName" in cdn: streams["cdn_" + name] = self._create_stream(cdn["cdnStreamUrl"], cdn["cdnStreamName"]) return streams
def _get_streams(self): self.logger.debug("Fetching stream info") res = urlget(self.url, params=dict(output="json")) if res.json is None: raise PluginError("No JSON data in stream info") streams = {} video = verifyjson(res.json, "video") videos = verifyjson(video, "videoReferences") for video in videos: if not ("url" in video and "playerType" in video): continue if video["playerType"] == "flash": if video["url"].startswith("rtmp"): stream = RTMPStream( self.session, { "rtmp": video["url"], "pageUrl": self.PageURL, "swfVfy": self.SWFURL, "live": True }) streams[str(video["bitrate"]) + "k"] = stream elif video["playerType"] == "ios": try: hlsstreams = HLSStream.parse_variant_playlist( self.session, video["url"]) streams.update(hlsstreams) except IOError as err: self.logger.warning("Failed to get variant playlist: {0}", err) return streams
def _get_live_streams(self): self._authenticate() sig, token = self._access_token() url = self.usher.select(self.channel, password=self.options.get("password"), nauthsig=sig, nauth=token) try: streams = HLSStream.parse_variant_playlist(self.session, url) except IOError as err: err = str(err) if "404 Client Error" in err or "Failed to parse playlist" in err: return else: raise PluginError(err) try: token = parse_json(token) chansub = verifyjson(token, "chansub") restricted_bitrates = verifyjson(chansub, "restricted_bitrates") for name in filter( lambda n: not re.match(r"(.+_)?archives|live", n), restricted_bitrates): self.logger.warning( "The quality '{0}' is not available " "since it requires a subscription.", name) except PluginError: pass return dict(starmap(self._check_stream_name, streams.items()))
def _get_streams(self): channelid = self._get_channel_id(self.url) if not channelid: raise NoStreamsError(self.url) self.logger.debug("Fetching stream info") res = urlget(self.AMFURL.format(channelid)) try: packet = AMF0Packet.deserialize(BytesIO(res.content)) except (IOError, AMFError) as err: raise PluginError( ("Failed to parse AMF packet: {0}").format(str(err))) result = None for message in packet.messages: if message.target_uri == "/1/onResult": result = message.value break if not result: raise PluginError("No result found in AMF packet") streams = {} if "liveHttpUrl" in result: try: hlsstreams = HLSStream.parse_variant_playlist( self.session, result["liveHttpUrl"]) streams.update(hlsstreams) except IOError as err: self.logger.warning("Failed to get variant playlist: {0}", err) if "streamName" in result: if "cdnUrl" in result: cdn = result["cdnUrl"] elif "fmsUrl" in result: cdn = result["fmsUrl"] else: self.logger.warning("Missing cdnUrl and fmsUrl from result") return streams if "videoCodec" in result and result["videoCodec"]["height"] > 0: streamname = "{0}p".format(int(result["videoCodec"]["height"])) else: streamname = "live" streams[streamname] = self._create_stream(cdn, result["streamName"]) if "streamVersions" in result: for version, info in result["streamVersions"].items(): if "streamVersionCdn" in info: for name, cdn in info["streamVersionCdn"].items(): if "cdnStreamUrl" in cdn and "cdnStreamName" in cdn: streams["cdn_" + name] = self._create_stream( cdn["cdnStreamUrl"], cdn["cdnStreamName"]) return streams
def _create_stream(self, stream, is_live): stream_name = "{0}p".format(stream["height"]) stream_type = stream["mediaType"] stream_url = stream["url"] if stream_type in ("hls", "mp4"): if urlparse(stream_url).path.endswith("m3u8"): try: streams = HLSStream.parse_variant_playlist(self.session, stream_url) # TODO: Replace with "yield from" when dropping Python 2. for stream in streams.items(): yield stream except IOError as err: self.logger.error("Failed to extract HLS streams: {0}", err) else: yield stream_name, HTTPStream(self.session, stream_url) elif stream_type == "rtmp": params = {"rtmp": stream["streamer"], "playpath": stream["url"], "swfVfy": SWF_URL, "pageUrl": self.url} if is_live: params["live"] = True else: params["playpath"] = "mp4:{0}".format(params["playpath"]) stream = RTMPStream(self.session, params) yield stream_name, stream
def _get_hls_streams(self): url = self.HLSStreamTokenURL.format(self.channelname) try: res = urlget(url, params=dict(type="any", connection="wifi"), exception=IOError) except IOError: return {} if not isinstance(res.json, list): raise PluginError("Stream info response is not JSON") if len(res.json) == 0: raise PluginError("No stream token in JSON") streams = {} token = verifyjson(res.json[0], "token") hashed = hmac.new(self.HLSStreamTokenKey, bytes(token, "utf8"), sha1) fulltoken = hashed.hexdigest() + ":" + token url = self.HLSSPlaylistURL.format(self.channelname) try: params = dict(token=fulltoken, hd="true") playlist = HLSStream.parse_variant_playlist(self.session, url, params=params) except IOError as err: raise PluginError(err) return playlist
def _get_streams_from_id(self, stream_id): res = urlget(CONFIG_URL, params=dict(id=stream_id)) config = res_json(res) media = verifyjson(config, "media") if not (media and isinstance(media, list)): return streams = {} media = media[0] hds_manifest = media.get("name") hls_manifest = media.get("hlsUrl") if hds_manifest: try: hds_streams = HDSStream.parse_manifest(self.session, hds_manifest) streams.update(hds_streams) except IOError as err: if not re.search(r"(404|400) Client Error", str(err)): self.logger.error("Failed to parse HDS manifest: {0}", err) if hls_manifest: try: hls_streams = HLSStream.parse_variant_playlist(self.session, hls_manifest, nameprefix="mobile_") streams.update(hls_streams) except IOError as err: if not re.search(r"(404|400) Client Error", str(err)): self.logger.error("Failed to parse HLS playlist: {0}", err) return streams
def _get_streams(self): info = self._get_stream_info() if not info: return stream_info = info["event"]["stream_info"] if not (stream_info and stream_info["is_live"]): # Stream is not live return play_url = stream_info.get("play_url") if play_url: swf_url = info.get("viewerPlusSwfUrl") or info.get("hdPlayerSwfUrl") if not swf_url.startswith("http"): swf_url = "http://" + swf_url # Work around broken SSL. swf_url = swf_url.replace("https://", "http://") qualities = stream_info["qualities"] for bitrate, stream in self._parse_smil(play_url, swf_url): name = "{0}k".format(bitrate / 1000) for quality in qualities: if quality["bitrate"] == bitrate: name = "{0}p".format(quality["height"]) yield name, stream m3u8_url = stream_info.get("m3u8_url") if m3u8_url: streams = HLSStream.parse_variant_playlist(self.session, m3u8_url, namekey="pixels") # TODO: Replace with "yield from" when dropping Python 2. for stream in streams.items(): yield stream
def _get_streams(self): streams = {} # streaming.media.ccc.de match = _url_streaming_media_re.match(self.url) if match: query_url = API_URL_STREAMING_MEDIA live_streams = parse_streaming_media_json(get_json(query_url),\ match.group('room')) for stream_name, stream_url in live_streams.items(): if re.search(r"m3u8", live_streams[stream_name]): streams[stream_name] = HLSStream(self.session,\ stream_url) else: streams[stream_name] = HTTPStream(self.session,\ stream_url) # media.ccc.de elif _url_media_re.search(self.url): event_id = get_event_id(self.url) query_url = "%s/public/events/%i" % (API_URL_MEDIA, event_id) recordings = parse_media_json(get_json(query_url)) for name, stream_url in recordings.items(): streams[name] = HTTPStream(self.session, stream_url) if not streams: raise PluginError("This plugin does not support your " "selected video.") return streams
def _get_live_streams(self): self._authenticate() sig, token = self._access_token() url = self.usher.select(self.channel, password=self.options.get("password"), nauthsig=sig, nauth=token) try: streams = HLSStream.parse_variant_playlist(self.session, url) except ValueError: return except IOError as err: if "404 Client Error" in str(err): return else: raise PluginError(err) try: token = parse_json(token) chansub = verifyjson(token, "chansub") restricted_bitrates = verifyjson(chansub, "restricted_bitrates") for name in filter(lambda n: n not in ("archives", "live"), restricted_bitrates): self.logger.warning("The quality '{0}' is not available " "since it requires a subscription.", name) except PluginError: pass return dict(starmap(self._check_stream_name, streams.items()))
def _get_streams(self): self.logger.debug("Fetching stream info") res = urlget(self.url, params=dict(output="json")) json = res_json(res) if not isinstance(json, dict): raise PluginError("Invalid JSON response") streams = {} video = verifyjson(json, "video") videos = verifyjson(video, "videoReferences") for video in videos: if not ("url" in video and "playerType" in video): continue if video["playerType"] == "flash": if video["url"].startswith("rtmp"): stream = RTMPStream( self.session, {"rtmp": video["url"], "pageUrl": self.PageURL, "swfVfy": self.SWFURL, "live": True}, ) streams[str(video["bitrate"]) + "k"] = stream elif video["playerType"] == "ios": try: hlsstreams = HLSStream.parse_variant_playlist(self.session, video["url"]) streams.update(hlsstreams) except IOError as err: self.logger.warning("Failed to get variant playlist: {0}", err) return streams
def _get_hls_streams(self): url = self.HLSStreamTokenURL.format(self.channelname) try: res = urlget(url, params=dict(type="any", connection="wifi"), exception=IOError) except IOError: self.logger.debug("HLS streams not available") return {} json = res_json(res, "stream token JSON") if not isinstance(json, list): raise PluginError("Invalid JSON response") if len(json) == 0: raise PluginError("No stream token in JSON") streams = {} token = verifyjson(json[0], "token") hashed = hmac.new(self.HLSStreamTokenKey, bytes(token, "utf8"), sha1) fulltoken = hashed.hexdigest() + ":" + token url = self.HLSSPlaylistURL.format(self.channelname) try: params = dict(token=fulltoken, hd="true") playlist = HLSStream.parse_variant_playlist(self.session, url, params=params) except IOError as err: raise PluginError(err) return playlist
def _get_streams(self): res = http.get(self.url) match = _info_re.search(res.text) if not match: return info = parse_json(match.group(1), schema=_schema) streams = defaultdict(list) stream_name = info["mode"] mp4_url = info.get("mp4_url") ios_url = info.get("ios_url") swf_url = info.get("swf_url") if mp4_url: stream = HTTPStream(self.session, mp4_url) streams[stream_name].append(stream) if ios_url: if urlparse(ios_url).path.endswith(".m3u8"): hls_streams = HLSStream.parse_variant_playlist( self.session, ios_url) for name, stream in hls_streams.items(): streams[name].append(stream) if swf_url: stream = self._get_rtmp_streams(swf_url) if stream: streams[stream_name].append(stream) return streams
def _get_streams(self): res = http.get(self.url, schema=_live_schema) if not res: return if res["type"] == "hls" and urlparse(res["url"]).path.endswith("m3u8"): stream = HLSStream(self.session, res["url"]) return dict(hls=stream)
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) if "hls_url" in playlist_url: return HLSStream.parse_variant_playlist(self.session, playlist_url["hls_url"]) elif "replay_url" in playlist_url: self.logger.info("Live Stream ended, using replay instead") return dict(replay=HLSStream(self.session, playlist_url["replay_url"])) else: return
def _parse_vod_streams(self, vod): for name, stream in vod["streams"].items(): scheme = urlparse(stream["url"]).scheme if scheme == "http": yield name, HLSStream(self.session, stream["url"]) elif scheme == "rtmp": yield name, self._create_rtmp_stream(stream, live=False)
def _get_streams(self): self.logger.debug('Extracting media URL') res = urlget(self.url, cookies = {'NRK_PLAYER_SETTINGS_TV': 'devicetype=desktop&preferred-player-odm=hlslink&preferred-player-live=hlslink'}) m = re.search(r'<div[^>]*?id="playerelement"[^>]+data-media="([^"]+)"', res.text) if not m: raise NoStreamsError(self.url) return HLSStream.parse_variant_playlist(self.session, m.group(1))
def _get_streams(self): url_match = _url_re.match(self.url) if url_match: _id = url_match.group(1) url = 'https://rtctw-rtcp-tw-1.livehouse.in/%s/video/playlist.m3u8' % (_id) streams = HLSStream.parse_variant_playlist(self.session, url) return streams else: raise StreamError("Error open playlist, maybe it's not live stream ")
def _get_streams(self): self.logger.debug('Extracting media URL') res = http.get(self.url, cookies=COOKIES) m = re.search(r'<div[^>]*?id="playerelement"[^>]+data-media="([^"]+)"', res.text) if not m: return return HLSStream.parse_variant_playlist(self.session, m.group(1))
def _get_streams(self): stream_type = _url_re.match(self.url).group(1).upper() cookie = { "NRK_PLAYER_SETTINGS_{0}".format(stream_type): COOKIE_PARAMS } playlist_url = http.get(self.url, cookies=cookie, schema=_schema) if not playlist_url: return return HLSStream.parse_variant_playlist(self.session, playlist_url)
def _get_streams(self): res = http.get(self.url) match = (_stream_hls_re.search(res.text) or _stream_data_re.search(res.text)) if not match: return stream_url = parse_json(match.group(1)) return HLSStream.parse_variant_playlist(self.session, stream_url)
def _get_live_streams(self): meta = self._get_meta() stream = filter(lambda x: x['type'] == 'hls', meta['streams'])[0]['url'] url = 'http://ida.omroep.nl/aapi/?type=jsonp&stream={}&token={}'.format(stream, self.get_token()) streamdata = http.get(url, headers=HTTP_HEADERS).json() deeplink = http.get(streamdata['stream'], headers=HTTP_HEADERS).content deeplink = re.compile('"(.*?)"', re.DOTALL + re.IGNORECASE).search(deeplink).group(1) playlist_url = deeplink.replace("\\/", "/") return HLSStream.parse_variant_playlist(self.session, playlist_url)
def _get_streams(self): stream_id = _id_map[self.channel_path] hls_url = "http://iphonelive.rtve.es/{0}_LV3_IPH/{0}_LV3_IPH.m3u8".format(stream_id) # Check if the stream is available res = http.head(hls_url, raise_for_status=False) if res.status_code == 404: raise PluginError("The program is not available due to rights restrictions") return HLSStream.parse_variant_playlist(self.session, hls_url)
def _get_streams(self): res = http.get(self.url, schema=_schema) if not res: return if res["type"] == "channel" and urlparse(res["url"]).path.endswith("m3u8"): return HLSStream.parse_variant_playlist(self.session, res["url"]) elif res["type"] == "video": stream = HTTPStream(self.session, res["url"]) return dict(video=stream)
def _get_streams(self): res = http.get(self.url, schema=_schema) if not res: return if res["type"] == "channel" and urlparse( res["url"]).path.endswith("m3u8"): return HLSStream.parse_variant_playlist(self.session, res["url"]) elif res["type"] == "video": stream = HTTPStream(self.session, res["url"]) return dict(video=stream)
def _get_streams(self): login_email = self.options.get("email") login_password = self.options.get("password") if login_email and login_password: self._authenticate(login_email, login_password) hls_playlist = http.get(self.url, schema=_hls_playlist_schema) if not hls_playlist: return return HLSStream.parse_variant_playlist(self.session, hls_playlist)
def _get_streams(self): channelname = urlparse(self.url).path.rstrip("/").rpartition("/")[-1].lower() channelname = channelname.replace("_", "-") try: streams = HLSStream.parse_variant_playlist(self.session, self.PlaylistURL.format(channelname)) except IOError: return return streams
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) return HLSStream.parse_variant_playlist(self.session, playlist_url)
def _get_streams(self): info = self._get_stream_info(self.url) if not info: raise NoStreamsError(self.url) args = verifyjson(info, "args") streams = {} uestreammap = verifyjson(args, "url_encoded_fmt_stream_map") fmtlist = verifyjson(args, "fmt_list") streammap = self._parse_stream_map(uestreammap) formatmap = self._parse_format_map(fmtlist) for streaminfo in streammap: if "s" in streaminfo and self._decrypt_signature(streaminfo["s"]): streaminfo["sig"] = self._decrypt_signature(streaminfo["s"]) if not ("url" in streaminfo and "sig" in streaminfo): continue stream = HTTPStream(self.session, streaminfo["url"], params=dict(signature=streaminfo["sig"])) if streaminfo["itag"] in formatmap: quality = formatmap[streaminfo["itag"]] else: quality = streaminfo["quality"] if streaminfo.get("stereo3d") == "1": quality += "_3d" streams[quality] = stream if "hlsvp" in args: url = args["hlsvp"] try: hlsstreams = HLSStream.parse_variant_playlist(self.session, url, namekey="pixels") streams.update(hlsstreams) except IOError as err: self.logger.warning("Failed to get variant playlist: {0}", err) if not streams and args.get("live_playback", "0") == "0": self.logger.warning( "VOD support may not be 100% complete. Try youtube-dl instead." ) return streams
def _create_stream(self, source): url = source["file"] if urlparse(url).path.endswith("m3u8"): streams = HLSStream.parse_variant_playlist(self.session, url) # TODO: Replace with "yield from" when dropping Python 2. for stream in streams.items(): yield stream else: name = source.get("label", "vod") yield name, HTTPStream(self.session, url)
def _get_hls_stream(self, url, cdn, quality, broad_key, bid): keyjson = self._get_hls_key(broad_key, bid) if keyjson["RESULT"] != CHANNEL_RESULT_OK: return key = keyjson["AID"] print key info = self._get_stream_info(url, cdn, quality, broad_key, "hls") if "view_url" in info: print info["view_url"] return HLSStream(self.session, info["view_url"], params=dict(aid=key))
def _get_streams(self): info = self._get_stream_info(self.url) if not info: return formats = info.get("fmt_list") streams = {} protected = False for stream_info in info.get("url_encoded_fmt_stream_map", []): if stream_info.get("s"): protected = True continue stream = HTTPStream(self.session, stream_info["url"]) name = formats.get(stream_info["itag"]) or stream_info["quality"] if stream_info.get("stereo3d"): name += "_3d" streams[name] = stream # Extract audio streams from the DASH format list for stream_info in info.get("adaptive_fmts", []): if stream_info.get("s"): protected = True continue stream_type, stream_format = stream_info["type"] if stream_type != "audio": continue stream = HTTPStream(self.session, stream_info["url"]) name = "audio_{0}".format(stream_format) streams[name] = stream hls_playlist = info.get("hlsvp") if hls_playlist: try: hls_streams = HLSStream.parse_variant_playlist( self.session, hls_playlist, headers=HLS_HEADERS, namekey="pixels") streams.update(hls_streams) except IOError as err: self.logger.warning("Failed to extract HLS streams: {0}", err) if not streams and protected: raise PluginError("This plugin does not support protected videos, " "try youtube-dl instead") return streams
def _get_streams(self): match = re.match(CHANNEL_REGEX, self.url) if not match: return username = match.group("username") broadcast = self._find_broadcast(username) if not broadcast: return return HLSStream.parse_variant_playlist(self.session, PLAYLIST_URL.format(broadcast))
def _get_streams(self): url_match = _url_re.match(self.url) if url_match: # find the list of channels from the html in the page res = http.get(self.url) channel_map = dict(_channel_map_re.findall(res.text)) channel_id = channel_map.get(url_match.group(1)) # get the stream urls res = http.get(STREAM_INFO_URL.format(id=channel_id)) stream_data = http.json(res, schema=_channel_schema) return HLSStream.parse_variant_playlist(self.session, stream_data["stream"])
def _get_mobile_streams(self, sig, token): url = TWITCH_HLS_PLAYLIST.format(self.channel, token, sig) try: streams = HLSStream.parse_variant_playlist(self.session, url, nameprefix="mobile_") except IOError as err: if "404 Client Error" in str(err): raise NoStreamsError(self.url) else: raise PluginError(err) return streams
def _get_streams(self): match = _url_re.match(self.url) if not match: return username = match.group("username") broadcast = self._find_broadcast(username) if not broadcast: return playlist_url = PLAYLIST_URL.format(broadcast) return HLSStream.parse_variant_playlist(self.session, playlist_url, headers=HEADERS)
def _get_streams(self): info = self._get_stream_info(self.url) if not info: return formats = info.get("fmt_list") streams = {} protected = False for stream_info in info.get("url_encoded_fmt_stream_map", []): if stream_info.get("s"): protected = True continue stream = HTTPStream(self.session, stream_info["url"]) name = formats.get(stream_info["itag"]) or stream_info["quality"] if stream_info.get("stereo3d"): name += "_3d" streams[name] = stream # Extract audio streams from the DASH format list for stream_info in info.get("adaptive_fmts", []): if stream_info.get("s"): protected = True continue stream_type, stream_format = stream_info["type"] if stream_type != "audio": continue stream = HTTPStream(self.session, stream_info["url"]) name = "audio_{0}".format(stream_format) streams[name] = stream hls_playlist = info.get("hlsvp") if hls_playlist: try: hls_streams = HLSStream.parse_variant_playlist( self.session, hls_playlist, headers=HLS_HEADERS, namekey="pixels" ) streams.update(hls_streams) except IOError as err: self.logger.warning("Failed to extract HLS streams: {0}", err) if not streams and protected: raise PluginError("This plugin does not support protected videos, " "try youtube-dl instead") return streams
def _get_streams(self): res = http.get(self.url) match = _meta_xmlurl_id_re.search(res.text) if not match: return; xml_info_url = STREAMS_INFO_URL.format(match.group(1)) video_info_res = http.get(xml_info_url) parsed_info = http.xml(video_info_res) live_el = parsed_info.find("live"); live = live_el is not None and live_el.text == "1" streams = { } hdsurl_el = parsed_info.find("hdsurl"); if hdsurl_el is not None and hdsurl_el.text is not None: hdsurl = hdsurl_el.text streams.update(HDSStream.parse_manifest(self.session, hdsurl)) if live: vurls_el = parsed_info.find("vurls"); if vurls_el is not None: for i, vurl_el in enumerate(vurls_el): bitrate = vurl_el.get("bitrate") name = bitrate + "k" if bitrate is not None else "rtmp{0}".format(i) params = { "rtmp": vurl_el.text, } streams[name] = RTMPStream(self.session, params) parsed_urls = set() mobileurls_el = parsed_info.find("mobileurls"); if mobileurls_el is not None: for mobileurl_el in mobileurls_el: text = mobileurl_el.text if not text: continue if text in parsed_urls: continue parsed_urls.add(text) url = urlparse(text) if url[0] == "http" and url[2].endswith("m3u8"): streams.update(HLSStream.parse_variant_playlist(self.session, text)) return streams