2014-03-25 15:37:41 +01:00
|
|
|
# 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
|
2014-03-25 15:37:41 +01:00
|
|
|
|
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
|
2014-03-25 15:37:41 +01:00
|
|
|
|
2015-09-15 20:10:32 +02:00
|
|
|
|
2014-03-25 15:37:41 +01:00
|
|
|
class Picsearch(Service, OpenGraphThumbMixin):
|
2023-05-11 19:00:17 +02:00
|
|
|
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
|
2014-03-25 15:37:41 +01:00
|
|
|
|
2015-12-26 11:46:14 +01:00
|
|
|
def get(self):
|
2016-03-16 22:50:43 +01:00
|
|
|
mediaid = self.get_mediaid()
|
2014-03-25 15:37:41 +01:00
|
|
|
if not mediaid:
|
2016-03-16 22:50:43 +01:00
|
|
|
yield ServiceError("Cant find media id")
|
|
|
|
return
|
2023-05-11 19:00:17 +02:00
|
|
|
mediaid = mediaid.group(1)
|
2016-03-16 22:50:43 +01:00
|
|
|
|
2023-05-11 19:00:17 +02:00
|
|
|
jsondata = self.http.request("get", f"https://api.screen9.com/player/config/{mediaid}").text
|
2014-03-25 15:37:41 +01:00
|
|
|
jsondata = json.loads(jsondata)
|
2017-01-27 02:02:57 +01:00
|
|
|
|
2023-05-11 19:00:17 +02:00
|
|
|
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,
|
|
|
|
)
|
2016-03-16 22:50:43 +01:00
|
|
|
|
|
|
|
def get_mediaid(self):
|
2023-05-11 19:00:17 +02:00
|
|
|
match = re.search(r'media-id="([^"]+)"', self.get_urldata())
|
2016-03-16 22:50:43 +01:00
|
|
|
if not match:
|
2023-05-11 19:00:17 +02:00
|
|
|
match = re.search(r'"mediaid": "([^"]+)"', self.get_urldata())
|
2016-03-16 22:50:43 +01:00
|
|
|
return match
|