2014-11-08 23:02:02 +01:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
from __future__ import absolute_import
|
|
|
|
import json
|
|
|
|
import re
|
|
|
|
import copy
|
2014-11-23 13:03:23 +01:00
|
|
|
import os
|
2014-11-08 23:02:02 +01:00
|
|
|
|
|
|
|
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
2015-08-30 00:06:20 +02:00
|
|
|
from svtplay_dl.utils import filenamify
|
2014-11-08 23:02:02 +01:00
|
|
|
from svtplay_dl.utils.urllib import urlparse
|
|
|
|
from svtplay_dl.fetcher.hls import HLS, hlsparse
|
|
|
|
from svtplay_dl.fetcher.http import HTTP
|
|
|
|
from svtplay_dl.log import log
|
|
|
|
|
|
|
|
class Disney(Service, OpenGraphThumbMixin):
|
|
|
|
supported_domains = ['disney.se', 'video.disney.se']
|
|
|
|
|
|
|
|
def get(self, options):
|
|
|
|
parse = urlparse(self.url)
|
|
|
|
if parse.hostname == "video.disney.se":
|
2015-08-30 00:06:20 +02:00
|
|
|
data = self.get_urldata()
|
2014-12-22 17:41:40 +01:00
|
|
|
|
|
|
|
if self.exclude(options):
|
|
|
|
return
|
|
|
|
|
2014-12-08 23:07:02 +01:00
|
|
|
match = re.search(r"Grill.burger=({.*}):", data)
|
2014-11-08 23:02:02 +01:00
|
|
|
if not match:
|
|
|
|
log.error("Can't find video info")
|
|
|
|
return
|
|
|
|
jsondata = json.loads(match.group(1))
|
|
|
|
for n in jsondata["stack"]:
|
|
|
|
if len(n["data"]) > 0:
|
|
|
|
for x in n["data"]:
|
|
|
|
if "flavors" in x:
|
|
|
|
for i in x["flavors"]:
|
|
|
|
if i["format"] == "mp4":
|
|
|
|
yield HTTP(copy.copy(options), i["url"], i["bitrate"])
|
|
|
|
else:
|
2015-08-30 00:06:20 +02:00
|
|
|
data = self.get_urldata()
|
2014-12-08 23:07:02 +01:00
|
|
|
match = re.search(r"uniqueId : '([^']+)'", data)
|
2014-11-08 23:02:02 +01:00
|
|
|
if not match:
|
|
|
|
log.error("Can't find video info")
|
|
|
|
return
|
|
|
|
uniq = match.group(1)
|
2015-08-30 00:06:20 +02:00
|
|
|
match = re.search("entryId : '([^']+)'", self.get_urldata())
|
2014-11-08 23:02:02 +01:00
|
|
|
entryid = match.group(1)
|
2015-08-30 00:06:20 +02:00
|
|
|
match = re.search("partnerId : '([^']+)'", self.get_urldata())
|
2014-11-08 23:02:02 +01:00
|
|
|
partnerid = match.group(1)
|
2015-08-30 00:06:20 +02:00
|
|
|
match = re.search("uiConfId : '([^']+)'", self.get_urldata())
|
2014-11-08 23:02:02 +01:00
|
|
|
uiconfid = match.group(1)
|
|
|
|
|
2015-08-30 00:06:20 +02:00
|
|
|
match = re.search("json : ({.*}}),", self.get_urldata())
|
2014-12-20 22:23:41 +01:00
|
|
|
jsondata = json.loads(match.group(1))
|
|
|
|
parse = urlparse(self.url)
|
|
|
|
if len(parse.fragment) > 0:
|
|
|
|
entry = parse.fragment[parse.fragment.rindex("/")+1:]
|
|
|
|
if entry in jsondata["idlist"]:
|
|
|
|
entryid = jsondata["idlist"][entry]
|
|
|
|
else:
|
|
|
|
log.error("Cant find video info")
|
|
|
|
return
|
|
|
|
if options.output_auto:
|
|
|
|
for i in jsondata["playlists"][0]["playlist"]:
|
|
|
|
if entryid in i["id"]:
|
|
|
|
title = i["longId"]
|
|
|
|
break
|
|
|
|
|
|
|
|
directory = os.path.dirname(options.output)
|
|
|
|
options.service = "disney"
|
|
|
|
title = "%s-%s" % (title, options.service)
|
|
|
|
title = filenamify(title)
|
|
|
|
if len(directory):
|
2015-08-24 23:02:18 +02:00
|
|
|
options.output = os.path.join(directory, title)
|
2014-12-20 22:23:41 +01:00
|
|
|
else:
|
|
|
|
options.output = title
|
2014-11-08 23:02:02 +01:00
|
|
|
|
2014-12-22 17:41:40 +01:00
|
|
|
if self.exclude(options):
|
|
|
|
return
|
|
|
|
|
2014-11-08 23:02:02 +01:00
|
|
|
url = "http://cdnapi.kaltura.com/html5/html5lib/v1.9.7.6/mwEmbedFrame.php?&wid=%s&uiconf_id=%s&entry_id=%s&playerId=%s&forceMobileHTML5=true&urid=1.9.7.6&callback=mwi" % \
|
|
|
|
(partnerid, uiconfid, entryid, uniq)
|
2015-08-31 16:51:09 +02:00
|
|
|
data = self.http.get(url).content
|
2014-11-09 02:15:43 +01:00
|
|
|
match = re.search(r"mwi\(({.*})\);", data)
|
2014-11-08 23:02:02 +01:00
|
|
|
jsondata = json.loads(match.group(1))
|
|
|
|
data = jsondata["content"]
|
2014-11-09 02:15:43 +01:00
|
|
|
match = re.search(r"window.kalturaIframePackageData = ({.*});", data)
|
2014-11-08 23:02:02 +01:00
|
|
|
jsondata = json.loads(match.group(1))
|
|
|
|
ks = jsondata["enviornmentConfig"]["ks"]
|
2014-11-23 13:03:23 +01:00
|
|
|
if options.output_auto:
|
|
|
|
name = jsondata["entryResult"]["meta"]["name"]
|
|
|
|
directory = os.path.dirname(options.output)
|
|
|
|
options.service = "disney"
|
|
|
|
title = "%s-%s" % (name, options.service)
|
|
|
|
title = filenamify(title)
|
|
|
|
if len(directory):
|
2015-08-24 23:02:18 +02:00
|
|
|
options.output = os.path.join(directory, title)
|
2014-11-23 13:03:23 +01:00
|
|
|
else:
|
|
|
|
options.output = title
|
2014-11-08 23:02:02 +01:00
|
|
|
|
|
|
|
url = "http://cdnapi.kaltura.com/p/%s/sp/%s00/playManifest/entryId/%s/format/applehttp/protocol/http/a.m3u8?ks=%s&referrer=aHR0cDovL3d3dy5kaXNuZXkuc2U=&" % (partnerid[1:], partnerid[1:], entryid, ks)
|
2015-08-30 00:06:20 +02:00
|
|
|
redirect = self.http.check_redirect(url)
|
2015-08-31 16:51:09 +02:00
|
|
|
streams = hlsparse(redirect, self.http.get(redirect).text)
|
2014-11-08 23:02:02 +01:00
|
|
|
for n in list(streams.keys()):
|
|
|
|
yield HLS(copy.copy(options), streams[n], n)
|