Skip to content

Commit

Permalink
Add Tubed integration
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaminister committed Apr 21, 2021
1 parent 9d4c264 commit 5a39be7
Show file tree
Hide file tree
Showing 9 changed files with 89 additions and 41 deletions.
32 changes: 24 additions & 8 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -762,38 +762,54 @@ msgid "YouTube settings…"
msgstr ""

msgctxt "#30869"
msgid "Install Up Next add-on…"
msgid "Install Tubed add-on…"
msgstr ""

msgctxt "#30870"
msgid "This enables a Netflix style pop up notification for watching the next episode using the Up Next service add-on."
msgid "Show YouTube channel content in the Channels menu."
msgstr ""

msgctxt "#30871"
msgid "Enable Up Next integration"
msgid "Enable Tubed integration"
msgstr ""

msgctxt "#30873"
msgid "Tubed settings…"
msgstr ""

msgctxt "#30875"
msgid "Install Up Next add-on…"
msgstr ""

msgctxt "#30876"
msgid "This enables a Netflix style pop up notification for watching the next episode using the Up Next service add-on."
msgstr ""

msgctxt "#30877"
msgid "Enable Up Next integration"
msgstr ""

msgctxt "#30879"
msgid "Up Next settings…"
msgstr ""

msgctxt "#30874"
msgctxt "#30880"
msgid "Open Up Next service add-on settings."
msgstr ""

msgctxt "#30875"
msgctxt "#30881"
msgid "Install IPTV Manager add-on…"
msgstr ""

msgctxt "#30877"
msgctxt "#30883"
msgid "Enable IPTV Manager integration"
msgstr ""

msgctxt "#30879"
msgctxt "#30885"
msgid "IPTV Manager settings…"
msgstr ""

msgctxt "#30881"
msgctxt "#30887"
msgid "Install PySocks library…"
msgstr ""

Expand Down
32 changes: 24 additions & 8 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -762,38 +762,54 @@ msgid "YouTube settings…"
msgstr "YouTube instellingen…"

msgctxt "#30869"
msgid "Install Tubed add-on…"
msgstr "Installeer de Tubed add-on…"

msgctxt "#30870"
msgid "Show YouTube channel content in the Channels menu."
msgstr "Toon YouTube kanaal video's in het Kanalen menu."

msgctxt "#30871"
msgid "Enable Tubed integration"
msgstr "Activeer Tubed integratie"

msgctxt "#30873"
msgid "Tubed settings…"
msgstr "Tubed instellingen…"

msgctxt "#30875"
msgid "Install Up Next add-on…"
msgstr "Installeer de Up Next add-on…"

msgctxt "#30870"
msgctxt "#30876"
msgid "This enables a Netflix style pop up notification for watching the next episode using the Up Next service add-on."
msgstr "Dit activeert een pop-upmelding in Netflix-stijl voor het bekijken van de volgende aflevering met de service-add-up Up Next."

msgctxt "#30871"
msgctxt "#30877"
msgid "Enable Up Next integration"
msgstr "Activeer Up Next integratie"

msgctxt "#30873"
msgctxt "#30879"
msgid "Up Next settings…"
msgstr "Up Next instellingen…"

msgctxt "#30874"
msgctxt "#30880"
msgid "Open Up Next service add-on settings."
msgstr "Open de Up Next service add-on instellingen."

msgctxt "#30875"
msgctxt "#30881"
msgid "Install IPTV Manager add-on…"
msgstr "Installeer de IPTV Manager add-on…"

msgctxt "#30877"
msgctxt "#30883"
msgid "Enable IPTV Manager integration"
msgstr "Activeer IPTV Manager integratie"

msgctxt "#30879"
msgctxt "#30885"
msgid "IPTV Manager settings…"
msgstr "IPTV Manager instellingen…"

msgctxt "#30881"
msgctxt "#30887"
msgid "Install PySocks library…"
msgstr "Installeer de PySocks library…"

Expand Down
15 changes: 10 additions & 5 deletions resources/lib/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
from data import CHANNELS
from helperobjects import TitleItem
from kodiutils import (delete_cached_thumbnail, get_cache, get_cached_url_json, get_global_setting,
get_setting_bool, get_setting_int, get_url_json, has_addon, localize,
localize_from_data, log, ttl, update_cache, url_for)
get_setting_bool, get_setting_int, get_url_json, has_addon, kodi_version_major, localize,
localize_from_data, log, ttl, update_cache, url_for, youtube_to_plugin_url)
from metadata import Metadata
from utils import (add_https_proto, html_to_kodi, find_entry, from_unicode, play_url_to_id,
program_to_url, realpage, url_to_program, youtube_to_plugin_url)
program_to_url, realpage, url_to_program)


class ApiHelper:
Expand Down Expand Up @@ -735,8 +735,13 @@ def list_youtube(channels=None):

youtube_items = []

if not has_addon('plugin.video.youtube') or not get_setting_bool('showyoutube', default=True):
return youtube_items
if kodi_version_major() > 18:
if (not (has_addon('plugin.video.youtube') and get_setting_bool('showyoutube', default=True)
or has_addon('plugin.video.tubed') and get_setting_bool('showtubed', default=True))):
return youtube_items
else:
if not (has_addon('plugin.video.youtube') and get_setting_bool('showyoutube', default=True)):
return youtube_items

for channel in CHANNELS:
if channels and channel.get('name') not in channels:
Expand Down
12 changes: 12 additions & 0 deletions resources/lib/kodiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ def url_for(name, *args, **kwargs):
return addon.plugin.url_for(getattr(addon, name), *args, **kwargs)


def youtube_to_plugin_url(url):
"""Convert a YouTube URL to a Kodi plugin URL"""
if kodi_version_major() > 18 and has_addon('plugin.video.tubed'):
replace_str = 'plugin://plugin.video.tubed/'
else:
replace_str = 'plugin://plugin.video.youtube/'
url = url.replace('https://www.youtube.com/', replace_str)
if not url.endswith('/'):
url += '/'
return url


def show_listing(list_items, category=None, sort='unsorted', ascending=True, content=None, cache=None, selected=None):
"""Show a virtual directory in Kodi"""
from xbmcgui import ListItem
Expand Down
8 changes: 0 additions & 8 deletions resources/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,11 +239,3 @@ def realpage(page):
def find_entry(dlist, key, value, default=None):
"""Find (the first) dictionary in a list where key matches value"""
return next((entry for entry in dlist if entry.get(key) == value), default)


def youtube_to_plugin_url(url):
"""Convert a YouTube URL to a Kodi plugin URL"""
url = url.replace('https://www.youtube.com/', 'plugin://plugin.video.youtube/')
if not url.endswith('/'):
url += '/'
return url
18 changes: 11 additions & 7 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,22 @@
<setting label="30863" help="30864" type="action" action="InstallAddon(plugin.video.youtube)" option="close" visible="!System.HasAddon(plugin.video.youtube)"/> <!-- Install YouTube add-on -->
<setting label="30865" help="30866" type="bool" id="showyoutube" default="true" visible="System.HasAddon(plugin.video.youtube)"/>
<setting label="30867" help="30868" type="action" option="close" action="Addon.OpenSettings(plugin.video.youtube)" enable="eq(-1,true)" visible="System.HasAddon(plugin.video.youtube)" subsetting="true"/> <!-- YouTube settings -->
<!-- Tubed -->
<setting label="30869" help="30870" type="action" action="InstallAddon(plugin.video.tubed)" option="close" visible="!System.HasAddon(plugin.video.tubed) + String.StartsWith(System.BuildVersion,19)"/>
<setting label="30871" help="30872" type="bool" id="showtubed" default="true" visible="System.HasAddon(plugin.video.tubed)"/>
<setting label="30873" help="30874" type="action" option="close" action="Addon.OpenSettings(plugin.video.tubed)" enable="eq(-1,true)" visible="System.HasAddon(plugin.video.tubed)" subsetting="true"/> <!-- Tubed settings -->
<!-- Up Next -->
<setting label="30869" help="30870" type="action" action="InstallAddon(service.upnext)" option="close" visible="!System.HasAddon(service.upnext)"/> <!-- Install Up Next add-on -->
<setting label="30871" help="30872" type="bool" id="useupnext" default="true" visible="System.HasAddon(service.upnext)" />
<setting label="30873" help="30874" type="action" action="Addon.OpenSettings(service.upnext)" enable="eq(-1,true)" option="close" visible="System.HasAddon(service.upnext)" subsetting="true"/> <!-- Up Next settings -->
<setting label="30875" help="30876" type="action" action="InstallAddon(service.upnext)" option="close" visible="!System.HasAddon(service.upnext)"/> <!-- Install Up Next add-on -->
<setting label="30877" help="30878" type="bool" id="useupnext" default="true" visible="System.HasAddon(service.upnext)" />
<setting label="30879" help="30880" type="action" action="Addon.OpenSettings(service.upnext)" enable="eq(-1,true)" option="close" visible="System.HasAddon(service.upnext)" subsetting="true"/> <!-- Up Next settings -->
<!-- IPTV Manager -->
<setting label="30875" help="30876" type="action" action="InstallAddon(service.iptv.manager)" option="close" visible="!System.HasAddon(service.iptv.manager)"/> <!-- Install IPTV Manager add-on -->
<setting label="30877" help="30878" type="bool" id="iptv.enabled" default="true" visible="String.StartsWith(System.BuildVersion,18) + System.HasAddon(service.iptv.manager) | System.AddonIsEnabled(service.iptv.manager)" />
<setting label="30879" help="30880" type="action" action="Addon.OpenSettings(service.iptv.manager)" enable="eq(-1,true)" option="close" visible="String.StartsWith(System.BuildVersion,18) + System.HasAddon(service.iptv.manager) | System.AddonIsEnabled(service.iptv.manager)" subsetting="true"/> <!-- IPTV Manager settings -->
<setting label="30881" help="30882" type="action" action="InstallAddon(service.iptv.manager)" option="close" visible="!System.HasAddon(service.iptv.manager)"/> <!-- Install IPTV Manager add-on -->
<setting label="30883" help="30884" type="bool" id="iptv.enabled" default="true" visible="String.StartsWith(System.BuildVersion,18) + System.HasAddon(service.iptv.manager) | System.AddonIsEnabled(service.iptv.manager)" />
<setting label="30885" help="30886" type="action" action="Addon.OpenSettings(service.iptv.manager)" enable="eq(-1,true)" option="close" visible="String.StartsWith(System.BuildVersion,18) + System.HasAddon(service.iptv.manager) | System.AddonIsEnabled(service.iptv.manager)" subsetting="true"/> <!-- IPTV Manager settings -->
<setting id="iptv.channels_uri" default="plugin://plugin.video.vrt.nu/iptv/channels" visible="false"/>
<setting id="iptv.epg_uri" default="plugin://plugin.video.vrt.nu/iptv/epg" visible="false"/>
<!-- PySocks -->
<setting label="30881" help="30882" type="action" action="InstallAddon(script.module.pysocks)" option="close" visible="!System.HasAddon(script.module.pysocks)"/>
<setting label="30887" help="30884" type="action" action="InstallAddon(script.module.pysocks)" option="close" visible="!System.HasAddon(script.module.pysocks)"/>
</category>
<category label="30890"> <!-- Updates -->
<setting label="30891" type="lsep"/> <!-- Update the VRT NU add-on -->
Expand Down
7 changes: 7 additions & 0 deletions tests/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def tearDown(self):
addon.settings['showfanart'] = True
addon.settings['showoneoff'] = True
addon.settings['showyoutube'] = True
addon.settings['showtubed'] = True
addon.settings['usedrm'] = True
addon.settings['usefavorites'] = True
addon.settings['usehttpcaching'] = True
Expand Down Expand Up @@ -88,6 +89,12 @@ def test_youtube_disabled():
addon.settings['showyoutube'] = False
plugin.run(['plugin://plugin.video.vrt.nu/channels/radio1', '0', ''])

@staticmethod
def test_tubed_disabled():
"""Test with showtubed disabled"""
addon.settings['showtubed'] = False
plugin.run(['plugin://plugin.video.vrt.nu/channels/radio1', '0', ''])

@staticmethod
def test_showfanart_disabled():
"""Test with showfanart disabled"""
Expand Down
5 changes: 0 additions & 5 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,6 @@ def test_find_entry(self):
needle = utils.find_entry(haystack, 'foo', 'blah', dict(foo='f', bar='r', baz='z'))
self.assertEqual(needle, dict(foo='f', bar='r', baz='z'))

def test_youtube_to_plugin_url(self):
"""youtube_to_plugin_url"""
self.assertEqual('plugin://plugin.video.youtube/foo/bar/', utils.youtube_to_plugin_url('https://www.youtube.com/foo/bar'))
self.assertEqual('plugin://plugin.video.youtube/foo/bar/baz/', utils.youtube_to_plugin_url('https://www.youtube.com/foo/bar/baz/'))


if __name__ == '__main__':
unittest.main()
1 change: 1 addition & 0 deletions tests/userdata/addon_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"showpermalink": "true",
"showsubtitles": "true",
"showyoutube": "true",
"showtubed": "true",
"sporza": "true",
"stubru": "true",
"usedrm": "true",
Expand Down

0 comments on commit 5a39be7

Please sign in to comment.