Skip to content

Commit

Permalink
Add support for nwsnwsnws.be in Tv Downloader
Browse files Browse the repository at this point in the history
  • Loading branch information
quintenvandamme committed May 2, 2024
1 parent ac93273 commit 29d578d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Tv Downloader is een tool om video's van verschillende websites te downloaden.
|[tvl.be](https://tvl.be)||
|[vrtnws.be](https://vrtnws.be)||
|[vrtmax.be](https://vrtmax.be)||
|[nwsnwsnws.be](https://nwsnwsnws.be)||

## Installatie

Expand Down
3 changes: 3 additions & 0 deletions gui/get_videos/getvideo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .rtv import get_video_from_rtv
from .ringtv import get_video_from_ringtv
from .standaard import get_video_from_standaard
from .nwsnwsnws import get_video_from_nwsnwsnws
from .constants import *
from .util import print_error

Expand All @@ -30,6 +31,8 @@ def get_videos(url, settings, guiParent):
videos = get_video_from_vrtnws_single(url,guiParent)
elif url.startswith("https://www.vrt.be/vrtnws/") and not '/kijk/' in url:
videos = get_video_from_vrtnws_multi(url,guiParent)
elif url.startswith("https://www.vrt.be/nwsnwsnws/"):
videos = get_video_from_nwsnwsnws(url,guiParent)
elif url.startswith("https://www.hln.be/"):
videos = get_video_from_hln(url)
elif url.startswith("https://www.bruzz.be/"):
Expand Down
38 changes: 38 additions & 0 deletions gui/get_videos/nwsnwsnws.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from .util import get_request, Video, unixTimeToDatetime, print_error
from .vrtmax import get_vrtmax_token
from .constants import *
import json

def get_streamUrl(mediaReference,guiParent):
vrtmaxToken = get_vrtmax_token()
url = 'https://media-services-public.vrt.be/media-aggregator/v2/media-items/' + mediaReference + '?vrtPlayerToken=' + vrtmaxToken + '&client=vrtnieuws'
a = get_request(url,{})
mpegUrl = a['targetUrls'][1]['url']
streamUrl = mpegUrl.split('?')[0]
if not 'nodrm' in streamUrl:
print_error(STR_6,guiParent)
return streamUrl

def get_video_from_nwsnwsnws(url,guiParent):
videos = []

body = get_request(url,{},False)
try:
data = body.split('<script id="__NEXT_DATA__" type="application/json">')[1].split('</script>')[0]
data = json.loads(data)

thumbnailUrl = data['props']['pageProps']['data']['compositions'][0]['compositions'][0]['action']['image']['url']
mediaReference = data['props']['pageProps']['data']['compositions'][0]['compositions'][0]['action']['mediaReference']
streamUrl = get_streamUrl(mediaReference,guiParent)
title = data['props']['pageProps']['data']['compositions'][0]['compositions'][1]['title']['text']
description = data['props']['pageProps']['data']['compositions'][0]['compositions'][2]['text']['html']
date = data['props']['pageProps']['data']['compositions'][0]['compositions'][2]['metadata'][0]['timestamp']
date = unixTimeToDatetime(int(date/1000))
fileName = mediaReference.split('$')[1] + '.mp4'

video = Video(streamUrl, url, title, description, thumbnailUrl, fileName, date)
videos.append(video)
except:
pass

return videos
2 changes: 1 addition & 1 deletion gui/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def resource_path(relative_path):
def create_icon_from_url(url):
image_data = requests.get(url).content

pixmap = QPixmap()
pixmap = QPixmap()()
pixmap.loadFromData(image_data)

icon = QIcon(pixmap)
Expand Down

0 comments on commit 29d578d

Please sign in to comment.