1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-28 06:04:17 +01:00
svtplay-dl/lib/svtplay_dl/service/qbrick.py

53 lines
2.1 KiB
Python
Raw Normal View History

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 -*-
from __future__ import absolute_import
import re
import copy
import xml.etree.ElementTree as ET
2014-01-26 01:19:47 +01:00
from svtplay_dl.service import Service, OpenGraphThumbMixin
from svtplay_dl.error import ServiceError
2014-04-21 18:24:26 +02:00
from svtplay_dl.fetcher.rtmp import RTMP
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']
def get(self):
2015-08-30 11:27:31 +02:00
data = self.get_urldata()
if re.findall(r"di.se", self.url):
match = re.search("src=\"(http://qstream.*)\"></iframe", data)
if not match:
yield ServiceError("Can't find video info for: {0}".format(self.url))
2014-10-06 23:21:43 +02:00
return
data = self.http.request("get", match.group(1)).content
match = re.search(r"data-qbrick-ccid=\"([0-9A-Z]+)\"", data)
if not match:
yield ServiceError("Can't find video file for: {0}".format(self.url))
2014-10-06 23:21:43 +02:00
return
host = "http://vms.api.qbrick.com/rest/v3/getplayer/{0}".format(match.group(1))
else:
yield ServiceError("Can't find any info for {0}".format(self.url))
2014-10-06 23:21:43 +02:00
return
data = self.http.request("get", host).content
xml = ET.XML(data)
try:
url = xml.find("media").find("item").find("playlist").find("stream").find("format").find("substream").text
except AttributeError:
yield ServiceError("Can't find video file")
2014-10-06 23:21:43 +02:00
return
live = xml.find("media").find("item").find("playlist").find("stream").attrib["isLive"]
if live == "true":
2018-05-13 13:06:45 +02:00
self.config.set("live", True)
data = self.http.request("get", url).content
xml = ET.XML(data)
server = xml.find("head").find("meta").attrib["base"]
streams = xml.find("body").find("switch")
2018-01-13 20:27:40 +01:00
sa = list(streams.iter("video"))
2014-04-21 18:24:26 +02:00
for i in sa:
2018-05-22 00:02:48 +02:00
yield RTMP(copy.copy(self.config), server, i.attrib["system-bitrate"], output=self.output,
other="-y '{0}'".format(i.attrib["src"]))