本文整理汇总了Python中svtplay_dl.fetcher.hls.hlsparse函数的典型用法代码示例。如果您正苦于以下问题:Python hlsparse函数的具体用法?Python hlsparse怎么用?Python hlsparse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hlsparse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
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")
示例2: _get_video
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]
示例3: get
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]
示例4: get
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]
示例5: get
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]
示例6: get
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'])
示例7: get
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]
示例8: get
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]
示例9: get
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]
示例10: get
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"])
示例11: get
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)
示例12: get
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]
示例13: get
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)
示例14: get
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]
示例15: get
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]