Skip to content

Commit

Permalink
Include list of channels
Browse files Browse the repository at this point in the history
A central database of all channels is very useful, and opens up the
possibility to fall back when web scraping fails.

It also makes it possible to start adding audio streams, or studio
translations.
  • Loading branch information
dagwieers committed Apr 30, 2019
1 parent 3a38bdf commit 2f0f7dc
Show file tree
Hide file tree
Showing 13 changed files with 351 additions and 160 deletions.
16 changes: 7 additions & 9 deletions addon.py
Expand Up @@ -25,12 +25,11 @@ def router(params_string):
addon = xbmcaddon.Addon()
kodi_wrapper = kodiwrapper.KodiWrapper(_ADDON_HANDLE, _ADDON_URL, addon)
token_resolver = tokenresolver.TokenResolver(kodi_wrapper)
stream_service = streamservice.StreamService(vrtplayer.VRTPlayer.VRT_BASE,
vrtplayer.VRTPlayer.VRTNU_BASE_URL,
kodi_wrapper, token_resolver)
stream_service = streamservice.StreamService(kodi_wrapper, token_resolver)
api_helper = vrtapihelper.VRTApiHelper(kodi_wrapper)
vrt_player = vrtplayer.VRTPlayer(addon.getAddonInfo('path'), kodi_wrapper, stream_service, api_helper)
params = dict(parse_qsl(params_string))
content_type = params.get('content_type')
action = params.get('action')
if action == actions.LISTING_AZ_TVSHOWS:
vrt_player.show_tvshow_menu_items(path=None)
Expand All @@ -46,12 +45,11 @@ def router(params_string):
tv_guide = tvguide.TVGuide(addon.getAddonInfo('path'), kodi_wrapper)
tv_guide.show_tvguide(params)
elif action == actions.PLAY:
video = dict(
video_url=params.get('video_url'),
video_id=params.get('video_id'),
publication_id=params.get('publication_id'),
)
vrt_player.play(video)
vrt_player.play(params)
elif action == actions.PLAY_RADIO:
vrt_player.play_radio(params)
elif content_type == 'audio':
vrt_player.show_radio_menu_items()
else:
vrt_player.show_main_menu_items()

Expand Down
2 changes: 1 addition & 1 deletion addon.xml
Expand Up @@ -15,7 +15,7 @@
</requires>

<extension point="xbmc.python.pluginsource" library="addon.py">
<provides>video</provides>
<provides>video audio</provides>
</extension>
<extension point="xbmc.service" library="service.py"/>
<extension point="xbmc.addon.metadata">
Expand Down
32 changes: 4 additions & 28 deletions resources/language/resource.language.en_gb/strings.po
Expand Up @@ -132,36 +132,12 @@ msgid "Episode"
msgstr "Episode"

msgctxt "#32101"
msgid "Eén live"
msgstr "Eén live"
msgid "%s live"
msgstr "%s live"

msgctxt "#32102"
msgid "Watch Eén live TV stream (via Internet)"
msgstr "Watch Eén live TV stream (via Internet)"

msgctxt "#32111"
msgid "Canvas live"
msgstr "Canvas live"

msgctxt "#32112"
msgid "Watch Canvas live TV stream (via Internet)"
msgstr "Watch Canvas live TV stream (via Internet)"

msgctxt "#32121"
msgid "Ketnet live"
msgstr "Ketnet live"

msgctxt "#32122"
msgid "Watch Ketnet live TV stream (via Internet)"
msgstr "Watch Ketnet live TV stream (via Internet)"

msgctxt "#32131"
msgid "Sporza live"
msgstr "Sporza live"

msgctxt "#32132"
msgid "Watch Sporza live TV stream (via Internet)"
msgstr "Watch Sporza live TV stream via (Internet)"
msgid "Watch %s live TV stream (via Internet)"
msgstr "Watch %s live TV stream (via Internet)"

msgctxt "#32201"
msgid "[B][COLOR red]Geo-blocked[/COLOR][/B]\n"
Expand Down
32 changes: 4 additions & 28 deletions resources/language/resource.language.nl_nl/strings.po
Expand Up @@ -133,36 +133,12 @@ msgid "Episode"
msgstr "Aflevering"

msgctxt "#32101"
msgid "Eén live"
msgstr "Eén live"
msgid "%s live"
msgstr "%s live"

msgctxt "#32102"
msgid "Watch Eén live TV stream (via Internet)"
msgstr "Bekijk Eén live tv stream (via Internet)"

msgctxt "#32111"
msgid "Canvas live"
msgstr "Canvas live"

msgctxt "#32112"
msgid "Watch Canvas live TV stream (via Internet)"
msgstr "Bekijk Canvas live tv stream (via Internet)"

msgctxt "#32121"
msgid "Ketnet live"
msgstr "Ketnet live"

msgctxt "#32122"
msgid "Watch Ketnet live TV stream (via Internet)"
msgstr "Bekijk Ketnet live tv stream (via Internet)"

msgctxt "#32131"
msgid "Sporza live"
msgstr "Sporza live"

msgctxt "#32132"
msgid "Watch Sporza live TV stream (via Internet)"
msgstr "Bekijk Sporza live tv stream (via Internet)"
msgid "Watch %s live TV stream (via Internet)"
msgstr "Bekijk %s live tv stream (via Internet)"

msgctxt "#32201"
msgid "[B][COLOR red]Geo-blocked[/COLOR][/B]\n"
Expand Down
11 changes: 9 additions & 2 deletions resources/lib/kodiwrappers/kodiwrapper.py
Expand Up @@ -50,7 +50,7 @@ def __init__(self, handle, url, addon):
self._addon = addon
self._addon_id = addon.getAddonInfo('id')

def show_listing(self, list_items, sort='unsorted', ascending=True, content_type='episodes', cache=True):
def show_listing(self, list_items, sort='unsorted', ascending=True, content_type='episodes', list_type='video', cache=True):
listing = []

xbmcplugin.setContent(self._handle, content=content_type)
Expand Down Expand Up @@ -90,7 +90,7 @@ def show_listing(self, list_items, sort='unsorted', ascending=True, content_type
list_item.setArt(title_item.art_dict)

if title_item.video_dict:
list_item.setInfo('video', infoLabels=title_item.video_dict)
list_item.setInfo(type=list_type, infoLabels=title_item.video_dict)

listing.append((url, list_item, not title_item.is_playable))

Expand Down Expand Up @@ -121,6 +121,13 @@ def play(self, video):
xbmc.sleep(100)
xbmc.Player().showSubtitles(subtitles_visible)

def play_radio(self, stream):
xbmc.Player().play(stream)
play_item = xbmcgui.ListItem(path=stream)
xbmcplugin.setResolvedUrl(self._handle, True, listitem=play_item)
while not xbmc.Player().isPlaying() and not xbmc.Monitor().abortRequested():
xbmc.sleep(100)

def show_ok_dialog(self, title, message):
xbmcgui.Dialog().ok(self._addon.getAddonInfo('name'), title, message)

Expand Down
215 changes: 215 additions & 0 deletions resources/lib/vrtplayer/__init__.py
@@ -0,0 +1,215 @@
# -*- coding: utf-8 -*-

# GNU General Public License v3.0 (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, unicode_literals

# Fallback list of categories so we don't depend on web scraping only
CATEGORIES = [
dict(name='Audiodescriptie', id='met-audiodescriptie'),
dict(name='Cultuur', id='cultuur'),
dict(name='Docu', id='docu'),
dict(name='Entertainment', id='entertainment'),
dict(name='Films', id='films'),
dict(name='Human interest', id='human-interest'),
dict(name='Humor', id='humor'),
dict(name='Kinderen', id='voor-kinderen'),
dict(name='Koken', id='koken'),
dict(name='Lifestyle', id='lifestyle'),
dict(name='Muziek', id='muziek'),
dict(name='Nieuws en actua', id='nieuws-en-actua'),
dict(name='Series', id='series'),
dict(name='Sport', id='sport'),
dict(name='Talkshows', id='talkshows'),
dict(name='Vlaamse Gebarentaal', id='met-gebarentaal'),
dict(name='Wetenschap en natuur', id='wetenschap-en-natuur'),
]

CHANNELS = {
'een': dict(
id='O8',
type='tv',
name='Eén',
tagline='',
studio='Een',
website='https://een.be/',
live_stream='https://www.vrt.be/vrtnu/kanalen/een/',

),
'canvas': dict(
id='1H',
type='tv',
name='Canvas',
tagline='',
studio='Canvas',
website='https://canvas.be/',
live_stream='https://www.vrt.be/vrtnu/kanalen/canvas/',
),
'ketnet': dict(
id='O9',
type='tv',
name='Ketnet',
tagline='',
studio='Ketnet',
website='https://ketnet.be/',
live_stream='https://www.vrt.be/vrtnu/kanalen/ketnet/',
),
'ketnet-jr': dict(
id='1H',
type='tv',
name='Ketnet Junior',
tagline='',
studio='Ketnet Junior',
website='https://ketnet.be/',
),
'radio1': dict(
id='11',
type='radio',
name='Radio 1',
tagline='Altijd Benieuwd',
studio='Radio 1',
hls_128='https://live-radio-cf-vrt.akamaized.net/groupb/live/47303075-8243-434b-8199-2e62cf4dd97a/live.isml/.m3u8',
mpeg_dash_128='https://live-radio-cf-vrt.akamaized.net/groupb/live/47303075-8243-434b-8199-2e62cf4dd97a/live.isml/.mpd',
mp3_128='http://icecast.vrtcdn.be/radio1-high.mp3',
mp3_64='http://icecast.vrtcdn.be/radio1-mid.mp3',
aac_128='http://icecast.vrtcdn.be/radio1.aac',
),
'radio2': dict(
id='24',
type='radio',
name='Radio 2',
tagline='De grootste familie',
studio='Radio 2',
hls_128='https://live-radio-cf-vrt.akamaized.net/groupb/live/93a8a402-9008-4a97-b473-bc107be7524d/live.isml/.m3u8',
mpeg_dash_128='https://live-radio-cf-vrt.akamaized.net/groupb/live/93a8a402-9008-4a97-b473-bc107be7524d/live.isml/.mpd',
mp3_128='http://icecast.vrtcdn.be/ra2ovl-high.mp3',
mp3_64='http://icecast.vrtcdn.be/ra2ovl-mid.mp3',
aac_128='http://icecast.vrtcdn.be/ra2ovl.aac',
),
'klara': dict(
id='31',
type='radio',
tagline='Blijf verwonderd',
name='Klara',
studio='Klara',
hls_128='https://live-radio-cf-vrt.akamaized.net/groupa/live/a9f36fda-cb3c-4b4e-9405-a5bba55654c0/live.isml/.m3u8',
mpeg_dash_128='https://live-radio-cf-vrt.akamaized.net/groupa/live/a9f36fda-cb3c-4b4e-9405-a5bba55654c0/live.isml/.mpd',
mp3_128='http://icecast.vrtcdn.be/klara-high.mp3',
mp3_64='http://icecast.vrtcdn.be/klara-mid.mp3',
aac_128='http://icecast.vrtcdn.be/klara.aac',
),
'klara-continuo': dict(
id='32',
type='radio',
tagline='Non-stop klassieke muziek',
name='Klara Continuo',
studio='Klara Continuo',
hls_128='https://live-radio-cf-vrt.akamaized.net/groupa/live/0d06dbbe-92d4-4cfe-a0b3-ccc6b7a32ec4/live.isml/.m3u8',
mpeg_dash_128='https://live-radio-cf-vrt.akamaized.net/groupa/live/0d06dbbe-92d4-4cfe-a0b3-ccc6b7a32ec4/live.isml/.mpd',
mp3_128='http://icecast.vrtcdn.be/klaracontinuo-high.mp3',
mp3_64='http://icecast.vrtcdn.be/klaracontinuo-mid.mp3',
aac_128='http://icecast.vrtcdn.be/klaracontinuo.aac',
),
'stubru': dict(
id='41',
type='radio',
name='Studio Brussel',
tagline='Life is Music',
studio='Studio Brussel',
website='https://stubru.be/',
hls_128='https://live-radio-cf-vrt.akamaized.net/groupc/live/f404f0f3-3917-40fd-80b6-a152761072fe/live.isml/.m3u8',
mpeg_dash_128='https://live-radio-cf-vrt.akamaized.net/groupc/live/f404f0f3-3917-40fd-80b6-a152761072fe/live.isml/.mpd',
mp3_128='http://icecast.vrtcdn.be/stubru-high.mp3',
mp3_64='http://icecast.vrtcdn.be/stubru-mid.mp3',
aac_128='http://icecast.vrtcdn.be/stubru.aac',
),
'de-tijdloze': dict(
id='44',
type='radio',
name='De Tijdloze',
tagline='Altijd en overal de beste Tijdloze muziek',
studio='Studio Brussel',
website='https://stubru.be/',
hls_128='https://live-radio-cf-vrt.akamaized.net/groupc/live/582109ca-1e71-4330-93fc-e9affee94d7d/live.isml/.m3u8',
mpeg_dash_128='https://live-radio-cf-vrt.akamaized.net/groupc/live/582109ca-1e71-4330-93fc-e9affee94d7d/live.isml/.mpd',
mp3_128='http://icecast.vrtcdn.be/stubru_tijdloze-high.mp3',
mp3_64='http://icecast.vrtcdn.be/stubru_tijdloze-mid.mp3',
aac_128='http://icecast.vrtcdn.be/stubru_tijdloze.aac',
),
'mnm': dict(
id='55',
type='radio',
name='MNM',
tagline='Music and More',
studio='MNM',
website='https://mnm.be/',
hls_128='https://live-radio-cf-vrt.akamaized.net/groupa/live/68dc3b80-040e-4a75-a394-72f3bb7aff9a/live.isml/.m3u8',
mpeg_dash_128='https://live-radio-cf-vrt.akamaized.net/groupa/live/68dc3b80-040e-4a75-a394-72f3bb7aff9a/live.isml/.mpd',
mp3_128='http://icecast.vrtcdn.be/mnm-high.mp3',
mp3_64='http://icecast.vrtcdn.be/mnm-mid.mp3',
aac_128='http://icecast.vrtcdn.be/mnm.aac',
),
'mnm-hits': dict(
id='56',
type='radio',
name='MNM Hits',
tagline='Music and More - The Hits',
studio='MNM',
website='http://mnm.be/',
hls_128='https://live-radio-cf-vrt.akamaized.net/groupb/live/35dd91de-0352-4865-8632-17e5af8dc6ba/live.isml/.m3u8',
mpeg_dash_128='https://live-radio-cf-vrt.akamaized.net/groupb/live/35dd91de-0352-4865-8632-17e5af8dc6ba/live.isml/.mpd',
mp3_128='http://icecast.vrtcdn.be/mnm_hits-high.mp3',
mp3_64='http://icecast.vrtcdn.be/mnm_hits-mid.mp3',
aac_128='http://icecast.vrtcdn.be/mnm_hits.aac',
),
'mnm-urbanice': dict(
id='57',
type='radio',
name='MNM UrbaNice',
tagline='De Online Urban Stream van MNM',
studio='MNM',
website='https://mnm.be/',
hls_128='https://live-radio-cf-vrt.akamaized.net/groupa/live/da0b681c-73db-4c9e-af32-7921591d3fbd/live.isml/.m3u8',
mpeg_dash_128='https://live-radio-cf-vrt.akamaized.net/groupa/live/da0b681c-73db-4c9e-af32-7921591d3fbd/live.isml/.mpd',
mp3_128='http://icecast.vrtcdn.be/mnm_urb-high.mp3',
mp3_64='http://icecast.vrtcdn.be/mnm_urb-mid.mp3',
aac_128='http://icecast.vrtcdn.be/mnm_urb.aac',
),
'ketnet-hits': dict(
id='O3',
type='radio',
name='Ketnet Hits',
tagline='De hipste, de coolste én de plezantste hits op een rijtje',
studio='Ketnet',
website='https://ketnet.be/',
hls_128='https://live-radio-cf-vrt.akamaized.net/groupa/live/014a9eea-af85-4da6-aab2-c472ca8d0149/live.isml/.m3u8',
mpeg_dash_128='https://live-radio-cf-vrt.akamaized.net/groupa/live/014a9eea-af85-4da6-aab2-c472ca8d0149/live.isml/.mpd',
mp3_128='http://icecast.vrtcdn.be/ketnetradio-high.mp3',
mp3_64='http://icecast.vrtcdn.be/ketnetradio-mid.mp3',
aac_128='http://icecast.vrtcdn.be/ketnetradio.aac',
),
'vrtnws': dict(
id='13',
type='radio',
name='VRT NWS',
tagline='Ieder moment het meest recente nieuws',
studio='VRT NWS',
website='https://www.vrtnieuws.be/',
hls_128='https://ondemand-radio-cf-vrt.akamaized.net/audioonly/content/fixed/11_11niws-snip_hi.mp4/.m3u8',
mpeg_dash_128='https://ondemand-radio-cf-vrt.akamaized.net/audioonly/content/fixed/11_11niws-snip_hi.mp4/.mpd',
mp3_128='https://progressive-audio.lwc.vrtcdn.be/content/fixed/11_11niws-snip_hi.mp3',
),
'vrt-event': dict(
id='71',
type='radio',
name='VRT Event',
tagline='',
studio='VRT',
website='https://vrt.be/',
hls_128='https://live-radio-cf-vrt.akamaized.net/groupa/live/779d53fc-9472-4fe8-b62a-1d38c5878c60/live.isml/.m3u8',
mpeg_dash_128='https://live-radio-cf-vrt.akamaized.net/groupa/live/779d53fc-9472-4fe8-b62a-1d38c5878c60/live.isml/.mpd',
mp3_128='http://icecast.vrtcdn.be/vrtevent-high.mp3',
mp3_64='http://icecast.vrtcdn.be/vrtevent-mid.mp3',
aac_128='http://icecast.vrtcdn.be/vrtevent.aac',
),
}
1 change: 1 addition & 0 deletions resources/lib/vrtplayer/actions.py
Expand Up @@ -14,3 +14,4 @@
LISTING_TVGUIDE = 'listingtvguide'

PLAY = 'play'
PLAY_RADIO = 'play_radio'
7 changes: 5 additions & 2 deletions resources/lib/vrtplayer/metadatacreator.py
Expand Up @@ -6,6 +6,8 @@
from datetime import datetime
import dateutil.tz

from resources.lib.vrtplayer import CHANNELS


class MetadataCreator:

Expand Down Expand Up @@ -160,8 +162,9 @@ def get_video_dict(self):
video_dict = dict()

if self.brands:
video_dict['studio'] = self.brands
# video_dict['channelname'] = self.brands[0] if isinstance(self.brands, list) else self.brands
video_dict['studio'] = CHANNELS.get(self.brands[0], {'studio': 'VRT'}).get('studio')
else:
video_dict['studio'] = 'VRT'

if self.datetime:
video_dict['aired'] = self.datetime.strftime('%Y-%m-%d %H:%M:%S')
Expand Down

0 comments on commit 2f0f7dc

Please sign in to comment.