1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-27 13:44:14 +01:00

dplay: add some error checks.

This commit is contained in:
Johan Andersson 2020-09-29 20:39:27 +02:00
parent 7db9f7ef7f
commit f5e967bffc

View File

@ -32,12 +32,18 @@ class Dplay(Service):
channel = False channel = False
if "kanaler" in parse.path: if "kanaler" in parse.path:
match = re.search("kanaler/([^/]+)$", parse.path) match = re.search("kanaler/([^/]+)$", parse.path)
if not match:
yield ServiceError("Can't detect 'kanaler'")
return
path = "/channels/{}".format(match.group(1)) path = "/channels/{}".format(match.group(1))
url = "https://disco-api.{}/content{}".format(self.domain, path) url = "https://disco-api.{}/content{}".format(self.domain, path)
channel = True channel = True
self.config.set("live", True) self.config.set("live", True)
elif "program" in parse.path: elif "program" in parse.path:
match = re.search("(programmer|program)/([^/]+)$", parse.path) match = re.search("(programmer|program)/([^/]+)$", parse.path)
if not match:
yield ServiceError("Can't find program url")
return
path = "/shows/{}".format(match.group(2)) path = "/shows/{}".format(match.group(2))
url = "https://disco-api.{}/content{}".format(self.domain, path) url = "https://disco-api.{}/content{}".format(self.domain, path)
res = self.http.get(url, headers={"x-disco-client": "WEB:UNKNOWN:dplay-client:0.0.1"}) res = self.http.get(url, headers={"x-disco-client": "WEB:UNKNOWN:dplay-client:0.0.1"})