本文整理汇总了Python中svtplay_dl.fetcher.hds.hdsparse函数的典型用法代码示例。如果您正苦于以下问题:Python hdsparse函数的具体用法?Python hdsparse怎么用?Python hdsparse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hdsparse函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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]
示例2: 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]
示例3: 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]
示例4: _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]
示例5: 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
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)
示例6: get
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)
示例7: 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]
示例8: 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"])
示例9: get
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)
示例10: _get_video
def _get_video(self, janson):
if "subtitleReferences" in janson:
for i in janson["subtitleReferences"]:
if i["format"] == "websrt" and "url" in i:
yield subtitle(copy.copy(self.config), "wrst", i["url"], output=self.output)
if "videoReferences" in janson:
if len(janson["videoReferences"]) == 0:
yield ServiceError("Media doesn't have any associated videos.")
return
for i in janson["videoReferences"]:
streams = None
alt_streams = None
alt = None
query = parse_qs(urlparse(i["url"]).query)
if "alt" in query and len(query["alt"]) > 0:
alt = self.http.get(query["alt"][0])
if i["format"] == "hls":
streams = hlsparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output)
if alt:
alt_streams = hlsparse(self.config, self.http.request("get", alt.request.url), alt.request.url, output=self.output)
elif i["format"] == "hds":
match = re.search(r"\/se\/secure\/", i["url"])
if not match:
streams = hdsparse(self.config, self.http.request("get", i["url"], params={"hdcore": "3.7.0"}),
i["url"], output=self.output)
if alt:
alt_streams = hdsparse(self.config, self.http.request("get", alt.request.url, params={"hdcore": "3.7.0"}),
alt.request.url, output=self.output)
elif i["format"] == "dash264" or i["format"] == "dashhbbtv":
streams = dashparse(self.config, self.http.request("get", i["url"]), i["url"], output=self.output)
if alt:
alt_streams = dashparse(self.config, self.http.request("get", alt.request.url),
alt.request.url, output=self.output)
if streams:
for n in list(streams.keys()):
yield streams[n]
if alt_streams:
for n in list(alt_streams.keys()):
yield alt_streams[n]
示例11: get
def get(self, options):
if re.findall("svt.se", self.url):
match = re.search(r"data-json-href=\"(.*)\"", self.get_urldata())
if match:
filename = match.group(1).replace("&", "&").replace("&format=json", "")
url = "http://www.svt.se%s" % filename
else:
log.error("Can't find video file")
sys.exit(2)
else:
url = self.url
pos = url.find("?")
if pos < 0:
dataurl = "%s?&output=json&format=json" % url
else:
dataurl = "%s&output=json&format=json" % url
data = json.loads(get_http_data(dataurl))
if "live" in data["video"]:
options.live = data["video"]["live"]
else:
options.live = False
if data["video"]["subtitleReferences"]:
try:
subtitle = data["video"]["subtitleReferences"][0]["url"]
except KeyError:
pass
if len(subtitle) > 0:
yield subtitle_wsrt(subtitle)
for i in data["video"]["videoReferences"]:
parse = urlparse(i["url"])
if parse.path.find("m3u8") > 0:
streams = hlsparse(i["url"])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
elif parse.path.find("f4m") > 0:
match = re.search(r"\/se\/secure\/", i["url"])
if not match:
parse = urlparse(i["url"])
manifest = "%s://%s%s?%s&hdcore=3.3.0" % (parse.scheme, parse.netloc, parse.path, parse.query)
streams = hdsparse(copy.copy(options), manifest)
for n in list(streams.keys()):
yield streams[n]
elif parse.scheme == "rtmp":
embedurl = "%s?type=embed" % url
data = get_http_data(embedurl)
match = re.search(r"value=\"(/(public)?(statiskt)?/swf(/video)?/svtplayer-[0-9\.a-f]+swf)\"", data)
swf = "http://www.svtplay.se%s" % match.group(1)
options.other = "-W %s" % swf
yield RTMP(copy.copy(options), i["url"], i["bitrate"])
else:
yield HTTP(copy.copy(options), i["url"], "0")
示例12: get
def get(self, options):
error, data = self.get_urldata()
if error:
log.error("Can't download page.")
return
if self.exclude(options):
return
match = re.search(r'id="(bcPl[^"]+)"', data)
if not match:
log.error("Can't find flash id.")
return
flashid = match.group(1)
match = re.search(r'playerID" value="([^"]+)"', self.get_urldata()[1])
if not match:
log.error("Can't find playerID")
return
playerid = match.group(1)
match = re.search(r'playerKey" value="([^"]+)"', self.get_urldata()[1])
if not match:
log.error("Can't find playerKey")
return
playerkey = match.group(1)
match = re.search(r'videoPlayer" value="([^"]+)"', self.get_urldata()[1])
if not match:
log.error("Can't find videoPlayer info")
return
videoplayer = match.group(1)
dataurl = "http://c.brightcove.com/services/viewer/htmlFederated?flashID=%s&playerID=%s&playerKey=%s&isVid=true&isUI=true&dynamicStreaming=true&@videoPlayer=%s" % (flashid, playerid, playerkey, videoplayer)
error, data = get_http_data(dataurl)
if error:
log.error("Cant download video info")
return
match = re.search(r'experienceJSON = ({.*});', data)
if not match:
log.error("Can't find json data")
return
jsondata = json.loads(match.group(1))
renditions = jsondata["data"]["programmedContent"]["videoPlayer"]["mediaDTO"]["renditions"]
for i in renditions:
if i["defaultURL"].endswith("f4m"):
streams = hdsparse(copy.copy(options), i["defaultURL"])
if streams:
for n in list(streams.keys()):
yield streams[n]
if i["defaultURL"].endswith("m3u8"):
streams = hlsparse(i["defaultURL"])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
示例13: get
def get(self, options):
error, data = self.get_urldata()
if error:
log.error("Can't download page.")
return
if self.exclude(options):
return
match = re.search(r'resource:[ ]*"([^"]*)",', data)
if match:
resource_url = match.group(1)
error, resource_data = get_http_data(resource_url)
if error:
log.error("Can't get resource data")
return
resource = json.loads(resource_data)
streams = find_stream(options, resource)
for i in streams:
yield i
else:
match = re.search(r'resource="([^"]*)"', data)
if not match:
log.error("Cant find resource info for this video")
return
resource_url = "%s" % match.group(1)
error, resource_data = get_http_data(resource_url)
if error:
log.error("Can't get resource data")
return
resource = json.loads(resource_data)
if "SubtitlesList" in resource:
suburl = resource["SubtitlesList"][0]["Uri"]
yield subtitle(copy.copy(options), "wrst", suburl)
if "Data" in resource:
streams = find_stream(options, resource)
for i in streams:
yield i
else:
for stream in resource['Links']:
if stream["Target"] == "HDS":
streams = hdsparse(copy.copy(options), stream["Uri"])
if streams:
for n in list(streams.keys()):
yield streams[n]
if stream["Target"] == "HLS":
streams = hlsparse(stream["Uri"])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
if stream["Target"] == "Streaming":
options.other = "-v -y '%s'" % stream['Uri'].replace("rtmp://vod.dr.dk/cms/", "")
rtmp = "rtmp://vod.dr.dk/cms/"
yield RTMP(copy.copy(options), rtmp, stream['Bitrate'])
示例14: get
def get(self, options):
data = self.get_urldata()
if self.exclude(options):
yield ServiceError("Excluding video")
return
match = re.search(r'resource:[ ]*"([^"]*)",', data)
if match:
resource_url = match.group(1)
resource_data = self.http.request("get", resource_url).content
resource = json.loads(resource_data)
streams = self.find_stream(options, resource)
for i in streams:
yield i
else:
match = re.search(r'resource="([^"]*)"', data)
if not match:
yield ServiceError("Cant find resource info for this video")
return
if match.group(1)[:4] != "http":
resource_url = "http:%s" % match.group(1)
else:
resource_url = match.group(1)
resource_data = self.http.request("get", resource_url).text
resource = json.loads(resource_data)
if "Links" not in resource:
yield ServiceError("Cant access this video. its geoblocked.")
return
if "SubtitlesList" in resource:
suburl = resource["SubtitlesList"][0]["Uri"]
yield subtitle(copy.copy(options), "wrst", suburl)
if "Data" in resource:
streams = self.find_stream(options, resource)
for i in streams:
yield i
else:
for stream in resource['Links']:
if stream["Target"] == "HDS":
streams = hdsparse(copy.copy(options), self.http.request("get", stream["Uri"], params={"hdcore": "3.7.0"}), stream["Uri"])
if streams:
for n in list(streams.keys()):
yield streams[n]
if stream["Target"] == "HLS":
streams = hlsparse(options, self.http.request("get", stream["Uri"]), stream["Uri"])
for n in list(streams.keys()):
yield streams[n]
if stream["Target"] == "Streaming":
options.other = "-v -y '%s'" % stream['Uri'].replace("rtmp://vod.dr.dk/cms/", "")
rtmp = "rtmp://vod.dr.dk/cms/"
yield RTMP(copy.copy(options), rtmp, stream['Bitrate'])
示例15: get
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]