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
|
2019-08-25 00:40:39 +02:00
|
|
|
|
|
|
|
import copy
|
2014-11-08 23:02:02 +01:00
|
|
|
import json
|
|
|
|
import re
|
2018-01-30 22:07:21 +01:00
|
|
|
from urllib.parse import urlparse
|
2014-11-08 23:02:02 +01:00
|
|
|
|
2019-08-25 00:40:39 +02:00
|
|
|
from svtplay_dl.error import ServiceError
|
2015-10-04 14:37:16 +02:00
|
|
|
from svtplay_dl.fetcher.hls import hlsparse
|
2014-11-08 23:02:02 +01:00
|
|
|
from svtplay_dl.fetcher.http import HTTP
|
2019-08-25 00:40:39 +02:00
|
|
|
from svtplay_dl.service import OpenGraphThumbMixin
|
|
|
|
from svtplay_dl.service import Service
|
2014-11-08 23:02:02 +01:00
|
|
|
|
2015-09-15 20:10:32 +02:00
|
|
|
|
2014-11-08 23:02:02 +01:00
|
|
|
class Disney(Service, OpenGraphThumbMixin):
|
2019-08-25 00:27:31 +02:00
|
|
|
supported_domains = ["disney.se", "video.disney.se", "disneyjunior.disney.se"]
|
2014-11-08 23:02:02 +01:00
|
|
|
|
2015-12-26 11:46:14 +01:00
|
|
|
def get(self):
|
2014-11-08 23:02:02 +01:00
|
|
|
parse = urlparse(self.url)
|
2019-09-06 22:49:49 +02:00
|
|
|
if parse.hostname == "video.disney.se" or parse.hostname == "disneyjunior.disney.se":
|
2015-08-30 00:06:20 +02:00
|
|
|
data = self.get_urldata()
|
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:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find video info")
|
2014-11-08 23:02:02 +01:00
|
|
|
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":
|
2017-09-17 19:48:08 +02:00
|
|
|
res = self.http.get(i["url"])
|
2019-09-06 22:49:49 +02:00
|
|
|
match = re.search('button primary" href="([^"]+)"', res.text)
|
2017-09-17 19:48:08 +02:00
|
|
|
if match:
|
2019-09-06 22:49:49 +02:00
|
|
|
yield HTTP(copy.copy(self.config), match.group(1), i["bitrate"], output=self.output)
|
2014-11-08 23:02:02 +01:00
|
|
|
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:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find video info")
|
2014-11-08 23:02:02 +01:00
|
|
|
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:
|
2019-08-25 00:27:31 +02:00
|
|
|
entry = parse.fragment[parse.fragment.rindex("/") + 1 :]
|
2014-12-20 22:23:41 +01:00
|
|
|
if entry in jsondata["idlist"]:
|
|
|
|
entryid = jsondata["idlist"][entry]
|
|
|
|
else:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Cant find video info")
|
2014-12-20 22:23:41 +01:00
|
|
|
return
|
2018-05-13 13:06:45 +02:00
|
|
|
for i in jsondata["playlists"][0]["playlist"]:
|
|
|
|
if entryid in i["id"]:
|
|
|
|
title = i["longId"]
|
|
|
|
break
|
|
|
|
self.output["title"] = title
|
2014-11-08 23:02:02 +01:00
|
|
|
|
2019-08-25 00:27:31 +02:00
|
|
|
url = (
|
2019-08-25 00:33:51 +02:00
|
|
|
"http://cdnapi.kaltura.com/html5/html5lib/v1.9.7.6/mwEmbedFrame.php?&wid={}&uiconf_id={}&entry_id={}"
|
2019-09-06 22:49:49 +02:00
|
|
|
"&playerId={}&forceMobileHTML5=true&urid=1.9.7.6&callback=mwi".format(partnerid, uiconfid, entryid, uniq)
|
2019-08-25 00:27:31 +02:00
|
|
|
)
|
2015-10-20 00:02:10 +02:00
|
|
|
data = self.http.request("get", url).text
|
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"]
|
2018-05-13 13:06:45 +02:00
|
|
|
name = jsondata["entryResult"]["meta"]["name"]
|
|
|
|
self.output["title"] = name
|
2016-05-15 22:47:38 +02:00
|
|
|
|
2019-08-25 00:27:31 +02:00
|
|
|
url = (
|
2019-08-25 00:33:51 +02:00
|
|
|
"http://cdnapi.kaltura.com/p/{}/sp/{}00/playManifest/entryId/{}/format/applehttp/protocol/http/a.m3u8"
|
2019-09-06 22:49:49 +02:00
|
|
|
"?ks={}&referrer=aHR0cDovL3d3dy5kaXNuZXkuc2U=&".format(partnerid[1:], partnerid[1:], entryid, ks)
|
2019-08-25 00:27:31 +02:00
|
|
|
)
|
2015-08-30 00:06:20 +02:00
|
|
|
redirect = self.http.check_redirect(url)
|
2019-09-06 22:49:49 +02:00
|
|
|
streams = hlsparse(self.config, self.http.request("get", redirect), redirect, output=self.output)
|
2014-11-08 23:02:02 +01:00
|
|
|
for n in list(streams.keys()):
|
2018-02-26 00:02:53 +01:00
|
|
|
yield streams[n]
|