2013-03-02 21:26:28 +01:00
|
|
|
# ex:ts=4:sw=4:sts=4:et
|
|
|
|
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
|
2013-03-01 23:39:42 +01:00
|
|
|
from __future__ import absolute_import
|
2013-02-12 19:43:37 +01:00
|
|
|
import re
|
2014-07-22 10:16:30 +02:00
|
|
|
import copy
|
2013-02-12 19:43:37 +01:00
|
|
|
import xml.etree.ElementTree as ET
|
|
|
|
|
2014-01-26 01:19:47 +01:00
|
|
|
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
2015-08-30 00:06:20 +02:00
|
|
|
from svtplay_dl.utils import is_py2_old
|
2015-09-06 14:19:10 +02:00
|
|
|
from svtplay_dl.error import ServiceError
|
2014-04-21 18:24:26 +02:00
|
|
|
from svtplay_dl.fetcher.rtmp import RTMP
|
2013-02-12 19:43:37 +01:00
|
|
|
|
2015-09-15 20:10:32 +02:00
|
|
|
|
2014-01-26 01:19:47 +01:00
|
|
|
class Qbrick(Service, OpenGraphThumbMixin):
|
2015-09-01 00:37:32 +02:00
|
|
|
supported_domains = ['di.seXX']
|
2013-01-17 00:21:47 +01:00
|
|
|
|
2015-12-26 11:46:14 +01:00
|
|
|
def get(self):
|
2015-08-30 11:27:31 +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
|
|
|
|
|
2015-03-08 14:46:27 +01:00
|
|
|
if re.findall(r"di.se", self.url):
|
2013-04-29 14:33:36 +02:00
|
|
|
match = re.search("src=\"(http://qstream.*)\"></iframe", data)
|
|
|
|
if not match:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find video info for: %s" % self.url)
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2015-08-31 19:45:15 +02:00
|
|
|
data = self.http.request("get", match.group(1)).content
|
2013-05-05 12:57:42 +02:00
|
|
|
match = re.search(r"data-qbrick-ccid=\"([0-9A-Z]+)\"", data)
|
2013-01-17 00:21:47 +01:00
|
|
|
if not match:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find video file for: %s" % self.url)
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2013-01-17 00:21:47 +01:00
|
|
|
host = "http://vms.api.qbrick.com/rest/v3/getplayer/%s" % match.group(1)
|
|
|
|
else:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find any info for %s" % self.url)
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2013-01-17 00:21:47 +01:00
|
|
|
|
2015-08-31 19:45:15 +02:00
|
|
|
data = self.http.request("get", host).content
|
2013-01-17 00:21:47 +01:00
|
|
|
xml = ET.XML(data)
|
|
|
|
try:
|
|
|
|
url = xml.find("media").find("item").find("playlist").find("stream").find("format").find("substream").text
|
|
|
|
except AttributeError:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find video file")
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2013-09-04 14:59:52 +02:00
|
|
|
live = xml.find("media").find("item").find("playlist").find("stream").attrib["isLive"]
|
|
|
|
if live == "true":
|
2015-12-26 11:46:14 +01:00
|
|
|
self.options.live = True
|
2015-08-31 19:45:15 +02:00
|
|
|
data = self.http.request("get", url).content
|
2013-01-17 00:21:47 +01:00
|
|
|
xml = ET.XML(data)
|
|
|
|
server = xml.find("head").find("meta").attrib["base"]
|
|
|
|
streams = xml.find("body").find("switch")
|
2013-12-30 01:35:08 +01:00
|
|
|
if is_py2_old:
|
2013-01-17 00:21:47 +01:00
|
|
|
sa = list(streams.getiterator("video"))
|
|
|
|
else:
|
|
|
|
sa = list(streams.iter("video"))
|
|
|
|
|
2014-04-21 18:24:26 +02:00
|
|
|
for i in sa:
|
2015-12-26 11:46:14 +01:00
|
|
|
self.options.other = "-y '%s'" % i.attrib["src"]
|
|
|
|
yield RTMP(copy.copy(self.options), server, i.attrib["system-bitrate"])
|