1
0
mirror of https://github.com/spaam/svtplay-dl.git synced 2024-11-30 07:04:15 +01:00

Compare commits

..

3 Commits

Author SHA1 Message Date
Johan Andersson
905b6d82b7 urplay: improve --all-episodes 2024-07-29 00:05:59 +02:00
Johan Andersson
b49d5f232a sr: fix support for music files via language argument 2024-07-29 00:05:59 +02:00
Johan Andersson
be2e1bcb31 setup: use entry point instead of scripts 2024-07-29 00:05:41 +02:00
3 changed files with 23 additions and 12 deletions

View File

@ -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
@ -17,15 +16,21 @@ class Sr(Service, OpenGraphThumbMixin):
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)

View File

@ -53,17 +53,19 @@ class Urplay(Service, OpenGraphThumbMixin):
logging.error("Can't find video info.")
return episodes
data = unescape(match.group(1))
jsondata = json.loads(data)
jsondata = json.loads(match.group(1))
seasons = jsondata["props"]["pageProps"]["superSeriesSeasons"]
build = jsondata["buildId"]
parse = urlparse(self.url)
url = f"https://{parse.netloc}{parse.path}"
episodes.append(url)
if seasons:
for season in seasons:
res = self.http.get(f'https://urplay.se/api/v1/series?id={season["id"]}')
for episode in res.json()["programs"]:
res = self.http.get(
f'https://urplay.se/_next/data/{build}{season["link"]}.json?productType={jsondata["query"]["productType"]}&id={jsondata["props"]["pageProps"]["program"]["seriesId"]}',
)
for episode in res.json()["pageProps"]["program"]["series"]["programs"]:
url = urljoin("https://urplay.se", episode["link"])
if url not in episodes:
episodes.append(url)

View File

@ -46,7 +46,11 @@ setup(
packages=find_packages("lib", exclude=["tests", "*.tests", "*.tests.*"]),
install_requires=deps,
package_dir={"": "lib"},
scripts=["bin/svtplay-dl"],
entry_points={
"console_scripts": [
"svtplat-dl = svtplay_dl:main",
],
},
author="Johan Andersson",
author_email="j@i19.se",
description="Command-line program to download videos from various video on demand sites",