1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-12-11 20:34:18 +01:00
svtplay-dl/lib/svtplay_dl/service/picsearch.py

40 lines
1.3 KiB
Python
Raw Normal View History

# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
2019-08-25 00:40:39 +02:00
import json
import re
2019-08-25 00:40:39 +02:00
from svtplay_dl.error import ServiceError
2016-04-19 21:08:17 +02:00
from svtplay_dl.fetcher.hls import hlsparse
2019-08-25 00:40:39 +02:00
from svtplay_dl.service import OpenGraphThumbMixin
from svtplay_dl.service import Service
2015-09-15 20:10:32 +02:00
class Picsearch(Service, OpenGraphThumbMixin):
supported_domains = ["dn.se", "mobil.dn.se", "di.se", "csp.picsearch.com", "csp.screen9.com", "cdn.screen9.com"]
2021-12-18 21:37:09 +01:00
backupapi = None
def get(self):
mediaid = self.get_mediaid()
if not mediaid:
yield ServiceError("Cant find media id")
return
mediaid = mediaid.group(1)
jsondata = self.http.request("get", f"https://api.screen9.com/player/config/{mediaid}").text
jsondata = json.loads(jsondata)
for i in jsondata["src"]:
if "application/x-mpegURL" in i["type"]:
yield from hlsparse(
self.config,
self.http.request("get", i["src"]),
i["src"],
output=self.output,
)
def get_mediaid(self):
match = re.search(r'media-id="([^"]+)"', self.get_urldata())
if not match:
match = re.search(r'"mediaid": "([^"]+)"', self.get_urldata())
return match