Skip to content

Commit

Permalink
sr: fix support for music files via language argument
Browse files Browse the repository at this point in the history
  • Loading branch information
spaam committed Jul 28, 2024
1 parent be2e1bc commit b49d5f2
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/svtplay_dl/service/sr.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# ex:ts=4:sw=4:sts=4:et
# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
import copy
import json
import re

from svtplay_dl.error import ServiceError
Expand All @@ -17,15 +16,21 @@ def get(self):
data = self.get_urldata()

match = re.search(r'data-audio-id="(\d+)"', data)
match2 = re.search(r'data-audio-type="(\w+)"', data)
match2 = re.search(r'data-publication-id="(\w+)"', data)
if match and match2:
aid = match.group(1)
type = match2.group(1)
pubid = match2.group(1)
else:
yield ServiceError("Can't find audio info")
return

dataurl = f"https://sverigesradio.se/sida/playerajax/getaudiourl?id={aid}&type={type}&quality=high&format=iis"
data = self.http.request("get", dataurl).text
playerinfo = json.loads(data)
yield HTTP(copy.copy(self.config), playerinfo["audioUrl"], 128, output=self.output)
for what in ["episode", "secondary"]:
language = ""
apiurl = f"https://sverigesradio.se/playerajax/audio?id={aid}&type={what}&publicationid={pubid}&quality=high"
resp = self.http.request("get", apiurl)
if resp.status_code > 400:
continue
playerinfo = resp.json()
if what == "secondary":
language = "musik"
yield HTTP(copy.copy(self.config), playerinfo["audioUrl"], 128, output=self.output, language=language)

0 comments on commit b49d5f2

Please sign in to comment.