def get(self): data = self.get_urldata() if self.exclude(): yield ServiceError("Excluding video") return match = re.search('="(https://www.expressen.se/tvspelare[^"]+)"', data) if not match: log.error("Can't find video id") return url = decode_html_entities(match.group(1)) data = self.http.request("get", url) match = re.search("window.Player.settings = ({.*});", data.text) if not match: log.error("Can't find json info.") dataj = json.loads(match.group(1)) if "streams" in dataj: if "iPad" in dataj["streams"]: streams = hlsparse(self.options, self.http.request("get", dataj["streams"]["iPad"]), dataj["streams"]["iPad"]) for n in list(streams.keys()): yield streams[n] if "hashHls" in dataj["streams"]: streams = hlsparse(self.options, self.http.request("get", dataj["streams"]["hashHls"]), dataj["streams"]["hashHls"]) for n in list(streams.keys()): yield streams[n]
def get(self, options): match = re.search(r"urPlayer.init\((.*)\);", self.get_urldata()) if not match: log.error("Can't find json info") sys.exit(2) data = match.group(1) jsondata = json.loads(data) yield subtitle_tt(jsondata["subtitles"].split(",")[0]) basedomain = jsondata["streaming_config"]["streamer"]["redirect"] http = "http://%s/%s" % (basedomain, jsondata["file_html5"]) hd = None if len(jsondata["file_html5_hd"]) > 0: http_hd = "http://%s/%s" % (basedomain, jsondata["file_html5_hd"]) hls_hd = "%s%s" % (http_hd, jsondata["streaming_config"]["http_streaming"]["hls_file"]) tmp = jsondata["file_html5_hd"] match = re.search(".*(mp[34]:.*$)", tmp) path_hd = match.group(1) hd = True hls = "%s%s" % (http, jsondata["streaming_config"]["http_streaming"]["hls_file"]) rtmp = "rtmp://%s/%s" % (basedomain, jsondata["streaming_config"]["rtmp"]["application"]) path = "mp%s:%s" % (jsondata["file_flash"][-1], jsondata["file_flash"]) streams = hlsparse(hls) for n in list(streams.keys()): yield HLS(options, streams[n], n) options.other = "-v -a %s -y %s" % (jsondata["streaming_config"]["rtmp"]["application"], path) yield RTMP(options, rtmp, "480") if hd: streams = hlsparse(hls_hd) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) options.other = "-v -a %s -y %s" % (jsondata["streaming_config"]["rtmp"]["application"], path_hd) yield RTMP(copy.copy(options), rtmp, "720")
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): data = self.get_urldata() match = re.search(r"urPlayer.init\((.*)\);", data) if not match: yield ServiceError("Can't find json info") return if self.exclude(self.options): yield ServiceError("Excluding video") return data = match.group(1) jsondata = json.loads(data) if len(jsondata["subtitles"]) > 0: yield subtitle(copy.copy(self.options), "tt", jsondata["subtitles"][0]["file"].split(",")[0]) if "streamer" in jsondata["streaming_config"]: basedomain = jsondata["streaming_config"]["streamer"]["redirect"] else: lbjson = self.http.request("get", jsondata["streaming_config"]["loadbalancer"]).text lbjson = json.loads(lbjson) basedomain = lbjson["redirect"] http = "http://%s/%s" % (basedomain, jsondata["file_http"]) hd = None if len(jsondata["file_http_hd"]) > 0: http_hd = "http://%s/%s" % (basedomain, jsondata["file_http_hd"]) hls_hd = "%s%s" % (http_hd, jsondata["streaming_config"]["http_streaming"]["hls_file"]) hd = True hls = "%s%s" % (http, jsondata["streaming_config"]["http_streaming"]["hls_file"]) streams = hlsparse(self.options, self.http.request("get", hls), hls) for n in list(streams.keys()): yield streams[n] if hd: streams = hlsparse(self.options, self.http.request("get", hls_hd), hls_hd) 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(minutes=1, 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.config.set("live", True) streams = hlsparse(self.config, self.http.request("get", url), url, output=self.output, hls_time_stamp=True) for n in list(streams.keys()): yield streams[n] return match = self._getjson() if not match: yield ServiceError("Can't find json data") return jansson = json.loads(match.group(1)) if "assetId" not in jansson["props"]["pageProps"]: yield ServiceError("Cant find video id for the video") return vid = jansson["props"]["pageProps"]["assetId"] janson2 = jansson["props"]["apolloState"] item = janson2["VideoAsset:{}".format(vid)] if item["is_drm_protected"]: yield ServiceError("We can't download DRM protected content from this site.") return if item["live"]: self.config.set("live", True) if item["season"] > 0: self.output["season"] = item["season"] if item["episode"] > 0: self.output["episode"] = item["episode"] self.output["title"] = item["program_nid"] self.output["episodename"] = item["title"] self.output["id"] = str(vid) if vid is None: yield ServiceError("Cant find video id for the video") return url = "https://playback-api.b17g.net/media/{}?service=tv4&device=browser&protocol=hls%2Cdash&drm=widevine".format(vid) res = self.http.request("get", url, cookies=self.cookies) if res.status_code > 200: yield ServiceError("Can't play this because the video is geoblocked or not available.") return if res.json()["playbackItem"]["type"] == "hls": streams = hlsparse(self.config, self.http.request("get", res.json()["playbackItem"]["manifestUrl"]), res.json()["playbackItem"]["manifestUrl"], output=self.output, httpobject=self.http) for n in list(streams.keys()): yield streams[n]
def get(self): data = self.get_urldata() match = re.search(r"urPlayer.init\((.*)\);", data) if not match: yield ServiceError("Can't find json info") return if self.exclude(): yield ServiceError("Excluding video") return data = match.group(1) jsondata = json.loads(data) if len(jsondata["subtitles"]) > 0: for sub in jsondata["subtitles"]: if "label" in sub: absurl = urljoin(self.url, sub["file"].split(",")[0]) if absurl.endswith("vtt"): subtype = "wrst" else: subtype = "tt" if self.options.get_all_subtitles: yield subtitle(copy.copy(self.options), subtype, absurl, "-" + filenamify(sub["label"])) else: yield subtitle(copy.copy(self.options), subtype, absurl) if "streamer" in jsondata["streaming_config"]: basedomain = jsondata["streaming_config"]["streamer"]["redirect"] else: url = jsondata["streaming_config"]["loadbalancer"] if url[:1] == "/": url = "https:{}".format(url) lbjson = self.http.request("get", url).text lbjson = json.loads(lbjson) basedomain = lbjson["redirect"] http = "https://{0}/{1}".format(basedomain, jsondata["file_http"]) hd = None if len(jsondata["file_http_hd"]) > 0: http_hd = "https://{0}/{1}".format(basedomain, jsondata["file_http_hd"]) hls_hd = "{0}{1}".format(http_hd, jsondata["streaming_config"]["http_streaming"]["hls_file"]) hd = True hls = "{0}{1}".format(http, jsondata["streaming_config"]["http_streaming"]["hls_file"]) streams = hlsparse(self.options, self.http.request("get", hls), hls) for n in list(streams.keys()): yield streams[n] if hd: streams = hlsparse(self.options, self.http.request("get", hls_hd), hls_hd) 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) 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, 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() 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): error, data = self.get_urldata() if error: log.error("Can't get the page") return if self.exclude(options): return match = re.search(r'"([^"]+geo.php)"', data) if match: error, data = get_http_data(match.group(1)) if error: log.error("Cant get stream info") return match = re.search(r'punktur=\(([^ ]+)\)', data) if match: janson = json.loads(match.group(1)) options.live = checklive(janson["result"][1]) streams = hlsparse(janson["result"][1]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) else: match = re.search(r'<source [^ ]*[ ]*src="([^"]+)" ', self.get_urldata()[1]) if not match: log.error("Can't find video info for: %s", self.url) return if match.group(1).endswith("mp4"): yield HTTP(copy.copy(options), match.group(1), 800) else: m3u8_url = match.group(1) options.live = checklive(m3u8_url) yield HLS(copy.copy(options), m3u8_url, 800)
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): data = self.get_urldata() match_cfg_url = re.search('data-config-url="([^"]+)" data-fallback-url', data) match_clip_page_cfg = re.search(r'vimeo\.clip_page_config\s*=\s*({.+?});', data) if match_cfg_url: player_url = match_cfg_url.group(1).replace("&", "&") elif match_clip_page_cfg: page_config = json.loads(match_clip_page_cfg.group(1)) player_url = page_config["player"]["config_url"] else: yield ServiceError("Can't find video file for: {0}".format(self.url)) return player_data = self.http.request("get", player_url).text if player_data: jsondata = json.loads(player_data) if ("hls" in jsondata["request"]["files"]) and ("fastly_skyfire" in jsondata["request"]["files"]["hls"]["cdns"]): hls_elem = jsondata["request"]["files"]["hls"]["cdns"]["fastly_skyfire"] stream = hlsparse(self.config, self.http.request("get", hls_elem["url"]), hls_elem["url"], output=self.output) if stream: for n in list(stream.keys()): yield stream[n] avail_quality = jsondata["request"]["files"]["progressive"] for i in avail_quality: yield HTTP(copy.copy(self.config), i["url"], i["height"], output=self.output) else: yield ServiceError("Can't find any streams.") return
def get_video(self, janson): videos = janson["videos"][0]["media"]["streams"] for i in videos: if i["name"] == "auto": hls = "{0}{1}".format(janson["videos"][0]["media"]["base"], i["url"]) streams = hlsparse(self.options, self.http.request("get", hls), hls) return streams
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.screen9.com/player?eventParam=1&ajaxauth=%s&method=embed&mediaid=%s" % (ajax_auth.group(1), mediaid)).text jsondata = json.loads(jsondata) if "live" in jsondata["data"]["publishing_status"]: self.options.live = jsondata["data"]["publishing_status"]["live"] playlist = jsondata["data"]["streams"] for i in playlist: if "application/x-mpegurl" in i: streams = hlsparse(self.options, self.http.request("get", i["application/x-mpegurl"]), i["application/x-mpegurl"]) if streams: 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 download webpage") return if self.exclude(options): return parse = urlparse(self.url) vidoid = parse.path[parse.path.rfind("/")+1:] match = re.search(r'JSONdata = ({.*});', data) if not match: log.error("Cant find json data") return janson = json.loads(match.group(1)) playlist = janson["playlist"] for i in playlist: if i["brightcoveId"] == vidoid: if i["HLSURL"]: streams = hlsparse(i["HLSURL"]) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n) for n in i["renditions"]: if n["container"] == "MP4": yield HTTP(copy.copy(options), n["URL"], int(n["rate"])/1000)
def get(self): data = self.get_urldata() parse = urlparse(self.url) match = re.search(r'^/([a-z]{2})/', parse.path) if not match: yield ServiceError("Cant county code") return res = self.http.get("http://www.pokemon.com/api/pokemontv/channels?region={0}".format(match.group(1))) janson = res.json() match = re.search('data-video-season="([0-9]+)"', data) season = match.group(1) match = re.search('data-video-episode="([0-9]+)"', data) episode = match.group(1) for i in janson: for n in i["media"]: if season == n["season"] and episode == n["episode"]: stream = n["stream_url"] self.output["title"] = "pokemon" self.output["season"] = season self.output["episode"] = episode streams = hlsparse(self.config, self.http.request("get", stream), stream, output=self.output) for n in list(streams.keys()): yield streams[n]
def get(self): match = re.search(r"[\/-](\d+)$", self.url) if not match: yield ServiceError("Cant find video id") return self.output["id"] = match.group(1) match = re.search("data-program-format='([^']+)'", self.get_urldata()) if not match: yield ServiceError("Cant find program name") return self.output["title"] = match.group(1) match = re.search('img alt="([^"]+)" class="video-image responsive"', self.get_urldata()) if not match: yield ServiceError("Cant find title of the video") return self.output["episodename"] = match.group(1) url = "https://playback-api.b17g.net/media/{}?service=tv4&device=browser&protocol=hls%2Cdash&drm=widevine".format(self.output["id"]) res = self.http.request("get", url, cookies=self.cookies) if res.status_code > 200: yield ServiceError("Can't play this because the video is geoblocked.") return if res.json()["playbackItem"]["type"] == "hls": streams = hlsparse(self.config, self.http.request("get", res.json()["playbackItem"]["manifestUrl"]), res.json()["playbackItem"]["manifestUrl"], output=self.output) 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 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): data = self.get_urldata() if self.exclude(self.options): yield ServiceError("Excluding video") return match = re.search('src="(http://mm-resource-service.herokuapp.com[^"]*)"', data) if match: data = self.http.request("get", match.group(1)).text match = re.search('src="(https://[^"]+solidtango[^"]+)" ', data) if match: data = self.http.request("get", match.group(1)).text match = re.search(r'<title>(http[^<]+)</title>', data) if match: data = self.http.request("get", match.group(1)).text match = re.search('is_livestream: true', data) if match: self.options.live = True match = re.search('html5_source: "([^"]+)"', data) if match: streams = hlsparse(self.options, self.http.request("get", match.group(1)), match.group(1)) for n in list(streams.keys()): yield streams[n] else: yield ServiceError("Can't find video info. if there is a video on the page. its a bug.") return
def get(self): data = self.get_urldata() if self.exclude(): yield ServiceError("Excluding video") return match = re.search(r'"([^"]+geo.php)"', data) if match: data = self.http.request("get", match.group(1)).content match = re.search(r'punktur=\(([^ ]+)\)', data) if match: janson = json.loads(match.group(1)) self.options.live = checklive(janson["result"][1]) streams = hlsparse(self.options, self.http.request("get", janson["result"][1]), janson["result"][1]) for n in list(streams.keys()): yield streams[n] else: yield ServiceError("Can't find json info") else: match = re.search(r'<source [^ ]*[ ]*src="([^"]+)" ', self.get_urldata()) if not match: yield ServiceError("Can't find video info for: %s" % self.url) return if match.group(1).endswith("mp4"): yield HTTP(copy.copy(self.options), match.group(1), 800) else: m3u8_url = match.group(1) self.options.live = checklive(m3u8_url) yield HLS(copy.copy(self.options), m3u8_url, 800)
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): 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() if self.exclude(): yield ServiceError("Excluding video") return apiurl = None match = re.search('data-player-config="([^"]+)"', data) if not match: yield ServiceError("Can't find video info") return janson = json.loads(decode_html_entities(match.group(1))) videoId = janson["playerOptions"]["id"] apiurl = janson["playerOptions"]["api"] vendor = janson["playerOptions"]["vendor"] self.options.live = janson["live"] if not self.options.live: dataurl = "{}{}/assets/{}?appName=svp-player".format(apiurl, vendor, videoId) data = self.http.request("get", dataurl).text data = json.loads(data) streams = hlsparse(self.options, self.http.request("get", data["streamUrls"]["hls"]), data["streamUrls"]["hls"]) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): parse = urlparse(self.url) if not parse.path.startswith("/video"): yield ServiceError("Can't find video info") return wanted_id = parse.path[7:] current_time = int((datetime.utcnow() - datetime.utcfromtimestamp(0)).total_seconds() * 1000) api_url = "https://www.atgplay.se/api/{0}/video/{1}".format(current_time, wanted_id) video_assets = self.http.request("get", api_url) try: janson = json.loads(video_assets.text) except json.decoder.JSONDecodeError: yield ServiceError("Can't decode api request: {0}".format(video_assets.text)) return if "title" in janson: self.output["title"] = janson["title"] if "urls" in janson: for i in janson["urls"]: if "m3u" == i: stream = hlsparse(self.config, self.http.request("get", janson["urls"]["m3u"]), janson["urls"]["m3u"], output=self.output) for key in list(stream.keys()): yield stream[key]
def get(self): data = self.get_urldata() match = re.search('window.pagePlaylist = (.*);', data) if not match: yield ServiceError("Can't find video info") return try: janson = json.loads(match.group(1)) except Exception: yield ServiceError("Can't decode api request: {0}".format(match.group(1))) return parse = urlparse(self.url) wanted_id = parse.path.split("/")[-1].split("-")[0] for n in janson: if wanted_id == str(n["id"]): mrssxmlurl = "http://media-utils.mtvnservices.com/services/MediaGenerator/" \ "mgid:arc:video:mtv.se:{0}?acceptMethods=hls".format(n["video_token"]) hls_asset = self.http.request("get", mrssxmlurl) xml = ET.XML(hls_asset.text) if xml.find("./video") is not None and xml.find("./video").find("item") is not None and \ xml.find("./video").find("item").find("rendition") is not None and \ xml.find("./video").find("item").find("rendition").find("src") is not None: hls_url = xml.find("./video").find("item").find("rendition").find("src").text stream = hlsparse(self.config, self.http.request("get", hls_url), hls_url, output=self.output) if stream: for key in list(stream.keys()): yield stream[key]
def get(self): if self.exclude(): yield ServiceError("Excluding video") return match = re.search('iframe src="(/embed/[^"]+)"', self.get_urldata()) if not match: yield ServiceError("Cant find video") return parse = urlparse(self.url) url = "{0}://{1}{2}".format(parse.scheme, parse.netloc, match.group(1)) data = self.http.get(url) match = re.search('src="([^"]+vtt)"', data.text) if match: yield subtitle(copy.copy(self.options), "wrst", match.group(1)) match = re.search('source src="([^"]+)" type="application/x-mpegURL"', data.text) if not match: yield ServiceError("Cant find video file") return streams = hlsparse(self.options, self.http.request("get", match.group(1)), match.group(1)) for n in list(streams.keys()): yield streams[n]
def get(self): vid = None data = self.get_urldata() if self.exclude(self.options): yield ServiceError("Excluding video") return match = re.search(r'video url-([^"]+)', data) if not match: match = re.search(r'embed.jsp\?([^"]+)"', self.get_urldata()) if not match: yield ServiceError("Can't find video id") return vid = match.group(1) if not vid: path = unquote_plus(match.group(1)) data = self.http.request("get", "http://www.svd.se%s" % path).content match = re.search(r'embed.jsp\?([^"]+)', data) if not match: yield ServiceError("Can't find video id") return vid = match.group(1) url = "http://ljsp.lwcdn.com/web/public/item.json?type=video&%s" % decode_html_entities(vid) data = self.http.request("get", url).text jdata = json.loads(data) videos = jdata["videos"][0]["media"]["streams"] for i in videos: if i["name"] == "auto": hls = "%s%s" % (jdata["videos"][0]["media"]["base"], i["url"]) streams = hlsparse(self.options, self.http.request("get", hls), hls) if streams: for n in list(streams.keys()): yield streams[n]
def _get_static_video(self, options, videoid): access = self._get_access_token(videoid) if options.output_auto: data = self.http.request("get", "https://api.twitch.tv/kraken/videos/v%s" % videoid) if data.status_code == 404: yield ServiceError("Can't find the video") return info = json.loads(data.text) name = "twitch-%s-%s" % (info["channel"]["name"], filenamify(info["title"])) directory = os.path.dirname(options.output) if os.path.isdir(directory): name = os.path.join(directory, name) options.output = name if "token" not in access: raise TwitchUrlException('video', self.url) nauth = quote_plus(str(access["token"])) authsig = access["sig"] url = "http://usher.twitch.tv/vod/%s?nauth=%s&nauthsig=%s" % ( videoid, nauth, authsig) streams = hlsparse(options, self.http.request("get", url), url) if streams: for n in list(streams.keys()): yield streams[n]
def get(self, options): match = re.search("xmlUrl=([^ ]+)\" ", self.get_urldata()) if match: xmlurl = unquote_plus(match.group(1)) else: match = re.search("moviesList: \[\{\"VideoId\":\"(\d+)\"", self.get_urldata()) if not match: log.error("Can't find video id") sys.exit(2) vid = match.group(1) xmlurl = "http://www.expressen.se/Handlers/WebTvHandler.ashx?id=%s" % vid data = get_http_data(xmlurl) xml = ET.XML(data) live = xml.find("live").text if live != "0": options.live = True ss = xml.find("vurls") if is_py2_old: sa = list(ss.getiterator("vurl")) else: sa = list(ss.iter("vurl")) for i in sa: options2 = copy.copy(options) match = re.search(r"rtmp://([-0-9a-z\.]+/[-a-z0-9]+/)(.*)", i.text) filename = "rtmp://%s" % match.group(1) options2.other = "-y %s" % match.group(2) yield RTMP(options2, filename, int(i.attrib["bitrate"])) ipadurl = xml.find("mobileurls").find("ipadurl").text streams = hlsparse(ipadurl) for n in list(streams.keys()): yield HLS(copy.copy(options), streams[n], n)
def get(self): match = re.search(r"[\/-](\d+)$", self.url) if not match: yield ServiceError("Cant find video id") return self.output["id"] = match.group(1) match = re.search("data-program-format='([^']+)'", self.get_urldata()) if not match: yield ServiceError("Cant find program name") return self.output["title"] = match.group(1) match = re.search('img alt="([^"]+)" class="video-image responsive"', self.get_urldata()) if not match: yield ServiceError("Cant find title of the video") return self.output["episodename"] = match.group(1) url = "https://playback-api.b17g.net/media/{}?service=tv4&device=browser&protocol=hls%2Cdash&drm=widevine".format( self.output["id"]) res = self.http.request("get", url, cookies=self.cookies) if res.status_code > 200: yield ServiceError( "Can't play this because the video is geoblocked.") return if res.json()["playbackItem"]["type"] == "hls": streams = hlsparse( self.config, self.http.request("get", res.json()["playbackItem"]["manifestUrl"]), res.json()["playbackItem"]["manifestUrl"], output=self.output, ) for n in list(streams.keys()): yield streams[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("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): parse = urlparse(self.url) if not parse.path.startswith("/video"): yield ServiceError("Can't find video info") return wanted_id = parse.path[7:] current_time = int( (datetime.utcnow() - datetime.utcfromtimestamp(0)).total_seconds() * 1000) api_url = "https://www.atgplay.se/api/{}/video/{}".format( current_time, wanted_id) video_assets = self.http.request("get", api_url) try: janson = json.loads(video_assets.text) except json.decoder.JSONDecodeError: yield ServiceError("Can't decode api request: {}".format( video_assets.text)) return if "title" in janson: self.output["title"] = janson["title"] if "urls" in janson: for i in janson["urls"]: if "m3u" == i: stream = hlsparse(self.config, self.http.request( "get", janson["urls"]["m3u"]), janson["urls"]["m3u"], output=self.output) for key in list(stream.keys()): yield stream[key]
def get(self): vid = None data = self.get_urldata() if self.exclude(): yield ServiceError("Excluding video") return match = re.search(r'video url-([^"]+)', data) if not match: match = re.search(r'embed.jsp\?([^"]+)"', self.get_urldata()) if not match: yield ServiceError("Can't find video id") return vid = match.group(1) if not vid: path = unquote_plus(match.group(1)) data = self.http.request("get", "http://www.svd.se%s" % path).content match = re.search(r'embed.jsp\?([^"]+)', data) if not match: yield ServiceError("Can't find video id") return vid = match.group(1) url = "http://ljsp.lwcdn.com/web/public/item.json?type=video&%s" % decode_html_entities( vid) data = self.http.request("get", url).text jdata = json.loads(data) videos = jdata["videos"][0]["media"]["streams"] for i in videos: if i["name"] == "auto": hls = "%s%s" % (jdata["videos"][0]["media"]["base"], i["url"]) streams = hlsparse(self.options, self.http.request("get", hls), hls) if streams: 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('window.FLUX_STATE = ({.*})</script>', data) if not match: yield ServiceError("Can't find video info") return janson = json.loads(match.group(1)) 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 n in list(streams.keys()): yield streams[n]
def _sport(self): content = self._conentpage(self.get_urldata()) if not content: yield ServiceError("Can't find video file for: {0}".format(self.url)) return janson = json.loads(content.group(1)) if not janson["sportsPlayer"]["currentVideo"]: yield ServiceError("Can't find video file for: {0}".format(self.url)) return self.output["title"] = janson["sportsPlayer"]["currentVideo"]["title"] res = self.http.request("get", janson["sportsPlayer"]["currentVideo"]["_links"]["streamLink"]["href"]) if res.status_code == 403: yield ServiceError("Can't play this because the video is geoblocked.") return for i in res.json()["embedded"]["prioritizedStreams"]: streams = hlsparse(self.config, self.http.request("get", i["links"]["stream"]["href"]), i["links"]["stream"]["href"], output=self.output) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): match = re.search("__STATE__']=({.*});</script><script>window", self.get_urldata()) if not match: yield ServiceError("Cant find video info") return dataj = json.loads(match.group(1)) vid = dataj["dataSources"]["article"][0]["videos"][0]["data"][ "mediaGuid"] url = f"https://viasport.mtg-api.com/stream-links/viasport/web/se/clear-media-guids/{vid}/streams" data = self.http.get(url) dataj = data.json() hls = dataj["embedded"]["prioritizedStreams"][0]["links"]["stream"][ "href"] if re.search("/live/", hls): self.config.set("live", True) streams = hlsparse(self.config, self.http.request("get", hls), hls, output=self.output) 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_video(self, janson): if "video" in janson and "formats" in janson["video"]: janson_v = janson["video"] if len(janson_v["formats"]) == 0: yield ServiceError("Media doesn't have any associated videos.") return for i in janson_v["formats"]: streams = None if i["type"] == "hls": streams = hlsparse(self.options, self.http.request("get", i["uri"]), i["uri"]) elif i["type"] == "dash": streams = dashparse(self.options, self.http.request("get", i["uri"]), i["uri"]) if streams: for n in list(streams.keys()): yield streams[n]
def get(self): login = self._login() if not login: yield ServiceError("You need to login") return data = self.get_urldata() match = re.search('}}}},("staticPages".*}}); windo', data) if not match: yield ServiceError("Cant find necessary info") return janson = json.loads("{}{}".format("{", match.group(1))) video = None for play in janson["page"]["blocks"]: if "componentName" in play and play["componentName"] == "player": video = play break if not video: yield ServiceError("Can't find video") return self._autoname(video) if "subtitles" in video["_embedded"][ "program"] and "subtitlesWebvtt" in video["_embedded"][ "program"]["subtitles"]: yield subtitle( copy.copy(self.config), "wrst", video["_embedded"]["program"]["subtitles"]["subtitlesWebvtt"], output=self.output) res = self.http.get( video["_embedded"]["program"]["_links"]["streamLink"]["href"]) janson = res.json() stream = janson["embedded"]["prioritizedStreams"][0]["links"]["stream"] if video["_embedded"]["program"]["_links"]["streamLink"]: streams = hlsparse( self.config, self.http.request("get", stream["href"]), stream["href"], output=self.output, authorization="MTG-AT {}".format(self.token), ) for n in list(streams.keys()): yield streams[n] if "subtitles" in janson["embedded"] and len( janson["embedded"]["subtitles"]) > 0: lang = re.search(r"(\.\w\w)$", urlparse(self.url).netloc).group(1) if lang in country: language = country[lang] else: language = None if not self.config.get("get_all_subtitles"): if not language: yield subtitle( copy.copy(self.config), "wrst", janson["embedded"]["subtitles"][0]["link"]["href"], output=self.output) else: for i in janson["embedded"]["subtitles"]: if i["data"]["language"] == language: yield subtitle(copy.copy(self.config), "wrst", i["link"]["href"], output=self.output) else: for i in janson["embedded"]["subtitles"]: yield subtitle(copy.copy(self.config), "wrst", i["link"]["href"], i["data"]["language"], output=copy.copy(self.output))
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): data = self.get_urldata() match = re.search(r"urPlayer.init\((.*)\);", data) if not match: yield ServiceError("Can't find json info") return data = match.group(1) jsondata = json.loads(data) if len(jsondata["subtitles"]) > 0: for sub in jsondata["subtitles"]: if "label" in sub: absurl = urljoin(self.url, sub["file"].split(",")[0]) if absurl.endswith("vtt"): subtype = "wrst" else: subtype = "tt" if self.config.get("get_all_subtitles"): yield subtitle(copy.copy(self.config), subtype, absurl, sub["label"], output=self.output) else: yield subtitle(copy.copy(self.config), subtype, absurl, output=self.output) if "streamer" in jsondata["streaming_config"]: basedomain = jsondata["streaming_config"]["streamer"]["redirect"] else: url = jsondata["streaming_config"]["loadbalancer"] if url[:1] == "/": url = "https:{}".format(url) lbjson = self.http.request("get", url).text lbjson = json.loads(lbjson) basedomain = lbjson["redirect"] http = "https://{}/{}".format(basedomain, jsondata["file_http"]) hd = None if len(jsondata["file_http_hd"]) > 0: http_hd = "https://{}/{}".format(basedomain, jsondata["file_http_hd"]) hls_hd = "{}{}".format( http_hd, jsondata["streaming_config"]["http_streaming"]["hls_file"]) hd = True hls = "{}{}".format( http, jsondata["streaming_config"]["http_streaming"]["hls_file"]) streams = hlsparse(self.config, self.http.request("get", hls), hls, output=self.output) for n in list(streams.keys()): yield streams[n] if hd: streams = hlsparse(self.config, self.http.request("get", hls_hd), hls_hd, 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): 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): data = self.http.get("https://www.sportlib.se/sportlib/login").text match = re.search('src="(/app[^"]+)">', data) if not match: yield ServiceError("Can't find url for login info") return url = urljoin("https://www.sportlib.se", match.group(1)) data = self.http.get(url).text match = re.search('CLIENT_SECRET:"([^"]+)"', data) if not match: yield ServiceError("Cant fint login info") return cs = match.group(1) match = re.search('CLIENT_ID:"([^"]+)"', data) if not match: yield ServiceError("Cant fint login info") return cid = match.group(1) res = self.http.get("https://core.oz.com/channels?slug=sportlib&org=www.sportlib.se") janson = res.json() sid = janson["data"][0]["id"] data = { "client_id": cid, "client_secret": cs, "grant_type": "password", "username": self.config.get("username"), "password": self.config.get("password"), } res = self.http.post("https://core.oz.com/oauth2/token?channelId={}".format(sid), data=data) if res.status_code > 200: yield ServiceError("Wrong username / password?") return janson = res.json() token_type = janson["token_type"].title() access_token = janson["access_token"] parse = urlparse(self.url) match = re.search("video/([-a-fA-F0-9]+)", parse.path) if not match: yield ServiceError("Cant find video id") return vid = match.group(1) headers = {"content-type": "application/json", "authorization": "{} {}".format(token_type, access_token)} url = "https://core.oz.com/channels/{}/videos/{}?include=collection,streamUrl".format(sid, vid) res = self.http.get(url, headers=headers) janson = res.json() cookiename = janson["data"]["streamUrl"]["cookieName"] token = janson["data"]["streamUrl"]["token"] hlsplaylist = janson["data"]["streamUrl"]["cdnUrl"] self.output["title"] = janson["data"]["title"] # get cookie postjson = {"name": cookiename, "value": token} res = self.http.post("https://playlist.oz.com/cookie", json=postjson) cookies = res.cookies streams = hlsparse(self.config, self.http.request("get", hlsplaylist), hlsplaylist, keycookie=cookies, 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): 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): # Get video id parse = urlparse(self.url) video_id = parse.path.split("/")[-1] if "__" in video_id: video_id = video_id.split("__")[-1] if not video_id: yield ServiceError("Can't find video info") return # Get prid prid_src = self.http.request( "get", "http://e.omroep.nl/metadata/{}".format(video_id)) prid_raw = prid_src.text.split("(", 1)[-1].split(")", 1)[0] try: janson = json.loads(prid_raw) prid = janson["prid"] if "titel" in janson: self.output["title"] = janson["titel"] except json.decoder.JSONDecodeError: yield ServiceError( "Can't decode prid request: {}".format(prid_raw)) return # Get token token_src = self.http.request( "get", "http://ida.omroep.nl/app.php/auth/{}".format(prid)) try: janson = json.loads(token_src.text) token = janson["token"] except json.decoder.JSONDecodeError: yield ServiceError("Can't decode token request: {}".format( token_src.text)) return # Get super api api_url = self.http.request( "get", "http://ida.omroep.nl/app.php/{}?token={}".format(prid, token)) try: janson = json.loads(api_url.text) except json.decoder.JSONDecodeError: yield ServiceError("Can't decode api request: {}".format( api_url.text)) return # Get sub api and streams for item in janson["items"][0]: stream = None if item["format"] == "hls": api = self.http.request("get", item["url"]).text raw_url = re.search(r'"url":"(.+?)"', api).group(1) url = json.loads('"{}"'.format(raw_url)) stream = hlsparse(self.config, self.http.request("get", url), url, output=self.output) if stream: for key in list(stream.keys()): yield stream[key]
def get(self): data = self.get_urldata() parse = urlparse(self.url) if parse.netloc.endswith("se"): match = re.search(r'<div class="video-player" (.*)>', data) if not match: yield ServiceError("Can't find video info") return match_id = re.search(r'data-id="([0-9a-fA-F|\-]+)" ', match.group(1)) if not match_id: yield ServiceError("Can't find video info") return wanted_id = match_id.group(1) url_service = "http://feeds.mtvnservices.com/od/feed/intl-mrss-player-feed?mgid=mgid:arc:episode:nick.intl:{0}" \ "&arcEp=nickelodeon.se&imageEp=nickelodeon.se&stage=staging&accountOverride=intl.mtvi.com&ep=a9cc543c".format(wanted_id) service_asset = self.http.request("get", url_service) match_guid = re.search('<guid isPermaLink="false">(.*)</guid>', service_asset.text) if not match_guid: yield ServiceError("Can't find video info") return hls_url = "https://mediautilssvcs-a.akamaihd.net/services/MediaGenerator/{0}?arcStage=staging&accountOverride=intl.mtvi.com&" \ "billingSection=intl&ep=a9cc543c&acceptMethods=hls".format(match_guid.group(1)) hls_asset = self.http.request("get", hls_url) xml = ET.XML(hls_asset.text) if xml.find("./video") is not None and xml.find("./video").find("item") is not None \ and xml.find("./video").find("item").find("rendition") is not None \ and xml.find("./video").find("item").find("rendition").find("src") is not None: hls_url = xml.find("./video").find("item").find( "rendition").find("src").text stream = hlsparse(self.config, self.http.request("get", hls_url), hls_url, output=self.output) for key in list(stream.keys()): yield stream[key] return match = re.search( r'data-mrss=[\'"](http://gakusei-cluster.mtvnn.com/v2/mrss.xml[^\'"]+)[\'"]', data) if not match: yield ServiceError("Can't find id for the video") return mrssxmlurl = match.group(1) data = self.http.request("get", mrssxmlurl).content xml = ET.XML(data) title = xml.find("channel").find("item").find("title").text self.output["title"] = title match = re.search("gon.viacom_config=([^;]+);", self.get_urldata()) if match: countrycode = json.loads(match.group(1))["country_code"].replace( "_", "/") match = re.search("mtvnn.com:([^&]+)", mrssxmlurl) if match: urlpart = match.group(1).replace("-", "/").replace( "playlist", "playlists" ) # it use playlists dunno from where it gets it hlsapi = "http://api.mtvnn.com/v2/{0}/{1}.json?video_format=m3u8&callback=&".format( countrycode, urlpart) data = self.http.request("get", hlsapi).text dataj = json.loads(data) for i in dataj["local_playlist_videos"]: streams = hlsparse(self.config, self.http.request("get", i["url"]), i["url"], 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']: 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() 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]
def get(self): parse = urlparse(self.url) if parse.path[:8] == "/kanaler": end_time_stamp = (datetime.utcnow() - timedelta(minutes=1, seconds=20)).replace(microsecond=0) start_time_stamp = end_time_stamp - timedelta(minutes=1) url = "https://bbr-l2v.akamaized.net/live/{}/master.m3u8?in={}&out={}?".format( parse.path[9:], start_time_stamp.isoformat(), end_time_stamp.isoformat() ) self.config.set("live", True) streams = hlsparse(self.config, self.http.request("get", url), url, output=self.output, hls_time_stamp=True) for n in list(streams.keys()): yield streams[n] return match = self._getjson() if not match: yield ServiceError("Can't find json data") return jansson = json.loads(match.group(1)) if "assetId" not in jansson["props"]["pageProps"]: yield ServiceError("Cant find video id for the video") return vid = jansson["props"]["pageProps"]["assetId"] janson2 = jansson["props"]["pageProps"]["initialApolloState"] item = janson2["VideoAsset:{}".format(vid)] if item["is_drm_protected"]: yield ServiceError("We can't download DRM protected content from this site.") return if item["live"]: self.config.set("live", True) if item["season"] > 0: self.output["season"] = item["season"] if item["episode"] > 0: self.output["episode"] = item["episode"] self.output["title"] = item["program_nid"] self.output["episodename"] = item["title"] self.output["id"] = str(vid) if vid is None: yield ServiceError("Cant find video id for the video") return url = "https://playback-api.b17g.net/media/{}?service=tv4&device=browser&protocol=hls%2Cdash&drm=widevine".format(vid) res = self.http.request("get", url, cookies=self.cookies) if res.status_code > 200: yield ServiceError("Can't play this because the video is geoblocked or not available.") return if res.json()["playbackItem"]["type"] == "hls": streams = hlsparse( self.config, self.http.request("get", res.json()["playbackItem"]["manifestUrl"]), res.json()["playbackItem"]["manifestUrl"], output=self.output, httpobject=self.http, ) for n in list(streams.keys()): yield streams[n]
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.") 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.options, self.http.request("get", i["url"]), i["url"]) if alt: alt_streams = hlsparse( self.options, self.http.request("get", alt.request.url), alt.request.url) elif 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 alt: alt_streams = hdsparse( self.options, self.http.request("get", alt.request.url, params={"hdcore": "3.7.0"}), alt.request.url) elif i["format"] == "dash264" or i["format"] == "dashhbbtv": streams = dashparse(self.options, self.http.request("get", i["url"]), i["url"]) if alt: 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] if alt_streams: for n in list(alt_streams.keys()): yield alt_streams[n]
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:%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 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 '%s'" % 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): parse = urlparse(self.url) match = re.search("window.server_path = ({.*});", self.get_urldata()) if not match: yield ServiceError("Cant find api key") return janson = json.loads(match.group(1)) clientapikey = janson["sdk"]["clientApiKey"] devices = "https://eu.edge.bamgrid.com/devices" postdata = { "deviceFamily": "browser", "applicationRuntime": "firefox", "deviceProfile": "macosx", "attributes": {} } header = {"authorization": f"Bearer {clientapikey}"} res = self.http.post(devices, headers=header, json=postdata) assertion = res.json()["assertion"] token = "https://eu.edge.bamgrid.com/token" data = { "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange", "latitude": 0, "longitude": 0, "platform": "browser", "subject_token": assertion, "subject_token_type": "urn:bamtech:params:oauth:token-type:device", } res = self.http.post(token, headers=header, data=data) access_token = res.json()["access_token"] login = "******" header = {"authorization": f"Bearer {access_token}"} res = self.http.post(login, headers=header, json={ "email": self.config.get("username"), "password": self.config.get("password") }) if res.status_code > 400: yield ServiceError("Wrong username or password") return id_token = res.json()["id_token"] grant = "https://eu.edge.bamgrid.com/accounts/grant" res = self.http.post(grant, headers=header, json={"id_token": id_token}) assertion = res.json()["assertion"] token = "https://eu.edge.bamgrid.com/token" data = { "grant_type": "urn:ietf:params:oauth:grant-type:token-exchange", "latitude": 0, "longitude": 0, "platform": "browser", "subject_token": assertion, "subject_token_type": "urn:bamtech:params:oauth:token-type:account", } header = {"authorization": f"Bearer {clientapikey}"} res = self.http.post(token, headers=header, data=data) access_token = res.json()["access_token"] query = { "preferredLanguages": ["en"], "mediaRights": ["GeoMediaRight"], "uiLang": "en", "include_images": True } if parse.path[:11] == "/en/channel": pagetype = "channel" match = re.search("/([^/]+)$", parse.path) if not match: yield ServiceError("Cant find channel") return (vid, ) = match.groups() query["pageType"] = pagetype query["channelCallsign"] = vid query["channelCallsigns"] = vid query["onAir"] = True self.config.set("live", True) # lets override to true url = ( "https://search-api.svcs.eurosportplayer.com/svc/search/v2/graphql/persisted/" "query/eurosport/web/Airings/onAir?variables={}".format( quote(json.dumps(query)))) res = self.http.get(url, headers={"authorization": access_token}) vid2 = res.json()["data"]["Airings"][0]["channel"]["id"] url = f"https://global-api.svcs.eurosportplayer.com/channels/{vid2}/scenarios/browser" res = self.http.get( url, headers={ "authorization": access_token, "Accept": "application/vnd.media-service+json; version=1" }) hls_url = res.json()["stream"]["slide"] else: pagetype = "event" match = re.search("/([^/]+)/([^/]+)$", parse.path) if not match: yield ServiceError("Cant fint event id") return query["title"], query["contentId"] = match.groups() query["pageType"] = pagetype url = "https://search-api.svcs.eurosportplayer.com/svc/search/v2/graphql/" "persisted/query/eurosport/Airings?variables={}".format( quote(json.dumps(query)), ) res = self.http.get(url, headers={"authorization": access_token}) programid = res.json()["data"]["Airings"][0]["programId"] mediaid = res.json()["data"]["Airings"][0]["mediaId"] url = f"https://global-api.svcs.eurosportplayer.com/programs/{programid}/media/{mediaid}/scenarios/browser" res = self.http.get( url, headers={ "authorization": access_token, "Accept": "application/vnd.media-service+json; version=1" }) hls_url = res.json()["stream"]["complete"] streams = hlsparse(self.config, self.http.request("get", hls_url), hls_url, authorization=access_token, output=self.output) for n in list(streams.keys()): yield streams[n]
def get(self): parse = urlparse(self.url) self.domain = re.search(r"(discoveryplus\.\w\w)", parse.netloc).group(1) if not self._token(): logging.error("Something went wrong getting token for requests") if not self._login(): yield ServiceError( "You need the 'st' cookie from your web brower for the site to make it work" ) return channel = False if "kanaler" in parse.path: match = re.search("kanaler/([^/]+)$", parse.path) if not match: yield ServiceError("Can't detect 'kanaler'") return path = "/channels/{}".format(match.group(1)) url = f"https://disco-api.{self.domain}/content{path}" channel = True self.config.set("live", True) elif "program" in parse.path: match = re.search("(programmer|program)/([^/]+)$", parse.path) if not match: yield ServiceError("Can't find program url") return path = "/shows/{}".format(match.group(2)) url = f"https://disco-api.{self.domain}/content{path}" res = self.http.get( url, headers={"x-disco-client": "WEB:UNKNOWN:dplay-client:0.0.1"}) programid = res.json()["data"]["id"] qyerystring = ( "include=primaryChannel,show&filter[videoType]=EPISODE&filter[show.id]={}&" "page[size]=100&sort=seasonNumber,episodeNumber,-earliestPlayableStart" .format(programid)) res = self.http.get( f"https://disco-api.{self.domain}/content/videos?{qyerystring}" ) janson = res.json() vid = 0 slug = None for i in janson["data"]: if int(i["id"]) > vid: vid = int(i["id"]) slug = i["attributes"]["path"] if slug: url = f"https://disco-api.{self.domain}/content/videos/{slug}" else: yield ServiceError("Cant find latest video on program url") return else: match = re.search("(videos|videoer)/(.*)$", parse.path) url = "https://disco-api.{}/content/videos/{}".format( self.domain, match.group(2)) res = self.http.get( url, headers={"x-disco-client": "WEB:UNKNOWN:dplay-client:0.0.1"}) janson = res.json() if "errors" in janson: yield ServiceError("Cant find any videos on this url") return if channel: name = janson["data"]["attributes"]["name"] self.output["title"] = name else: name = self._autoname(janson) if name is None: yield ServiceError("Cant find vid id for autonaming") return self.output["id"] = janson["data"]["id"] api = "https://disco-api.{}/playback/videoPlaybackInfo/{}?usePreAuth=true".format( self.domain, janson["data"]["id"]) res = self.http.get(api) if res.status_code > 400: yield ServiceError("You dont have permission to watch this") return streams = hlsparse( self.config, self.http.request( "get", res.json()["data"]["attributes"]["streaming"]["hls"]["url"]), res.json()["data"]["attributes"]["streaming"]["hls"]["url"], httpobject=self.http, output=self.output, ) for n in list(streams.keys()): if isinstance( streams[n], subtitle): # we get the subtitles from the hls playlist. if self.config.get("get_all_subtitles"): yield streams[n] else: if streams[n].subfix in country and country[ streams[n].subfix] in self.domain: yield streams[n] else: yield streams[n]
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): 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): 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]