本文整理汇总了Python中svtplay_dl.subtitle.subtitle函数的典型用法代码示例。如果您正苦于以下问题:Python subtitle函数的具体用法?Python subtitle怎么用?Python subtitle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了subtitle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: 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]
开发者ID:olof,项目名称:svtplay-dl,代码行数:49,代码来源:urplay.py
示例2: 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
示例3: hlsparse
def hlsparse(options, res, url, **kwargs):
streams = {}
if not res:
return None
if res.status_code > 400:
streams[0] = ServiceError("Can't read HLS playlist. {0}".format(res.status_code))
return streams
m3u8 = M3U8(res.text)
keycookie = kwargs.pop("keycookie", None)
authorization = kwargs.pop("authorization", None)
httpobject = kwargs.pop("httpobject", None)
media = {}
segments = None
if m3u8.master_playlist:
for i in m3u8.master_playlist:
audio_url = None
subtitle_url = None
if i["TAG"] == "EXT-X-MEDIA":
if "AUTOSELECT" in i and (i["AUTOSELECT"].upper() == "YES"):
if i["TYPE"]:
if "URI" in i:
if segments is None:
segments = True
if i["GROUP-ID"] not in media:
media[i["GROUP-ID"]] = []
media[i["GROUP-ID"]].append(i["URI"])
else:
segments = False
continue
elif i["TAG"] == "EXT-X-STREAM-INF":
bit_rate = float(i["BANDWIDTH"]) / 1000
if "AUDIO" in i and (i["AUDIO"] in media):
audio_url = _get_full_url(media[i["AUDIO"]][0], url)
if "SUBTITLES" in i and (i["SUBTITLES"] in media):
subtitle_url = _get_full_url(media[i["SUBTITLES"]][0], url)
urls = _get_full_url(i["URI"], url)
else:
continue # Needs to be changed to utilise other tags.
options.segments = bool(segments)
if subtitle_url and httpobject:
m3u8s = M3U8(httpobject.request("get", subtitle_url, cookies=res.cookies).text)
streams[1] = subtitle(copy.copy(options), "wrst", _get_full_url(m3u8s.media_segment[0]["URI"], url))
streams[int(bit_rate)] = HLS(copy.copy(options), urls, bit_rate, cookies=res.cookies, keycookie=keycookie, authorization=authorization, audio=audio_url)
elif m3u8.media_segment:
options.segments = False
streams[0] = HLS(copy.copy(options), url, 0, cookies=res.cookies, keycookie=keycookie, authorization=authorization)
else:
streams[0] = ServiceError("Can't find HLS playlist in m3u8 file.")
return streams
开发者ID:olof,项目名称:svtplay-dl,代码行数:58,代码来源:hls.py
示例4: 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'])
开发者ID:dapstr,项目名称:svtplay-dl,代码行数:54,代码来源:dr.py
示例5: 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'])
开发者ID:deadbeef84,项目名称:svtplay-dl,代码行数:53,代码来源:dr.py
示例6: 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']:
if stream["Target"] == "HDS":
streams = hdsparse(copy.copy(self.config),
self.http.request("get", stream["Uri"], params={"hdcore": "3.7.0"}),
stream["Uri"], output=self.output)
if streams:
for n in list(streams.keys()):
yield streams[n]
if stream["Target"] == "HLS":
streams = hlsparse(self.config, self.http.request("get", stream["Uri"]), stream["Uri"], output=self.output)
for n in list(streams.keys()):
yield streams[n]
if stream["Target"] == "Streaming":
self.config.set("other", "-v -y '{0}'".format(stream['Uri'].replace("rtmp://vod.dr.dk/cms/", "")))
rtmp = "rtmp://vod.dr.dk/cms/"
yield RTMP(copy.copy(self.config), rtmp, stream['Bitrate'], output=self.output)
开发者ID:olof,项目名称:debian-svtplay-dl,代码行数:50,代码来源:dr.py
示例7: 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]
开发者ID:spaam,项目名称:svtplay-dl,代码行数:50,代码来源:dr.py
示例8: get
def get(self):
data = self.get_urldata()
if self.exclude(self.options):
yield ServiceError("Excluding video")
return
match = re.search("data-subtitlesurl = \"(/.*)\"", data)
if match:
parse = urlparse(self.url)
suburl = "%s://%s%s" % (parse.scheme, parse.netloc, match.group(1))
yield subtitle(copy.copy(self.options), "tt", suburl)
if self.options.force_subtitle:
return
match = re.search(r'data-media="(.*manifest.f4m)"', self.get_urldata())
if match:
manifest_url = match.group(1)
else:
match = re.search(r'data-nrk-id="([^"]+)"></div><script', self.get_urldata())
if match is None:
match = re.search(r'video-id="([^"]+)"', self.get_urldata())
if match is None:
yield ServiceError("Can't find video id.")
return
vid = match.group(1)
dataurl = "http://v8.psapi.nrk.no/mediaelement/%s" % vid
data = self.http.request("get", dataurl).text
data = json.loads(data)
manifest_url = data["mediaUrl"]
self.options.live = data["isLive"]
hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8")
data = self.http.request("get", hlsurl)
if data.status_code == 403:
yield ServiceError("Can't fetch the video because of geoblocked")
return
streams = hlsparse(self.options, data, hlsurl)
for n in list(streams.keys()):
yield streams[n]
streams = hdsparse(copy.copy(self.options), self.http.request("get", manifest_url, params={"hdcore": "3.7.0"}), manifest_url)
if streams:
for n in list(streams.keys()):
yield streams[n]
开发者ID:gusseleet,项目名称:svtplay-dl,代码行数:47,代码来源:nrk.py
示例9: 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("data-subtitlesurl = \"(/.*)\"", data)
if match:
parse = urlparse(self.url)
suburl = "%s://%s%s" % (parse.scheme, parse.netloc, match.group(1))
yield subtitle(copy.copy(options), "tt", suburl)
if options.force_subtitle:
return
match = re.search(r'data-media="(.*manifest.f4m)"', self.get_urldata()[1])
if match:
manifest_url = match.group(1)
else:
match = re.search(r'data-video-id="(\d+)"', self.get_urldata()[1])
if match is None:
log.error("Can't find video id.")
return
vid = match.group(1)
match = re.search(r"PS_VIDEO_API_URL : '([^']*)',", self.get_urldata()[1])
if match is None:
log.error("Can't find server address with media info")
return
dataurl = "%smediaelement/%s" % (match.group(1), vid)
error, data = get_http_data(dataurl)
data = json.loads(data)
manifest_url = data["mediaUrl"]
options.live = data["isLive"]
hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8")
streams = hlsparse(hlsurl)
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], n)
streams = hdsparse(copy.copy(options), manifest_url)
if streams:
for n in list(streams.keys()):
yield streams[n]
开发者ID:dapstr,项目名称:svtplay-dl,代码行数:47,代码来源:nrk.py
示例10: get
def get(self):
if self.exclude():
yield ServiceError("Excluding video")
return
# First, fint the video ID from the html document
match = re.search("programId: \"([^\"]+)\"", self.get_urldata())
if match:
video_id = match.group(1)
else:
yield ServiceError("Can't find video id.")
return
# Get media element details
match = re.search("apiBaseUrl: '([^']+)'", self.get_urldata())
if not match:
yield ServiceError("Cant find apiurl.")
return
dataurl = "{0}/mediaelement/{1}".format(match.group(1), video_id)
data = self.http.request("get", dataurl).text
data = json.loads(data)
manifest_url = data["mediaUrl"]
self.options.live = data["isLive"]
if manifest_url is None:
yield ServiceError(data["messageType"])
return
# Check if subtitles are available
if data["subtitlesUrlPath"]:
yield subtitle(copy.copy(self.options), "tt", data["subtitlesUrlPath"])
hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8")
data = self.http.request("get", hlsurl)
if data.status_code == 403:
yield ServiceError("Can't fetch the video because of geoblocking")
return
streams = hlsparse(self.options, data, hlsurl)
if streams:
for n in list(streams.keys()):
yield streams[n]
streams = hdsparse(copy.copy(self.options), self.http.request("get", manifest_url, params={"hdcore": "3.7.0"}),
manifest_url)
if streams:
for n in list(streams.keys()):
yield streams[n]
开发者ID:olof,项目名称:svtplay-dl,代码行数:45,代码来源:nrk.py
示例11: _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]
开发者ID:spaam,项目名称:svtplay-dl,代码行数:44,代码来源:svtplay.py
示例12: get
def get(self, options):
error, data = self.get_urldata()
if error:
log.error("Can't get the page")
return
match = re.search(r"urPlayer.init\((.*)\);", data)
if not match:
log.error("Can't find json info")
return
if self.exclude(options):
return
data = match.group(1)
jsondata = json.loads(data)
if len(jsondata["subtitles"]) > 0:
yield subtitle(copy.copy(options), "tt", jsondata["subtitles"][0]["file"].split(",")[0])
basedomain = jsondata["streaming_config"]["streamer"]["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"])
tmp = jsondata["file_http_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"])
match = re.search("(mp[34]:.*$)", jsondata["file_rtmp"])
path = match.group(1)
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")
开发者ID:dapstr,项目名称:svtplay-dl,代码行数:42,代码来源:urplay.py
示例13: get
def get(self):
data = self.get_urldata()
match_data_video_id = re.search("data-video-id=\"(.+?)\"", data)
if match_data_video_id:
id = match_data_video_id.group(1)
else:
yield ServiceError("Cant find video info.")
return
res = self.http.get("http://api.svt.se/videoplayer-api/video/{0}".format(id))
janson = res.json()
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)
videos = self._get_video(janson)
for i in videos:
yield i
开发者ID:spaam,项目名称:svtplay-dl,代码行数:22,代码来源:svt.py
示例14: get
def get(self):
if self.exclude():
yield ServiceError("Excluding video")
return
# First, fint the video ID from the html document
video_id = re.search("<meta name=\"programid\".*?content=\"([^\"]*)\"", self.get_urldata()).group(1)
if video_id is None:
yield ServiceError("Can't find video id.")
return
# Get media element details
parse = urlparse(self.url)
dataurl = "%s://v8.psapi.nrk.no/mediaelement/%s" % (parse.scheme, video_id)
data = self.http.request("get", dataurl).text
data = json.loads(data)
manifest_url = data["mediaUrl"]
self.options.live = data["isLive"]
# Check if subtitles are available
if data["subtitlesUrlPath"]:
yield subtitle(copy.copy(self.options), "tt", data["subtitlesUrlPath"])
hlsurl = manifest_url.replace("/z/", "/i/").replace("manifest.f4m", "master.m3u8")
data = self.http.request("get", hlsurl)
if data.status_code == 403:
yield ServiceError("Can't fetch the video because of geoblocking")
return
streams = hlsparse(self.options, data, hlsurl)
for n in list(streams.keys()):
yield streams[n]
streams = hdsparse(copy.copy(self.options), self.http.request("get", manifest_url, params={"hdcore": "3.7.0"}),
manifest_url)
if streams:
for n in list(streams.keys()):
yield streams[n]
开发者ID:sveinhansen,项目名称:svtplay-dl,代码行数:37,代码来源:nrk.py
示例15: get
def get(self):
parse = urlparse(self.url)
vid = self._get_video_id()
if vid is None:
if parse.path[:6] == "/sport":
result = self._sport()
for i in result:
yield i
return
else:
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.config.set("live", True)
self.output["id"] = vid
self._autoname(dataj)
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.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]
开发者ID:olof,项目名称:debian-svtplay-dl,代码行数:70,代码来源:viaplay.py
示例16: get
def get(self, options):
if re.findall("svt.se", self.url):
data = self.get_urldata()
match = re.search(r"data-json-href=\"(.*)\"", data)
if match:
filename = match.group(1).replace("&", "&").replace("&format=json", "")
url = "http://www.svt.se%s" % filename
else:
yield ServiceError("Can't find video file for: %s" % self.url)
return
else:
url = self.url
if "svt.se" in url:
params = {"format": "json"}
else:
params = {"output": "json"}
data = self.http.request("get", url, params=params)
if data.status_code == 404:
yield ServiceError("Can't get the json file for %s" % url)
return
data = data.json()
if "live" in data["video"]:
options.live = data["video"]["live"]
if options.output_auto:
options.service = "svtplay"
options.output = outputfilename(data, options.output, ensure_unicode(self.get_urldata()))
if self.exclude(options):
yield ServiceError("Excluding video")
return
if data["video"]["subtitleReferences"]:
try:
suburl = data["video"]["subtitleReferences"][0]["url"]
except KeyError:
pass
if suburl and len(suburl) > 0:
yield subtitle(copy.copy(options), "wrst", suburl)
if options.force_subtitle:
return
if len(data["video"].get("videoReferences", [])) == 0:
yield ServiceError("Media doesn't have any associated videos (yet?)")
return
for i in data["video"]["videoReferences"]:
parse = urlparse(i["url"])
if parse.path.find("m3u8") > 0:
streams = hlsparse(options, self.http.request("get", i["url"]), i["url"])
if streams:
for n in list(streams.keys()):
yield streams[n]
elif parse.path.find("f4m") > 0:
match = re.search(r"\/se\/secure\/", i["url"])
if not match:
streams = hdsparse(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]
elif parse.scheme == "rtmp":
embedurl = "%s?type=embed" % url
data = self.http.request("get", embedurl).text
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:Fredro,项目名称:svtplay-dl,代码行数:74,代码来源:svtplay.py
示例17: get
def get(self, options):
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 options.username and options.password:
work = self._login(options.username, options.password)
if isinstance(work, Exception):
yield work
return
url = "http://premium.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 downoad this video because of geoblocked.")
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":
options.live = True
if xml.find("drmProtected").text == "true":
yield ServiceError("We cant download DRM protected content from this site.")
return
if options.output_auto:
directory = os.path.dirname(options.output)
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, options.service)
title = filenamify(title)
if len(directory):
options.output = os.path.join(directory, title)
else:
options.output = title
if self.exclude(options):
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
|
请发表评论