Skip to content

Commit

Permalink
Add a channel filter for Most recent and Soon offline (#265)
Browse files Browse the repository at this point in the history
This PR includes:
- Replace a fixed channel filter by a dynamic filter
- Add a Channels settings tab for configuring the filter
  • Loading branch information
dagwieers authored May 22, 2019
1 parent 90cd5e8 commit 0ab8859
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 40 deletions.
76 changes: 66 additions & 10 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -331,46 +331,102 @@ msgid "In case you have limited bandwidth available, you may want to specify a m
msgstr ""

msgctxt "#30860"
msgid "Troubleshooting"
msgid "Channels"
msgstr ""

msgctxt "#30861"
msgid "Cache"
msgid "Select channels to use for 'Most recent' and 'Soon offline' listings"
msgstr ""

msgctxt "#30863"
msgid "Clear VRT tokens"
msgid "Eén"
msgstr ""

msgctxt "#30864"
msgid "Canvas"
msgstr ""

msgctxt "#30865"
msgid "Refresh favorites"
msgid "Ketnet"
msgstr ""

msgctxt "#30866"
msgid "Ketnet Junior"
msgstr ""

msgctxt "#30867"
msgid "Invalidate local HTTP caches"
msgid "Sporza"
msgstr ""

msgctxt "#30868"
msgid "Radio 1"
msgstr ""

msgctxt "#30869"
msgid "Streaming"
msgid "Radio 2"
msgstr ""

msgctxt "#30870"
msgid "Klara"
msgstr ""

msgctxt "#30871"
msgid "Use InputStream Adaptive"
msgid "Studio Brussel"
msgstr ""

msgctxt "#30872"
msgid "MNM"
msgstr ""

msgctxt "#30873"
msgid "VRT NXT"
msgstr ""

msgctxt "#30874"
msgid "VRT NWS"
msgstr ""

msgctxt "#30900"
msgid "Troubleshooting"
msgstr ""

msgctxt "#30901"
msgid "Cache"
msgstr ""

msgctxt "#30903"
msgid "Clear VRT tokens"
msgstr ""

msgctxt "#30905"
msgid "Refresh favorites"
msgstr ""

msgctxt "#30907"
msgid "Invalidate local HTTP caches"
msgstr ""

msgctxt "#30909"
msgid "Streaming"
msgstr ""

msgctxt "#30911"
msgid "Use InputStream Adaptive"
msgstr ""

msgctxt "#30913"
msgid "InputStream Adaptive settings..."
msgstr ""

msgctxt "#30875"
msgctxt "#30915"
msgid "Install Widevine... [COLOR gray][I](needed for DRM content)[/I][/COLOR]"
msgstr ""

msgctxt "#30877"
msgctxt "#30917"
msgid "Logging"
msgstr ""

msgctxt "#30879"
msgctxt "#30919"
msgid "Log level"
msgstr ""

Expand Down
78 changes: 67 additions & 11 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -307,47 +307,103 @@ msgctxt "#30849"
msgid "Maximum bandwidth (kbps)"
msgstr "Maximale bandbreedte (kbps)"

msgctxt "#30060"
msgctxt "#30860"
msgid "Channels"
msgstr "Kanalen"

msgctxt "#30861"
msgid "Select channels for 'Most recent' and 'Soon offline' listings"
msgstr "Selecteer kanalen voor de 'Meest recent' en 'Binnenkort verwijderd' lijsten"

msgctxt "#30863"
msgid "Eén"
msgstr "Eén"

msgctxt "#30864"
msgid "Canvas"
msgstr "Canvas"

msgctxt "#30865"
msgid "Ketnet"
msgstr "Ketnet"

msgctxt "#30866"
msgid "Ketnet Junior"
msgstr "Ketnet Junior"

msgctxt "#30867"
msgid "Sporza"
msgstr "Sporza"

msgctxt "#30868"
msgid "Radio 1"
msgstr "Radio 1"

msgctxt "#30869"
msgid "Radio 2"
msgstr "Radio 2"

msgctxt "#30870"
msgid "Klara"
msgstr "Klara"

msgctxt "#30871"
msgid "Studio Brussel"
msgstr "Studio Brussel"

msgctxt "#30872"
msgid "MNM"
msgstr "MNM"

msgctxt "#30873"
msgid "VRT NXT"
msgstr "VRT NXT"

msgctxt "#30874"
msgid "VRT NWS"
msgstr "VRT NWS"

msgctxt "#30900"
msgid "Troubleshooting"
msgstr "Foutopsporing"

msgctxt "#30861"
msgctxt "#30901"
msgid "Cache"
msgstr "Cache"

msgctxt "#30063"
msgctxt "#30903"
msgid "Clear VRT tokens"
msgstr "Verwijder VRT tokens"

msgctxt "#30065"
msgctxt "#30905"
msgid "Refresh favorites"
msgstr "Ververs gevolgde programma's"

msgctxt "#30867"
msgctxt "#30907"
msgid "Invalidate local HTTP caches"
msgstr "Invalideer local HTTP caches"

msgctxt "#30069"
msgctxt "#30909"
msgid "Streaming"
msgstr "Streaming"

msgctxt "#30870"
msgctxt "#30911"
msgid "Use InputStream Adaptive"
msgstr "Gebruik InputStream Adaptive"

msgctxt "#30073"
msgctxt "#30913"
msgid "InputStream Adaptive settings..."
msgstr "InputStream Adaptive instellingen..."

msgctxt "#30075"
msgctxt "#30915"
msgid "Install Widevine... [COLOR gray][I](needed for DRM content)[/I][/COLOR]"
msgstr "Installeer Widevine... [COLOR gray][I](nodig voor DRM content)[/I][/COLOR]"

msgctxt "#30077"
msgctxt "#30917"
msgid "Logging"
msgstr "Logboek"

msgctxt "#30079"
msgctxt "#30919"
msgid "Log level"
msgstr "Log level"

Expand Down
5 changes: 4 additions & 1 deletion resources/lib/kodiwrappers/kodiwrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,11 @@ def update_cache(self, path, data):
def invalidate_cache(self, path):
self.delete_file(self._cache_path + path)

def invalidate_caches(self):
def invalidate_caches(self, expr=None):
import fnmatch
_, files = self.listdir(self._cache_path)
if expr:
files = fnmatch.filter(files, expr)
for f in files:
self.delete_file(self._cache_path + f)

Expand Down
9 changes: 5 additions & 4 deletions resources/lib/vrtplayer/vrtapihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from __future__ import absolute_import, division, unicode_literals
from resources.lib.helperobjects.helperobjects import TitleItem
from resources.lib.vrtplayer import actions, metadatacreator, statichelper
from resources.lib.vrtplayer import CHANNELS, actions, metadatacreator, statichelper

try:
from urllib.parse import urlencode, unquote
Expand All @@ -28,6 +28,7 @@ def __init__(self, _kodi, _favorites):
self._showfanart = _kodi.get_setting('showfanart') == 'true'
self._showpermalink = _kodi.get_setting('showpermalink') == 'true'
self._favorites = _favorites
self._channel_filter = [channel.get('name') for channel in CHANNELS if _kodi.get_setting(channel.get('name')) == 'true']

def get_tvshow_items(self, category=None, channel=None, filtered=False):
params = dict()
Expand Down Expand Up @@ -125,10 +126,10 @@ def get_episode_items(self, path=None, page=None, show_seasons=False, filtered=F

if statichelper.is_filtered(filtered):
params['facets[programName]'] = '[%s]' % (','.join(self._favorites.names()))
cache_file = '%s-filtered.json' % variety
cache_file = 'my-%s-%s.json' % (variety, page)
else:
params['facets[programBrands]'] = '[een,canvas,sporza,vrtnws,vrtnxt,radio1,radio2,klara,stubru,mnm]'
cache_file = '%s.json' % variety
params['facets[programBrands]'] = '[%s]' % ','.join(self._channel_filter)
cache_file = '%s-%s.json' % (variety, page)

# Try the cache if it is fresh
api_json = self._kodi.get_cache(cache_file, ttl=60 * 60)
Expand Down
37 changes: 26 additions & 11 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,31 @@
<setting label="30847" help="30848" type="bool" id="usedrm" default="false"/>
<setting label="30849" help="30850" type="select" id="max_bandwidth" default="0" values="0|256|512|1024|1536|2048|2560|3072|4096|6144|8192|10240|15360|20480|25600|30720"/>
</category>
<category label="30860"> <!-- Troubleshooting -->
<setting label="30861" type="lsep"/> <!-- Cache -->
<setting label="30863" help="30864" type="action" id="clear_tokens" action="RunPlugin(plugin://plugin.video.vrt.nu/?action=clearcookies)"/>
<setting label="30865" help="30866" type="action" id="refresh_favorites" action="RunPlugin(plugin://plugin.video.vrt.nu/?action=refreshfavorites)"/>
<setting label="30867" help="30868" type="action" id="invalidate_caches" action="RunPlugin(plugin://plugin.video.vrt.nu/?action=invalidatecaches)"/>
<setting label="30869" type="lsep"/> <!-- InputStream Adaptive -->
<setting label="30871" help="30872" type="bool" id="useinputstreamadaptive" default="true" visible="System.HasAddon(inputstream.adaptive)"/>
<setting label="30873" help="30874" type="action" id="adaptive_settings" option="close" action="Addon.OpenSettings(inputstream.adaptive)" visible="System.HasAddon(inputstream.adaptive)" enable="eq(-1,true)" subsetting="true"/>
<setting label="30875" help="30876" type="action" id="widevine_install" option="close" action="RunPlugin(plugin://plugin.video.vrt.nu?action=installwidevine)" visible="System.HasAddon(inputstream.adaptive)" enable="eq(-2,true)" subsetting="true"/>
<setting label="30877" type="lsep"/> <!-- Logging -->
<setting label="30879" help="30880" type="select" id="max_log_level" values="Quiet|Info|Verbose|Debug" default="Info"/>
<category label="30860"> <!--Channels -->
<setting label="30861" type="lsep"/>
<setting label="30863" type="bool" id="een" default="true"/> <!-- Eén -->
<setting label="30864" type="bool" id="canvas" default="true"/> <!-- Canvas -->
<setting label="30865" type="bool" id="ketnet" default="false"/> <!-- Ketnet -->
<setting label="30866" type="bool" id="ketnet-jr" default="false"/> <!-- Ketnet Junior -->
<setting label="30867" type="bool" id="sporza" default="true"/> <!-- Sporza -->
<setting label="30868" type="bool" id="radio1" default="true"/> <!-- Radio 1 -->
<setting label="30869" type="bool" id="radio2" default="true"/> <!-- Radio 2 -->
<setting label="30870" type="bool" id="klara" default="true"/> <!-- Klara -->
<setting label="30871" type="bool" id="stubru" default="true"/> <!-- Studio Brussel -->
<setting label="30872" type="bool" id="mnm" default="true"/> <!-- MNM -->
<setting label="30873" type="bool" id="vrtnws" default="true"/> <!-- VRT NWS -->
<setting label="30874" type="bool" id="vrtnxt" default="true"/> <!-- VRT NXT -->
</category>
<category label="30900"> <!-- Troubleshooting -->
<setting label="30901" type="lsep"/> <!-- Cache -->
<setting label="30903" help="30904" type="action" id="clear_tokens" action="RunPlugin(plugin://plugin.video.vrt.nu/?action=clearcookies)"/>
<setting label="30905" help="30906" type="action" id="refresh_favorites" action="RunPlugin(plugin://plugin.video.vrt.nu/?action=refreshfavorites)"/>
<setting label="30907" help="30908" type="action" id="invalidate_caches" action="RunPlugin(plugin://plugin.video.vrt.nu/?action=invalidatecaches)"/>
<setting label="30909" type="lsep"/> <!-- InputStream Adaptive -->
<setting label="30911" help="30912" type="bool" id="useinputstreamadaptive" default="true" visible="System.HasAddon(inputstream.adaptive)"/>
<setting label="30913" help="30914" type="action" id="adaptive_settings" option="close" action="Addon.OpenSettings(inputstream.adaptive)" visible="System.HasAddon(inputstream.adaptive)" enable="eq(-1,true)" subsetting="true"/>
<setting label="30915" help="30916" type="action" id="widevine_install" option="close" action="RunPlugin(plugin://plugin.video.vrt.nu?action=installwidevine)" visible="System.HasAddon(inputstream.adaptive)" enable="eq(-2,true)" subsetting="true"/>
<setting label="30917" type="lsep"/> <!-- Logging -->
<setting label="30919" help="30920" type="select" id="max_log_level" values="Quiet|Info|Verbose|Debug" default="Info"/>
</category>
</settings>
3 changes: 3 additions & 0 deletions service.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ def onSettingsChanged(self):
_kodi.log_notice('VRT NU Addon: settings changed')
_kodi.container_refresh()

_kodi.invalidate_caches('offline-*.json')
_kodi.invalidate_caches('recent-*.json')

_tokenresolver = tokenresolver.TokenResolver(_kodi)
_tokenresolver.reset_cookies()

Expand Down
25 changes: 22 additions & 3 deletions test/xbmcaddon.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,33 @@

# FIXME: Maybe move this to test/userdata/settings.xml ?
SETTINGS = {
# credentials
'username': 'qsdfdsq',
'password': 'qsdfqsdfds',
'log_level': 'Verbose',
'max_bandwidth': 0,
# interface
'usefavorites': 'false',
'showpermalink': 'true',
'usemenucaching': 'true',
'usehttpcaching': 'true',
# playback
'showsubtitles': 'true',
'max_bandwidth': 0,
'usedrm': 'false',
'usefavorites': 'false',
# channels
'een': 'true',
'canvas': 'true',
'ketnet': 'false',
'ketnet-jr': 'false',
'sporza': 'true',
'radio1': 'true',
'radio2': 'true',
'klara': 'true',
'stubru': 'true',
'mnm': 'true',
'vrtnws': 'true',
'vrtnxt': 'true',
# troubleshooting
'log_level': 'Verbose',
}

# Read credentials from credentials.json
Expand Down

0 comments on commit 0ab8859

Please sign in to comment.