2013-03-02 21:26:28 +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 copy
|
2014-02-05 21:34:41 +01:00
|
|
|
import json
|
2013-02-12 19:43:37 +01:00
|
|
|
import re
|
|
|
|
|
2015-09-06 14:19:10 +02:00
|
|
|
from svtplay_dl.error import ServiceError
|
2019-08-25 00:40:39 +02:00
|
|
|
from svtplay_dl.fetcher.http import HTTP
|
|
|
|
from svtplay_dl.service import OpenGraphThumbMixin
|
|
|
|
from svtplay_dl.service import Service
|
2013-02-12 19:43:37 +01:00
|
|
|
|
2015-09-15 20:10:32 +02:00
|
|
|
|
2014-02-05 21:34:41 +01:00
|
|
|
class Sr(Service, OpenGraphThumbMixin):
|
2019-08-25 00:27:31 +02:00
|
|
|
supported_domains = ["sverigesradio.se"]
|
2013-01-17 00:21:47 +01:00
|
|
|
|
2015-12-26 11:46:14 +01:00
|
|
|
def get(self):
|
2015-08-30 11:27:31 +02:00
|
|
|
data = self.get_urldata()
|
2014-12-22 17:41:40 +01:00
|
|
|
|
2019-01-09 21:35:12 +01:00
|
|
|
match = re.search(r'data-audio-id="(\d+)"', data)
|
|
|
|
match2 = re.search(r'data-audio-type="(\w+)"', data)
|
|
|
|
if match and match2:
|
|
|
|
aid = match.group(1)
|
|
|
|
type = match2.group(1)
|
2016-10-17 23:58:23 +02:00
|
|
|
else:
|
2019-01-09 21:35:12 +01:00
|
|
|
yield ServiceError("Can't find audio info")
|
|
|
|
return
|
2016-10-17 23:58:23 +02:00
|
|
|
|
2021-12-18 19:52:08 +01:00
|
|
|
dataurl = f"https://sverigesradio.se/sida/playerajax/getaudiourl?id={aid}&type={type}&quality=high&format=iis"
|
2015-09-07 19:03:31 +02:00
|
|
|
data = self.http.request("get", dataurl).text
|
2016-10-17 23:58:23 +02:00
|
|
|
playerinfo = json.loads(data)
|
2019-09-06 22:49:49 +02:00
|
|
|
yield HTTP(copy.copy(self.config), playerinfo["audioUrl"], 128, output=self.output)
|