2014-09-06 11:35:11 +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
|
|
|
|
import json
|
|
|
|
import copy
|
|
|
|
|
|
|
|
from svtplay_dl.service import Service, OpenGraphThumbMixin
|
2015-09-06 14:19:10 +02:00
|
|
|
from svtplay_dl.error import ServiceError
|
2014-09-06 11:35:11 +02:00
|
|
|
from svtplay_dl.fetcher.hds import hdsparse
|
2015-10-04 14:37:16 +02:00
|
|
|
from svtplay_dl.fetcher.hls import hlsparse
|
2015-10-29 18:20:17 +01:00
|
|
|
from svtplay_dl.fetcher.http import HTTP
|
2014-09-06 11:35:11 +02:00
|
|
|
|
2015-09-15 20:10:32 +02:00
|
|
|
|
2014-11-09 02:15:09 +01:00
|
|
|
class Bigbrother(Service, OpenGraphThumbMixin):
|
2014-09-06 11:35:11 +02:00
|
|
|
supported_domains = ["bigbrother.se"]
|
|
|
|
|
2015-12-26 11:46:14 +01:00
|
|
|
def get(self):
|
2015-08-30 00:06:20 +02:00
|
|
|
data = self.get_urldata()
|
2014-12-22 17:41:40 +01:00
|
|
|
|
2016-05-14 22:54:30 +02:00
|
|
|
if self.exclude():
|
2015-09-06 23:04:48 +02:00
|
|
|
yield ServiceError("Excluding video")
|
2014-12-22 17:41:40 +01:00
|
|
|
return
|
|
|
|
|
2014-11-25 23:20:14 +01:00
|
|
|
match = re.search(r'id="(bcPl[^"]+)"', data)
|
2014-09-06 11:35:11 +02:00
|
|
|
if not match:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find flash id.")
|
2014-11-25 21:46:33 +01:00
|
|
|
return
|
2014-09-06 11:35:11 +02:00
|
|
|
flashid = match.group(1)
|
|
|
|
|
2015-08-30 00:06:20 +02:00
|
|
|
match = re.search(r'playerID" value="([^"]+)"', self.get_urldata())
|
2014-09-06 11:35:11 +02:00
|
|
|
if not match:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find playerID")
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2014-09-06 11:35:11 +02:00
|
|
|
playerid = match.group(1)
|
|
|
|
|
2015-08-30 00:06:20 +02:00
|
|
|
match = re.search(r'playerKey" value="([^"]+)"', self.get_urldata())
|
2014-09-06 11:35:11 +02:00
|
|
|
if not match:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find playerKey")
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2014-09-06 11:35:11 +02:00
|
|
|
playerkey = match.group(1)
|
|
|
|
|
2015-08-30 00:06:20 +02:00
|
|
|
match = re.search(r'videoPlayer" value="([^"]+)"', self.get_urldata())
|
2014-09-06 11:35:11 +02:00
|
|
|
if not match:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find videoPlayer info")
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2014-09-06 11:35:11 +02:00
|
|
|
videoplayer = match.group(1)
|
|
|
|
|
2018-01-30 23:10:22 +01:00
|
|
|
dataurl = "http://c.brightcove.com/services/viewer/htmlFederated?flashID={0}&playerID={1}&playerKey={2}" \
|
|
|
|
"&isVid=true&isUI=true&dynamicStreaming=true&@videoPlayer={3}".format(flashid, playerid, playerkey, videoplayer)
|
2015-08-31 19:45:15 +02:00
|
|
|
data = self.http.request("get", dataurl).content
|
2014-09-06 11:35:11 +02:00
|
|
|
match = re.search(r'experienceJSON = ({.*});', data)
|
|
|
|
if not match:
|
2015-09-06 14:19:10 +02:00
|
|
|
yield ServiceError("Can't find json data")
|
2014-10-06 23:21:43 +02:00
|
|
|
return
|
2014-09-06 11:35:11 +02:00
|
|
|
jsondata = json.loads(match.group(1))
|
|
|
|
renditions = jsondata["data"]["programmedContent"]["videoPlayer"]["mediaDTO"]["renditions"]
|
2015-10-29 19:32:12 +01:00
|
|
|
|
|
|
|
if jsondata["data"]["publisherType"] == "PREMIUM":
|
|
|
|
yield ServiceError("Premium content")
|
|
|
|
return
|
|
|
|
|
2014-09-06 11:35:11 +02:00
|
|
|
for i in renditions:
|
|
|
|
if i["defaultURL"].endswith("f4m"):
|
2018-05-13 13:06:45 +02:00
|
|
|
streams = hdsparse(copy.copy(self.config),
|
|
|
|
self.http.request("get", i["defaultURL"], params={"hdcore": "3.7.0"}), i["defaultURL"])
|
2018-05-08 22:48:55 +02:00
|
|
|
for n in list(streams.keys()):
|
|
|
|
yield streams[n]
|
2014-09-06 11:35:11 +02:00
|
|
|
|
|
|
|
if i["defaultURL"].endswith("m3u8"):
|
2018-05-13 13:06:45 +02:00
|
|
|
streams = hlsparse(self.config, self.http.request("get", i["defaultURL"]), i["defaultURL"])
|
2014-09-06 11:35:11 +02:00
|
|
|
for n in list(streams.keys()):
|
2015-10-04 14:37:16 +02:00
|
|
|
yield streams[n]
|
2015-10-29 18:20:17 +01:00
|
|
|
|
|
|
|
if i["defaultURL"].endswith("mp4"):
|
2018-05-13 13:06:45 +02:00
|
|
|
yield HTTP(copy.copy(self.config), i["defaultURL"], i["encodingRate"] / 1024)
|