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_streams(self): match = _url_re.match(self.url) channel = match.group("channel") ts = int(time.time() / 60) sign = hashlib.md5( ("{0}{1}{2}".format(channel, API_SECRET, ts)).encode("utf-8")).hexdigest() res = http.get(API_URL.format(channel, ts, sign)) room = http.json(res, schema=_room_schema) if not room: return if room["show_status"] != SHOW_STATUS_ONLINE: return url = "{room[rtmp_url]}/{room[rtmp_live]}".format(room=room) stream = HTTPStream(self.session, url) yield "source", stream for name, url in room["rtmp_multi_bitrate"].items(): url = "{room[rtmp_url]}/{url}".format(room=room, url=url) stream = HTTPStream(self.session, url) yield name, stream
def _create_video_clip(self, chunks, start_offset, stop_offset): playlist_duration = stop_offset - start_offset playlist_offset = 0 playlist_streams = [] playlist_tags = [] for chunk in chunks: chunk_url = chunk.get("url") chunk_length = chunk.get("length") chunk_start = playlist_offset chunk_stop = chunk_start + chunk_length chunk_stream = HTTPStream(self.session, chunk_url) if start_offset >= chunk_start and start_offset <= chunk_stop: headers = extract_flv_header_tags(chunk_stream) if not headers.metadata: raise StreamError( "Missing metadata tag in the first chunk") metadata = headers.metadata.data.value keyframes = metadata.get("keyframes") if not keyframes: raise StreamError( "Missing keyframes info in the first chunk") keyframe_offset = None keyframe_offsets = keyframes.get("filepositions") keyframe_times = [ playlist_offset + t for t in keyframes.get("times") ] for time, offset in izip(keyframe_times, keyframe_offsets): if time > start_offset: break keyframe_offset = offset if keyframe_offset is None: raise StreamError("Unable to find a keyframe to seek to " "in the first chunk") chunk_headers = dict( Range="bytes={0}-".format(int(keyframe_offset))) chunk_stream = HTTPStream(self.session, chunk_url, headers=chunk_headers) playlist_streams.append(chunk_stream) for tag in headers: playlist_tags.append(tag) elif chunk_start >= start_offset and chunk_start < stop_offset: playlist_streams.append(chunk_stream) playlist_offset += chunk_length return FLVPlaylist(self.session, playlist_streams, tags=playlist_tags, duration=playlist_duration)
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 _create_playlist_streams(self, videos): start_offset = int(videos.get("start_offset", 0)) stop_offset = int(videos.get("end_offset", 0)) streams = {} for quality, chunks in videos.get("chunks").items(): if not chunks: if videos.get("restrictions", {}).get(quality) == "chansub": self.logger.warning( "The quality '{0}' is not available " "since it requires a subscription.", quality) continue # Rename 'live' to 'source' if quality == "live": quality = "source" chunks_filtered = list(filter(lambda c: c["url"], chunks)) if len(chunks) != len(chunks_filtered): self.logger.warning( "The video '{0}' contains invalid chunks. " "There will be missing data.", quality) chunks = chunks_filtered chunks_duration = sum(c.get("length") for c in chunks) # If it's a full broadcast we just use all the chunks if start_offset == 0 and chunks_duration == stop_offset: # No need to use the FLV concat if it's just one chunk if len(chunks) == 1: url = chunks[0].get("url") stream = HTTPStream(self.session, url) else: chunks = [ HTTPStream(self.session, c.get("url")) for c in chunks ] stream = FLVPlaylist(self.session, chunks, duration=chunks_duration) else: try: stream = self._create_video_clip(chunks, start_offset, stop_offset) except StreamError as err: self.logger.error("Error while creating video '{0}': {1}", quality, err) continue streams[quality] = stream 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_vod_streams(self): url = 'http://ida.omroep.nl/odi/?prid={}&puboptions=adaptive,h264_bb,h264_std,h264_sb&adaptive=no&part=1&token={}'.format(self.npo_id, self.get_token()) data = http.get(url, headers=HTTP_HEADERS).json() streams = {} stream = http.get(data['streams'][0].replace('jsonp', 'json'), headers=HTTP_HEADERS).json() streams['best'] = streams['high'] = HTTPStream(self.session, stream['url']) return streams
def _create_flv_playlist(self, template): res = http.get(template) json = http.json(res) if not isinstance(json, dict): raise PluginError("Invalid JSON response") parsed = urlparse(template) try: url_template = '{0}://{1}{2}'.format(parsed.scheme, parsed.netloc, json['template']) segment_max = reduce(lambda i, j: i + j[0], json['fragments'], 0) duration = json['duration'] except KeyError: raise PluginError('Unexpected JSON response') substreams = [ HTTPStream(self.session, url_template.replace('$fragment$', str(i))) for i in range(1, segment_max + 1) ] return FLVPlaylist(self.session, streams=substreams, duration=duration, skip_header=True, flatten_timestamps=True)
def _get_streams(self): match = _url_re.match(self.url) parsed = urlparse(self.url) if parsed.fragment: channel_id = parsed.fragment else: channel_id = match.group("channel") if not channel_id: return channel_id = channel_id.lower().replace("/", "_") res = http.get(API_URL.format(channel_id)) info = http.json(res, schema=_schema) if not info["success"]: return if info.get("isLive"): name = "live" else: name = "vod" stream = HTTPStream(self.session, info["payload"]) # Wrap the stream in a FLVPlaylist to verify the FLV tags stream = FLVPlaylist(self.session, [stream]) return {name: stream}
def _get_streams(self): parsed = urlparse(self.url) if parsed.fragment: channelid = parsed.fragment else: channelid = parsed.path.rpartition("view/")[-1] if not channelid: raise NoStreamsError(self.url) channelid = channelid.lower().replace("/", "_") self.logger.debug("Fetching stream info") res = urlget(self.APIURL.format(channelid)) json = res_json(res) if not isinstance(json, dict): raise PluginError("Invalid JSON response") elif not ("success" in json and "payload" in json): raise PluginError("Invalid JSON response") elif json["success"] == False: raise NoStreamsError(self.url) streams = {} streams["live"] = HTTPStream(self.session, json["payload"]) return streams
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) # temporary fix until the jwplayer-parser works for this site again # refer to: https://github.com/chrippa/livestreamer/issues/588 # # not working: # playlist = jwplayer.parse_playlist(res) playlist = re.compile(r"playlist: (\[{.*?}\]),", re.DOTALL + re.IGNORECASE).search( res.content).group(1).strip() playlist = playlist.replace('sources:', '"sources":') playlist = playlist.replace('file:', '"file":') playlist = json.loads(playlist) if not playlist: return for item in playlist: for source in item["sources"]: filename = source["file"] if filename.endswith(".smil"): # TODO: Replace with "yield from" when dropping Python 2. for stream in self._get_smil_streams(filename): yield stream elif filename.startswith("/"): name = source.get("label", "vod") url = BASE_VOD_URL + filename yield name, HTTPStream(self.session, url) break
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(self.url) if not info: raise NoStreamsError(self.url) args = verifyjson(info, "args") if not "live_playback" in args or args["live_playback"] == "0": raise NoStreamsError(self.url) 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 not ("url" in streaminfo and "sig" in streaminfo): continue stream = HTTPStream(self.session, streaminfo["url"][0], params=dict(signature=streaminfo["sig"][0])) if streaminfo["itag"][0] in formatmap: quality = formatmap[streaminfo["itag"][0]] else: quality = streaminfo["quality"] streams[quality] = stream return streams
def _get_streams(self): self.rsession = requests.session(prefetch=True) options = self.options if options.get("cookie"): self._authenticate(cookies=options.get("cookie")) else: self._authenticate(options.get("username"), options.get("password")) streams = {} qualities = ["HQ", "SQ", "HQTest", "SQTest"] res = self._get_live_page(self.url) urls = self._find_stream_urls(res.text) for quality in qualities: for url in urls: # Grab the response of the URL listed on the Live page for a stream url = url.format(quality=quality) res = urlget(url, session=self.rsession) # The response for the GOX XML if an incorrect stream quality is chosen is 1002. if res.text != "1002" and len(res.text) > 0: streamurl = self._parse_gox_file(res.text) streams[quality.lower()] = HTTPStream( self.session, streamurl, headers=self.StreamHeaders) return streams
def _get_streams(self): match = _url_re.match(self.url) channel = match.group("channel") http.headers.update({"User-Agent": USER_AGENT}) room_id = http.get(self.url, schema=_room_id_schema) channel = room_id["room_id"] res = http.get(MAPI_URL.format(channel)) room = http.json(res, schema=_room_schema) if not room: return if room["show_status"] != SHOW_STATUS_ONLINE: return ts = int(time.time() / 60) did = uuid.uuid4().hex.upper() sign = hashlib.md5( ("{0}{1}{2}{3}".format(channel, did, LAPI_SECRET, ts)).encode("utf-8")).hexdigest() data = {"cdn": "ws", "rate": "0", "tt": ts, "did": did, "sign": sign} res = http.post(LAPI_URL.format(channel), data=data) room = http.json(res, schema=_lapi_schema) url = "{room[rtmp_url]}/{room[rtmp_live]}".format(room=room) stream = HTTPStream(self.session, url) yield "source", stream data = {"cdn": "ws", "rate": "2", "tt": ts, "did": did, "sign": sign} res = http.post(LAPI_URL.format(channel), data=data) room = http.json(res, schema=_lapi_schema) url = "{room[rtmp_url]}/{room[rtmp_live]}".format(room=room) stream = HTTPStream(self.session, url) yield "middle", stream data = {"cdn": "ws", "rate": "1", "tt": ts, "did": did, "sign": sign} res = http.post(LAPI_URL.format(channel), data=data) room = http.json(res, schema=_lapi_schema) url = "{room[rtmp_url]}/{room[rtmp_live]}".format(room=room) stream = HTTPStream(self.session, url) yield "low", stream
def _get_recorded_streams(self, video_id): streams = {} if HAS_LIBRTMP: module_info = self._get_module_info("recorded", video_id) if not module_info: raise NoStreamsError(self.url) providers = module_info.get("stream") if not isinstance(providers, list): raise PluginError("Invalid stream info: {0}".format(providers)) for provider in providers: base_url = provider.get("url") for stream_info in provider.get("streams"): bitrate = int(stream_info.get("bitrate", 0)) stream_name = (bitrate > 0 and "{0}k".format(bitrate) or "recorded") if stream_name in streams: stream_name += "_alt" url = stream_info.get("streamName") if base_url: url = base_url + url if url.startswith("http"): streams[stream_name] = HTTPStream(self.session, url) elif url.startswith("rtmp"): params = dict(rtmp=url, pageUrl=self.url) streams[stream_name] = RTMPStream(self.session, params) else: self.logger.warning("The proper API could not be used without " "python-librtmp installed. Stream URL may be " "incorrect.") url = RECORDED_URL.format(video_id) random_hash = "{0:02x}{1:02x}".format(randint(0, 255), randint(0, 255)) params = dict(hash=random_hash) stream = HTTPStream(self.session, url, params=params) streams["recorded"] = stream return streams
def _get_http_streams(self, info): name = QUALITY_MAP.get(info["_quality"], "vod") urls = info["_stream"] if not isinstance(info["_stream"], list): urls = [urls] for url in urls: stream = HTTPStream(self.session, url) yield name, stream
def _get_recorded_streams(self, video_id): streams = {} if HAS_LIBRTMP: recording = self._get_module_info("recorded", video_id, schema=_recorded_schema) if not isinstance(recording.get("stream"), list): return for provider in recording["stream"]: base_url = provider.get("url") for stream_info in provider["streams"]: bitrate = int(stream_info.get("bitrate", 0)) stream_name = (bitrate > 0 and "{0}k".format(bitrate) or "recorded") if stream_name in streams: stream_name += "_alt" url = stream_info["streamName"] if base_url: url = base_url + url if url.startswith("http"): streams[stream_name] = HTTPStream(self.session, url) elif url.startswith("rtmp"): params = dict(rtmp=url, pageUrl=self.url) streams[stream_name] = RTMPStream(self.session, params) else: self.logger.warning( "The proper API could not be used without python-librtmp " "installed. Stream URL is not guaranteed to be valid") url = RECORDED_URL.format(video_id) random_hash = "{0:02x}{1:02x}".format(randint(0, 255), randint(0, 255)) params = dict(hash=random_hash) stream = HTTPStream(self.session, url, params=params) streams["recorded"] = stream return streams
def _get_streams(self): self.logger.debug("Fetching stream info") media_is_live = 0 match = re.search(r".*hitbox.tv/([^/]*)/?(\d+)?", self.url) if not match: raise NoStreamsError(self.url) stream_name, media_id = match.groups() if stream_name != "video": res = urlget(LIVE_API.format(stream_name)) json = res_json(res) livestream = verifyjson(json, "livestream") media_id = verifyjson(livestream[0], "media_id") media_is_live = int(verifyjson(livestream[0], "media_is_live")) if not media_is_live: raise NoStreamsError(self.url) media_type = "live" if media_is_live else "video" res = urlget(PLAYER_API.format(media_type, media_id)) json = res_json(res) clip = verifyjson(json, "clip") live = verifyjson(clip, "live") bitrates = verifyjson(clip, "bitrates") streams = {} if live: for bitrate in bitrates: connection_provider = clip.get("connectionProvider", "clustering") plugins = verifyjson(json, "plugins") provider_plugin = verifyjson(plugins, connection_provider) swf = verifyjson(provider_plugin, "url") rtmp = verifyjson(provider_plugin, "netConnectionUrl") quality = self._get_quality(verifyjson(bitrate, "label")) url = verifyjson(bitrate, "url") streams[quality] = RTMPStream( self.session, { "rtmp": rtmp, "pageUrl": self.url, "playpath": url, "swfVfy": SWF_BASE + swf, "live": True }) else: for bitrate in bitrates: base_url = verifyjson(clip, "baseUrl") url = verifyjson(bitrate, "url") quality = self._get_quality(verifyjson(bitrate, "label")) streams[quality] = HTTPStream(self.session, base_url + "/" + url) return streams
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): match = _url_re.match(self.url) channel = match.group("channel") res = http.get(API_URL.format(channel)) room = http.json(res, schema=_room_schema) if not room: return if room["show_status"] != SHOW_STATUS_ONLINE: return url = "{room[rtmp_url]}/{room[rtmp_live]}".format(room=room) stream = HTTPStream(self.session, url) yield "source", stream for name, url in room["rtmp_multi_bitrate"].items(): url = "{room[rtmp_url]}/{url}".format(room=room, url=url) stream = HTTPStream(self.session, url) yield name, stream
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 _get_source_streams(self): res = http.get(self.url) streams = {} sources = _source_re.findall(res.text) for source in sources: src = _source_src_re.search(source).group("src") pixels = _source_type_re.search(source).group("type") streams[pixels] = HTTPStream(self.session, src) return streams
def _get_vod_streams(self): res = urlget(self.url) flashvars = re.search("FlashVars=\"(.+?)\"", res.text) if not flashvars: raise PluginError("Unable to find flashvars on page") flashvars = parse_qs(flashvars.group(1)) for var in ("vjoinid", "conid", "leagueid"): if not var in flashvars: raise PluginError( ("Missing key '{0}' in flashvars").format(var)) streams = {} qualities = ["SQ", "HQ"] for quality in qualities: params = dict(leagueid=flashvars["leagueid"][0], vjoinid=flashvars["vjoinid"][0], conid=flashvars["conid"][0], title="", ref="", tmpstamp=int(time.time()), strLevel=quality) res = urlget(self.GOXVODURL, params=params, session=self.rsession) if res.text != "1002" and len(res.text) > 0: gox = self._parse_gox_file(res.text) entry = gox[0] nokey = False for var in ("NODEIP", "NODEID", "UNO", "USERIP"): if not var in entry: nokey = True if nokey: self.logger.warning( "Unable to fetch key, make sure that you have access to this VOD" ) continue key = self._check_vod_key(entry["NODEIP"], entry["NODEID"], entry["UNO"], entry["USERIP"]) streams[quality.lower()] = HTTPStream( self.session, gox[0]["REF"], params=dict(key=key), headers=self.StreamHeaders) return streams
def _get_streams(self): self.logger.debug("Fetching stream info") media_is_live = 0 match = re.search(r".*hitbox.tv/([^/]*)/?(\d+)?", self.url) if not match: return stream_name, media_id = match.groups() if stream_name != "video": res = http.get(LIVE_API.format(stream_name)) json = http.json(res) livestream = verifyjson(json, "livestream") media_id = verifyjson(livestream[0], "media_id") media_is_live = int(verifyjson(livestream[0], "media_is_live")) if not media_is_live: return media_type = "live" if media_is_live else "video" res = http.get(PLAYER_API.format(media_type, media_id)) json = http.json(res) clip = verifyjson(json, "clip") live = verifyjson(clip, "live") streams = {} if live: playlists = verifyjson(json, "playlist") or [] for playlist in filter(valid_playlist, playlists): bitrates = playlist.get("bitrates") rtmp = playlist.get("netConnectionUrl") for bitrate in bitrates: quality = self._get_quality(verifyjson(bitrate, "label")) url = verifyjson(bitrate, "url") streams[quality] = RTMPStream(self.session, { "rtmp": rtmp, "pageUrl": self.url, "playpath": url, "swfVfy": SWF_URL, "live": True }) else: bitrates = verifyjson(clip, "bitrates") for bitrate in bitrates: base_url = verifyjson(clip, "baseUrl") url = verifyjson(bitrate, "url") quality = self._get_quality(verifyjson(bitrate, "label")) streams[quality] = HTTPStream(self.session, base_url + "/" + url) return streams
def _get_streams(self): res = http.get(self.url, schema=_schema) if res["export_url"]: return self._get_live_stream(res["export_url"]) elif res["video_flashvars"]: stream = RTMPStream( self.session, { "rtmp": res["video_flashvars"]["_111pix_serverURL"], "playpath": res["video_flashvars"]["en_flash_providerName"], "swfVfy": SWF_VIDEO_URL, "pageUrl": self.url }) return dict(video=stream) elif res["standby_video"]: for stream in res["standby_video"]: stream = HTTPStream(self.session, stream["streamName"]) return dict(replay=stream) elif res["history_video"]: stream = HTTPStream(self.session, res["history_video"]) return dict(history=stream) return
def _get_http_streams(self, info): name = QUALITY_MAP.get(info["_quality"], "vod") urls = info["_stream"] if not isinstance(info["_stream"], list): urls = [urls] streams = {} for url in urls: stream = HTTPStream(self.session, url) if streams: streams[name + "_alt"] = stream else: streams[name] = stream return streams
def _get_streams(self): playlist = http.get(self.url, schema=_playlist_schema) streams = {} for item in playlist: for source in item["sources"]: filename = source["file"] if filename.endswith(".smil"): streams.update(self._get_smil_streams(filename)) elif filename.startswith("/"): name = source.get("label", "vod") url = BASE_VOD_URL + filename streams[name] = HTTPStream(self.session, url) break return streams
def _get_history(self): video_id = self.url.rstrip("/").rpartition("/")[2] self.logger.debug("Testing if video exist") history_url = 'http://www.filmon.us/video/history/hid/' + video_id if urlresolve(prepend_www(history_url)) == '/': raise PluginError("history number " + video_id + " don't exist") self.logger.debug("Fetching video URL") res = urlget(history_url) match = re.search("http://cloud.battlecam.com/([/\w]+).flv", res.text) if not match: return url = match.group(0) return HTTPStream(self.session, url)