def _get_video(self, janson): if "live" in janson: self.options.live = janson["live"] if "subtitleReferences" in janson: for i in janson["subtitleReferences"]: if i["format"] == "websrt" and "url" in i: yield subtitle(copy.copy(self.options), "wrst", i["url"]) if "videoReferences" in janson: if len(janson["videoReferences"]) == 0: yield ServiceError("Media doesn't have any associated videos (yet?)") return for i in janson["videoReferences"]: parse = urlparse(i["url"]) query = parse_qs(parse.query) if i["format"] == "hls": streams = hlsparse(self.options, self.http.request("get", i["url"]), i["url"]) if streams: for n in list(streams.keys()): yield streams[n] if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if alt: streams = hlsparse(self.options, self.http.request("get", alt.request.url), alt.request.url) if streams: for n in list(streams.keys()): yield streams[n] if i["format"] == "hds": match = re.search(r"\/se\/secure\/", i["url"]) if not match: streams = hdsparse(self.options, self.http.request("get", i["url"], params={"hdcore": "3.7.0"}), i["url"]) if streams: for n in list(streams.keys()): yield streams[n] if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if alt: streams = hdsparse(self.options, self.http.request("get", alt.request.url, params={"hdcore": "3.7.0"}), alt.request.url) if streams: for n in list(streams.keys()): yield streams[n] if i["format"] == "dash264" or i["format"] == "dashhbbtv": streams = dashparse(self.options, self.http.request("get", i["url"]), i["url"]) if streams: for n in list(streams.keys()): yield streams[n] if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if alt: streams = dashparse(self.options, self.http.request("get", alt.request.url), alt.request.url) if streams: for n in list(streams.keys()): yield streams[n]
def _get_video(self, janson): articleid = janson["article"]["currentArticleId"] components = janson["articles"][articleid]["article"]["components"] for i in components: if "components" in i: for n in i["components"]: if "type" in n and n["type"] == "video": streams = hlsparse(self.options, self.http.request("get", n["videoAsset"]["streamUrls"]["hls"]), n["videoAsset"]["streamUrls"]["hls"]) if streams: for key in list(streams.keys()): yield streams[key] if "videoAsset" in i and "streamUrls" in i["videoAsset"]: streams = [] streamUrls = i["videoAsset"]["streamUrls"] if "hls" in streamUrls: streams.append(hlsparse(self.options, self.http.request("get", streamUrls["hls"]), streamUrls["hls"])) if "hds" in streamUrls: streams.append(hdsparse(self.options, self.http.request("get", streamUrls["hds"], params={"hdcore": "3.7.0"}), streamUrls["hds"])) if streams: for s in streams: for key in list(s.keys()): yield s[key]
def get(self, options): data = self.get_urldata() if self.exclude(options): yield ServiceError("Excluding video") return match = re.search("<link rel='shortlink' href='http://www.dplay.se/\?p=(\d+)", data) if not match: yield ServiceError("Can't find video id") return data = self.http.request("get", "http://geo.dplay.se/geo.js").text dataj = json.loads(data) geo = dataj["countryCode"] timestamp = (int(time.time())+3600)*1000 cookie = {"dsc-geo": quote('{"countryCode":"%s","expiry":%s}' % (geo, timestamp))} data = self.http.request("get", "https://secure.dplay.se/secure/api/v2/user/authorization/stream/%s?stream_type=hds" % match.group(1), cookies=cookie) dataj = json.loads(data.text) if "hds" in dataj: streams = hdsparse(copy.copy(options), self.http.request("get", dataj["hds"], params={"hdcore": "3.8.0"}), dataj["hds"]) if streams: for n in list(streams.keys()): yield streams[n] data = self.http.request("get", "https://secure.dplay.se/secure/api/v2/user/authorization/stream/%s?stream_type=hls" % match.group(1), cookies=cookie) dataj = json.loads(data.text) if "hls" in dataj: streams = hlsparse(options, self.http.request("get", dataj["hls"]), dataj["hls"]) if streams: for n in list(streams.keys()): yield streams[n]
def get(self, options): data = self.get_urldata() if self.exclude(options): return extention = False filename = os.path.basename(self.url[:self.url.rfind("/")-1]) if options.output and os.path.isdir(options.output): options.output = os.path.join(os.path.dirname(options.output), filename) extention = True elif options.output is None: options.output = "%s" % filename extention = True if self.url.find(".f4m") > 0: if extention: options.output = "%s.flv" % options.output streams = hdsparse(options, self.http.request("get", self.url, params={"hdcore": "3.7.0"}), self.url) if streams: for n in list(streams.keys()): yield streams[n] if self.url.find(".m3u8") > 0: streams = hlsparse(options, self.http.request("get", self.url), self.url) if extention: options.output = "%s.ts" % options.output for n in list(streams.keys()): yield streams[n]
def get(self): if self.exclude(): return extention = False filename = os.path.basename(self.url[:self.url.rfind("/")]) if self.options.output and os.path.isdir(self.options.output): self.options.output = os.path.join(os.path.dirname(self.options.output), filename) extention = True elif self.options.output is None: self.options.output = filename extention = True streams = [] if re.search(".f4m", self.url): if extention: self.options.output = "{0}.flv".format(self.options.output) streams.append(hdsparse(self.options, self.http.request("get", self.url, params={"hdcore": "3.7.0"}), self.url)) if re.search(".m3u8", self.url): streams.append(hlsparse(self.options, self.http.request("get", self.url), self.url)) if re.search(".mpd", self.url): streams.append(dashparse(self.options, self.http.request("get", self.url), self.url)) for stream in streams: if stream: for n in list(stream.keys()): yield stream[n]
def get(self, options): error, data = self.get_urldata() if error: log.error("Can't get the page") return if self.exclude(options): return extention = False filename = os.path.basename(self.url[:self.url.rfind("/")-1]) if options.output and os.path.isdir(options.output): options.output = "%s/%s" % (os.path.dirname(options.output), filename) extention = True elif options.output is None: options.output = "%s" % filename extention = True if self.url.find(".f4m") > 0: if extention: options.output = "%s.flv" % options.output streams = hdsparse(copy.copy(options), self.url) if streams: for n in list(streams.keys()): yield streams[n] if self.url.find(".m3u8") > 0: streams = hlsparse(self.url) if extention: options.output = "%s.ts" % options.output for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n)
def get(self): if self.exclude(): return extention = False filename = os.path.basename(self.url[:self.url.rfind("/") - 1]) if self.options.output and os.path.isdir(self.options.output): self.options.output = os.path.join( os.path.dirname(self.options.output), filename) extention = True elif self.options.output is None: self.options.output = filename extention = True if re.search(".f4m", self.url): if extention: self.options.output = "%s.flv" % self.options.output streams = hdsparse( self.options, self.http.request("get", self.url, params={"hdcore": "3.7.0"}), self.url) if streams: for n in list(streams.keys()): yield streams[n] if re.search(".m3u8", self.url): streams = hlsparse(self.options, self.http.request("get", self.url), self.url) if extention: self.options.output = "%s.ts" % self.options.output for n in list(streams.keys()): yield streams[n]
def get(self): filename = os.path.basename(self.url[:self.url.rfind("/")]) self.output["title"] = filename streams = [] if re.search(".f4m", self.url): self.output["ext"] = "flv" streams.append( hdsparse(self.config, self.http.request("get", self.url, params={"hdcore": "3.7.0"}), self.url, output=self.output)) if re.search(".m3u8", self.url): streams.append( hlsparse(self.config, self.http.request("get", self.url), self.url, output=self.output)) if re.search(".mpd", self.url): streams.append( dashparse(self.config, self.http.request("get", self.url), self.url, output=self.output)) for stream in streams: if stream: for n in list(stream.keys()): yield stream[n]
def get(self): data = self.get_urldata() match = re.search(r'data-videoid="([^"]+)"', data) if not match: parse = urlparse(self.url) match = re.search(r"video/(\d+)/", parse.fragment) if not match: yield ServiceError(f"Can't find video file for: {self.url}") return videoid = match.group(1) data = self.http.request("get", f"http://svp.vg.no/svp/api/v1/vgtv/assets/{videoid}?appName=vgtv-website").text jsondata = json.loads(data) self.output["title"] = jsondata["title"] if "hds" in jsondata["streamUrls"]: streams = hdsparse( self.config, self.http.request("get", jsondata["streamUrls"]["hds"], params={"hdcore": "3.7.0"}), jsondata["streamUrls"]["hds"], output=self.output, ) for n in list(streams.keys()): yield streams[n] if "hls" in jsondata["streamUrls"]: streams = hlsparse( self.config, self.http.request("get", jsondata["streamUrls"]["hls"]), jsondata["streamUrls"]["hls"], output=self.output, ) for n in list(streams.keys()): yield streams[n] if "mp4" in jsondata["streamUrls"]: yield HTTP(copy.copy(self.config), jsondata["streamUrls"]["mp4"], output=self.output)
def get(self): data = self.get_urldata() match = re.search(r'data-videoid="([^"]+)"', data) if not match: parse = urlparse(self.url) match = re.search(r'video/(\d+)/', parse.fragment) if not match: yield ServiceError("Can't find video file for: {0}".format(self.url)) return videoid = match.group(1) data = self.http.request("get", "http://svp.vg.no/svp/api/v1/vgtv/assets/{0}?appName=vgtv-website".format(videoid)).text jsondata = json.loads(data) self.output["title"] = jsondata["title"] if "hds" in jsondata["streamUrls"]: streams = hdsparse(self.config, self.http.request("get", jsondata["streamUrls"]["hds"], params={"hdcore": "3.7.0"}), jsondata["streamUrls"]["hds"], output=self.output) for n in list(streams.keys()): yield streams[n] if "hls" in jsondata["streamUrls"]: streams = hlsparse(self.config, self.http.request("get", jsondata["streamUrls"]["hls"]), jsondata["streamUrls"]["hls"], output=self.output) for n in list(streams.keys()): yield streams[n] if "mp4" in jsondata["streamUrls"]: yield HTTP(copy.copy(self.config), jsondata["streamUrls"]["mp4"], output=self.output)
def get(self, options): data = self.get_urldata() match = re.search('data-subtitlesurl = "(/.*)"', data) if match: parse = urlparse(self.url) subtitle = "%s://%s%s" % (parse.scheme, parse.netloc, match.group(1)) yield subtitle_tt(subtitle) match = re.search(r'data-media="(.*manifest.f4m)"', data) if match: manifest_url = match.group(1) else: match = re.search(r'data-video-id="(\d+)"', data) if match is None: log.error("Can't find video id.") sys.exit(2) vid = match.group(1) match = re.search(r"PS_VIDEO_API_URL : '([^']*)',", data) if match is None: log.error("Can't find server address with media info") sys.exit(2) dataurl = "%smediaelement/%s" % (match.group(1), vid) data = json.loads(get_http_data(dataurl)) manifest_url = data["mediaUrl"] options.live = data["isLive"] hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8") streams = hlsparse(hlsurl) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) manifest_url = "%s?hdcore=2.8.0&g=hejsan" % manifest_url streams = hdsparse(copy.copy(options), manifest_url) for n in list(streams.keys()): yield streams[n]
def get(self, options): match = re.search(r'data-videoid="([^"]+)"', self.get_urldata()) if not match: parse = urlparse(self.url) match = re.search(r'video/(\d+)/', parse.fragment) if not match: log.error("Can't find video id") sys.exit(2) videoid = match.group(1) data = get_http_data("http://svp.vg.no/svp/api/v1/vgtv/assets/%s?appName=vgtv-website" % videoid) jsondata = json.loads(data) if options.output_auto: directory = os.path.dirname(options.output) title = "%s" % jsondata["title"] title = filenamify(title) if len(directory): options.output = "%s/%s" % (directory, title) else: options.output = title if "hds" in jsondata["streamUrls"]: parse = urlparse(jsondata["streamUrls"]["hds"]) manifest = "%s://%s%s?%s&hdcore=3.3.0" % (parse.scheme, parse.netloc, parse.path, parse.query) streams = hdsparse(copy.copy(options), manifest) if streams: for n in list(streams.keys()): yield streams[n] if "hls" in jsondata["streamUrls"]: streams = hlsparse(jsondata["streamUrls"]["hls"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) if "mp4" in jsondata["streamUrls"]: yield HTTP(copy.copy(options), jsondata["streamUrls"]["mp4"])
def get(self): data = self.get_urldata() match = re.search(r'resource:[ ]*"([^"]*)",', data) if match: resource_url = match.group(1) resource_data = self.http.request("get", resource_url).content resource = json.loads(resource_data) streams = self.find_stream(self.config, resource) yield from streams else: match = re.search(r'resource="([^"]*)"', data) if not match: yield ServiceError("Cant find resource info for this video") return if match.group(1)[:4] != "http": resource_url = "http:{}".format(match.group(1)) else: resource_url = match.group(1) resource_data = self.http.request("get", resource_url).text resource = json.loads(resource_data) if "Links" not in resource: yield ServiceError("Cant access this video. its geoblocked.") return if "SubtitlesList" in resource and len( resource["SubtitlesList"]) > 0: suburl = resource["SubtitlesList"][0]["Uri"] yield subtitle(copy.copy(self.config), "wrst", suburl, output=self.output) if "Data" in resource: streams = self.find_stream(self.config, resource) yield from streams else: for stream in resource["Links"]: uri = stream["Uri"] if uri is None: uri = self._decrypt(stream["EncryptedUri"]) if stream["Target"] == "HDS": streams = hdsparse(copy.copy(self.config), self.http.request( "get", uri, params={"hdcore": "3.7.0"}), uri, output=self.output) if streams: for n in list(streams.keys()): yield streams[n] if stream["Target"] == "HLS": streams = hlsparse(self.config, self.http.request("get", uri), uri, output=self.output) for n in list(streams.keys()): yield streams[n]
def get(self): data = self.get_urldata() if self.exclude(): yield ServiceError("Excluding video") return match = re.search(r'id="(bcPl[^"]+)"', data) if not match: yield ServiceError("Can't find flash id.") return flashid = match.group(1) match = re.search(r'playerID" value="([^"]+)"', self.get_urldata()) if not match: yield ServiceError("Can't find playerID") return playerid = match.group(1) match = re.search(r'playerKey" value="([^"]+)"', self.get_urldata()) if not match: yield ServiceError("Can't find playerKey") return playerkey = match.group(1) match = re.search(r'videoPlayer" value="([^"]+)"', self.get_urldata()) if not match: yield ServiceError("Can't find videoPlayer info") return videoplayer = match.group(1) dataurl = "http://c.brightcove.com/services/viewer/htmlFederated?flashID={0}&playerID={1}&playerKey={2}&isVid=true&isUI=true&dynamicStreaming=true&@videoPlayer={3}".format(flashid, playerid, playerkey, videoplayer) data = self.http.request("get", dataurl).content match = re.search(r'experienceJSON = ({.*});', data) if not match: yield ServiceError("Can't find json data") return jsondata = json.loads(match.group(1)) renditions = jsondata["data"]["programmedContent"]["videoPlayer"]["mediaDTO"]["renditions"] if jsondata["data"]["publisherType"] == "PREMIUM": yield ServiceError("Premium content") return for i in renditions: if i["defaultURL"].endswith("f4m"): streams = hdsparse(copy.copy(self.options), self.http.request("get", i["defaultURL"], params={"hdcore": "3.7.0"}), i["defaultURL"]) if streams: for n in list(streams.keys()): yield streams[n] if i["defaultURL"].endswith("m3u8"): streams = hlsparse(self.options, self.http.request("get", i["defaultURL"]), i["defaultURL"]) for n in list(streams.keys()): yield streams[n] if i["defaultURL"].endswith("mp4"): yield HTTP(copy.copy(self.options), i["defaultURL"], i["encodingRate"] / 1024)
def get(self): if self.exclude(): yield ServiceError("Excluding video") return ajax_auth = self.get_auth() if not ajax_auth: yield ServiceError("Cant find token for video") return mediaid = self.get_mediaid() if not mediaid: yield ServiceError("Cant find media id") return if not isinstance(mediaid, str): mediaid = mediaid.group(1) jsondata = self.http.request( "get", "http://csp.picsearch.com/rest?jsonp=&eventParam=1&auth=%s&method=embed&mediaid=%s" % (ajax_auth.group(1), mediaid)).text jsondata = json.loads(jsondata) if "playerconfig" not in jsondata["media"]: yield ServiceError(jsondata["error"]) return if "live" in jsondata["media"]["playerconfig"]["clip"]: self.options.live = jsondata["media"]["playerconfig"]["clip"] playlist = jsondata["media"]["playerconfig"]["playlist"][1] if "bitrates" in playlist: files = playlist["bitrates"] server = jsondata["media"]["playerconfig"]["plugins"]["bwcheck"][ "netConnectionUrl"] for i in files: self.options.other = "-y '%s'" % i["url"] yield RTMP(copy.copy(self.options), server, i["height"]) if "provider" in playlist: if playlist["provider"] != "rtmp": if "live" in playlist: self.options.live = playlist["live"] if playlist["url"].endswith(".f4m"): streams = hdsparse( self.options, self.http.request("get", playlist["url"], params={"hdcore": "3.7.0"}), playlist["url"]) if streams: for n in list(streams.keys()): yield streams[n] if ".m3u8" in playlist["url"]: streams = hlsparse( self.options, self.http.request("get", playlist["url"]), playlist["url"]) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): data = self.get_urldata() match = re.search(r'id="(bcPl[^"]+)"', data) if not match: yield ServiceError("Can't find flash id.") return flashid = match.group(1) match = re.search(r'playerID" value="([^"]+)"', self.get_urldata()) if not match: yield ServiceError("Can't find playerID") return playerid = match.group(1) match = re.search(r'playerKey" value="([^"]+)"', self.get_urldata()) if not match: yield ServiceError("Can't find playerKey") return playerkey = match.group(1) match = re.search(r'videoPlayer" value="([^"]+)"', self.get_urldata()) if not match: yield ServiceError("Can't find videoPlayer info") return videoplayer = match.group(1) dataurl = ( "http://c.brightcove.com/services/viewer/htmlFederated?flashID={}&playerID={}&playerKey={}" "&isVid=true&isUI=true&dynamicStreaming=true&@videoPlayer={}".format(flashid, playerid, playerkey, videoplayer) ) data = self.http.request("get", dataurl).content match = re.search(r"experienceJSON = ({.*});", data) if not match: yield ServiceError("Can't find json data") return jsondata = json.loads(match.group(1)) renditions = jsondata["data"]["programmedContent"]["videoPlayer"]["mediaDTO"]["renditions"] if jsondata["data"]["publisherType"] == "PREMIUM": yield ServiceError("Premium content") return for i in renditions: if i["defaultURL"].endswith("f4m"): streams = hdsparse( copy.copy(self.config), self.http.request("get", i["defaultURL"], params={"hdcore": "3.7.0"}), i["defaultURL"], output=self.output ) for n in list(streams.keys()): yield streams[n] if i["defaultURL"].endswith("m3u8"): streams = hlsparse(self.config, self.http.request("get", i["defaultURL"]), i["defaultURL"], output=self.output) for n in list(streams.keys()): yield streams[n] if i["defaultURL"].endswith("mp4"): yield HTTP(copy.copy(self.config), i["defaultURL"], i["encodingRate"] / 1024, output=self.output)
def _get_video(self, janson): if "subtitleReferences" in janson: for i in janson["subtitleReferences"]: if i["format"] == "websrt" and "url" in i: yield subtitle(copy.copy(self.config), "wrst", i["url"], output=self.output) if "videoReferences" in janson: if len(janson["videoReferences"]) == 0: yield ServiceError("Media doesn't have any associated videos.") return for i in janson["videoReferences"]: streams = None alt_streams = None alt = None query = parse_qs(urlparse(i["url"]).query) if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if i["format"] == "hls": streams = hlsparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output) if alt: alt_streams = hlsparse(self.config, self.http.request("get", alt.request.url), alt.request.url, output=self.output) elif i["format"] == "hds": match = re.search(r"\/se\/secure\/", i["url"]) if not match: streams = hdsparse(self.config, self.http.request("get", i["url"], params={"hdcore": "3.7.0"}), i["url"], output=self.output) if alt: alt_streams = hdsparse(self.config, self.http.request("get", alt.request.url, params={"hdcore": "3.7.0"}), alt.request.url, output=self.output) elif i["format"] == "dash264" or i["format"] == "dashhbbtv": streams = dashparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output) if alt: alt_streams = dashparse(self.config, self.http.request("get", alt.request.url), alt.request.url, output=self.output) if streams: for n in list(streams.keys()): yield streams[n] if alt_streams: for n in list(alt_streams.keys()): yield alt_streams[n]
def get(self, options): if re.findall("svt.se", self.url): match = re.search(r"data-json-href=\"(.*)\"", self.get_urldata()) if match: filename = match.group(1).replace("&", "&").replace("&format=json", "") url = "http://www.svt.se%s" % filename else: log.error("Can't find video file") sys.exit(2) else: url = self.url pos = url.find("?") if pos < 0: dataurl = "%s?&output=json&format=json" % url else: dataurl = "%s&output=json&format=json" % url data = json.loads(get_http_data(dataurl)) if "live" in data["video"]: options.live = data["video"]["live"] else: options.live = False if data["video"]["subtitleReferences"]: try: subtitle = data["video"]["subtitleReferences"][0]["url"] except KeyError: pass if len(subtitle) > 0: yield subtitle_wsrt(subtitle) for i in data["video"]["videoReferences"]: parse = urlparse(i["url"]) if parse.path.find("m3u8") > 0: streams = hlsparse(i["url"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) elif parse.path.find("f4m") > 0: match = re.search(r"\/se\/secure\/", i["url"]) if not match: parse = urlparse(i["url"]) manifest = "%s://%s%s?%s&hdcore=3.3.0" % (parse.scheme, parse.netloc, parse.path, parse.query) streams = hdsparse(copy.copy(options), manifest) for n in list(streams.keys()): yield streams[n] elif parse.scheme == "rtmp": embedurl = "%s?type=embed" % url data = get_http_data(embedurl) match = re.search(r"value=\"(/(public)?(statiskt)?/swf(/video)?/svtplayer-[0-9\.a-f]+swf)\"", data) swf = "http://www.svtplay.se%s" % match.group(1) options.other = "-W %s" % swf yield RTMP(copy.copy(options), i["url"], i["bitrate"]) else: yield HTTP(copy.copy(options), i["url"], "0")
def get(self, options): error, data = self.get_urldata() if error: log.error("Can't download page.") return if self.exclude(options): return match = re.search(r'id="(bcPl[^"]+)"', data) if not match: log.error("Can't find flash id.") return flashid = match.group(1) match = re.search(r'playerID" value="([^"]+)"', self.get_urldata()[1]) if not match: log.error("Can't find playerID") return playerid = match.group(1) match = re.search(r'playerKey" value="([^"]+)"', self.get_urldata()[1]) if not match: log.error("Can't find playerKey") return playerkey = match.group(1) match = re.search(r'videoPlayer" value="([^"]+)"', self.get_urldata()[1]) if not match: log.error("Can't find videoPlayer info") return videoplayer = match.group(1) dataurl = "http://c.brightcove.com/services/viewer/htmlFederated?flashID=%s&playerID=%s&playerKey=%s&isVid=true&isUI=true&dynamicStreaming=true&@videoPlayer=%s" % (flashid, playerid, playerkey, videoplayer) error, data = get_http_data(dataurl) if error: log.error("Cant download video info") return match = re.search(r'experienceJSON = ({.*});', data) if not match: log.error("Can't find json data") return jsondata = json.loads(match.group(1)) renditions = jsondata["data"]["programmedContent"]["videoPlayer"]["mediaDTO"]["renditions"] for i in renditions: if i["defaultURL"].endswith("f4m"): streams = hdsparse(copy.copy(options), i["defaultURL"]) if streams: for n in list(streams.keys()): yield streams[n] if i["defaultURL"].endswith("m3u8"): streams = hlsparse(i["defaultURL"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n)
def get(self, options): error, data = self.get_urldata() if error: log.error("Can't download page.") return if self.exclude(options): return match = re.search(r'resource:[ ]*"([^"]*)",', data) if match: resource_url = match.group(1) error, resource_data = get_http_data(resource_url) if error: log.error("Can't get resource data") return resource = json.loads(resource_data) streams = find_stream(options, resource) for i in streams: yield i else: match = re.search(r'resource="([^"]*)"', data) if not match: log.error("Cant find resource info for this video") return resource_url = "%s" % match.group(1) error, resource_data = get_http_data(resource_url) if error: log.error("Can't get resource data") return resource = json.loads(resource_data) if "SubtitlesList" in resource: suburl = resource["SubtitlesList"][0]["Uri"] yield subtitle(copy.copy(options), "wrst", suburl) if "Data" in resource: streams = find_stream(options, resource) for i in streams: yield i else: for stream in resource['Links']: if stream["Target"] == "HDS": streams = hdsparse(copy.copy(options), stream["Uri"]) if streams: for n in list(streams.keys()): yield streams[n] if stream["Target"] == "HLS": streams = hlsparse(stream["Uri"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) if stream["Target"] == "Streaming": options.other = "-v -y '%s'" % stream['Uri'].replace("rtmp://vod.dr.dk/cms/", "") rtmp = "rtmp://vod.dr.dk/cms/" yield RTMP(copy.copy(options), rtmp, stream['Bitrate'])
def get(self, options): vid = self._get_video_id() if vid is None: log.error("Cant find video file") sys.exit(2) url = "http://playapi.mtgx.tv/v3/videos/%s" % vid options.other = "" data = get_http_data(url) dataj = json.loads(data) if "msg" in dataj: log.error("%s" % dataj["msg"]) return if dataj["type"] == "live": options.live = True if dataj["sami_path"]: yield subtitle_sami(dataj["sami_path"]) streams = get_http_data("http://playapi.mtgx.tv/v3/videos/stream/%s" % vid) streamj = json.loads(streams) if "msg" in streamj: log.error( "Can't play this because the video is either not found or geoblocked." ) return if streamj["streams"]["medium"]: filename = streamj["streams"]["medium"] if filename[len(filename) - 3:] == "f4m": manifest = "%s?hdcore=2.8.0&g=hejsan" % filename streams = hdsparse(copy.copy(options), manifest) if streams: for n in list(streams.keys()): yield streams[n] else: parse = urlparse(filename) match = re.search("^(/[^/]+)/(.*)", parse.path) if not match: log.error("Somthing wrong with rtmpparse") sys.exit(2) filename = "%s://%s:%s%s" % (parse.scheme, parse.hostname, parse.port, match.group(1)) path = "-y %s" % match.group(2) options.other = "-W http://flvplayer.viastream.viasat.tv/flvplayer/play/swf/player.swf %s" % path yield RTMP(copy.copy(options), filename, 800) if streamj["streams"]["hls"]: streams = hlsparse(streamj["streams"]["hls"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n)
def get(self, options): data = self.get_urldata() if self.exclude(options): yield ServiceError("Excluding video") return match = re.search(r'resource:[ ]*"([^"]*)",', data) if match: resource_url = match.group(1) resource_data = self.http.request("get", resource_url).content resource = json.loads(resource_data) streams = self.find_stream(options, resource) for i in streams: yield i else: match = re.search(r'resource="([^"]*)"', data) if not match: yield ServiceError("Cant find resource info for this video") return if match.group(1)[:4] != "http": resource_url = "http:%s" % match.group(1) else: resource_url = match.group(1) resource_data = self.http.request("get", resource_url).text resource = json.loads(resource_data) if "Links" not in resource: yield ServiceError("Cant access this video. its geoblocked.") return if "SubtitlesList" in resource: suburl = resource["SubtitlesList"][0]["Uri"] yield subtitle(copy.copy(options), "wrst", suburl) if "Data" in resource: streams = self.find_stream(options, resource) for i in streams: yield i else: for stream in resource['Links']: if stream["Target"] == "HDS": streams = hdsparse(copy.copy(options), self.http.request("get", stream["Uri"], params={"hdcore": "3.7.0"}), stream["Uri"]) if streams: for n in list(streams.keys()): yield streams[n] if stream["Target"] == "HLS": streams = hlsparse(options, self.http.request("get", stream["Uri"]), stream["Uri"]) for n in list(streams.keys()): yield streams[n] if stream["Target"] == "Streaming": options.other = "-v -y '%s'" % stream['Uri'].replace("rtmp://vod.dr.dk/cms/", "") rtmp = "rtmp://vod.dr.dk/cms/" yield RTMP(copy.copy(options), rtmp, stream['Bitrate'])
def get(self): data = self.get_urldata() if self.exclude(): yield ServiceError("Excluding video") return match = re.search(r'resource:[ ]*"([^"]*)",', data) if match: resource_url = match.group(1) resource_data = self.http.request("get", resource_url).content resource = json.loads(resource_data) streams = self.find_stream(self.options, resource) for i in streams: yield i else: match = re.search(r'resource="([^"]*)"', data) if not match: yield ServiceError("Cant find resource info for this video") return if match.group(1)[:4] != "http": resource_url = "http:{0}".format(match.group(1)) else: resource_url = match.group(1) resource_data = self.http.request("get", resource_url).text resource = json.loads(resource_data) if "Links" not in resource: yield ServiceError("Cant access this video. its geoblocked.") return if "SubtitlesList" in resource and len(resource["SubtitlesList"]) > 0: suburl = resource["SubtitlesList"][0]["Uri"] yield subtitle(copy.copy(self.options), "wrst", suburl) if "Data" in resource: streams = self.find_stream(self.options, resource) for i in streams: yield i else: for stream in resource['Links']: if stream["Target"] == "HDS": streams = hdsparse(copy.copy(self.options), self.http.request("get", stream["Uri"], params={"hdcore": "3.7.0"}), stream["Uri"]) if streams: for n in list(streams.keys()): yield streams[n] if stream["Target"] == "HLS": streams = hlsparse(self.options, self.http.request("get", stream["Uri"]), stream["Uri"]) for n in list(streams.keys()): yield streams[n] if stream["Target"] == "Streaming": self.options.other = "-v -y '{0}'".format(stream['Uri'].replace("rtmp://vod.dr.dk/cms/", "")) rtmp = "rtmp://vod.dr.dk/cms/" yield RTMP(copy.copy(self.options), rtmp, stream['Bitrate'])
def get(self): data = self.get_urldata() match = re.search(r'resource:[ ]*"([^"]*)",', data) if match: resource_url = match.group(1) resource_data = self.http.request("get", resource_url).content resource = json.loads(resource_data) streams = self.find_stream(self.config, resource) for i in streams: yield i else: match = re.search(r'resource="([^"]*)"', data) if not match: yield ServiceError("Cant find resource info for this video") return if match.group(1)[:4] != "http": resource_url = "http:{0}".format(match.group(1)) else: resource_url = match.group(1) resource_data = self.http.request("get", resource_url).text resource = json.loads(resource_data) if "Links" not in resource: yield ServiceError("Cant access this video. its geoblocked.") return if "SubtitlesList" in resource and len(resource["SubtitlesList"]) > 0: suburl = resource["SubtitlesList"][0]["Uri"] yield subtitle(copy.copy(self.config), "wrst", suburl, output=self.output) if "Data" in resource: streams = self.find_stream(self.config, resource) for i in streams: yield i else: for stream in resource['Links']: uri = stream["Uri"] if uri is None: uri = self._decrypt(stream["EncryptedUri"]) if stream["Target"] == "HDS": streams = hdsparse(copy.copy(self.config), self.http.request("get", uri, params={"hdcore": "3.7.0"}), uri, output=self.output) if streams: for n in list(streams.keys()): yield streams[n] if stream["Target"] == "HLS": streams = hlsparse(self.config, self.http.request("get", uri), uri, output=self.output) for n in list(streams.keys()): yield streams[n]
def get(self): data = self.get_urldata() match = re.search(r'resource:[ ]*"([^"]*)",', data) if match: resource_url = match.group(1) resource_data = self.http.request("get", resource_url).content resource = json.loads(resource_data) streams = self.find_stream(self.config, resource) for i in streams: yield i else: match = re.search(r'resource="([^"]*)"', data) if not match: yield ServiceError("Cant find resource info for this video") return if match.group(1)[:4] != "http": resource_url = "http:{0}".format(match.group(1)) else: resource_url = match.group(1) resource_data = self.http.request("get", resource_url).text resource = json.loads(resource_data) if "Links" not in resource: yield ServiceError("Cant access this video. its geoblocked.") return if "SubtitlesList" in resource and len(resource["SubtitlesList"]) > 0: suburl = resource["SubtitlesList"][0]["Uri"] yield subtitle(copy.copy(self.config), "wrst", suburl, output=self.output) if "Data" in resource: streams = self.find_stream(self.config, resource) for i in streams: yield i else: for stream in resource['Links']: if stream["Target"] == "HDS": streams = hdsparse(copy.copy(self.config), self.http.request("get", stream["Uri"], params={"hdcore": "3.7.0"}), stream["Uri"], output=self.output) if streams: for n in list(streams.keys()): yield streams[n] if stream["Target"] == "HLS": streams = hlsparse(self.config, self.http.request("get", stream["Uri"]), stream["Uri"], output=self.output) for n in list(streams.keys()): yield streams[n] if stream["Target"] == "Streaming": self.config.set("other", "-v -y '{0}'".format(stream['Uri'].replace("rtmp://vod.dr.dk/cms/", ""))) rtmp = "rtmp://vod.dr.dk/cms/" yield RTMP(copy.copy(self.config), rtmp, stream['Bitrate'], output=self.output)
def get(self): if self.exclude(): yield ServiceError("Excluding video") return # First, fint the video ID from the html document match = re.search("programId: \"([^\"]+)\"", self.get_urldata()) if match: video_id = match.group(1) else: yield ServiceError("Can't find video id.") return # Get media element details match = re.search("apiBaseUrl: '([^']+)'", self.get_urldata()) if not match: yield ServiceError("Cant find apiurl.") return dataurl = "{0}/mediaelement/{1}".format(match.group(1), video_id) data = self.http.request("get", dataurl).text data = json.loads(data) manifest_url = data["mediaUrl"] self.options.live = data["isLive"] if manifest_url is None: yield ServiceError(data["messageType"]) return # Check if subtitles are available if data["subtitlesUrlPath"]: yield subtitle(copy.copy(self.options), "tt", data["subtitlesUrlPath"]) hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8") data = self.http.request("get", hlsurl) if data.status_code == 403: yield ServiceError("Can't fetch the video because of geoblocking") return streams = hlsparse(self.options, data, hlsurl) if streams: for n in list(streams.keys()): yield streams[n] streams = hdsparse( copy.copy(self.options), self.http.request("get", manifest_url, params={"hdcore": "3.7.0"}), manifest_url) if streams: for n in list(streams.keys()): yield streams[n]
def get(self, options): vid = self._get_video_id() if vid is None: log.error("Cant find video file") sys.exit(2) url = "http://playapi.mtgx.tv/v3/videos/%s" % vid options.other = "" data = get_http_data(url) dataj = json.loads(data) if "msg" in dataj: log.error("%s" % dataj["msg"]) return if dataj["type"] == "live": options.live = True if dataj["sami_path"]: yield subtitle_sami(dataj["sami_path"]) streams = get_http_data("http://playapi.mtgx.tv/v3/videos/stream/%s" % vid) streamj = json.loads(streams) if "msg" in streamj: log.error("Can't play this because the video is either not found or geoblocked.") return if streamj["streams"]["medium"]: filename = streamj["streams"]["medium"] if filename[len(filename)-3:] == "f4m": manifest = "%s?hdcore=2.8.0&g=hejsan" % filename streams = hdsparse(copy.copy(options), manifest) if streams: for n in list(streams.keys()): yield streams[n] else: parse = urlparse(filename) match = re.search("^(/[^/]+)/(.*)", parse.path) if not match: log.error("Somthing wrong with rtmpparse") sys.exit(2) filename = "%s://%s:%s%s" % (parse.scheme, parse.hostname, parse.port, match.group(1)) path = "-y %s" % match.group(2) options.other = "-W http://flvplayer.viastream.viasat.tv/flvplayer/play/swf/player.swf %s" % path yield RTMP(copy.copy(options), filename, 800) if streamj["streams"]["hls"]: streams = hlsparse(streamj["streams"]["hls"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n)
def get(self, options): data = self.get_urldata() match = re.search(r'resource:[ ]*"([^"]*)",', data) if match: resource_url = match.group(1) resource_data = get_http_data(resource_url) resource = json.loads(resource_data) tempresource = resource['Data'][0]['Assets'] # To find the VideoResource, they have Images as well for resources in tempresource: if resources['Kind'] == 'VideoResource': links = resources['Links'] break for i in links: if i["Target"] == "Ios": streams = hlsparse(i["Uri"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) else: if i["Target"] == "Streaming": options.other = "-y '%s'" % i["Uri"].replace("rtmp://vod.dr.dk/cms/", "") rtmp = "rtmp://vod.dr.dk/cms/" yield RTMP(copy.copy(options), rtmp, i["Bitrate"]) else: match = re.search(r'resource="([^"]*)"', data) if not match: log.error("Cant find resource info for this video") sys.exit(2) resource_url = "%s" % match.group(1) resource_data = get_http_data(resource_url) resource = json.loads(resource_data) for stream in resource['Links']: if stream["Target"] == "HDS": manifest = "%s?hdcore=2.8.0&g=hejsan" % stream["Uri"] streams = hdsparse(copy.copy(options), manifest) for n in list(streams.keys()): yield streams[n] if stream["Target"] == "HLS": streams = hlsparse(stream["Uri"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) if stream["Target"] == "Streaming": options.other = "-v -y '%s'" % stream['Uri'].replace("rtmp://vod.dr.dk/cms/", "") rtmp = "rtmp://vod.dr.dk/cms/" yield RTMP(copy.copy(options), rtmp, stream['Bitrate'])
def get(self): data = self.get_urldata() if self.exclude(self.options): yield ServiceError("Excluding video") return match = re.search("data-subtitlesurl = \"(/.*)\"", data) if match: parse = urlparse(self.url) suburl = "%s://%s%s" % (parse.scheme, parse.netloc, match.group(1)) yield subtitle(copy.copy(self.options), "tt", suburl) if self.options.force_subtitle: return match = re.search(r'data-media="(.*manifest.f4m)"', self.get_urldata()) if match: manifest_url = match.group(1) else: match = re.search(r'data-nrk-id="([^"]+)"></div><script', self.get_urldata()) if match is None: match = re.search(r'video-id="([^"]+)"', self.get_urldata()) if match is None: yield ServiceError("Can't find video id.") return vid = match.group(1) dataurl = "http://v8.psapi.nrk.no/mediaelement/%s" % vid data = self.http.request("get", dataurl).text data = json.loads(data) manifest_url = data["mediaUrl"] self.options.live = data["isLive"] hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8") data = self.http.request("get", hlsurl) if data.status_code == 403: yield ServiceError("Can't fetch the video because of geoblocked") return streams = hlsparse(self.options, data, hlsurl) for n in list(streams.keys()): yield streams[n] streams = hdsparse(copy.copy(self.options), self.http.request("get", manifest_url, params={"hdcore": "3.7.0"}), manifest_url) if streams: for n in list(streams.keys()): yield streams[n]
def get(self, options): error, data = self.get_urldata() if error: log.error("Can't get the page") return if self.exclude(options): return match = re.search("data-subtitlesurl = \"(/.*)\"", data) if match: parse = urlparse(self.url) suburl = "%s://%s%s" % (parse.scheme, parse.netloc, match.group(1)) yield subtitle(copy.copy(options), "tt", suburl) if options.force_subtitle: return match = re.search(r'data-media="(.*manifest.f4m)"', self.get_urldata()[1]) if match: manifest_url = match.group(1) else: match = re.search(r'data-video-id="(\d+)"', self.get_urldata()[1]) if match is None: log.error("Can't find video id.") return vid = match.group(1) match = re.search(r"PS_VIDEO_API_URL : '([^']*)',", self.get_urldata()[1]) if match is None: log.error("Can't find server address with media info") return dataurl = "%smediaelement/%s" % (match.group(1), vid) error, data = get_http_data(dataurl) data = json.loads(data) manifest_url = data["mediaUrl"] options.live = data["isLive"] hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8") streams = hlsparse(hlsurl) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) streams = hdsparse(copy.copy(options), manifest_url) if streams: for n in list(streams.keys()): yield streams[n]
def get(self, options): match = re.search(r'id="(bcPl[^"]+)"', self.get_urldata()) if not match: log.error("Can't find flash id.") sys.exit(2) flashid = match.group(1) match = re.search(r'playerID" value="([^"]+)"', self.get_urldata()) if not match: log.error("Can't find playerID") sys.exit(2) playerid = match.group(1) match = re.search(r'playerKey" value="([^"]+)"', self.get_urldata()) if not match: log.error("Can't find playerKey") sys.exit(2) playerkey = match.group(1) match = re.search(r'videoPlayer" value="([^"]+)"', self.get_urldata()) if not match: log.error("Can't find videoPlayer info") sys.exit(2) videoplayer = match.group(1) dataurl = "http://c.brightcove.com/services/viewer/htmlFederated?flashID=%s&playerID=%s&playerKey=%s&isVid=true&isUI=true&dynamicStreaming=true&@videoPlayer=%s" % ( flashid, playerid, playerkey, videoplayer) data = get_http_data(dataurl) match = re.search(r'experienceJSON = ({.*});', data) if not match: log.error("Can't find json data") sys.exit(2) jsondata = json.loads(match.group(1)) renditions = jsondata["data"]["programmedContent"]["videoPlayer"][ "mediaDTO"]["renditions"] for i in renditions: if i["defaultURL"].endswith("f4m"): manifest = "%s?hdcore=3.3.0" % i["defaultURL"] streams = hdsparse(copy.copy(options), manifest) if streams: for n in list(streams.keys()): yield streams[n] if i["defaultURL"].endswith("m3u8"): streams = hlsparse(i["defaultURL"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n)
def get(self): # First, fint the video ID from the html document match = re.search('program-id" content="([^"]+)"', self.get_urldata()) if match: video_id = match.group(1) else: yield ServiceError("Can't find video id.") return # Get media element details match = re.search('psapi-base-url="([^"]+)"', self.get_urldata()) if not match: yield ServiceError("Cant find apiurl.") return dataurl = "{}/mediaelement/{}".format(match.group(1), video_id) data = self.http.request("get", dataurl).text data = json.loads(data) manifest_url = data["mediaUrl"] self.config.set("live", data["isLive"]) if manifest_url is None: yield ServiceError(data["messageType"]) return # Check if subtitles are available if data["subtitlesUrlPath"]: yield subtitle(copy.copy(self.config), "tt", data["subtitlesUrlPath"], output=self.output) hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8") data = self.http.request("get", hlsurl) if data.status_code == 403: yield ServiceError("Can't fetch the video because of geoblocking") return streams = hlsparse(self.config, data, hlsurl, output=self.output) if streams: for n in list(streams.keys()): yield streams[n] else: streams = hdsparse( copy.copy(self.config), self.http.request("get", manifest_url, params={"hdcore": "3.7.0"}), manifest_url, output=self.output, ) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): if self.exclude(): yield ServiceError("Excluding video") return ajax_auth = self.get_auth() if not ajax_auth: yield ServiceError("Cant find token for video") return mediaid = self.get_mediaid() if not mediaid: yield ServiceError("Cant find media id") return if not isinstance(mediaid, str): mediaid = mediaid.group(1) jsondata = self.http.request("get", "http://csp.picsearch.com/rest?jsonp=&eventParam=1&auth=%s&method=embed&mediaid=%s" % (ajax_auth.group(1), mediaid)).text jsondata = json.loads(jsondata) if "playerconfig" not in jsondata["media"]: yield ServiceError(jsondata["error"]) return if "live" in jsondata["media"]["playerconfig"]["clip"]: self.options.live = jsondata["media"]["playerconfig"]["clip"] playlist = jsondata["media"]["playerconfig"]["playlist"][1] if "bitrates" in playlist: files = playlist["bitrates"] server = jsondata["media"]["playerconfig"]["plugins"]["bwcheck"]["netConnectionUrl"] for i in files: self.options.other = "-y '%s'" % i["url"] yield RTMP(copy.copy(self.options), server, i["height"]) if "provider" in playlist: if playlist["provider"] != "rtmp": if "live" in playlist: self.options.live = playlist["live"] if playlist["url"].endswith(".f4m"): streams = hdsparse(self.options, self.http.request("get", playlist["url"], params={"hdcore": "3.7.0"}), playlist["url"]) if streams: for n in list(streams.keys()): yield streams[n] if ".m3u8" in playlist["url"]: streams = hlsparse(self.options, self.http.request("get", playlist["url"]), playlist["url"]) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): if self.exclude(): yield ServiceError("Excluding video") return # First, fint the video ID from the html document match = re.search("programId: \"([^\"]+)\"", self.get_urldata()) if match: video_id = match.group(1) else: yield ServiceError("Can't find video id.") return # Get media element details match = re.search("apiBaseUrl: '([^']+)'", self.get_urldata()) if not match: yield ServiceError("Cant find apiurl.") return dataurl = "{0}/mediaelement/{1}".format(match.group(1), video_id) data = self.http.request("get", dataurl).text data = json.loads(data) manifest_url = data["mediaUrl"] self.options.live = data["isLive"] if manifest_url is None: yield ServiceError(data["messageType"]) return # Check if subtitles are available if data["subtitlesUrlPath"]: yield subtitle(copy.copy(self.options), "tt", data["subtitlesUrlPath"]) hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8") data = self.http.request("get", hlsurl) if data.status_code == 403: yield ServiceError("Can't fetch the video because of geoblocking") return streams = hlsparse(self.options, data, hlsurl) if streams: for n in list(streams.keys()): yield streams[n] streams = hdsparse(copy.copy(self.options), self.http.request("get", manifest_url, params={"hdcore": "3.7.0"}), manifest_url) if streams: for n in list(streams.keys()): yield streams[n]
def get(self, options): data = self.get_urldata() if self.exclude(options): yield ServiceError("Excluding video") return ajax_auth = re.search(r"picsearch_ajax_auth = '(\w+)'", data) if not ajax_auth: ajax_auth = re.search(r'screen9-ajax-auth="([^"]+)"', data) if not ajax_auth: yield ServiceError("Cant find token for video") return mediaid = re.search(r"mediaId = '([^']+)';", self.get_urldata()) if not mediaid: mediaid = re.search(r'media-id="([^"]+)"', self.get_urldata()) if not mediaid: mediaid = re.search(r'screen9-mid="([^"]+)"', self.get_urldata()) if not mediaid: yield ServiceError("Cant find media id") return jsondata = self.http.request("get", "http://csp.picsearch.com/rest?jsonp=&eventParam=1&auth=%s&method=embed&mediaid=%s" % (ajax_auth.group(1), mediaid.group(1))).text jsondata = json.loads(jsondata) if "playerconfig" not in jsondata["media"]: yield ServiceError(jsondata["error"]) return if "live" in jsondata["media"]["playerconfig"]["clip"]: options.live = jsondata["media"]["playerconfig"]["clip"] playlist = jsondata["media"]["playerconfig"]["playlist"][1] if "bitrates" in playlist: files = playlist["bitrates"] server = jsondata["media"]["playerconfig"]["plugins"]["bwcheck"]["netConnectionUrl"] for i in files: options.other = "-y '%s'" % i["url"] yield RTMP(copy.copy(options), server, i["height"]) if "provider" in playlist: if playlist["provider"] != "rtmp": if "live" in playlist: options.live = playlist["live"] if playlist["url"].endswith(".f4m"): streams = hdsparse(options, self.http.request("get", playlist["url"], params={"hdcore": "3.7.0"}), playlist["url"]) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): filename = os.path.basename(self.url[:self.url.rfind("/")]) self.output["title"] = filename streams = [] if re.search(".f4m", self.url): self.output["ext"] = "flv" streams.append(hdsparse(self.config, self.http.request("get", self.url, params={"hdcore": "3.7.0"}), self.url, output=self.output)) if re.search(".m3u8", self.url): streams.append(hlsparse(self.config, self.http.request("get", self.url), self.url, output=self.output)) if re.search(".mpd", self.url): streams.append(dashparse(self.config, self.http.request("get", self.url), self.url, output=self.output)) for stream in streams: if stream: for n in list(stream.keys()): yield stream[n]
def get(self, options): data = self.get_urldata() match = re.search("data-subtitlesurl = \"(/.*)\"", data) if match: parse = urlparse(self.url) subtitle = "%s://%s%s" % (parse.scheme, parse.netloc, match.group(1)) yield subtitle_tt(subtitle) if options.force_subtitle: return match = re.search(r'data-media="(.*manifest.f4m)"', data) if match: manifest_url = match.group(1) else: match = re.search(r'data-video-id="(\d+)"', data) if match is None: log.error("Can't find video id.") sys.exit(2) vid = match.group(1) match = re.search(r"PS_VIDEO_API_URL : '([^']*)',", data) if match is None: log.error("Can't find server address with media info") sys.exit(2) dataurl = "%smediaelement/%s" % (match.group(1), vid) data = json.loads(get_http_data(dataurl)) manifest_url = data["mediaUrl"] options.live = data["isLive"] hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8") streams = hlsparse(hlsurl) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) manifest_url = "%s?hdcore=2.8.0&g=hejsan" % manifest_url streams = hdsparse(copy.copy(options), manifest_url) if streams: for n in list(streams.keys()): yield streams[n]
def get(self, options): error, data = self.get_urldata() if error: log.error("Can't get the page") return match = re.search(r'data-videoid="([^"]+)"', data) if not match: parse = urlparse(self.url) match = re.search(r'video/(\d+)/', parse.fragment) if not match: log.error("Can't find video file for: %s", self.url) return videoid = match.group(1) error, data = get_http_data("http://svp.vg.no/svp/api/v1/vgtv/assets/%s?appName=vgtv-website" % videoid) if error: log.error("Cant get video info") return jsondata = json.loads(data) if options.output_auto: directory = os.path.dirname(options.output) title = "%s" % jsondata["title"] title = filenamify(title) if len(directory): options.output = "%s/%s" % (directory, title) else: options.output = title if self.exclude(options): return if "hds" in jsondata["streamUrls"]: streams = hdsparse(copy.copy(options), jsondata["streamUrls"]["hds"]) if streams: for n in list(streams.keys()): yield streams[n] if "hls" in jsondata["streamUrls"]: streams = hlsparse(jsondata["streamUrls"]["hls"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) if "mp4" in jsondata["streamUrls"]: yield HTTP(copy.copy(options), jsondata["streamUrls"]["mp4"])
def get(self, options): error, data = self.get_urldata() if error: log.error("Can't get the page.") return if self.exclude(options): return ajax_auth = re.search(r"picsearch_ajax_auth = '(\w+)'", data) if not ajax_auth: log.error("Cant find token for video") return mediaid = re.search(r"mediaId = '([^']+)';", self.get_urldata()[1]) if not mediaid: mediaid = re.search(r'media-id="([^"]+)"', self.get_urldata()[1]) if not mediaid: log.error("Cant find media id") return error, jsondata = get_http_data("http://csp.picsearch.com/rest?jsonp=&eventParam=1&auth=%s&method=embed&mediaid=%s" % (ajax_auth.group(1), mediaid.group(1))) if error: log.error("Cant get stream info") return jsondata = json.loads(jsondata) playlist = jsondata["media"]["playerconfig"]["playlist"][1] if "bitrates" in playlist: files = playlist["bitrates"] server = jsondata["media"]["playerconfig"]["plugins"]["bwcheck"]["netConnectionUrl"] for i in files: options.other = "-y '%s'" % i["url"] yield RTMP(copy.copy(options), server, i["height"]) if "provider" in playlist: if playlist["provider"] != "rtmp": if "live" in playlist: options.live = playlist["live"] if playlist["url"].endswith(".f4m"): streams = hdsparse(copy.copy(options), playlist["url"]) if streams: for n in list(streams.keys()): yield streams[n]
def get(self, options): data = self.get_urldata() match = re.search(r'resource:[ ]*"([^"]*)",', data) if match: resource_url = match.group(1) resource_data = get_http_data(resource_url) resource = json.loads(resource_data) streams = find_stream(options, resource) for i in streams: yield i else: match = re.search(r'resource="([^"]*)"', data) if not match: log.error("Cant find resource info for this video") sys.exit(2) resource_url = "%s" % match.group(1) resource_data = get_http_data(resource_url) resource = json.loads(resource_data) if "Data" in resource: streams = find_stream(options, resource) for i in streams: yield i else: for stream in resource['Links']: if stream["Target"] == "HDS": manifest = "%s?hdcore=2.8.0&g=hejsan" % stream["Uri"] streams = hdsparse(copy.copy(options), manifest) if streams: for n in list(streams.keys()): yield streams[n] if stream["Target"] == "HLS": streams = hlsparse(stream["Uri"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) if stream["Target"] == "Streaming": options.other = "-v -y '%s'" % stream['Uri'].replace( "rtmp://vod.dr.dk/cms/", "") rtmp = "rtmp://vod.dr.dk/cms/" yield RTMP(copy.copy(options), rtmp, stream['Bitrate'])
def get(self): if self.exclude(): return extention = False filename = os.path.basename(self.url[:self.url.rfind("/")]) if self.options.output and os.path.isdir(self.options.output): self.options.output = os.path.join( os.path.dirname(self.options.output), filename) extention = True elif self.options.output is None: self.options.output = filename extention = True streams = [] if re.search(".f4m", self.url): if extention: self.options.output = "{0}.flv".format(self.options.output) streams.append( hdsparse( self.options, self.http.request("get", self.url, params={"hdcore": "3.7.0"}), self.url)) if re.search(".m3u8", self.url): streams.append( hlsparse(self.options, self.http.request("get", self.url), self.url)) if re.search(".mpd", self.url): streams.append( dashparse(self.options, self.http.request("get", self.url), self.url)) for stream in streams: if stream: for n in list(stream.keys()): yield stream[n]
def get(self, options): data = self.get_urldata() match = re.search(r'resource:[ ]*"([^"]*)",', data) if match: resource_url = match.group(1) resource_data = get_http_data(resource_url) resource = json.loads(resource_data) streams = find_stream(options, resource) for i in streams: yield i else: match = re.search(r'resource="([^"]*)"', data) if not match: log.error("Cant find resource info for this video") sys.exit(2) resource_url = "%s" % match.group(1) resource_data = get_http_data(resource_url) resource = json.loads(resource_data) if "Data" in resource: streams = find_stream(options, resource) for i in streams: yield i else: for stream in resource['Links']: if stream["Target"] == "HDS": manifest = "%s?hdcore=2.8.0&g=hejsan" % stream["Uri"] streams = hdsparse(copy.copy(options), manifest) if streams: for n in list(streams.keys()): yield streams[n] if stream["Target"] == "HLS": streams = hlsparse(stream["Uri"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) if stream["Target"] == "Streaming": options.other = "-v -y '%s'" % stream['Uri'].replace("rtmp://vod.dr.dk/cms/", "") rtmp = "rtmp://vod.dr.dk/cms/" yield RTMP(copy.copy(options), rtmp, stream['Bitrate'])
def get(self): data = self.get_urldata() match = re.search(r'data-videoid="([^"]+)"', data) if not match: parse = urlparse(self.url) match = re.search(r'video/(\d+)/', parse.fragment) if not match: yield ServiceError("Can't find video file for: %s" % self.url) return videoid = match.group(1) data = self.http.request("get", "http://svp.vg.no/svp/api/v1/vgtv/assets/%s?appName=vgtv-website" % videoid).text jsondata = json.loads(data) if self.options.output_auto: directory = os.path.dirname(self.options.output) title = "%s" % jsondata["title"] title = filenamify(title) if len(directory): self.options.output = os.path.join(directory, title) else: self.options.output = title if self.exclude(): yield ServiceError("Excluding video") return if "hds" in jsondata["streamUrls"]: streams = hdsparse(self.options, self.http.request("get", jsondata["streamUrls"]["hds"], params={"hdcore": "3.7.0"}), jsondata["streamUrls"]["hds"]) if streams: for n in list(streams.keys()): yield streams[n] if "hls" in jsondata["streamUrls"]: streams = hlsparse(self.options, self.http.request("get", jsondata["streamUrls"]["hls"]), jsondata["streamUrls"]["hls"]) for n in list(streams.keys()): yield streams[n] if "mp4" in jsondata["streamUrls"]: yield HTTP(copy.copy(self.options), jsondata["streamUrls"]["mp4"])
def get(self): if self.exclude(): yield ServiceError("Excluding video") return # First, fint the video ID from the html document video_id = re.search("<meta name=\"programid\".*?content=\"([^\"]*)\"", self.get_urldata()).group(1) if video_id is None: yield ServiceError("Can't find video id.") return # Get media element details parse = urlparse(self.url) dataurl = "%s://v8.psapi.nrk.no/mediaelement/%s" % (parse.scheme, video_id) data = self.http.request("get", dataurl).text data = json.loads(data) manifest_url = data["mediaUrl"] self.options.live = data["isLive"] # Check if subtitles are available if data["subtitlesUrlPath"]: yield subtitle(copy.copy(self.options), "tt", data["subtitlesUrlPath"]) hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8") data = self.http.request("get", hlsurl) if data.status_code == 403: yield ServiceError("Can't fetch the video because of geoblocking") return streams = hlsparse(self.options, data, hlsurl) for n in list(streams.keys()): yield streams[n] streams = hdsparse(copy.copy(self.options), self.http.request("get", manifest_url, params={"hdcore": "3.7.0"}), manifest_url) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): if self.exclude(): yield ServiceError("Excluding video") return # First, fint the video ID from the html document video_id = re.search("<meta name=\"programid\".*?content=\"([^\"]*)\"", self.get_urldata()).group(1) if video_id is None: yield ServiceError("Can't find video id.") return # Get media element details dataurl = "http://v8.psapi.nrk.no/mediaelement/%s" % (video_id) data = self.http.request("get", dataurl).text data = json.loads(data) manifest_url = data["mediaUrl"] self.options.live = data["isLive"] # Check if subtitles are available if data["subtitlesUrlPath"]: yield subtitle(copy.copy(self.options), "tt", data["subtitlesUrlPath"]) hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8") data = self.http.request("get", hlsurl) if data.status_code == 403: yield ServiceError("Can't fetch the video because of geoblocking") return streams = hlsparse(self.options, data, hlsurl) for n in list(streams.keys()): yield streams[n] streams = hdsparse(copy.copy(self.options), self.http.request("get", manifest_url, params={"hdcore": "3.7.0"}), manifest_url) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): vid = self._get_video_id() if vid is None: yield ServiceError("Can't find video file for: {0}".format( self.url)) return data = self._get_video_data(vid) if data.status_code == 403: yield ServiceError( "Can't play this because the video is geoblocked.") return dataj = json.loads(data.text) if "msg" in dataj: yield ServiceError(dataj["msg"]) return if dataj["type"] == "live": self.options.live = True if self.options.output_auto: self.options.output = self.outputfilename(dataj, vid, self.options.output) if self.exclude(): yield ServiceError("Excluding video") return streams = self.http.request( "get", "http://playapi.mtgx.tv/v3/videos/stream/{0}".format(vid)) if streams.status_code == 403: yield ServiceError( "Can't play this because the video is geoblocked.") return streamj = json.loads(streams.text) if "msg" in streamj: yield ServiceError( "Can't play this because the video is either not found or geoblocked." ) return if dataj["sami_path"]: if dataj["sami_path"].endswith("vtt"): subtype = "wrst" else: subtype = "sami" yield subtitle(copy.copy(self.options), subtype, dataj["sami_path"]) if dataj["subtitles_webvtt"]: yield subtitle(copy.copy(self.options), "wrst", dataj["subtitles_webvtt"]) if dataj["subtitles_for_hearing_impaired"]: if dataj["subtitles_for_hearing_impaired"].endswith("vtt"): subtype = "wrst" else: subtype = "sami" if self.options.get_all_subtitles: yield subtitle(copy.copy(self.options), subtype, dataj["subtitles_for_hearing_impaired"], "-SDH") else: yield subtitle(copy.copy(self.options), subtype, dataj["subtitles_for_hearing_impaired"]) if streamj["streams"]["medium"]: filename = streamj["streams"]["medium"] if ".f4m" in filename: streams = hdsparse( self.options, self.http.request("get", filename, params={"hdcore": "3.7.0"}), filename) if streams: for n in list(streams.keys()): yield streams[n] else: parse = urlparse(filename) match = re.search("^(/[^/]+)/(.*)", parse.path) if not match: yield ServiceError("Can't get rtmpparse info") return filename = "{0}://{1}:{2}{3}".format(parse.scheme, parse.hostname, parse.port, match.group(1)) path = "-y {0}".format(match.group(2)) self.options.other = "-W http://flvplayer.viastream.viasat.tv/flvplayer/play/swf/player.swf {0}".format( path) yield RTMP(copy.copy(self.options), filename, 800) if streamj["streams"]["hls"]: streams = hlsparse( self.options, self.http.request("get", streamj["streams"]["hls"]), streamj["streams"]["hls"]) if streams: for n in list(streams.keys()): yield streams[n]
def get(self, options): parse = urlparse(self.url) if "tv4play.se" in self.url: try: vid = parse_qs(parse.query)["video_id"][0] except KeyError: log.error("Can't find video file") sys.exit(2) else: match = re.search(r"\"vid\":\"(\d+)\",", self.get_urldata()) if match: vid = match.group(1) else: match = re.search(r"-(\d+)$", self.url) if match: vid = match.group(1) else: log.error("Can't find video id") sys.exit(2) url = "http://premium.tv4play.se/api/web/asset/%s/play" % vid data = get_http_data(url) xml = ET.XML(data) ss = xml.find("items") if is_py2_old: sa = list(ss.getiterator("item")) else: sa = list(ss.iter("item")) if xml.find("live").text: if xml.find("live").text != "false": options.live = True if xml.find("drmProtected").text == "true": log.error("DRM protected content.") sys.exit(2) if options.output_auto: directory = os.path.dirname(options.output) options.service = "tv4play" title = "%s-%s-%s" % (options.output, vid, options.service) title = filenamify(title) if len(directory): options.output = "%s/%s" % (directory, title) else: options.output = title for i in sa: if i.find("mediaFormat").text == "mp4": base = urlparse(i.find("base").text) parse = urlparse(i.find("url").text) if base.scheme == "rtmp": swf = "http://www.tv4play.se/flash/tv4playflashlets.swf" options.other = "-W %s -y %s" % (swf, i.find("url").text) yield RTMP(copy.copy(options), i.find("base").text, i.find("bitrate").text) elif parse.path[len(parse.path)-3:len(parse.path)] == "f4m": query = "" if i.find("url").text[-1] != "?": query = "?" manifest = "%s%shdcore=2.8.0&g=hejsan" % (i.find("url").text, query) streams = hdsparse(copy.copy(options), manifest) if streams: for n in list(streams.keys()): yield streams[n] elif i.find("mediaFormat").text == "smi": yield subtitle_smi(i.find("url").text) url = "http://premium.tv4play.se/api/web/asset/%s/play?protocol=hls" % vid data = get_http_data(url) xml = ET.XML(data) ss = xml.find("items") if is_py2_old: sa = list(ss.getiterator("item")) else: sa = list(ss.iter("item")) for i in sa: if i.find("mediaFormat").text == "mp4": parse = urlparse(i.find("url").text) if parse.path.endswith("m3u8"): streams = hlsparse(i.find("url").text) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n)
def get(self): vid = self.find_video_id() if vid is None: yield ServiceError("Cant find video id for this video") return url = "http://api.svt.se/videoplayer-api/video/{0}".format(vid) data = self.http.request("get", url) if data.status_code == 404: yield ServiceError("Can't get the json file for {0}".format(url)) return data = data.json() if "live" in data: self.options.live = data["live"] if self.options.output_auto: self.options.service = "svtplay" self.options.output = self.outputfilename(data, self.options.output, ensure_unicode(self.get_urldata())) if self.exclude(): yield ServiceError("Excluding video") return if "subtitleReferences" in data: for i in data["subtitleReferences"]: if i["format"] == "websrt": yield subtitle(copy.copy(self.options), "wrst", i["url"]) if len(data["videoReferences"]) == 0: yield ServiceError("Media doesn't have any associated videos (yet?)") return for i in data["videoReferences"]: parse = urlparse(i["url"]) query = parse_qs(parse.query) if i["format"] == "hls" or i["format"] == "ios": streams = hlsparse(self.options, self.http.request("get", i["url"]), i["url"]) if streams: for n in list(streams.keys()): yield streams[n] if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if alt: streams = hlsparse(self.options, self.http.request("get", alt.request.url), alt.request.url) if streams: for n in list(streams.keys()): yield streams[n] if i["format"] == "hds" or i["format"] == "flash": match = re.search(r"\/se\/secure\/", i["url"]) if not match: streams = hdsparse(self.options, self.http.request("get", i["url"], params={"hdcore": "3.7.0"}), i["url"]) if streams: for n in list(streams.keys()): yield streams[n] if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if alt: streams = hdsparse(self.options, self.http.request("get", alt.request.url, params={"hdcore": "3.7.0"}), alt.request.url) if streams: for n in list(streams.keys()): yield streams[n] if i["format"] == "dash264" or i["format"] == "dashhbbtv": streams = dashparse(self.options, self.http.request("get", i["url"]), i["url"]) if streams: for n in list(streams.keys()): yield streams[n] if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if alt: streams = dashparse(self.options, self.http.request("get", alt.request.url), alt.request.url) if streams: for n in list(streams.keys()): yield streams[n]
def get(self, options): if re.findall("svt.se", self.url): match = re.search(r"data-json-href=\"(.*)\"", self.get_urldata()) if match: filename = match.group(1).replace("&", "&").replace( "&format=json", "") url = "http://www.svt.se%s" % filename else: log.error("Can't find video file") sys.exit(2) else: url = self.url pos = url.find("?") if pos < 0: dataurl = "%s?&output=json&format=json" % url else: dataurl = "%s&output=json&format=json" % url data = json.loads(get_http_data(dataurl)) if "live" in data["video"]: options.live = data["video"]["live"] else: options.live = False if data["video"]["subtitleReferences"]: subtitle = None try: subtitle = data["video"]["subtitleReferences"][0]["url"] except KeyError: pass if subtitle and len(subtitle) > 0: yield subtitle_wsrt(subtitle) if options.output_auto: directory = os.path.dirname(options.output) options.service = "svtplay" name = data["statistics"]["folderStructure"] if name.find(".") > 0: title = "%s-%s-%s-%s" % (name[:name.find(".")], data["statistics"]["title"], data["videoId"], options.service) else: title = "%s-%s-%s-%s" % (name, data["statistics"]["title"], data["videoId"], options.service) title = filenamify(title) if len(directory): options.output = "%s/%s" % (directory, title) else: options.output = title if options.force_subtitle: return for i in data["video"]["videoReferences"]: parse = urlparse(i["url"]) if parse.path.find("m3u8") > 0: streams = hlsparse(i["url"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) elif parse.path.find("f4m") > 0: match = re.search(r"\/se\/secure\/", i["url"]) if not match: parse = urlparse(i["url"]) manifest = "%s://%s%s?%s&hdcore=3.3.0" % ( parse.scheme, parse.netloc, parse.path, parse.query) streams = hdsparse(copy.copy(options), manifest) if streams: for n in list(streams.keys()): yield streams[n] elif parse.scheme == "rtmp": embedurl = "%s?type=embed" % url data = get_http_data(embedurl) match = re.search( r"value=\"(/(public)?(statiskt)?/swf(/video)?/svtplayer-[0-9\.a-f]+swf)\"", data) swf = "http://www.svtplay.se%s" % match.group(1) options.other = "-W %s" % swf yield RTMP(copy.copy(options), i["url"], i["bitrate"]) else: yield HTTP(copy.copy(options), i["url"], "0")
def get(self): old = False parse = urlparse(self.url) if parse.netloc == "www.svtplay.se" or parse.netloc == "svtplay.se": if parse.path[:6] != "/video" and parse.path[:6] != "/klipp": yield ServiceError( "This mode is not supported anymore. need the url with the video" ) return vid = self.find_video_id() if vid is None: yield ServiceError("Cant find video id for this video") return if re.match("^[0-9]+$", vid): old = True url = "http://www.svt.se/videoplayer-api/video/%s" % vid data = self.http.request("get", url) if data.status_code == 404: yield ServiceError("Can't get the json file for %s" % url) return data = data.json() if "live" in data: self.options.live = data["live"] if old: params = {"output": "json"} try: dataj = self.http.request("get", self.url, params=params).json() except ValueError: dataj = data old = False else: dataj = data if self.options.output_auto: self.options.service = "svtplay" self.options.output = self.outputfilename( dataj, self.options.output, ensure_unicode(self.get_urldata())) if self.exclude(): yield ServiceError("Excluding video") return if "subtitleReferences" in data: for i in data["subtitleReferences"]: if i["format"] == "websrt": yield subtitle(copy.copy(self.options), "wrst", i["url"]) if old and dataj["video"]["subtitleReferences"]: try: suburl = dataj["video"]["subtitleReferences"][0]["url"] except KeyError: pass if suburl and len(suburl) > 0: yield subtitle(copy.copy(self.options), "wrst", suburl) if len(data["videoReferences"]) == 0: yield ServiceError( "Media doesn't have any associated videos (yet?)") return for i in data["videoReferences"]: if i["format"] == "hls" or i["format"] == "ios": streams = hlsparse(self.options, self.http.request("get", i["url"]), i["url"]) if streams: for n in list(streams.keys()): yield streams[n] if i["format"] == "hds" or i["format"] == "flash": match = re.search(r"\/se\/secure\/", i["url"]) if not match: streams = hdsparse( self.options, self.http.request("get", i["url"], params={"hdcore": "3.7.0"}), i["url"]) if streams: for n in list(streams.keys()): yield streams[n] if i["format"] == "dash264": streams = dashparse(self.options, self.http.request("get", i["url"]), i["url"]) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): parse = urlparse(self.url) vid = self._get_video_id() if vid is None: if parse.path[:6] == "/sport": result = self._sport() yield from result return else: yield ServiceError("Can't find video file for: {}".format( self.url)) return data = self._get_video_data(vid) if data.status_code == 403: yield ServiceError( "Can't play this because the video is geoblocked.") return dataj = json.loads(data.text) if "msg" in dataj: yield ServiceError(dataj["msg"]) return if dataj["type"] == "live": self.config.set("live", True) self.output["id"] = vid self._autoname(dataj) streams = self.http.request( "get", "http://playapi.mtgx.tv/v3/videos/stream/{}".format(vid)) if streams.status_code == 403: yield ServiceError( "Can't play this because the video is geoblocked.") return streamj = json.loads(streams.text) if "msg" in streamj: yield ServiceError( "Can't play this because the video is either not found or geoblocked." ) return if dataj["sami_path"]: if dataj["sami_path"].endswith("vtt"): subtype = "wrst" else: subtype = "sami" yield subtitle(copy.copy(self.config), subtype, dataj["sami_path"], output=self.output) if dataj["subtitles_webvtt"]: yield subtitle(copy.copy(self.config), "wrst", dataj["subtitles_webvtt"], output=self.output) if dataj["subtitles_for_hearing_impaired"]: if dataj["subtitles_for_hearing_impaired"].endswith("vtt"): subtype = "wrst" else: subtype = "sami" if self.config.get("get_all_subtitles"): yield subtitle(copy.copy(self.config), subtype, dataj["subtitles_for_hearing_impaired"], "-SDH", output=self.output) else: yield subtitle(copy.copy(self.config), subtype, dataj["subtitles_for_hearing_impaired"], output=self.output) if streamj["streams"][ "medium"] and streamj["streams"]["medium"][:7] != "[empty]": filename = streamj["streams"]["medium"] if ".f4m" in filename: streams = hdsparse(self.config, self.http.request( "get", filename, params={"hdcore": "3.7.0"}), filename, output=self.output) for n in list(streams.keys()): yield streams[n] if streamj["streams"]["hls"]: streams = hlsparse(self.config, self.http.request("get", streamj["streams"]["hls"]), streamj["streams"]["hls"], output=self.output) for n in list(streams.keys()): yield streams[n]
def get(self): parse = urlparse(self.url) if parse.netloc == "www.svtplay.se" or parse.netloc == "svtplay.se": if parse.path[:6] != "/video" and parse.path[:6] != "/klipp": yield ServiceError( "This mode is not supported anymore. need the url with the video" ) return match = re.search("__svtplay'] = ({.*});", self.get_urldata()) if not match: yield ServiceError("Cant find video info.") return janson = json.loads(match.group(1))["videoTitlePage"] if "live" in janson["video"]: self.options.live = janson["video"]["live"] if not "programTitle" in janson["video"]: yield ServiceError("Can't find any video on that page") return if self.options.output_auto: self.options.service = "svtplay" self.options.output = self.outputfilename(janson["video"], self.options.output) if self.exclude(): yield ServiceError("Excluding video") return if "programVersionId" in janson["video"]: vid = janson["video"]["programVersionId"] else: vid = janson["video"]["id"] res = self.http.get( "http://api.svt.se/videoplayer-api/video/{0}".format(vid)) janson = res.json() if "live" in janson: self.options.live = janson["live"] if "subtitleReferences" in janson: for i in janson["subtitleReferences"]: if i["format"] == "websrt" and "url" in i: yield subtitle(copy.copy(self.options), "wrst", i["url"]) if "videoReferences" in janson: if len(janson["videoReferences"]) == 0: yield ServiceError( "Media doesn't have any associated videos (yet?)") return for i in janson["videoReferences"]: parse = urlparse(i["url"]) query = parse_qs(parse.query) if i["format"] == "hls": streams = hlsparse(self.options, self.http.request("get", i["url"]), i["url"]) if streams: for n in list(streams.keys()): yield streams[n] if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if alt: streams = hlsparse( self.options, self.http.request("get", alt.request.url), alt.request.url) if streams: for n in list(streams.keys()): yield streams[n] if i["format"] == "hds": match = re.search(r"\/se\/secure\/", i["url"]) if not match: streams = hdsparse( self.options, self.http.request("get", i["url"], params={"hdcore": "3.7.0"}), i["url"]) if streams: for n in list(streams.keys()): yield streams[n] if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if alt: streams = hdsparse( self.options, self.http.request( "get", alt.request.url, params={"hdcore": "3.7.0"}), alt.request.url) if streams: for n in list(streams.keys()): yield streams[n] if i["format"] == "dash264" or i["format"] == "dashhbbtv": streams = dashparse(self.options, self.http.request("get", i["url"]), i["url"]) if streams: for n in list(streams.keys()): yield streams[n] if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if alt: streams = dashparse( self.options, self.http.request("get", alt.request.url), alt.request.url) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): parse = urlparse(self.url) if parse.path[:8] == "/kanaler": end_time_stamp = (datetime.utcnow() - timedelta(seconds=20)).replace(microsecond=0) start_time_stamp = end_time_stamp - timedelta(minutes=1) url = "https://bbr-l2v.akamaized.net/live/{0}/master.m3u8?in={1}&out={2}?".format(parse.path[9:], start_time_stamp.isoformat(), end_time_stamp.isoformat()) self.options.live = True self.options.hls_time_stamp = True streams = hlsparse(self.options, self.http.request("get", url), url) if streams: for n in list(streams.keys()): yield streams[n] return data = self.get_urldata() vid = findvid(self.url, data) if not vid: yield ServiceError("Can't find video id for {0}.".format(self.url)) return url = "http://prima.tv4play.se/api/web/asset/{0}/play".format(vid) data = self.http.request("get", url, cookies=self.cookies) if data.status_code == 401: xml = ET.XML(data.content) code = xml.find("code").text if code == "SESSION_NOT_AUTHENTICATED": yield ServiceError("Can't access premium content") elif code == "ASSET_PLAYBACK_INVALID_GEO_LOCATION": yield ServiceError("Can't download this video because of geoblock.") else: yield ServiceError("Can't find any info for that video.") return if data.status_code == 404: yield ServiceError("Can't find the video api.") return xml = ET.XML(data.content) ss = xml.find("items") if is_py2_old: sa = list(ss.getiterator("item")) else: sa = list(ss.iter("item")) if xml.find("live").text: self.options.live = (xml.find("live").text != "false") if xml.find("drmProtected").text == "true": yield ServiceError("We can't download DRM protected content from this site.") return if xml.find("playbackStatus").text == "NOT_STARTED": yield ServiceError("Can't download something that is not started.") return if self.options.output_auto: directory = os.path.dirname(self.options.output) self.options.service = "tv4play" basename = self._autoname(vid) if not basename: yield ServiceError("Cant find vid id for autonaming.") return title = "{0}-{1}-{2}".format(basename, vid, self.options.service) title = filenamify(title) if len(directory): self.options.output = os.path.join(directory, title) else: self.options.output = title if self.exclude(): yield ServiceError("Excluding video.") return for i in sa: if i.find("mediaFormat").text == "mp4": base = urlparse(i.find("base").text) parse = urlparse(i.find("url").text) if "rtmp" in base.scheme: swf = "http://www.tv4play.se/flash/tv4playflashlets.swf" self.options.other = "-W {0} -y {1}".format(swf, i.find("url").text) yield RTMP(copy.copy(self.options), i.find("base").text, i.find("bitrate").text) elif parse.path[len(parse.path) - 3:len(parse.path)] == "f4m": streams = hdsparse(self.options, self.http.request("get", i.find("url").text, params={"hdcore": "3.7.0"}), i.find("url").text) if streams: for n in list(streams.keys()): yield streams[n] elif i.find("mediaFormat").text == "webvtt": yield subtitle(copy.copy(self.options), "wrst", i.find("url").text) url = "https://prima.tv4play.se/api/web/asset/{0}/play?protocol=hls3".format(vid) data = self.http.request("get", url, cookies=self.cookies).content xml = ET.XML(data) ss = xml.find("items") if is_py2_old: sa = list(ss.getiterator("item")) else: sa = list(ss.iter("item")) for i in sa: if i.find("mediaFormat").text == "mp4": parse = urlparse(i.find("url").text) if parse.path.endswith("m3u8"): streams = hlsparse(self.options, self.http.request("get", i.find("url").text), i.find("url").text) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): data = self.get_urldata() premium = False parse = urlparse(self.url) domain = re.search(r"(dplay\.\w\w)", parse.netloc).group(1) match = re.search(r"<link rel='shortlink' href='[^']+/\?p=(\d+)", data) if not match: match = re.search(r'data-video-id="([^"]+)"', data) if not match: yield ServiceError("Can't find video id") return vid = match.group(1) data = self.http.request( "get", "http://%s/api/v2/ajax/videos?video_id=%s" % (parse.netloc, vid)).text dataj = json.loads(data) if dataj["data"] is None: yield ServiceError("Cant find video. wrong url without video?") return if self.options.username and self.options.password: premium = self._login(self.options) if not premium: yield ServiceError("Wrong username or password") return what = self._playable(dataj, premium) if what == 1: yield ServiceError("Premium content") return if what == 2: yield ServiceError("DRM protected. Can't do anything") return if self.options.output_auto: directory = os.path.dirname(self.options.output) self.options.service = "dplay" name = self._autoname(dataj) if name is None: yield ServiceError("Cant find vid id for autonaming") return title = "%s-%s-%s" % (name, vid, self.options.service) if len(directory): self.options.output = os.path.join(directory, title) else: self.options.output = title if self.exclude(): yield ServiceError("Excluding video") return suburl = dataj["data"][0]["subtitles_sv_srt"] if len(suburl) > 0: yield subtitle(copy.copy(self.options), "raw", suburl) data = self.http.request("get", "http://geo.%s/geo.js" % domain).text dataj = json.loads(data) geo = dataj["countryCode"] timestamp = (int(time.time()) + 3600) * 1000 cookie = { "dsc-geo": quote('{"countryCode":"%s","expiry":%s}' % (geo, timestamp)) } if self.options.cookies: self.options.cookies.update(cookie) else: self.options.cookies = cookie data = self.http.request( "get", "https://secure.%s/secure/api/v2/user/authorization/stream/%s?stream_type=hds" % (domain, vid), cookies=self.options.cookies) if data.status_code == 403 or data.status_code == 401: yield ServiceError("Geoblocked video") return dataj = json.loads(data.text) if "hds" in dataj: streams = hdsparse( copy.copy(self.options), self.http.request("get", dataj["hds"], params={"hdcore": "3.8.0"}), dataj["hds"]) if streams: for n in list(streams.keys()): yield streams[n] data = self.http.request( "get", "https://secure.%s/secure/api/v2/user/authorization/stream/%s?stream_type=hls" % (domain, vid), cookies=self.options.cookies) dataj = json.loads(data.text) if "hls" in dataj: streams = hlsparse(self.options, self.http.request("get", dataj["hls"]), dataj["hls"]) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): vid = self._get_video_id() if vid is None: yield ServiceError("Can't find video file for: %s" % self.url) return url = "http://playapi.mtgx.tv/v3/videos/%s" % vid self.options.other = "" data = self.http.request("get", url) if data.status_code == 403: yield ServiceError( "Can't play this because the video is geoblocked.") return dataj = json.loads(data.text) if "msg" in dataj: yield ServiceError(dataj["msg"]) return if dataj["type"] == "live": self.options.live = True if self.exclude(): yield ServiceError("Excluding video") return streams = self.http.request( "get", "http://playapi.mtgx.tv/v3/videos/stream/%s" % vid) if streams.status_code == 403: yield ServiceError( "Can't play this because the video is geoblocked.") return streamj = json.loads(streams.text) if "msg" in streamj: yield ServiceError( "Can't play this because the video is either not found or geoblocked." ) return if self.options.output_auto: directory = os.path.dirname(self.options.output) self.options.service = "tv3play" basename = self._autoname(dataj) title = "%s-%s-%s" % (basename, vid, self.options.service) if len(directory): self.options.output = os.path.join(directory, title) else: self.options.output = title if dataj["sami_path"]: yield subtitle(copy.copy(self.options), "sami", dataj["sami_path"]) if dataj["subtitles_for_hearing_impaired"]: yield subtitle(copy.copy(self.options), "sami", dataj["subtitles_for_hearing_impaired"]) if streamj["streams"]["medium"]: filename = streamj["streams"]["medium"] if ".f4m" in filename: streams = hdsparse( self.options, self.http.request("get", filename, params={"hdcore": "3.7.0"}), filename) if streams: for n in list(streams.keys()): yield streams[n] else: parse = urlparse(filename) match = re.search("^(/[^/]+)/(.*)", parse.path) if not match: yield ServiceError("Can't get rtmpparse info") return filename = "%s://%s:%s%s" % (parse.scheme, parse.hostname, parse.port, match.group(1)) path = "-y %s" % match.group(2) self.options.other = "-W http://flvplayer.viastream.viasat.tv/flvplayer/play/swf/player.swf %s" % path yield RTMP(copy.copy(self.options), filename, 800) if streamj["streams"]["hls"]: streams = hlsparse( self.options, self.http.request("get", streamj["streams"]["hls"]), streamj["streams"]["hls"]) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): vid = self.find_video_id() if vid is None: yield ServiceError("Cant find video id for this video") return url = "http://api.svt.se/videoplayer-api/video/{}".format(vid) data = self.http.request("get", url) if data.status_code == 404: yield ServiceError("Can't get the json file for {}".format(url)) return data = data.json() if "live" in data: self.config.set("live", data["live"]) self.outputfilename(data) if "subtitleReferences" in data: for i in data["subtitleReferences"]: if i["format"] == "websrt": yield subtitle(copy.copy(self.config), "wrst", i["url"], output=self.output) if len(data["videoReferences"]) == 0: yield ServiceError("Media doesn't have any associated videos (yet?)") return for i in data["videoReferences"]: parse = urlparse(i["url"]) query = parse_qs(parse.query) if i["format"] == "hls" or i["format"] == "ios": streams = hlsparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output) for n in list(streams.keys()): yield streams[n] if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if alt: streams = hlsparse(self.config, self.http.request("get", alt.request.url), alt.request.url, output=self.output) for n in list(streams.keys()): yield streams[n] if i["format"] == "hds" or i["format"] == "flash": match = re.search(r"\/se\/secure\/", i["url"]) if not match: streams = hdsparse(self.config, self.http.request("get", i["url"], params={"hdcore": "3.7.0"}), i["url"], output=self.output) for n in list(streams.keys()): yield streams[n] if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if alt: streams = hdsparse( self.config, self.http.request("get", alt.request.url, params={"hdcore": "3.7.0"}), alt.request.url, output=self.output, ) for n in list(streams.keys()): yield streams[n] if i["format"] == "dash264" or i["format"] == "dashhbbtv": streams = dashparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output) for n in list(streams.keys()): yield streams[n] if "alt" in query and len(query["alt"]) > 0: alt = self.http.get(query["alt"][0]) if alt: streams = dashparse(self.config, self.http.request("get", alt.request.url), alt.request.url, output=self.output) for n in list(streams.keys()): yield streams[n]
def get(self): data = self.get_urldata() if self.exclude(): yield ServiceError("Excluding video") return match = re.search("data-subtitlesurl = \"(/.*)\"", data) if match: parse = urlparse(self.url) suburl = "%s://%s%s" % (parse.scheme, parse.netloc, match.group(1)) yield subtitle(copy.copy(self.options), "tt", suburl) match = re.search(r'data-media="(.*manifest.f4m)"', self.get_urldata()) if match: manifest_url = match.group(1) else: match = re.search(r'data-nrk-id="([^"]+)"></div><script', self.get_urldata()) if match is None: match = re.search(r'video-id="([^"]+)"', self.get_urldata()) if match is None: match = re.search( "<meta name=\"programid\".*?content=\"([^\"]*)\"", self.get_urldata()) if match is None: yield ServiceError("Can't find video id.") return vid = match.group(1) dataurl = "https://psapi-we.nrk.no/mediaelement/%s" % vid data = self.http.request("get", dataurl).text data = json.loads(data) manifest_url = data["mediaUrl"] self.options.live = data["isLive"] if manifest_url is None: if data["messageType"] == "ProgramIsGeoBlocked": yield ServiceError( "Can't fetch the video because of geoblocked") return if manifest_url is None: yield ServiceError("No videos available") return hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8") data = self.http.request("get", hlsurl) if data.status_code == 403: yield ServiceError("Can't fetch the video because of geoblocked") return streams = hlsparse(self.options, data, hlsurl) for n in list(streams.keys()): yield streams[n] streams = hdsparse( copy.copy(self.options), self.http.request("get", manifest_url, params={"hdcore": "3.7.0"}), manifest_url) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): data = self.get_urldata() vid = findvid(self.url, data) if vid is None: yield ServiceError("Can't find video id for %s" % self.url) return # if self.options.username and self.options.password: # work = self._login(self.options.username, self.options.password) # if isinstance(work, Exception): # yield work # return url = "http://prima.tv4play.se/api/web/asset/%s/play" % vid data = self.http.request("get", url, cookies=self.cookies) if data.status_code == 401: xml = ET.XML(data.content) code = xml.find("code").text if code == "SESSION_NOT_AUTHENTICATED": yield ServiceError("Can't access premium content") elif code == "ASSET_PLAYBACK_INVALID_GEO_LOCATION": yield ServiceError( "Can't download this video because of geoblock.") else: yield ServiceError("Can't find any info for that video") return if data.status_code == 404: yield ServiceError("Can't find the video api") return xml = ET.XML(data.content) ss = xml.find("items") if is_py2_old: sa = list(ss.getiterator("item")) else: sa = list(ss.iter("item")) if xml.find("live").text: if xml.find("live").text != "false": self.options.live = True if xml.find("drmProtected").text == "true": yield ServiceError( "We cant download DRM protected content from this site.") return if xml.find("playbackStatus").text == "NOT_STARTED": yield ServiceError("Can't download something that is not started") return if self.options.output_auto: directory = os.path.dirname(self.options.output) self.options.service = "tv4play" basename = self._autoname(vid) if basename is None: yield ServiceError("Cant find vid id for autonaming") return title = "%s-%s-%s" % (basename, vid, self.options.service) title = filenamify(title) if len(directory): self.options.output = os.path.join(directory, title) else: self.options.output = title if self.exclude(): yield ServiceError("Excluding video") return for i in sa: if i.find("mediaFormat").text == "mp4": base = urlparse(i.find("base").text) parse = urlparse(i.find("url").text) if "rtmp" in base.scheme: swf = "http://www.tv4play.se/flash/tv4playflashlets.swf" self.options.other = "-W %s -y %s" % (swf, i.find("url").text) yield RTMP(copy.copy(self.options), i.find("base").text, i.find("bitrate").text) elif parse.path[len(parse.path) - 3:len(parse.path)] == "f4m": streams = hdsparse( self.options, self.http.request("get", i.find("url").text, params={"hdcore": "3.7.0"}), i.find("url").text) if streams: for n in list(streams.keys()): yield streams[n] elif i.find("mediaFormat").text == "webvtt": yield subtitle(copy.copy(self.options), "wrst", i.find("url").text) url = "https://prima.tv4play.se/api/web/asset/%s/play?protocol=hls3" % vid data = self.http.request("get", url, cookies=self.cookies).content xml = ET.XML(data) ss = xml.find("items") if is_py2_old: sa = list(ss.getiterator("item")) else: sa = list(ss.iter("item")) for i in sa: if i.find("mediaFormat").text == "mp4": parse = urlparse(i.find("url").text) if parse.path.endswith("m3u8"): streams = hlsparse( self.options, self.http.request("get", i.find("url").text), i.find("url").text) if streams: for n in list(streams.keys()): yield streams[n]