2014-05-01 23:17:57 +02:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2015-11-15 11:19:51 +01:00
|
|
|
import json
|
2019-08-25 00:40:39 +02:00
|
|
|
import re
|
2014-05-01 23:17:57 +02:00
|
|
|
|
2015-09-06 14:19:10 +02:00
|
|
|
from svtplay_dl.error import ServiceError
|
2015-11-15 11:19:51 +01:00
|
|
|
from svtplay_dl.fetcher.hls import hlsparse
|
2019-08-25 00:40:39 +02:00
|
|
|
from svtplay_dl.service import Service
|
2018-03-13 00:33:39 +01:00
|
|
|
from svtplay_dl.utils.text import decode_html_entities
|
2015-09-15 20:10:32 +02:00
|
|
|
|
2018-01-30 20:11:37 +01:00
|
|
|
|
2014-05-01 23:17:57 +02:00
|
|
|
class Lemonwhale(Service):
|
2016-03-16 20:56:20 +01:00
|
|
|
# lemonwhale.com is just bogus for generic
|
2019-08-25 00:27:31 +02:00
|
|
|
supported_domains = ["vk.se", "lemonwhale.com"]
|
2014-05-01 23:17:57 +02:00
|
|
|
|
2015-12-26 11:46:14 +01:00
|
|
|
def get(self):
|
2017-06-05 13:15:42 +02:00
|
|
|
vid = self.get_vid()
|
2014-05-01 23:17:57 +02:00
|
|
|
if not vid:
|
2017-06-05 13:15:42 +02:00
|
|
|
yield ServiceError("Can't find video id")
|
|
|
|
return
|
2014-05-01 23:17:57 +02:00
|
|
|
|
2019-09-06 22:49:49 +02:00
|
|
|
url = "http://ljsp.lwcdn.com/web/public/item.json?type=video&%s" % decode_html_entities(vid)
|
2015-11-15 11:19:51 +01:00
|
|
|
data = self.http.request("get", url).text
|
|
|
|
jdata = json.loads(data)
|
2017-06-05 13:15:42 +02:00
|
|
|
if "videos" in jdata:
|
|
|
|
streams = self.get_video(jdata)
|
|
|
|
if streams:
|
|
|
|
for n in list(streams.keys()):
|
|
|
|
yield streams[n]
|
|
|
|
|
2019-09-06 22:49:49 +02:00
|
|
|
url = "http://ljsp.lwcdn.com/web/public/video.json?id={}&delivery=hls".format(decode_html_entities(vid))
|
2017-06-05 13:15:42 +02:00
|
|
|
data = self.http.request("get", url).text
|
|
|
|
jdata = json.loads(data)
|
|
|
|
if "videos" in jdata:
|
|
|
|
streams = self.get_video(jdata)
|
2018-05-08 22:48:55 +02:00
|
|
|
for n in list(streams.keys()):
|
|
|
|
yield streams[n]
|
2017-06-05 13:15:42 +02:00
|
|
|
|
|
|
|
def get_vid(self):
|
|
|
|
match = re.search(r'video url-([^"]+)', self.get_urldata())
|
|
|
|
if match:
|
|
|
|
return match.group(1)
|
|
|
|
|
2019-08-25 00:27:31 +02:00
|
|
|
match = re.search(r"__INITIAL_STATE__ = ({.*})</script>", self.get_urldata())
|
2017-06-05 13:15:42 +02:00
|
|
|
if match:
|
|
|
|
janson = json.loads(match.group(1))
|
2019-09-06 22:49:49 +02:00
|
|
|
vid = janson["content"]["current"]["data"]["templateData"]["pageData"]["video"]["id"]
|
2017-06-05 13:15:42 +02:00
|
|
|
return vid
|
|
|
|
|
|
|
|
match = re.search(r'embed.jsp\?([^"]+)"', self.get_urldata())
|
|
|
|
if match:
|
|
|
|
return match.group(1)
|
|
|
|
return None
|
|
|
|
|
|
|
|
def get_video(self, janson):
|
|
|
|
videos = janson["videos"][0]["media"]["streams"]
|
2015-11-15 11:19:51 +01:00
|
|
|
for i in videos:
|
|
|
|
if i["name"] == "auto":
|
2019-08-25 00:33:51 +02:00
|
|
|
hls = "{}{}".format(janson["videos"][0]["media"]["base"], i["url"])
|
2019-09-06 22:49:49 +02:00
|
|
|
streams = hlsparse(self.config, self.http.request("get", hls), hls, output=self.output)
|
2017-06-05 13:15:42 +02:00
|
|
|
return streams
|