Skip to content

Commit

Permalink
Add YouTube support to VRT NU plugin (#364)
Browse files Browse the repository at this point in the history
This PR includes:
- A YouTube entry in the channels menu
  • Loading branch information
dagwieers authored Jul 6, 2019
1 parent 741eebe commit 682f517
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 14 deletions.
22 changes: 17 additions & 5 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ msgctxt "#30102"
msgid "Watch [B]{label}[/B] live via Internet"
msgstr ""

msgctxt "#30103"
msgid "{label} on YouTube"
msgstr ""

msgctxt "#30104"
msgid "Watch [B]{label}[/B] on YouTube"
msgstr ""

msgctxt "#30201"
msgid "[B][COLOR red]Geo-blocked[/COLOR][/B]\n"
msgstr ""
Expand Down Expand Up @@ -432,26 +440,30 @@ msgid "Show fanart"
msgstr ""

msgctxt "#30833"
msgid "Show youtube channel information"
msgstr ""

msgctxt "#30835"
msgid "Show episode permalink in plot"
msgstr ""

msgctxt "#30834"
msgctxt "#30836"
msgid "When enabled, the video description will include a permanent link that points to this episode. This is useful for quickly opening an episode or movie on a mobile device."
msgstr ""

msgctxt "#30835"
msgctxt "#30837"
msgid "Cache"
msgstr ""

msgctxt "#30837"
msgctxt "#30838"
msgid "Enable menu caching"
msgstr ""

msgctxt "#30838"
msgctxt "#30839"
msgid "When enabled, menus are being cached so they work more quickly. Only in very specific use-cases this is problematic as new episodes may not appear when they are expected."
msgstr ""

msgctxt "#30839"
msgctxt "#30840"
msgid "Enable local HTTP caching"
msgstr ""

Expand Down
20 changes: 16 additions & 4 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ msgctxt "#30102"
msgid "Watch [B]{label}[/B] live via Internet"
msgstr "Bekijk [B]{label}[/B] live via Internet"

msgctxt "#30103"
msgid "{label} on YouTube"
msgstr "{label} op YouTube"

msgctxt "#30104"
msgid "Watch [B]{label}[/B] on YouTube"
msgstr "Bekijk [B]{label}[/B] op YouTube"

msgctxt "#30201"
msgid "[B][COLOR red]Geo-blocked[/COLOR][/B]\n"
msgstr "[B][COLOR red]Geo-geblokkeerd[/COLOR][/B]\n"
Expand Down Expand Up @@ -328,22 +336,26 @@ msgid "Show fanart"
msgstr "Toon fanart"

msgctxt "#30833"
msgid "Show youtube channel information"
msgstr ""

msgctxt "#30835"
msgid "Show episode permalink in plot"
msgstr "Toon aflevering permalink in beschrijving"

msgctxt "#30834"
msgctxt "#30836"
msgid "When enabled, the video description will include a permanent link that points to this episode. This is useful for quickly opening an episode or movie on a mobile device."
msgstr "Indien actief zal de beschrijving van iedere video een permanent link bevatten die je rechtstreeks naar de VRT NU website brengt. Dit is handig om snel een aflevering of film to openen op een mobiel toestel."

msgctxt "#30835"
msgctxt "#30837"
msgid "Cache"
msgstr "Cache"

msgctxt "#30837"
msgctxt "#30838"
msgid "Enable menu caching"
msgstr "Gebruik menu caching"

msgctxt "#30839"
msgctxt "#30840"
msgid "Enable local HTTP caching"
msgstr "Gebruik local HTTP caching"

Expand Down
29 changes: 29 additions & 0 deletions resources/lib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
dict(name='Wetenschap en natuur', id='wetenschap-en-natuur', msgctxt='30086'),
]

# VRT: https://www.youtube.com/channel/UCojJNXcer3yKj9Q-RWOFZuw
# VRT NU: https://www.youtube.com/channel/UCt3RWMlMKf5jKg5cvqxC_xA

CHANNELS = [
dict(
id='O8',
Expand All @@ -35,6 +38,8 @@
studio='Een',
live_stream='https://www.vrt.be/vrtnu/kanalen/een/',
live_stream_id='vualto_een_geo',
# Eén: https://www.youtube.com/user/welkombijeen
youtube='plugin://plugin.video.youtube/user/welkombijeen/',
),
dict(
id='1H',
Expand All @@ -43,6 +48,8 @@
studio='Canvas',
live_stream='https://www.vrt.be/vrtnu/kanalen/canvas/',
live_stream_id='vualto_canvas_geo',
# Canvas: https://www.youtube.com/user/CanvasTV
youtube='plugin://plugin.video.youtube/user/CanvasTV/',
),
dict(
id='O9',
Expand All @@ -51,20 +58,27 @@
studio='Ketnet',
live_stream='https://www.vrt.be/vrtnu/kanalen/ketnet/',
live_stream_id='vualto_ketnet_geo',
# Ketnet: https://www.youtube.com/user/KetnetVideo
# Ketnet Musical: https://www.youtube.com/channel/UCB90ZMfqVLgGtp3Z99h4GWg
youtube='plugin://plugin.video.youtube/user/KetnetVideo/',
),
dict(
id='1H',
name='ketnet-jr',
label='Ketnet Junior',
studio='Ketnet Junior',
live_stream_id='ketnet_jr',
# Ketnet Juior: https://www.youtube.com/channel/UCTxm_H52WlKWBEB_h7PjzFA
youtube='plugin://plugin.video.youtube/channel/UCTxm_H52WlKWBEB_h7PjzFA/',
),
dict(
id='12',
name='sporza',
label='Sporza',
studio='Sporza',
live_stream_id='vualto_sporza_geo',
# Sporza: https://www.youtube.com/user/SporzaOfficial
youtube='plugin://plugin.video.youtube/user/SporzaOfficial/',
),
dict(
id='13',
Expand All @@ -73,25 +87,34 @@
studio='VRT NWS',
live_stream_id='vualto_nieuws',
# live_stream_id='vualto_journaal',
# VRT NWS: https://www.youtube.com/channel/UC59gT3bFTFNSqafRcluDIsQ
# Terzake: https://www.youtube.com/user/terzaketv
youtube='plugin://plugin.video.youtube/channel/UC59gT3bFTFNSqafRcluDIsQ/',
),
dict(
id='11',
name='radio1',
label='Radio 1',
studio='Radio 1',
live_stream_id='vualto_events3_geo',
# Radio 1: https://www.youtube.com/user/vrtradio1
youtube='plugin://plugin.video.youtube/user/vrtradio1/',
),
dict(
id='24',
name='radio2',
label='Radio 2',
studio='Radio 2',
# Radio 2: https://www.youtube.com/user/radio2inbeeld
youtube='plugin://plugin.video.youtube/user/radio2inbeeld/',
),
dict(
id='31',
name='klara',
label='Klara',
studio='Klara',
# Klara: https://www.youtube.com/user/klararadio
youtube='plugin://plugin.video.youtube/user/klararadio/',
),
dict(
id='41',
Expand All @@ -100,6 +123,8 @@
studio='Studio Brussel',
# live_stream='https://stubru.be/live',
live_stream_id='vualto_stubru',
# youtube='https://www.youtube.com/user/StuBru',
youtube='plugin://plugin.video.youtube/user/StuBru/',
),
dict(
id='55',
Expand All @@ -108,12 +133,16 @@
studio='MNM',
# live_stream='https://mnm.be/kijk/live',
live_stream_id='vualto_mnm',
# MNM: https://www.youtube.com/user/MNMbe
youtube='plugin://plugin.video.youtube/user/MNMbe/',
),
dict(
id='',
name='vrtnxt',
label='VRT NXT',
studio='VRT NXT',
# VRT NXT: https://www.youtube.com/channel/UCO-VoGCVzhYVwvQvWYJq4-Q
youtube='plugin://plugin.video.youtube/channel/UCO-VoGCVzhYVwvQvWYJq4-Q/',
),
]

Expand Down
4 changes: 4 additions & 0 deletions resources/lib/kodiwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,10 @@ def get_proxies(self):

return dict(http=proxy_address, https=proxy_address)

def get_cond_visibility(self, condition):
''' Test a condition in XBMC '''
return xbmc.getCondVisibility(condition)

def has_inputstream_adaptive(self):
''' Whether InputStream Adaptive is installed and enabled in add-on settings '''
return self.get_setting('useinputstreamadaptive', 'true') == 'true' and xbmc.getCondVisibility('System.HasAddon(inputstream.adaptive)') == 1
Expand Down
40 changes: 40 additions & 0 deletions resources/lib/vrtapihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,46 @@ def get_channel_items(self, channels=None, live=True):

return channel_items

def get_youtube_items(self, channels=None, live=True):
''' Construct a list of channel ListItems, either for Live TV or the TV Guide listing '''

youtube_items = []

if self._kodi.get_cond_visibility('System.HasAddon(plugin.video.youtube)') == 0:
return youtube_items

for channel in CHANNELS:
if channels and channel.get('name') not in channels:
continue

fanart = 'resource://resource.images.studios.coloured/%(studio)s.png' % channel
thumb = 'resource://resource.images.studios.white/%(studio)s.png' % channel

if channel.get('youtube'):
path = channel.get('youtube')
label = self._kodi.localize(30103).format(**channel)
# A single Live channel means it is the entry for channel's TV Show listing, so make it stand out
if channels and len(channels) == 1:
label = '[B]%s[/B]' % label
plot = self._kodi.localize(30104).format(**channel)
# NOTE: Playcount is required to not have live streams as "Watched"
info_dict = dict(title=label, plot=plot, studio=channel.get('studio'), mediatype='video', playcount=0)
context_menu = [(self._kodi.localize(30413), 'RunPlugin(%s)' % self._kodi.url_for('delete_cache', cache_file='channel.%s.json' % channel))]
else:
# Not a playable channel
continue

youtube_items.append(TitleItem(
title=label,
path=path,
art_dict=dict(thumb=thumb, fanart=fanart),
info_dict=info_dict,
context_menu=context_menu,
is_playable=False,
))

return youtube_items

def get_featured_items(self):
''' Construct a list of featured Listitems '''
from resources.lib import FEATURED
Expand Down
3 changes: 2 additions & 1 deletion resources/lib/vrtplayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,9 @@ def show_channels_menu_items(self, channel=None):
self._favorites.get_favorites(ttl=60 * 60)
# Add Live TV channel entry
channel_item = self._apihelper.get_channel_items(channels=[channel])
youtube_item = self._apihelper.get_youtube_items(channels=[channel])
tvshow_items = self._apihelper.get_tvshow_items(channel=channel)
self._kodi.show_listing(channel_item + tvshow_items, sort='unsorted', content='tvshows')
self._kodi.show_listing(channel_item + youtube_item + tvshow_items, sort='unsorted', content='tvshows')
else:
channel_items = self._apihelper.get_channel_items(live=False)
self._kodi.show_listing(channel_items, cache=False)
Expand Down
9 changes: 5 additions & 4 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
<setting label="30827" help="30828" type="bool" id="addmydocu" default="true" enable="eq(-2,true)" subsetting="true"/>
<setting label="30829" help="30830" type="bool" id="showoneoff" default="true"/>
<setting label="30831" help="30832" type="bool" id="showfanart" default="true"/>
<setting label="30833" help="30834" type="bool" id="showpermalink" default="false"/>
<setting label="30835" type="lsep"/> <!-- Cache -->
<setting label="30837" help="30838" type="bool" id="usemenucaching" default="true"/>
<setting label="30839" help="30840" type="bool" id="usehttpcaching" default="true"/>
<setting label="30833" help="30834" type="bool" id="showyoutube" default="true" enable="System.HasAddon(plugin.video.youtube)"/>
<setting label="30835" help="30836" type="bool" id="showpermalink" default="false"/>
<setting label="30836" type="lsep"/> <!-- Cache -->
<setting label="30839" help="30840" type="bool" id="usemenucaching" default="true"/>
<setting label="30841" help="30843" type="bool" id="usehttpcaching" default="true"/>
</category>
<category label="30860"> <!-- Playback -->
<setting label="30861" type="lsep"/>
Expand Down

0 comments on commit 682f517

Please sign in to comment.