1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-30 15:14:14 +01:00
svtplay-dl/lib/svtplay_dl/service/bigbrother.py

66 lines
2.4 KiB
Python
Raw Normal View History

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 -*-
import copy
2019-08-25 00:40:39 +02:00
import json
import re
2014-09-06 11:35:11 +02:00
from svtplay_dl.error import ServiceError
from svtplay_dl.fetcher.hls import hlsparse
from svtplay_dl.fetcher.http import HTTP
2019-08-25 00:40:39 +02:00
from svtplay_dl.service import OpenGraphThumbMixin
from svtplay_dl.service import Service
2014-09-06 11:35:11 +02:00
2015-09-15 20:10:32 +02:00
class Bigbrother(Service, OpenGraphThumbMixin):
2014-09-06 11:35:11 +02:00
supported_domains = ["bigbrother.se"]
def get(self):
data = self.get_urldata()
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:
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)
match = re.search(r'playerID" value="([^"]+)"', self.get_urldata())
2014-09-06 11:35:11 +02:00
if not match:
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)
match = re.search(r'playerKey" value="([^"]+)"', self.get_urldata())
2014-09-06 11:35:11 +02:00
if not match:
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)
match = re.search(r'videoPlayer" value="([^"]+)"', self.get_urldata())
2014-09-06 11:35:11 +02:00
if not match:
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)
2019-08-25 00:27:31 +02:00
dataurl = (
2021-12-18 19:52:08 +01:00
f"http://c.brightcove.com/services/viewer/htmlFederated?flashID={flashid}&"
f"playerID={playerid}&playerKey={playerkey}&isVid=true&isUI=true&dynamicStreaming=true&@videoPlayer={videoplayer}"
2019-08-25 00:27:31 +02:00
)
data = self.http.request("get", dataurl).content
2019-08-25 00:27:31 +02:00
match = re.search(r"experienceJSON = ({.*});", data)
2014-09-06 11:35:11 +02:00
if not match:
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"]
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("m3u8"):
yield from hlsparse(self.config, self.http.request("get", i["defaultURL"]), i["defaultURL"], output=self.output)
if i["defaultURL"].endswith("mp4"):
yield HTTP(copy.copy(self.config), i["defaultURL"], i["encodingRate"] / 1024, output=self.output)