def _parse_smil(self, url): res = urlget(url) try: dom = xml.dom.minidom.parseString(res.text) except Exception as err: raise PluginError(("Unable to parse config XML: {0})").format(err)) httpbase = None streams = {} for meta in dom.getElementsByTagName("meta"): if meta.getAttribute("name") == "httpBase": httpbase = meta.getAttribute("content") break if not httpbase: raise PluginError("Missing HTTP base in SMIL") for video in dom.getElementsByTagName("video"): url = "{0}/{1}".format(httpbase, video.getAttribute("src")) bitrate = int(video.getAttribute("system-bitrate")) streams[bitrate] = AkamaiHDStream(self.session, url) return streams
def _parse_smil(self, url, swf_url): res = http.get(url) smil = http.xml(res, "SMIL config", schema=_smil_schema) for src, bitrate in smil["videos"]: url = urljoin(smil["http_base"], src) yield bitrate, AkamaiHDStream(self.session, url, swf=swf_url)
def _parse_result(self, res): res = _viewerexp_schema.validate(res) player = res.programmedContent["videoPlayer"] renditions = sorted(player.mediaDTO.renditions.values(), key=attrgetter("encodingRate")) streams = {} for stream_name, rendition in zip(STREAM_NAMES, renditions): stream = AkamaiHDStream(self.session, rendition.defaultURL) streams[stream_name] = stream return streams
def _parse_result(self, res): streams = {} if not hasattr(res, "programmedContent"): raise PluginError("Invalid result") player = res.programmedContent["videoPlayer"] if not hasattr(player, "mediaDTO"): raise PluginError("Invalid result") for i, rendition in player.mediaDTO.renditions.items(): stream = AkamaiHDStream(self.session, rendition.defaultURL) streamname = "{0}p".format(rendition.frameHeight) streams[streamname] = stream return streams
def _parse_result(self, res): streams = {} if not hasattr(res, "programmedContent"): raise PluginError("Invalid result") player = res.programmedContent["videoPlayer"] if not hasattr(player, "mediaDTO"): raise PluginError("Invalid result") renditions = sorted(player.mediaDTO.renditions.values(), key=attrgetter("encodingRate")) for stream_name, rendition in zip(STREAM_NAMES, renditions): stream = AkamaiHDStream(self.session, rendition.defaultURL) streams[stream_name] = stream return streams
def _parse_smil(self, url): res = urlget(url) dom = res_xml(res, "config XML") httpbase = None streams = {} for meta in dom.getElementsByTagName("meta"): if meta.getAttribute("name") == "httpBase": httpbase = meta.getAttribute("content") break if not httpbase: raise PluginError("Missing HTTP base in SMIL") for video in dom.getElementsByTagName("video"): url = "{0}/{1}".format(httpbase, video.getAttribute("src")) bitrate = int(video.getAttribute("system-bitrate")) streams[bitrate] = AkamaiHDStream(self.session, url) return streams
def _parse_smil(self, url): res = urlget(url) smil = res_xml(res, "SMIL config") streams = {} httpbase = smil.find("{http://www.w3.org/2001/SMIL20/Language}head/" "{http://www.w3.org/2001/SMIL20/Language}meta[@name='httpBase']") if not (httpbase is not None and httpbase.attrib.get("content")): raise PluginError("Missing HTTP base in SMIL") httpbase = httpbase.attrib.get("content") videos = smil.findall("{http://www.w3.org/2001/SMIL20/Language}body/" "{http://www.w3.org/2001/SMIL20/Language}switch/" "{http://www.w3.org/2001/SMIL20/Language}video") for video in videos: url = urljoin(httpbase, video.attrib.get("src")) bitrate = int(video.attrib.get("system-bitrate")) streams[bitrate] = AkamaiHDStream(self.session, url) return streams