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 -*-
|
|
|
|
from __future__ import absolute_import
|
|
|
|
import re
|
2014-06-07 20:43:40 +02:00
|
|
|
import copy
|
2015-11-15 11:19:51 +01:00
|
|
|
import json
|
2014-05-01 23:17:57 +02:00
|
|
|
|
|
|
|
from svtplay_dl.utils.urllib import unquote_plus
|
|
|
|
from svtplay_dl.service import Service
|
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
|
|
|
|
from svtplay_dl.utils import decode_html_entities
|
2015-09-15 20:10:32 +02:00
|
|
|
|
2014-05-01 23:17:57 +02:00
|
|
|
class Lemonwhale(Service):
|
|
|
|
supported_domains = ['svd.se']
|
|
|
|
|
2015-12-26 11:46:14 +01:00
|
|
|
def get(self):
|
2014-05-01 23:17:57 +02:00
|
|
|
vid = None
|
2015-08-30 00:06:20 +02:00
|
|
|
data = self.get_urldata()
|
2014-12-22 17:41:40 +01:00
|
|
|
|
2015-12-26 11:46:14 +01:00
|
|
|
if self.exclude(self.options):
|
2015-09-06 23:04:48 +02:00
|
|
|
yield ServiceError("Excluding video")
|
2014-12-22 17:41:40 +01:00
|
|
|
return
|
|
|
|
|
2014-12-08 23:07:02 +01:00
|
|
|
match = re.search(r'video url-([^"]+)', data)
|
2014-05-01 23:17:57 +02:00
|
|
|
if not match:
|
2015-08-30 00:06:20 +02:00
|
|
|
match = re.search(r'embed.jsp\?([^"]+)"', self.get_urldata())
|
2014-05-01 23:17:57 +02:00
|
|
|
if not match:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find video id")
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2014-05-01 23:17:57 +02:00
|
|
|
vid = match.group(1)
|
|
|
|
if not vid:
|
|
|
|
path = unquote_plus(match.group(1))
|
2015-08-31 19:45:15 +02:00
|
|
|
data = self.http.request("get", "http://www.svd.se%s" % path).content
|
2014-11-26 15:46:31 +01:00
|
|
|
match = re.search(r'embed.jsp\?([^"]+)', data)
|
2014-05-01 23:17:57 +02:00
|
|
|
if not match:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find video id")
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2014-05-01 23:17:57 +02:00
|
|
|
vid = match.group(1)
|
|
|
|
|
2015-11-15 11:19:51 +01:00
|
|
|
url = "http://ljsp.lwcdn.com/web/public/item.json?type=video&%s" % decode_html_entities(vid)
|
|
|
|
data = self.http.request("get", url).text
|
|
|
|
jdata = json.loads(data)
|
|
|
|
videos = jdata["videos"][0]["media"]["streams"]
|
|
|
|
for i in videos:
|
|
|
|
if i["name"] == "auto":
|
|
|
|
hls = "%s%s" % (jdata["videos"][0]["media"]["base"], i["url"])
|
2015-12-26 11:46:14 +01:00
|
|
|
streams = hlsparse(self.options, self.http.request("get", hls), hls)
|
2015-11-15 11:19:51 +01:00
|
|
|
if streams:
|
|
|
|
for n in list(streams.keys()):
|
|
|
|
yield streams[n]
|