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
|
2014-05-01 23:17:57 +02:00
|
|
|
import xml.etree.ElementTree as ET
|
|
|
|
|
|
|
|
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
|
2014-06-02 21:43:02 +02:00
|
|
|
from svtplay_dl.fetcher.http import HTTP
|
2014-05-01 23:17:57 +02:00
|
|
|
|
|
|
|
class Lemonwhale(Service):
|
|
|
|
supported_domains = ['svd.se']
|
|
|
|
|
|
|
|
def get(self, options):
|
|
|
|
vid = None
|
2015-08-30 00:06:20 +02:00
|
|
|
data = self.get_urldata()
|
2014-12-22 17:41:40 +01:00
|
|
|
|
|
|
|
if self.exclude(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)
|
|
|
|
|
2014-11-26 15:46:31 +01:00
|
|
|
url = "http://amz.lwcdn.com/api/cache/VideoCache.jsp?%s" % vid
|
2015-08-31 19:45:15 +02:00
|
|
|
data = self.http.request("get", url).content
|
2014-05-01 23:17:57 +02:00
|
|
|
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:
|
2014-06-07 20:43:40 +02:00
|
|
|
yield HTTP(copy.copy(options), high.text, 720)
|
2014-07-22 10:10:11 +02:00
|
|
|
videourl = mediafiles.find(
|
|
|
|
"{http://www.lemonwhale.com/xml11}VideoURL").text
|
|
|
|
yield HTTP(copy.copy(options), videourl, 480)
|