Skip to content

Commit

Permalink
Add option to completely remove VRT NU resumepoints
Browse files Browse the repository at this point in the history
  • Loading branch information
mediaminister committed Dec 20, 2019
1 parent de0b6d7 commit b01feef
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 23 deletions.
26 changes: 19 additions & 7 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -773,34 +773,38 @@ msgid "Refresh watching activity"
msgstr ""

msgctxt "#30921"
msgid "Remove watching activity"
msgstr ""

msgctxt "#30923"
msgid "Use menu caching"
msgstr ""

msgctxt "#30922"
msgctxt "#30924"
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. You can also use [B]Refresh[/B] from the context-menu."
msgstr ""

msgctxt "#30923"
msgctxt "#30925"
msgid "Use local HTTP caching"
msgstr ""

msgctxt "#30925"
msgctxt "#30927"
msgid "Invalidate local HTTP caches"
msgstr ""

msgctxt "#30927"
msgctxt "#30929"
msgid "Direct HTTP cache time-to-live [COLOR gray](in minutes)[/COLOR]"
msgstr ""

msgctxt "#30929"
msgctxt "#30931"
msgid "Indirect HTTP cache time-to-live [COLOR gray](in minutes)[/COLOR]"
msgstr ""

msgctxt "#30931"
msgctxt "#30933"
msgid "Logging"
msgstr ""

msgctxt "#30933"
msgctxt "#30935"
msgid "Log level"
msgstr ""

Expand Down Expand Up @@ -913,3 +917,11 @@ msgstr ""
msgctxt "#30986"
msgid "No on demand stream available for {title}."
msgstr ""

msgctxt "#30987"
msgid "Are you sure you want to permantly remove all VRT NU watching activity?"
msgstr ""

msgctxt "#30988"
msgid "Successfully removed watching activity."
msgstr ""
26 changes: 19 additions & 7 deletions resources/language/resource.language.nl_nl/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -773,34 +773,38 @@ msgid "Refresh watching activity"
msgstr "Ververs kijkactiviteit"

msgctxt "#30921"
msgid "Remove watching activity"
msgstr "Verwijder kijkactiviteit"

msgctxt "#30923"
msgid "Use menu caching"
msgstr "Gebruik menu caching"

msgctxt "#30922"
msgctxt "#30924"
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. You can also use [B]Refresh[/B] from the context-menu."
msgstr "Indien geactiveerd worden Kodi menus gecached zodat ze sneller werken. Enkel in heel uitzonderlijke gevallen is het interessanter noodzakelijk om altijd nieuwe episodes te zijn als ze uitkomen. Je kan ook [B]Ververs[/B] gebruiken vanuit het context-menu."

msgctxt "#30923"
msgctxt "#30925"
msgid "Use local HTTP caching"
msgstr "Gebruik lokale HTTP caching"

msgctxt "#30925"
msgctxt "#30927"
msgid "Invalidate local HTTP caches"
msgstr "Maak lokale HTTP caches ongeldig"

msgctxt "#30927"
msgctxt "#30929"
msgid "Direct HTTP cache time-to-live [COLOR gray](in minutes)[/COLOR]"
msgstr "Directe HTTP cache time-to-live [COLOR gray](in minuten)[/COLOR]"

msgctxt "#30929"
msgctxt "#30931"
msgid "Indirect HTTP cache time-to-live [COLOR gray](in minutes)[/COLOR]"
msgstr "Indirecte HTTP cache time-to-live [COLOR gray](in minuten)[/COLOR]"

msgctxt "#30931"
msgctxt "#30933"
msgid "Logging"
msgstr "Logboek"

msgctxt "#30933"
msgctxt "#30935"
msgid "Log level"
msgstr "Log niveau"

Expand Down Expand Up @@ -913,3 +917,11 @@ msgstr "VRT tokens werden verwijderd."
msgctxt "#30986"
msgid "No on demand stream available for {title}."
msgstr "Geen on demand stream beschikbaar voor {title}"

msgctxt "#30987"
msgid "Are you sure you want to permantly remove all VRT NU watching activity?"
msgstr "Ben je zeker dat je alle VRT NU kijkactiviteit permanent wil verwijderen?"

msgctxt "#30988"
msgid "Successfully removed watching activity."
msgstr "Kijkactiviteit werd verwijderd."
7 changes: 7 additions & 0 deletions resources/lib/addon.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ def resumepoints_watchlater():
VRTPlayer().show_watchlater_menu(page=1)


@plugin.route('/resumepoints/remove')
def resumepoints_remove():
"""Remove all VRT NU resumepoints online and locally"""
from resumepoints import ResumePoints
ResumePoints().remove_resumepoints()


@plugin.route('/programs')
@plugin.route('/programs/<program>')
@plugin.route('/programs/<program>/<season>')
Expand Down
8 changes: 8 additions & 0 deletions resources/lib/kodiutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,14 @@ def ok_dialog(heading='', message=''):
return Dialog().ok(heading=heading, line1=message)


def yesno_dialog(heading='', message=''):
"""Show Kodi's Yes/No dialog"""
from xbmcgui import Dialog
if not heading:
heading = addon_name()
return Dialog().yesno(heading=heading, line1=message)


def notification(heading='', message='', icon='info', time=4000):
"""Show a Kodi notification"""
from xbmcgui import Dialog
Expand Down
30 changes: 28 additions & 2 deletions resources/lib/resumepoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from urllib2 import build_opener, HTTPError, install_opener, ProxyHandler, Request, urlopen

from data import SECONDS_MARGIN
from kodiutils import (container_refresh, get_cache, get_proxies, get_setting, get_url_json, has_credentials,
input_down, invalidate_caches, localize, log, log_error, notification, update_cache)
from kodiutils import (addon_name, container_refresh, get_cache, get_proxies, get_setting, get_url_json, has_credentials,
input_down, invalidate_caches, localize, log, log_error, notification, update_cache, yesno_dialog)


class ResumePoints:
Expand Down Expand Up @@ -223,6 +223,32 @@ def resumepoints_urls(self):
return [self.get_url(asset_id) for asset_id in self._data
if self.still_watching(self.get_position(asset_id), self.get_total(asset_id))]

def remove_resumepoints(self):
"""Remove all VRT NU resumepoints online and locally"""
confirmation = yesno_dialog(heading=addon_name(), message=localize(30987))
if confirmation:
# Reset internal respresentation
self._data = dict()

# Invalidate all resumepoint related caches
caches = ['resume_points.json', 'continue-*.json', 'watchlater-*.json']
invalidate_caches(*caches)

# Get all VRT NU Resumepoints and delete
resumepoints_url = 'https://video-user-data.vrt.be/resume_points'
resumepoints_json = get_url_json(url=resumepoints_url, headers=self.resumepoint_headers())
for key, _ in resumepoints_json.items():
# Delete
url = 'https://video-user-data.vrt.be/resume_points/%s' % key
req = Request(url, headers=self.resumepoint_headers())
req.get_method = lambda: 'DELETE'
result = urlopen(req)
if result.getcode() == 200:
log(3, "[Resumepoints] {key} deleted", key=key)
notification(message=localize(30988))
return True
return False

@staticmethod
def still_watching(position, total):
"""Determine if the video is still being watched"""
Expand Down
15 changes: 8 additions & 7 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,13 @@
<setting label="30915" help="30916" type="action" action="RunPlugin(plugin://plugin.video.vrt.nu/tokens/delete)"/> <!-- Delete tokens -->
<setting label="30917" help="30918" type="action" action="RunPlugin(plugin://plugin.video.vrt.nu/favorites/refresh)"/> <!-- Refresh favorites -->
<setting label="30919" help="30920" type="action" action="RunPlugin(plugin://plugin.video.vrt.nu/resumepoints/refresh)"/> <!-- Refresh resumepoints -->
<setting label="30921" help="30922" type="bool" id="usemenucaching" default="true"/>
<setting label="30923" help="30924" type="bool" id="usehttpcaching" default="true"/>
<setting label="30925" help="30926" type="action" action="RunPlugin(plugin://plugin.video.vrt.nu/cache/delete)" enable="eq(-1,true)" subsetting="true"/>
<setting label="30927" help="30928" type="slider" id="httpcachettldirect" default="5" range="1,1,240" option="int" enable="eq(-2,true)" subsetting="true"/>
<setting label="30929" help="30930" type="slider" id="httpcachettlindirect" default="60" range="1,1,240" option="int" enable="eq(-3,true)" subsetting="true"/>
<setting label="30931" type="lsep"/> <!-- Logging -->
<setting label="30933" help="30934" type="enum" id="max_log_level" lvalues="30430|30431|30432|30433" default="0"/>
<setting label="30921" help="30922" type="action" action="RunPlugin(plugin://plugin.video.vrt.nu/resumepoints/remove)"/> <!-- Remove resumepoints -->
<setting label="30923" help="30924" type="bool" id="usemenucaching" default="true"/>
<setting label="30925" help="30926" type="bool" id="usehttpcaching" default="true"/>
<setting label="30927" help="30928" type="action" action="RunPlugin(plugin://plugin.video.vrt.nu/cache/delete)" enable="eq(-1,true)" subsetting="true"/>
<setting label="30929" help="30930" type="slider" id="httpcachettldirect" default="5" range="1,1,240" option="int" enable="eq(-2,true)" subsetting="true"/>
<setting label="30931" help="30932" type="slider" id="httpcachettlindirect" default="60" range="1,1,240" option="int" enable="eq(-3,true)" subsetting="true"/>
<setting label="30933" type="lsep"/> <!-- Logging -->
<setting label="30935" help="30936" type="enum" id="max_log_level" lvalues="30430|30431|30432|30433" default="0"/>
</category>
</settings>

0 comments on commit b01feef

Please sign in to comment.