def get(self, options):
match = re.search(r'mrss\s+:\s+"([^"]+)"', self.get_urldata())
if not match:
log.error("Can't find id for the video")
sys.exit(2)
swfurl = re.search(r'embedSWF\( "([^"]+)"', self.get_urldata())
options.other = "-W %s" % swfurl.group(1)
data = get_http_data(match.group(1))
xml = ET.XML(data)
mediagen = xml.find("channel").find("item").find("{http://search.yahoo.com/mrss/}group")
title = xml.find("channel").find("item").find("title").text
if options.output_auto:
directory = os.path.dirname(options.output)
if len(directory):
options.output = "%s/%s" % (directory, title)
else:
options.output = title
contenturl = mediagen.find("{http://search.yahoo.com/mrss/}content").attrib["url"]
content = get_http_data(contenturl)
xml = ET.XML(content)
ss = xml.find("video").find("item")
if is_py2_old:
sa = list(ss.getiterator("rendition"))
else:
sa = list(ss.iter("rendition"))
for i in sa:
yield RTMP(options, i.find("src").text, i.attrib["bitrate"])
def download_hds(options, url, swf=None):
data = get_http_data(url)
streams = {}
bootstrap = {}
xml = ET.XML(data)
prefix = xml.find("{http://ns.adobe.com/f4m/1.0}id").text
if sys.version_info < (2, 7):
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")
for i in bootstrapIter:
bootstrap[i.attrib["id"]] = i.text
for i in mediaIter:
streams[int(i.attrib["bitrate"])] = {"url": i.attrib["url"], "bootstrapInfoId": i.attrib["bootstrapInfoId"], "metadata": i.find("{http://ns.adobe.com/f4m/1.0}metadata").text}
test = select_quality(options, streams)
bootstrap = base64.b64decode(bootstrap[test["bootstrapInfoId"]])
box = readboxtype(bootstrap, 0)
if box[2] == "abst":
antal = readbox(bootstrap, box[0])
baseurl = url[0:url.rfind("/")]
i = 1
if options.output != "-":
extension = re.search("(\.[a-z0-9]+)$", options.output)
if not extension:
options.output = "%s.flv" % options.output
log.info("Outfile: %s", options.output)
file_d = open(options.output, "wb")
else:
file_d = sys.stdout
metasize = struct.pack(">L", len(base64.b64decode(test["metadata"])))[1:]
file_d.write(binascii.a2b_hex(b"464c560105000000090000000012"))
file_d.write(metasize)
file_d.write(binascii.a2b_hex(b"00000000000000"))
file_d.write(base64.b64decode(test["metadata"]))
file_d.write(binascii.a2b_hex(b"00000000"))
total = antal[1]["total"]
eta = ETA(total)
while i <= total:
url = "%s/%sSeg1-Frag%s" % (baseurl, test["url"], i)
if options.output != "-":
eta.update(i)
progressbar(total, i, ''.join(["ETA: ", str(eta)]))
data = get_http_data(url)
number = decode_f4f(i, data)
file_d.write(data[number:])
i += 1
if options.output != "-":
file_d.close()
progress_stream.write('\n')
开发者ID:drtobbe,项目名称:svtplay-dl,代码行数:60,代码来源:hds.py
示例4: get
def get(self, options):
vid = None
data = self.get_urldata()
match = re.search(r'video url-([^"]+)', data)
if not match:
match = re.search(r'embed.jsp\?id=([^&]+)&', data)
if not match:
log.error("Cant find video id")
sys.exit(2)
vid = match.group(1)
if not vid:
path = unquote_plus(match.group(1))
data = get_http_data("http://www.svd.se%s" % path)
match = re.search(r'embed.jsp\?id=([^&]+)&', data)
if not match:
log.error("Cant find video id2")
sys.exit(2)
vid = match.group(1)
url = "http://amz.lwcdn.com/api/cache/VideoCache.jsp?id=%s" % vid
data = get_http_data(url)
xml = ET.XML(data)
videofile = xml.find("{http://www.lemonwhale.com/xml11}VideoFile")
mediafiles = videofile.find("{http://www.lemonwhale.com/xml11}MediaFiles")
high = mediafiles.find("{http://www.lemonwhale.com/xml11}VideoURLHigh")
if high.text:
yield HTTP(copy.copy(options), high.text, 720)
file = mediafiles.find("{http://www.lemonwhale.com/xml11}VideoURL").text
yield HTTP(copy.copy(options), file, 480)
def get(self, options, url):
parse = urlparse(url)
try:
other = parse[5]
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 sys.version_info < (2, 7):
sa = list(ss.getiterator("size"))
else:
sa = list(ss.iter("size"))
streams = {}
for i in sa:
stream = {}
stream["path"] = i.find("tv14").find("path").text
streams[int(i.attrib["width"])] = stream
test = select_quality(options, streams)
download_rtmp(options, test["path"])
开发者ID:drtobbe,项目名称:svtplay-dl,代码行数:32,代码来源:hbo.py
示例6: get
def get(self, options, url):
parse = urlparse(url)
data = get_http_data(url)
match = re.search("abTvArticlePlayer-player-(.*)-[0-9]+-[0-9]+-clickOverlay", data)
if not match:
log.error("Can't find video file")
sys.exit(2)
try:
start = parse_qs(parse[4])["start"][0]
except KeyError:
start = 0
url = "http://www.aftonbladet.se/resource/webbtv/article/%s/player" % match.group(1)
data = get_http_data(url)
xml = ET.XML(data)
url = xml.find("articleElement").find("mediaElement").find("baseUrl").text
path = xml.find("articleElement").find("mediaElement").find("media").attrib["url"]
live = xml.find("articleElement").find("mediaElement").find("isLive").text
options.other = "-y %s" % path
if start > 0:
options.other = "%s -A %s" % (options.other, str(start))
if live == "true":
options.live = True
if url == None:
log.error("Can't find any video on that page")
sys.exit(3)
if url[0:4] == "rtmp":
download_rtmp(options, url)
else:
filename = url + path
download_http(options, filename)
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: get
def get(self, options, url):
data = get_http_data(url)
match = re.search("xmlUrl: '(http://www.expressen.*)'", data)
if not match:
log.error("Can't find video file")
sys.exit(2)
url = "http://tv.expressen.se/%s/?standAlone=true&output=xml" % quote_plus(match.group(1))
url = match.group(1)
data = get_http_data(url)
xml = ET.XML(data)
ss = xml.find("vurls")
if sys.version_info < (2, 7):
sa = list(ss.getiterator("vurl"))
else:
sa = list(ss.iter("vurl"))
streams = {}
for i in sa:
streams[int(i.attrib["bitrate"])] = i.text
test = select_quality(options, streams)
filename = test
match = re.search("rtmp://([0-9a-z\.]+/[0-9]+/)(.*)", filename)
filename = "rtmp://%s" % match.group(1)
options.other = "-y %s" % match.group(2)
download_rtmp(options, filename)
def get(self, options):
if re.findall(r"sydsvenskan.se", self.url):
data = self.get_urldata()
match = re.search(r"data-qbrick-mcid=\"([0-9A-F]+)\"", data)
if not match:
log.error("Can't find video file")
sys.exit(2)
mcid = match.group(1)
host = "http://vms.api.qbrick.com/rest/v3/getsingleplayer/%s" % mcid
elif re.findall(r"di.se", self.url):
data = self.get_urldata()
match = re.search("src=\"(http://qstream.*)\"></iframe", data)
if not match:
log.error("Can't find video info")
sys.exit(2)
data = get_http_data(match.group(1))
match = re.search(r"data-qbrick-ccid=\"([0-9A-Z]+)\"", data)
if not match:
log.error("Can't find video file")
sys.exit(2)
host = "http://vms.api.qbrick.com/rest/v3/getplayer/%s" % match.group(1)
elif re.findall(r"svd.se", self.url):
match = re.search(r'video url-([^"]*)\"', self.get_urldata())
if not match:
log.error("Can't find video file")
sys.exit(2)
path = unquote_plus(match.group(1))
data = get_http_data("http://www.svd.se%s" % path)
match = re.search(r"mcid=([A-F0-9]+)\&width=", data)
if not match:
log.error("Can't find video file")
sys.exit(2)
host = "http://vms.api.qbrick.com/rest/v3/getsingleplayer/%s" % match.group(1)
else:
log.error("Can't find site")
sys.exit(2)
data = get_http_data(host)
xml = ET.XML(data)
try:
url = xml.find("media").find("item").find("playlist").find("stream").find("format").find("substream").text
except AttributeError:
log.error("Can't find video file")
sys.exit(2)
live = xml.find("media").find("item").find("playlist").find("stream").attrib["isLive"]
if live == "true":
options.live = True
data = get_http_data(url)
xml = ET.XML(data)
server = xml.find("head").find("meta").attrib["base"]
streams = xml.find("body").find("switch")
if is_py2_old:
sa = list(streams.getiterator("video"))
else:
sa = list(streams.iter("video"))
for i in sa:
options.other = "-y '%s'" % i.attrib["src"]
yield RTMP(copy.copy(options), server, i.attrib["system-bitrate"])
def get(self, options, url):
if re.findall("dn.se", url):
data = get_http_data(url)
match = re.search("data-qbrick-mcid=\"([0-9A-F]+)\"", data)
if not match:
match = re.search("mediaId = \'([0-9A-F]+)\';", data)
if not match:
log.error("Can't find video file")
sys.exit(2)
mcid = "%sDE1BA107" % match.group(1)
else:
mcid = match.group(1)
host = "http://vms.api.qbrick.com/rest/v3/getsingleplayer/%s" % mcid
elif re.findall("di.se", url):
data = get_http_data(url)
match = re.search("ccid: \"(.*)\"\,", data)
if not match:
log.error("Can't find video file")
sys.exit(2)
host = "http://vms.api.qbrick.com/rest/v3/getplayer/%s" % match.group(1)
elif re.findall("svd.se", url):
match = re.search("_([0-9]+)\.svd", url)
if not match:
log.error("Can't find video file")
sys.exit(2)
data = get_http_data("http://www.svd.se/?service=ajax&type=webTvClip&articleId=%s" % match.group(1))
match = re.search("mcid=([A-F0-9]+)\&width=", data)
if not match:
log.error("Can't find video file")
sys.exit(2)
host = "http://vms.api.qbrick.com/rest/v3/getsingleplayer/%s" % match.group(1)
else:
log.error("Can't find site")
sys.exit(2)
data = get_http_data(host)
xml = ET.XML(data)
try:
url = xml.find("media").find("item").find("playlist").find("stream").find("format").find("substream").text
except AttributeError:
log.error("Can't find video file")
sys.exit(2)
data = get_http_data(url)
xml = ET.XML(data)
server = xml.find("head").find("meta").attrib["base"]
streams = xml.find("body").find("switch")
if sys.version_info < (2, 7):
sa = list(streams.getiterator("video"))
else:
sa = list(streams.iter("video"))
streams = {}
for i in sa:
streams[int(i.attrib["system-bitrate"])] = i.attrib["src"]
path = select_quality(options, streams)
options.other = "-y %s" % path
download_rtmp(options, server)
def download(self):
if self.options.live and not self.options.force:
raise LiveHLSException(self.url)
error, m3u8 = get_http_data(self.url)
if error:
log.error("Cant get m3u8 file.")
return
globaldata, files = parsem3u(m3u8)
encrypted = False
key = None
if "KEY" in globaldata:
keydata = globaldata["KEY"]
encrypted = True
if encrypted:
try:
from Crypto.Cipher import AES
except ImportError:
log.error("You need to install pycrypto to download encrypted HLS streams")
sys.exit(2)
match = re.search(r'URI="(https?://.*?)"', keydata)
error, key = get_http_data(match.group(1))
if error:
log.error("Can't get crypto key to decode files.")
return
rand = os.urandom(16)
decryptor = AES.new(key, AES.MODE_CBC, rand)
file_d = output(self.options, "ts")
if hasattr(file_d, "read") is False:
return
n = 1
eta = ETA(len(files))
for i in files:
item = _get_full_url(i[0], self.url)
if self.options.output != "-":
eta.increment()
progressbar(len(files), n, "".join(["ETA: ", str(eta)]))
n += 1
error, data = get_http_data(item)
if error:
log.error("Missing segment in playlist")
return
if encrypted:
data = decryptor.decrypt(data)
file_d.write(data)
if self.options.output != "-":
file_d.close()
progress_stream.write("\n")
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
示例17: get
def get(self, options):
vid = self._get_video_id()
if vid is None:
log.error("Cant find video file")
sys.exit(2)
url = "http://playapi.mtgx.tv/v3/videos/%s" % vid
options.other = ""
data = get_http_data(url)
dataj = json.loads(data)
if "msg" in dataj:
log.error("%s" % dataj["msg"])
return
if dataj["type"] == "live":
options.live = True
if dataj["sami_path"]:
yield subtitle_sami(dataj["sami_path"])
streams = get_http_data("http://playapi.mtgx.tv/v3/videos/stream/%s" % vid)
streamj = json.loads(streams)
if "msg" in streamj:
log.error("Can't play this because the video is either not found or geoblocked.")
return
if streamj["streams"]["medium"]:
filename = streamj["streams"]["medium"]
if filename[len(filename)-3:] == "f4m":
manifest = "%s?hdcore=2.8.0&g=hejsan" % filename
streams = hdsparse(copy.copy(options), manifest)
if streams:
for n in list(streams.keys()):
yield streams[n]
else:
parse = urlparse(filename)
match = re.search("^(/[^/]+)/(.*)", parse.path)
if not match:
log.error("Somthing wrong with rtmpparse")
sys.exit(2)
filename = "%s://%s:%s%s" % (parse.scheme, parse.hostname, parse.port, match.group(1))
path = "-y %s" % match.group(2)
options.other = "-W http://flvplayer.viastream.viasat.tv/flvplayer/play/swf/player.swf %s" % path
yield RTMP(copy.copy(options), filename, 800)
if streamj["streams"]["hls"]:
streams = hlsparse(streamj["streams"]["hls"])
for n in list(streams.keys()):
yield HLS(copy.copy(options), streams[n], 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'])
请发表评论