mirror of
https://github.com/spaam/svtplay-dl.git
synced 2024-11-23 19:55:38 +01:00
Compare commits
14 Commits
9dfbbdb061
...
03f52f298b
Author | SHA1 | Date | |
---|---|---|---|
|
03f52f298b | ||
|
ace235c6c8 | ||
|
2083ee9978 | ||
|
ce5859346c | ||
|
583a2edf4d | ||
|
f8a450208c | ||
|
e65e90c62e | ||
|
da6654396b | ||
|
6f6d970f0b | ||
|
759feec608 | ||
|
634411666e | ||
|
74c7d25293 | ||
|
c4afda5919 | ||
|
c81de1f693 |
@ -115,15 +115,13 @@ This script works for:
|
|||||||
|
|
||||||
- aftonbladet.se
|
- aftonbladet.se
|
||||||
- bambuser.com
|
- bambuser.com
|
||||||
- comedycentral.se
|
|
||||||
- di.se
|
- di.se
|
||||||
|
- discoveryplus.com
|
||||||
- dn.se
|
- dn.se
|
||||||
- dplay.se
|
|
||||||
- dr.dk
|
- dr.dk
|
||||||
- efn.se
|
- efn.se
|
||||||
- expressen.se
|
- expressen.se
|
||||||
- hbo.com
|
- hbo.com
|
||||||
- kanal9play.se
|
|
||||||
- nickelodeon.nl
|
- nickelodeon.nl
|
||||||
- nickelodeon.no
|
- nickelodeon.no
|
||||||
- nickelodeon.se
|
- nickelodeon.se
|
||||||
@ -143,7 +141,6 @@ This script works for:
|
|||||||
- ur.se
|
- ur.se
|
||||||
- urplay.se
|
- urplay.se
|
||||||
- vg.no
|
- vg.no
|
||||||
- viagame.com
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# using edge to get ffmpeg-4.x
|
# using edge to get ffmpeg-4.x
|
||||||
FROM alpine:edge
|
FROM alpine:latest
|
||||||
LABEL maintainer="j@i19.se"
|
LABEL maintainer="j@i19.se"
|
||||||
|
|
||||||
COPY dist/*.whl .
|
COPY dist/*.whl .
|
||||||
|
@ -97,7 +97,7 @@ def _hlsparse(config, text, url, output, **kwargs):
|
|||||||
if "CHARACTERISTICS" in i:
|
if "CHARACTERISTICS" in i:
|
||||||
role = f'{role}-{i["CHARACTERISTICS"].replace("se.svt.accessibility.", "")}'
|
role = f'{role}-{i["CHARACTERISTICS"].replace("se.svt.accessibility.", "")}'
|
||||||
|
|
||||||
media[i["GROUP-ID"]].append([uri, chans, language, role])
|
media[i["GROUP-ID"]].append([uri, chans, language, role, segments])
|
||||||
|
|
||||||
if i["TYPE"] == "SUBTITLES":
|
if i["TYPE"] == "SUBTITLES":
|
||||||
if "URI" in i:
|
if "URI" in i:
|
||||||
@ -161,7 +161,7 @@ def _hlsparse(config, text, url, output, **kwargs):
|
|||||||
role=group[3],
|
role=group[3],
|
||||||
video_role=video_role,
|
video_role=video_role,
|
||||||
output=loutput,
|
output=loutput,
|
||||||
segments=bool(segments),
|
segments=bool(group[4]),
|
||||||
channels=chans,
|
channels=chans,
|
||||||
codec=codec,
|
codec=codec,
|
||||||
resolution=resolution,
|
resolution=resolution,
|
||||||
@ -187,7 +187,7 @@ def _hlsparse(config, text, url, output, **kwargs):
|
|||||||
audio=audio_url,
|
audio=audio_url,
|
||||||
video_role=video_role,
|
video_role=video_role,
|
||||||
output=loutput,
|
output=loutput,
|
||||||
segments=bool(segments),
|
segments=bool(group[4]),
|
||||||
channels=chans,
|
channels=chans,
|
||||||
codec=codec,
|
codec=codec,
|
||||||
resolution=resolution,
|
resolution=resolution,
|
||||||
|
@ -14,7 +14,6 @@ class Aftonbladettv(Service):
|
|||||||
|
|
||||||
def get(self):
|
def get(self):
|
||||||
data = self.get_urldata()
|
data = self.get_urldata()
|
||||||
|
|
||||||
match = re.search('data-player-config="([^"]+)"', data)
|
match = re.search('data-player-config="([^"]+)"', data)
|
||||||
if not match:
|
if not match:
|
||||||
match = re.search('data-svpPlayer-video="([^"]+)"', data)
|
match = re.search('data-svpPlayer-video="([^"]+)"', data)
|
||||||
@ -24,7 +23,27 @@ class Aftonbladettv(Service):
|
|||||||
yield ServiceError("Can't find video info")
|
yield ServiceError("Can't find video info")
|
||||||
return
|
return
|
||||||
data = json.loads(decode_html_entities(match.group(1)))
|
data = json.loads(decode_html_entities(match.group(1)))
|
||||||
yield from hlsparse(self.config, self.http.request("get", data["streamUrls"]["hls"]), data["streamUrls"]["hls"], output=self.output)
|
hdnea = self._login()
|
||||||
|
url = data["streamUrls"]["hls"] + hdnea if hdnea else data["streamUrls"]["hls"]
|
||||||
|
yield from hlsparse(config=self.config, res=self.http.request("get", url), url=url, output=self.output)
|
||||||
|
|
||||||
|
def _login(self):
|
||||||
|
if (token := self.config.get("token")) is None:
|
||||||
|
return None
|
||||||
|
if (match := re.search(r"^.*tv.aftonbladet.+video/([a-zA-Z0-9]+)/.*$", self.url)) is None:
|
||||||
|
return None
|
||||||
|
|
||||||
|
service = match.group(1)
|
||||||
|
res = self.http.request("get", f"https://svp-token-api.aftonbladet.se/svp/token/{service}?access=plus", headers={"x-sp-id": token})
|
||||||
|
if res.status_code != 200:
|
||||||
|
return None
|
||||||
|
expires = res.json()["expiry"]
|
||||||
|
hmac = res.json()["value"]
|
||||||
|
|
||||||
|
res = self.http.request("get", f"https://svp.vg.no/svp/token/v1/?vendor=ab&assetId={service}&expires={expires}&hmac={hmac}")
|
||||||
|
if res.status_code != 200:
|
||||||
|
return None
|
||||||
|
return f"?hdnea={res.text.replace('/', '%2F').replace('=', '%3D').replace(',', '%2C')}"
|
||||||
|
|
||||||
|
|
||||||
class Aftonbladet(Service):
|
class Aftonbladet(Service):
|
||||||
|
@ -3,7 +3,6 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import uuid
|
import uuid
|
||||||
from urllib.parse import urlparse
|
|
||||||
|
|
||||||
from svtplay_dl.error import ServiceError
|
from svtplay_dl.error import ServiceError
|
||||||
from svtplay_dl.fetcher.hls import hlsparse
|
from svtplay_dl.fetcher.hls import hlsparse
|
||||||
@ -31,6 +30,11 @@ class Dr(Service, OpenGraphThumbMixin):
|
|||||||
else:
|
else:
|
||||||
yield from hlsparse(self.config, res, match.group(1), output=self.output)
|
yield from hlsparse(self.config, res, match.group(1), output=self.output)
|
||||||
return
|
return
|
||||||
|
apimatch = re.search("CLIENT_SERVICE_URL='([^']+)", data)
|
||||||
|
if not apimatch:
|
||||||
|
yield ServiceError("Can't find api server.")
|
||||||
|
return
|
||||||
|
apiserver = apimatch.group(1)
|
||||||
janson = json.loads(match.group(1))
|
janson = json.loads(match.group(1))
|
||||||
page = janson["cache"]["page"][list(janson["cache"]["page"].keys())[0]]
|
page = janson["cache"]["page"][list(janson["cache"]["page"].keys())[0]]
|
||||||
resolution = None
|
resolution = None
|
||||||
@ -55,7 +59,7 @@ class Dr(Service, OpenGraphThumbMixin):
|
|||||||
|
|
||||||
offerlist = []
|
offerlist = []
|
||||||
for i in offers:
|
for i in offers:
|
||||||
if i["deliveryType"] == "Stream":
|
if i["deliveryType"] == "StreamOrDownload":
|
||||||
offerlist.append([i["scopes"][0], i["resolution"]])
|
offerlist.append([i["scopes"][0], i["resolution"]])
|
||||||
|
|
||||||
deviceid = uuid.uuid1()
|
deviceid = uuid.uuid1()
|
||||||
@ -73,10 +77,13 @@ class Dr(Service, OpenGraphThumbMixin):
|
|||||||
for i in offerlist:
|
for i in offerlist:
|
||||||
vid, resolution = i
|
vid, resolution = i
|
||||||
url = (
|
url = (
|
||||||
f"https://isl.dr-massive.com/api/account/items/{vid}/videos?delivery=stream&device=web_browser&"
|
f"{apiserver}/account/items/{vid}/videos?delivery=stream&device=web_browser&"
|
||||||
f"ff=idp%2Cldp&lang=da&resolution={resolution}&sub=Anonymous"
|
f"ff=idp%2Cldp&lang=da&resolution={resolution}&sub=Anonymous"
|
||||||
)
|
)
|
||||||
res = self.http.request("get", url, headers={"authorization": f"Bearer {token}"})
|
res = self.http.request("get", url, headers={"authorization": f"Bearer {token}"})
|
||||||
|
if res.status_code > 400:
|
||||||
|
yield ServiceError("Can't find the video or its geoblocked")
|
||||||
|
return
|
||||||
for video in res.json():
|
for video in res.json():
|
||||||
if video["accessService"] == "StandardVideo" and video["format"] == "video/hls":
|
if video["accessService"] == "StandardVideo" and video["format"] == "video/hls":
|
||||||
res = self.http.request("get", video["url"])
|
res = self.http.request("get", video["url"])
|
||||||
@ -93,26 +100,25 @@ class Dr(Service, OpenGraphThumbMixin):
|
|||||||
data = self.get_urldata()
|
data = self.get_urldata()
|
||||||
match = re.search("__data = ([^<]+)</script>", data)
|
match = re.search("__data = ([^<]+)</script>", data)
|
||||||
if not match:
|
if not match:
|
||||||
if "bonanza" in self.url:
|
|
||||||
parse = urlparse(self.url)
|
|
||||||
match = re.search(r"(\/bonanza\/serie\/[0-9]+\/[\-\w]+)", parse.path)
|
|
||||||
if match:
|
|
||||||
match = re.findall(rf"a href=\"({match.group(1)}\/\d+[^\"]+)\"", data)
|
|
||||||
if not match:
|
|
||||||
logging.error("Can't find video info.")
|
|
||||||
for url in match:
|
|
||||||
episodes.append(f"https://www.dr.dk{url}")
|
|
||||||
else:
|
|
||||||
logging.error("Can't find video info.")
|
|
||||||
return episodes
|
|
||||||
else:
|
|
||||||
logging.error("Can't find video info.")
|
logging.error("Can't find video info.")
|
||||||
return episodes
|
return episodes
|
||||||
|
|
||||||
janson = json.loads(match.group(1))
|
janson = json.loads(match.group(1))
|
||||||
|
|
||||||
|
if "/saeson/" in self.url:
|
||||||
|
page = janson["cache"]["page"][list(janson["cache"]["page"].keys())[0]]
|
||||||
|
for i in page["item"]["show"]["seasons"]["items"]:
|
||||||
|
seasons.append(f'https://www.dr.dk/drtv{i["path"]}')
|
||||||
|
|
||||||
page = janson["cache"]["page"][list(janson["cache"]["page"].keys())[0]]
|
page = janson["cache"]["page"][list(janson["cache"]["page"].keys())[0]]
|
||||||
|
|
||||||
if "show" in page["item"] and "seasons" in page["item"]["show"]:
|
if (
|
||||||
for i in page["item"]["show"]["seasons"]["items"]:
|
"item" in page["entries"][0]
|
||||||
|
and "season" in page["entries"][0]["item"]
|
||||||
|
and "show" in page["entries"][0]["item"]["season"]
|
||||||
|
and "seasons" in page["entries"][0]["item"]["season"]["show"]
|
||||||
|
):
|
||||||
|
for i in page["entries"][0]["item"]["season"]["show"]["seasons"]["items"]:
|
||||||
seasons.append(f'https://www.dr.dk/drtv{i["path"]}')
|
seasons.append(f'https://www.dr.dk/drtv{i["path"]}')
|
||||||
|
|
||||||
if seasons:
|
if seasons:
|
||||||
|
@ -116,11 +116,11 @@ class Svtplay(Service, MetadataThumbMixin):
|
|||||||
|
|
||||||
drm = janson["rights"]["drmCopyProtection"]
|
drm = janson["rights"]["drmCopyProtection"]
|
||||||
if not drm and "variants" in janson and "default" in janson["variants"]:
|
if not drm and "variants" in janson and "default" in janson["variants"]:
|
||||||
if len(janson["variants"]["default"]["videoReferences"]) == 0:
|
if len(janson["videoReferences"]) == 0:
|
||||||
yield ServiceError("Media doesn't have any associated videos.")
|
yield ServiceError("Media doesn't have any associated videos.")
|
||||||
return
|
return
|
||||||
|
|
||||||
for videorfc in janson["variants"]["default"]["videoReferences"]:
|
for videorfc in janson["videoReferences"]:
|
||||||
params = {}
|
params = {}
|
||||||
special = False
|
special = False
|
||||||
params["manifestUrl"] = quote_plus(videorfc["url"])
|
params["manifestUrl"] = quote_plus(videorfc["url"])
|
||||||
|
@ -4,6 +4,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
from urllib.parse import parse_qs
|
||||||
from urllib.parse import urlparse
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
from svtplay_dl.error import ServiceError
|
from svtplay_dl.error import ServiceError
|
||||||
@ -54,7 +55,7 @@ class Tv4play(Service, OpenGraphThumbMixin):
|
|||||||
|
|
||||||
item = jansson["metadata"]
|
item = jansson["metadata"]
|
||||||
if item["isDrmProtected"]:
|
if item["isDrmProtected"]:
|
||||||
yield ServiceError("We can't download DRM protected content from this site.")
|
yield ServiceError("We can't download DRM protected content from this site. This isn't a svtplay-dl issue.")
|
||||||
return
|
return
|
||||||
|
|
||||||
if item["isLive"]:
|
if item["isLive"]:
|
||||||
@ -107,6 +108,7 @@ class Tv4play(Service, OpenGraphThumbMixin):
|
|||||||
def find_all_episodes(self, config):
|
def find_all_episodes(self, config):
|
||||||
episodes = []
|
episodes = []
|
||||||
items = []
|
items = []
|
||||||
|
seasonq = None
|
||||||
|
|
||||||
parse = urlparse(self.url)
|
parse = urlparse(self.url)
|
||||||
if parse.path.startswith("/klipp"):
|
if parse.path.startswith("/klipp"):
|
||||||
@ -130,6 +132,8 @@ class Tv4play(Service, OpenGraphThumbMixin):
|
|||||||
episodes = self._graphlista(token, show)
|
episodes = self._graphlista(token, show)
|
||||||
return episodes
|
return episodes
|
||||||
|
|
||||||
|
query = parse_qs(parse.query)
|
||||||
|
seasonq = query.get("season", None)
|
||||||
showid, jansson, kind = self._get_seriesid(self.get_urldata(), dict())
|
showid, jansson, kind = self._get_seriesid(self.get_urldata(), dict())
|
||||||
if showid is None:
|
if showid is None:
|
||||||
logging.error("Cant find any videos")
|
logging.error("Cant find any videos")
|
||||||
@ -139,9 +143,17 @@ class Tv4play(Service, OpenGraphThumbMixin):
|
|||||||
return episodes
|
return episodes
|
||||||
if kind == "Movie":
|
if kind == "Movie":
|
||||||
return [f"https://www.tv4play.se/video/{showid}"]
|
return [f"https://www.tv4play.se/video/{showid}"]
|
||||||
|
|
||||||
jansson = self._graphdetails(token, showid)
|
jansson = self._graphdetails(token, showid)
|
||||||
for season in jansson["data"]["media"]["allSeasonLinks"]:
|
graph_list = None
|
||||||
graph_list = self._graphql(season["seasonId"])
|
for season in reversed(jansson["data"]["media"]["allSeasonLinks"]):
|
||||||
|
if seasonq:
|
||||||
|
if seasonq[0] == season["seasonId"]:
|
||||||
|
graph_list = self._graphql(token, season["seasonId"])
|
||||||
|
else:
|
||||||
|
graph_list = self._graphql(token, season["seasonId"])
|
||||||
|
|
||||||
|
if graph_list:
|
||||||
for i in graph_list:
|
for i in graph_list:
|
||||||
if i not in items:
|
if i not in items:
|
||||||
items.append(i)
|
items.append(i)
|
||||||
@ -197,7 +209,7 @@ class Tv4play(Service, OpenGraphThumbMixin):
|
|||||||
}
|
}
|
||||||
res = self.http.request(
|
res = self.http.request(
|
||||||
"post",
|
"post",
|
||||||
"https://client-gateway.tv4.a2d.tv/graphql",
|
"https://nordic-gateway.tv4.a2d.tv/graphql",
|
||||||
headers={"Client-Name": "tv4-web", "Client-Version": "5.2.0", "Content-Type": "application/json", "Authorization": f"Bearer {token}"},
|
headers={"Client-Name": "tv4-web", "Client-Version": "5.2.0", "Content-Type": "application/json", "Authorization": f"Bearer {token}"},
|
||||||
json=data,
|
json=data,
|
||||||
)
|
)
|
||||||
@ -241,13 +253,13 @@ class Tv4play(Service, OpenGraphThumbMixin):
|
|||||||
}
|
}
|
||||||
res = self.http.request(
|
res = self.http.request(
|
||||||
"post",
|
"post",
|
||||||
"https://client-gateway.tv4.a2d.tv/graphql",
|
"https://nordic-gateway.tv4.a2d.tv/graphql",
|
||||||
headers={"Client-Name": "tv4-web", "Client-Version": "5.2.0", "Content-Type": "application/json", "Authorization": f"Bearer {token}"},
|
headers={"Client-Name": "tv4-web", "Client-Version": "5.2.0", "Content-Type": "application/json", "Authorization": f"Bearer {token}"},
|
||||||
json=data,
|
json=data,
|
||||||
)
|
)
|
||||||
return res.json()
|
return res.json()
|
||||||
|
|
||||||
def _graphql(self, show):
|
def _graphql(self, token, show):
|
||||||
items = []
|
items = []
|
||||||
nr = 0
|
nr = 0
|
||||||
total = 100
|
total = 100
|
||||||
@ -260,8 +272,8 @@ class Tv4play(Service, OpenGraphThumbMixin):
|
|||||||
|
|
||||||
res = self.http.request(
|
res = self.http.request(
|
||||||
"post",
|
"post",
|
||||||
"https://client-gateway.tv4.a2d.tv/graphql",
|
"https://nordic-gateway.tv4.a2d.tv/graphql",
|
||||||
headers={"Client-Name": "tv4-web", "Client-Version": "5.2.0", "Content-Type": "application/json"},
|
headers={"Client-Name": "tv4-web", "Client-Version": "5.2.0", "Content-Type": "application/json", "Authorization": f"Bearer {token}"},
|
||||||
json=data,
|
json=data,
|
||||||
)
|
)
|
||||||
janson = res.json()
|
janson = res.json()
|
||||||
|
@ -236,25 +236,25 @@ class formatnameTest(unittest.TestCase):
|
|||||||
[
|
[
|
||||||
"{episodename}a{title}-{service}",
|
"{episodename}a{title}-{service}",
|
||||||
{"title": "title", "season": 99, "episode": 21, "episodename": "episodename", "id": "0xdeadface", "ext": "ext"},
|
{"title": "title", "season": 99, "episode": 21, "episodename": "episodename", "id": "0xdeadface", "ext": "ext"},
|
||||||
"episodenameatitle-service",
|
"episodenameatitle-service.mp4",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"{episodename}a{title}-{service}",
|
"{episodename}a{title}-{service}",
|
||||||
{"title": "title", "season": 99, "episodename": "episodename", "id": "0xdeadface", "ext": "ext"},
|
{"title": "title", "season": 99, "episodename": "episodename", "id": "0xdeadface", "ext": "ext"},
|
||||||
"episodenameatitle-service",
|
"episodenameatitle-service.mp4",
|
||||||
],
|
],
|
||||||
["{episodename}a{title}-{service}", {"title": "title", "season": 99, "id": "0xdeadface", "ext": "ext"}, "atitle-service"],
|
["{episodename}a{title}-{service}", {"title": "title", "season": 99, "id": "0xdeadface", "ext": "ext"}, "atitle-service.mp4"],
|
||||||
[
|
[
|
||||||
"{episodename}a{title}-{service}",
|
"{episodename}a{title}-{service}",
|
||||||
{"title": "title", "episode": 21, "episodename": "episodename", "id": "0xdeadface", "ext": "ext"},
|
{"title": "title", "episode": 21, "episodename": "episodename", "id": "0xdeadface", "ext": "ext"},
|
||||||
"episodenameatitle-service",
|
"episodenameatitle-service.mp4",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"{episodename}a{title}-{service}",
|
"{episodename}a{title}-{service}",
|
||||||
{"title": "title", "episodename": "episodename", "id": "0xdeadface", "ext": "ext"},
|
{"title": "title", "episodename": "episodename", "id": "0xdeadface", "ext": "ext"},
|
||||||
"episodenameatitle-service",
|
"episodenameatitle-service.mp4",
|
||||||
],
|
],
|
||||||
["{episodename}a{title}-{service}", {"title": "title", "episodename": "episodename", "id": "0xdeadface"}, "episodenameatitle-service"],
|
["{episodename}a{title}-{service}", {"title": "title", "episodename": "episodename", "id": "0xdeadface"}, "episodenameatitle-service.mp4"],
|
||||||
[
|
[
|
||||||
"{title}.{episode}.{episodename}-{id}-{service}.{ext}",
|
"{title}.{episode}.{episodename}-{id}-{service}.{ext}",
|
||||||
{"title": "title", "season": 99, "episode": 21, "episodename": "episodename", "id": "0xdeadface", "ext": "ext"},
|
{"title": "title", "season": 99, "episode": 21, "episodename": "episodename", "id": "0xdeadface", "ext": "ext"},
|
||||||
|
@ -194,7 +194,10 @@ def _formatname(output, config):
|
|||||||
if key == "service" and output[key]:
|
if key == "service" and output[key]:
|
||||||
name = name.replace("{service}", output[key])
|
name = name.replace("{service}", output[key])
|
||||||
if key == "ext" and output[key]:
|
if key == "ext" and output[key]:
|
||||||
|
if "{ext}" in name:
|
||||||
name = name.replace("{ext}", output[key])
|
name = name.replace("{ext}", output[key])
|
||||||
|
else:
|
||||||
|
name = f"{name}.{output[key]}"
|
||||||
|
|
||||||
# Remove all {text} we cant replace with something
|
# Remove all {text} we cant replace with something
|
||||||
for item in re.findall(r"([\.\-]?(([^\.\-]+\w+)?\{[\w\-]+\}))", name):
|
for item in re.findall(r"([\.\-]?(([^\.\-]+\w+)?\{[\w\-]+\}))", name):
|
||||||
|
Loading…
Reference in New Issue
Block a user