From 005a39979f41c90352196fc3b8a8911ec891453e Mon Sep 17 00:00:00 2001 From: Johan Andersson Date: Sat, 19 Mar 2022 19:24:32 +0100 Subject: [PATCH] dr.dk: add support for bonanza videos fixes: #1458 --- lib/svtplay_dl/service/dr.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/lib/svtplay_dl/service/dr.py b/lib/svtplay_dl/service/dr.py index 6a3aea1..ac0e07f 100644 --- a/lib/svtplay_dl/service/dr.py +++ b/lib/svtplay_dl/service/dr.py @@ -3,6 +3,7 @@ import json import logging import re import uuid +from urllib.parse import urlparse from svtplay_dl.error import ServiceError from svtplay_dl.fetcher.hls import hlsparse @@ -19,7 +20,16 @@ class Dr(Service, OpenGraphThumbMixin): match = re.search("__data = ([^<]+)", data) if not match: - yield ServiceError("Cant find info for this video") + match = re.search('source src="([^"]+)"', data) + if not match: + yield ServiceError("Cant find info for this video") + return + + res = self.http.request("get", match.group(1)) + if res.status_code > 400: + yield ServiceError("Can't play this because the video is geoblocked or not available.") + else: + yield from hlsparse(self.config, res, match.group(1), output=self.output) return janson = json.loads(match.group(1)) page = janson["cache"]["page"][list(janson["cache"]["page"].keys())[0]] @@ -70,8 +80,21 @@ class Dr(Service, OpenGraphThumbMixin): data = self.get_urldata() match = re.search("__data = ([^<]+)", data) if not match: - logging.error("Can't find video info.") - return episodes + if "bonanza" in self.url: + parse = urlparse(self.url) + match = re.search(r"(\/bonanza\/serie\/[0-9]+\/[\-\w]+)", parse.path) + if match: + match = re.findall(rf"a href=\"({match.group(1)}\/\d+[^\"]+)\"", data) + if not match: + logging.error("Can't find video info.") + for url in match: + episodes.append(f"https://www.dr.dk{url}") + else: + logging.error("Can't find video info.") + return episodes + else: + logging.error("Can't find video info.") + return episodes janson = json.loads(match.group(1)) page = janson["cache"]["page"][list(janson["cache"]["page"].keys())[0]]