本文整理汇总了Python中svtplay_dl.utils.urllib.urlparse函数的典型用法代码示例。如果您正苦于以下问题:Python urlparse函数的具体用法?Python urlparse怎么用?Python urlparse使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了urlparse函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _isswe
def _isswe(self, url):
if re.search(".se$", urlparse(url).netloc):
return "sasong"
elif re.search(".dk$", urlparse(url).netloc):
return "saeson"
else:
return "sesong"
开发者ID:olof,项目名称:svtplay-dl,代码行数:7,代码来源:viaplay.py
示例2: 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"])
开发者ID:TetragrammatonHermit,项目名称:svtplay-dl,代码行数:33,代码来源:vg.py
示例3: 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")
开发者ID:antoneliasson,项目名称:svtplay-dl,代码行数:55,代码来源:svtplay.py
示例4: get
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]
开发者ID:magic75,项目名称:svtplay-dl,代码行数:27,代码来源:flowonline.py
示例5: get_mediaid
def get_mediaid(self):
match = re.search(r"mediaId = '([^']+)';", self.get_urldata())
if not match:
match = re.search(r'media-id="([^"]+)"', self.get_urldata())
if not match:
match = re.search(r'screen9-mid="([^"]+)"', self.get_urldata())
if not match:
match = re.search(r'data-id="([^"]+)"', self.get_urldata())
if not match:
match = re.search(r'data-videoid="([^"]+)"', self.get_urldata())
if not match:
match = re.search('s.src="(https://csp-ssl.picsearch.com[^"]+|http://csp.picsearch.com/rest[^"]+)', self.get_urldata())
if match:
data = self.http.request("get", match.group(1))
match = re.search(r'mediaid": "([^"]+)"', data.text)
if not match:
match = re.search('iframe src="(//csp.screen9.com[^"]+)"', self.get_urldata())
if match:
url = "http:%s" % match.group(1)
data = self.http.request("get", url)
match = re.search(r"mediaid: '([^']+)'", data.text)
if not match:
urlp = urlparse(self.url)
match = urlp.fragment
return match
开发者ID:andreaskristensson,项目名称:svtplay-dl,代码行数:25,代码来源:picsearch.py
示例6: get
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)
开发者ID:dapstr,项目名称:svtplay-dl,代码行数:26,代码来源:dbtv.py
示例7: get
def get(self, options):
parse = urlparse(self.url)
try:
other = parse.fragment
except KeyError:
log.error("Something wrong with that url")
sys.exit(2)
match = re.search("^/(.*).html", other)
if not match:
log.error("Cant find video file")
sys.exit(2)
url = "http://www.hbo.com/data/content/%s.xml" % match.group(1)
data = get_http_data(url)
xml = ET.XML(data)
videoid = xml.find("content")[1].find("videoId").text
url = "http://render.cdn.hbo.com/data/content/global/videos/data/%s.xml" % videoid
data = get_http_data(url)
xml = ET.XML(data)
ss = xml.find("videos")
if is_py2_old:
sa = list(ss.getiterator("size"))
else:
sa = list(ss.iter("size"))
for i in sa:
videourl = i.find("tv14").find("path").text
match = re.search("/([a-z0-9]+:[a-z0-9]+)/", videourl)
options.other = "-y %s" % videourl[videourl.index(match.group(1)):]
yield RTMP(copy.copy(options), videourl[:videourl.index(match.group(1))], i.attrib["width"])
开发者ID:Cybjit,项目名称:svtplay-dl,代码行数:29,代码来源:hbo.py
示例8: hdsparse
def hdsparse(options, data, manifest):
streams = {}
bootstrap = {}
xml = ET.XML(data)
if is_py2_old:
bootstrapIter = xml.getiterator("{http://ns.adobe.com/f4m/1.0}bootstrapInfo")
mediaIter = xml.getiterator("{http://ns.adobe.com/f4m/1.0}media")
else:
bootstrapIter = xml.iter("{http://ns.adobe.com/f4m/1.0}bootstrapInfo")
mediaIter = xml.iter("{http://ns.adobe.com/f4m/1.0}media")
if xml.find("{http://ns.adobe.com/f4m/1.0}drmAdditionalHeader") is not None:
log.error("HDS DRM protected content.")
return
for i in bootstrapIter:
if "id" in i.attrib:
bootstrap[i.attrib["id"]] = i.text
else:
bootstrap["0"] = i.text
parse = urlparse(manifest)
querystring = parse.query
for i in mediaIter:
if len(bootstrap) == 1:
bootstrapid = bootstrap["0"]
else:
bootstrapid = bootstrap[i.attrib["bootstrapInfoId"]]
streams[int(i.attrib["bitrate"])] = HDS(options, i.attrib["url"], i.attrib["bitrate"], manifest=manifest, bootstrap=bootstrapid,
metadata=i.find("{http://ns.adobe.com/f4m/1.0}metadata").text, querystring=querystring)
return streams
开发者ID:leakim,项目名称:svtplay-dl,代码行数:30,代码来源:hds.py
示例9: find_all_episodes
def find_all_episodes(self, options):
episodes = []
match = re.search('"ContentPageProgramStore":({.*}),"ApplicationStore', self.get_urldata())
if match:
janson = json.loads(match.group(1))
season = re.search("sasong-(\d+)", urlparse(self.url).path)
if season:
season = season.group(1)
seasons = []
for i in janson["format"]["seasons"]:
if season:
if int(season) == i["seasonNumber"]:
seasons.append(i["seasonNumber"])
else:
seasons.append(i["seasonNumber"])
for i in seasons:
if "program" in janson["format"]["videos"][str(i)]:
for n in janson["format"]["videos"][str(i)]["program"]:
episodes = self._videos_to_list(n["sharingUrl"],n["id"],episodes)
if self.options.include_clips:
if "clip" in janson["format"]["videos"][str(i)]:
for n in janson["format"]["videos"][str(i)]["clip"]:
episodes = self._videos_to_list(n["sharingUrl"],n["id"],episodes)
if options.all_last > 0:
return sorted(episodes[-options.all_last:])
return sorted(episodes)
开发者ID:andreaskristensson,项目名称:svtplay-dl,代码行数:28,代码来源:viaplay.py
示例10: 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]
开发者ID:antoneliasson,项目名称:svtplay-dl,代码行数:34,代码来源:nrk.py
示例11: find_all_episodes
def find_all_episodes(self, options):
parse = urlparse(self.url)
show = parse.path[parse.path.find("/", 1)+1:]
if not re.search("%", show):
show = quote_plus(show)
error, data = get_http_data("http://webapi.tv4play.se/play/video_assets?type=episode&is_live=false&platform=web&node_nids=%s&per_page=99999" % show)
if error:
log.error("Can't get api page")
return
jsondata = json.loads(data)
episodes = []
n = 1
for i in jsondata["results"]:
try:
days = int(i["availability"]["availability_group_free"])
except (ValueError, TypeError):
days = 999
if days > 0:
video_id = i["id"]
url = "http://www.tv4play.se/program/%s?video_id=%s" % (
show, video_id)
episodes.append(url)
if n == options.all_last:
break
n += 1
return episodes
开发者ID:persundstrom,项目名称:svtplay-dl,代码行数:27,代码来源:tv4play.py
示例12: get
def get(self):
parse = urlparse(self.url)
try:
other = parse.fragment
except KeyError:
log.error("Something wrong with that url")
return
if self.exclude():
yield ServiceError("Excluding video")
return
match = re.search("^/(.*).html", other)
if not match:
log.error("Cant find video file")
return
url = "http://www.hbo.com/data/content/{0}.xml".format(match.group(1))
data = self.http.request("get", url).content
xml = ET.XML(data)
videoid = xml.find("content")[1].find("videoId").text
url = "http://render.cdn.hbo.com/data/content/global/videos/data/{0}.xml".format(videoid)
data = self.http.request("get", url).content
xml = ET.XML(data)
ss = xml.find("videos")
if is_py2_old:
sa = list(ss.getiterator("size"))
else:
sa = list(ss.iter("size"))
for i in sa:
videourl = i.find("tv14").find("path").text
match = re.search("/([a-z0-9]+:[a-z0-9]+)/", videourl)
self.options.other = "-y {0}".format(videourl[videourl.index(match.group(1)):])
yield RTMP(copy.copy(self.options), videourl[:videourl.index(match.group(1))], i.attrib["width"])
开发者ID:magic75,项目名称:svtplay-dl,代码行数:34,代码来源:hbo.py
示例13: hdsparse
def hdsparse(options, res, manifest):
streams = {}
bootstrap = {}
if res.status_code == 403:
streams[0] = ServiceError("Can't read HDS playlist. permission denied")
return streams
xml = ET.XML(res.text)
if is_py2_old:
bootstrapIter = xml.getiterator("{http://ns.adobe.com/f4m/1.0}bootstrapInfo")
mediaIter = xml.getiterator("{http://ns.adobe.com/f4m/1.0}media")
else:
bootstrapIter = xml.iter("{http://ns.adobe.com/f4m/1.0}bootstrapInfo")
mediaIter = xml.iter("{http://ns.adobe.com/f4m/1.0}media")
if xml.find("{http://ns.adobe.com/f4m/1.0}drmAdditionalHeader") is not None:
streams[0] = ServiceError("HDS DRM protected content.")
return streams
for i in bootstrapIter:
if "id" in i.attrib:
bootstrap[i.attrib["id"]] = i.text
else:
bootstrap["0"] = i.text
parse = urlparse(manifest)
querystring = parse.query
manifest = "%s://%s%s" % (parse.scheme, parse.netloc, parse.path)
for i in mediaIter:
if len(bootstrap) == 1:
bootstrapid = bootstrap["0"]
else:
bootstrapid = bootstrap[i.attrib["bootstrapInfoId"]]
streams[int(i.attrib["bitrate"])] = HDS(copy.copy(options), i.attrib["url"], i.attrib["bitrate"], manifest=manifest, bootstrap=bootstrapid,
metadata=i.find("{http://ns.adobe.com/f4m/1.0}metadata").text, querystring=querystring, cookies=res.cookies)
return streams
开发者ID:Fredro,项目名称:svtplay-dl,代码行数:34,代码来源:hds.py
示例14: findvid
def findvid(url, data):
parse = urlparse(url)
if "tv4play.se" in url:
try:
vid = parse_qs(parse.query)["video_id"][0]
except KeyError:
return None
else:
match = re.search(r"\"vid\":\"(\d+)\",", data)
if match:
vid = match.group(1)
else:
match = re.search(r"-(\d+)$", url)
if match:
vid = match.group(1)
else:
match = re.search(r"meta content='([^']+)' property='og:video'", data)
if match:
match = re.search(r"vid=(\d+)&", match.group(1))
if match:
vid = match.group(1)
else:
log.error("Can't find video id for %s", url)
return
else:
return None
return vid
开发者ID:deadbeef84,项目名称:svtplay-dl,代码行数:27,代码来源:tv4play.py
示例15: find_all_episodes
def find_all_episodes(self, options):
episodes = []
matches = re.findall(r'<button class="show-more" data-url="([^"]+)" data-partial="([^"]+)"',
self.get_urldata())
for encpath, enccomp in matches:
newstyle = '_' in encpath
if newstyle:
encbasepath = encpath.split('_')[0]
path = base64.b64decode(encbasepath + '===').decode('latin1') if is_py3 else base64.b64decode(encbasepath + '===')
else:
path = base64.b64decode(encpath + '===').decode('latin1') if is_py3 else base64.b64decode(encpath + '===')
if '/view/' in path:
continue
params = 'offset=0&limit=1000'
if newstyle:
encparams = base64.b64encode(params.encode('latin1')).decode('latin1').rstrip('=') if is_py3 else \
base64.b64encode(params).rstrip('=')
encpath = '{0}_{1}'.format(encbasepath, encparams)
else:
path = '{0}?{1}'.format(urlparse(path).path, params)
encpath = base64.b64encode(path.encode('latin1')).decode('latin1').rstrip('=') if is_py3 else \
base64.b64encode(path).rstrip('=')
url = urljoin('https://www.dr.dk/tv/partial/',
'{0}/{1}'.format(enccomp, encpath))
data = self.http.request('get', url).content.decode('latin1') if is_py3 else \
self.http.request('get', url).content
matches = re.findall(r'"program-link" href="([^"]+)">', data)
episodes = [urljoin('https://www.dr.dk/', url) for url in matches]
break
if not episodes:
prefix = '/'.join(urlparse(self.url).path.rstrip('/').split('/')[:-1])
matches = re.findall(r'"program-link" href="([^"]+)">', self.get_urldata())
episodes = [urljoin('https://www.dr.dk/', url)
for url in matches
if url.startswith(prefix)]
if options.all_last != -1:
episodes = episodes[:options.all_last]
else:
episodes.reverse()
return episodes
开发者ID:olof,项目名称:svtplay-dl,代码行数:47,代码来源:dr.py
示例16: _country2lang
def _country2lang(self):
parse = urlparse(self.url)
domain = re.search(r"dplay\.(\w\w)", parse.netloc).group(1)
country = {"se": "sv", "no": "no", "dk": "da"}
if domain and domain in country:
return country[domain]
else:
return "sv"
开发者ID:spaam,项目名称:svtplay-dl,代码行数:8,代码来源:dplay.py
示例17: _get_show_info
def _get_show_info(self):
parse = urlparse(self.url)
show = parse.path[parse.path.find("/", 1)+1:]
if not re.search("%", show):
show = quote_plus(show)
data = self.http.request("get", "http://webapi.tv4play.se/play/video_assets?type=episode&is_live=false&platform=web&node_nids=%s&per_page=99999" % show).text
jsondata = json.loads(data)
return jsondata
开发者ID:deadbeef84,项目名称:svtplay-dl,代码行数:8,代码来源:tv4play.py
示例18: videos_to_list
def videos_to_list(self, lvideos, videos):
for n in lvideos:
parse = urlparse(n["contentUrl"])
if parse.path not in videos:
filename = self.outputfilename(n, self.options.output)
if not self.exclude2(filename):
videos.append(parse.path)
return videos
开发者ID:qnorsten,项目名称:svtplay-dl,代码行数:8,代码来源:svtplay.py
示例19: videos_to_list
def videos_to_list(self, lvideos, videos):
url = self.url + "/" + str(lvideos["id"])
parse = urlparse(url)
if parse.path not in videos:
filename = self.outputfilename(lvideos, self.options.output)
if not self.exclude2(filename):
videos.append(parse.path)
return videos
开发者ID:olof,项目名称:svtplay-dl,代码行数:9,代码来源:barnkanalen.py
示例20: get
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
query = parse_qs(parse.query)
self.access = None
if "accessService" in query:
self.access = query["accessService"]
match = re.search("__svtplay'] = ({.*});", self.get_urldata())
if not match:
yield ServiceError("Can't find video info.")
return
janson = json.loads(match.group(1))["videoPage"]
if "programTitle" not in janson["video"]:
yield ServiceError("Can't find any video on that page.")
return
if self.access:
for i in janson["video"]["versions"]:
if i["accessService"] == self.access:
url = urljoin("http://www.svtplay.se", i["contentUrl"])
res = self.http.get(url)
match = re.search("__svtplay'] = ({.*});", res.text)
if not match:
yield ServiceError("Can't find video info.")
return
janson = json.loads(match.group(1))["videoPage"]
if "live" in janson["video"]:
self.options.live = janson["video"]["live"]
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))
try:
janson = res.json()
except json.decoder.JSONDecodeError:
yield ServiceError("Can't decode api request: {0}".format(res.request.url))
return
videos = self._get_video(janson)
for i in videos:
yield i
开发者ID:magic75,项目名称:svtplay-dl,代码行数:57,代码来源:svtplay.py
注:本文中的svtplay_dl.utils.urllib.urlparse函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论