Skip to content

Commit

Permalink
Made some changes to use a new livestream mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
pietje666 committed Jun 17, 2018
1 parent ba75125 commit 0118de9
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 8 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ prompted.
you can report issues here at github or you can send a message to the facebook page https://www.facebook.com/kodivrtnu/

## Releases
#### v1.2.0 (June 17, 2018)
- New stream links for live streaming (Thanks yorickps)
- Changed live streaming mechanism
#### v1.1.2 (June 14, 2018)
- New stream links for live streaming (Thanks yorickps)

Expand Down
4 changes: 3 additions & 1 deletion addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from resources.lib.vrtplayer import actions
from resources.lib.kodiwrappers import sortmethod
from resources.lib.vrtplayer import urltostreamservice
from resources.lib.vrtplayer import urltolivestreamservice

_url = sys.argv[0]
_handle = int(sys.argv[1])
Expand All @@ -17,7 +18,8 @@ def router(params_string):
stream_service = urltostreamservice.UrlToStreamService(vrtplayer.VRTPlayer._VRT_BASE,
vrtplayer.VRTPlayer._VRTNU_BASE_URL,
kodi_wrapper)
vrt_player = vrtplayer.VRTPlayer(addon.getAddonInfo("path"), kodi_wrapper, stream_service)
livestream_service = urltolivestreamservice.UrlToLivestreamService()
vrt_player = vrtplayer.VRTPlayer(addon.getAddonInfo("path"), kodi_wrapper, stream_service, livestream_service)
params = dict(parse_qsl(params_string))
if params:
if params['action'] == actions.LISTING_AZ:
Expand Down
4 changes: 3 additions & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.vrt.nu"
name="VRT Nu"
version="1.1.2"
version="1.2.0"
provider-name="Martijn Moreel">

<requires>
Expand All @@ -23,6 +23,8 @@
<platform>all</platform>
<license>GNU General Public License, v3</license>
<news>
v1.2.0 (17-06-2018)
- Changed live streaming mechanism
v1.1.2 (14-06-2018)
- New stream links for live streaming (Thanks yorickps)
v1.1.1 (13-03-2018)
Expand Down
21 changes: 21 additions & 0 deletions resources/lib/vrtplayer/urltolivestreamservice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import requests

class UrlToLivestreamService:

_TOKEN_URL = "https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1/tokens"

def get_stream_from_url(self, url):
token_response = requests.post(self._TOKEN_URL)
token = token_response.json()['vrtPlayerToken']
stream_response = requests.get(url, {'vrtPlayerToken': token, 'client':'vrtvideo' }).json()
target_urls = stream_response['targetUrls']
found_url = False
index = 0
while not found_url and index < len(target_urls):
item = target_urls[index]
found_url = item['type'] == 'hls_aes'
stream = item['url']
index +=1
return stream


15 changes: 9 additions & 6 deletions resources/lib/vrtplayer/vrtplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,22 @@
class VRTPlayer:

#Url met de urls https://services.vrt.be/videoplayer/r/live.json
_EEN_LIVESTREAM = "https://live-aka.vrtcdn.be/groupc/live/d05012c2-6a5d-49ff-a711-79b32684615b/live.isml/.m3u8"
_CANVAS_LIVESTREAM_ = "https://live-aka.vrtcdn.be/groupc/live/905b0602-9719-4d14-ae2a-a9b459630653/live.isml/.m3u8"
_KETNET_LIVESTREAM = "https://live-aka.vrtcdn.be/groupc/live/8b898c7d-adf7-4d44-ab82-b5bb3a069989/live.isml/.m3u8"
_SPORZA_LIVESTREAM = "https://live-aka.vrtcdn.be/groupa/live/bf2f7c79-1d77-4cdc-80e8-47ae024f30ba/live.isml/.m3u8"
_EEN_LIVESTREAM = "https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1/videos/vualto_een_geo"
_CANVAS_LIVESTREAM_ = "https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1/videos/vualto_canvas_geo"
_KETNET_LIVESTREAM = "https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1/videos/vualto_ketnet_geo"
_SPORZA_LIVESTREAM = "https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1/videos/vualto_sporza_geo"

_VRT_BASE = "https://www.vrt.be/"
_VRTNU_BASE_URL = urljoin(_VRT_BASE, "/vrtnu/")
_VRTNU_SEARCH_URL = "https://search.vrt.be/suggest?facets[categories]="

def __init__(self, addon_path, kodi_wrapper, url_to_stream_service):
def __init__(self, addon_path, kodi_wrapper, url_to_stream_service, url_to_livestream_service):
self.metadata_collector = metadatacollector.MetadataCollector()
self._addon_path = addon_path
self._kodi_wrapper = kodi_wrapper
self._url_toStream_service = url_to_stream_service
self.url_to_livestream_service = url_to_livestream_service


def show_main_menu_items(self):
menu_items = {helperobjects.TitleItem(self._kodi_wrapper.get_localized_string(32091), {'action': actions.LISTING_AZ}, False,
Expand Down Expand Up @@ -77,7 +79,8 @@ def play_vrtnu_video(self, url):
self._kodi_wrapper.play_video(stream)

def play_livestream(self, url):
self._kodi_wrapper.play_livestream(url)
stream = self.url_to_livestream_service.get_stream_from_url(url)
self._kodi_wrapper.play_livestream(stream)

def show_livestream_items(self):
livestream_items = {helperobjects.TitleItem(self._kodi_wrapper.get_localized_string(32101),
Expand Down

0 comments on commit 0118de9

Please sign in to comment.