Add Clean Metadata setting (#34)

This commit is contained in:
Michaël Arnauts 2020-06-19 15:20:20 +02:00 committed by GitHub
parent 3477fd4aa2
commit 6ed3b1097b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 79 additions and 28 deletions

View File

@ -136,8 +136,12 @@ msgctxt "#30713"
msgid "The requested video was not found in the guide." msgid "The requested video was not found in the guide."
msgstr "" msgstr ""
msgctxt "#30714"
msgid "Local metadata is cleared."
msgstr ""
msgctxt "#30715" msgctxt "#30715"
msgid "Updating metadata" msgid "Updating metadata..."
msgstr "" msgstr ""
msgctxt "#30716" msgctxt "#30716"
@ -162,11 +166,11 @@ msgctxt "#30801"
msgid "Credentials" msgid "Credentials"
msgstr "" msgstr ""
msgctxt "#30803" msgctxt "#30802"
msgid "Email address" msgid "Email address"
msgstr "" msgstr ""
msgctxt "#30805" msgctxt "#30803"
msgid "Password" msgid "Password"
msgstr "" msgstr ""
@ -174,17 +178,21 @@ msgctxt "#30820"
msgid "Interface" msgid "Interface"
msgstr "" msgstr ""
msgctxt "#30827" msgctxt "#30821"
msgid "Metadata" msgid "Metadata"
msgstr "" msgstr ""
msgctxt "#30829" msgctxt "#30822"
msgid "Periodically refresh metadata in the background" msgid "Periodically refresh metadata in the background"
msgstr "" msgstr ""
msgctxt "#30831" msgctxt "#30823"
msgid "Update local metadata now" msgid "Update local metadata now…"
msgstr "" msgstr "De lokale metadata nu vernieuwen…"
msgctxt "#30824"
msgid "Clear local metadata…"
msgstr "De lokale metadata verwijderen…"
msgctxt "#30880" msgctxt "#30880"
msgid "Expert" msgid "Expert"

View File

@ -137,9 +137,13 @@ msgctxt "#30713"
msgid "The requested video was not found in the guide." msgid "The requested video was not found in the guide."
msgstr "De gevraagde video werd niet gevonden in de tv-gids." msgstr "De gevraagde video werd niet gevonden in de tv-gids."
msgctxt "#30714"
msgid "Local metadata is cleared."
msgstr "De lokale metadata is verwijderd."
msgctxt "#30715" msgctxt "#30715"
msgid "Updating metadata" msgid "Updating metadata..."
msgstr "Vernieuwen metadata" msgstr "Vernieuwen metadata..."
msgctxt "#30716" msgctxt "#30716"
msgid "Updating metadata ({index}/{total})..." msgid "Updating metadata ({index}/{total})..."
@ -164,11 +168,11 @@ msgctxt "#30801"
msgid "Credentials" msgid "Credentials"
msgstr "Inloggegevens" msgstr "Inloggegevens"
msgctxt "#30803" msgctxt "#30802"
msgid "Email address" msgid "Email address"
msgstr "E-mailadres" msgstr "E-mailadres"
msgctxt "#30805" msgctxt "#30803"
msgid "Password" msgid "Password"
msgstr "Wachtwoord" msgstr "Wachtwoord"
@ -176,17 +180,21 @@ msgctxt "#30820"
msgid "Interface" msgid "Interface"
msgstr "Interface" msgstr "Interface"
msgctxt "#30827" msgctxt "#30821"
msgid "Metadata" msgid "Metadata"
msgstr "Metadata" msgstr "Metadata"
msgctxt "#30829" msgctxt "#30822"
msgid "Periodically refresh metadata in the background" msgid "Periodically refresh metadata in the background"
msgstr "Vernieuw de lokale metdata automatisch in de achtergrond" msgstr "Vernieuw de lokale metdata automatisch in de achtergrond"
msgctxt "#30831" msgctxt "#30823"
msgid "Update local metadata now" msgid "Update local metadata now…"
msgstr "De lokale metadata nu vernieuwen" msgstr "De lokale metadata nu vernieuwen…"
msgctxt "#30824"
msgid "Clear local metadata…"
msgstr "De lokale metadata verwijderen…"
msgctxt "#30880" msgctxt "#30880"
msgid "Expert" msgid "Expert"

View File

@ -146,6 +146,13 @@ def metadata_update():
Metadata().update() Metadata().update()
@routing.route('/metadata/clean')
def metadata_clean():
""" Clear the metadata for the listings (called from settings) """
from resources.lib.modules.metadata import Metadata
Metadata().clean()
@routing.route('/iptv/channels') @routing.route('/iptv/channels')
def iptv_channels(): def iptv_channels():
""" Generate channel data for the Kodi PVR integration """ """ Generate channel data for the Kodi PVR integration """

View File

@ -30,7 +30,8 @@ _LOGGER = logging.getLogger('kodiutils')
class TitleItem: class TitleItem:
""" This helper object holds all information to be used with Kodi xbmc's ListItem object """ """ This helper object holds all information to be used with Kodi xbmc's ListItem object """
def __init__(self, title, path=None, art_dict=None, info_dict=None, prop_dict=None, stream_dict=None, context_menu=None, subtitles_path=None, def __init__(self, title, path=None, art_dict=None, info_dict=None, prop_dict=None, stream_dict=None,
context_menu=None, subtitles_path=None,
is_playable=False): is_playable=False):
""" The constructor for the TitleItem class """ The constructor for the TitleItem class
:type title: str :type title: str
@ -256,7 +257,8 @@ def multiselect(heading='', options=None, autoclose=0, preselect=None, use_detai
from xbmcgui import Dialog from xbmcgui import Dialog
if not heading: if not heading:
heading = addon_name() heading = addon_name()
return Dialog().multiselect(heading=heading, options=options, autoclose=autoclose, preselect=preselect, useDetails=use_details) return Dialog().multiselect(heading=heading, options=options, autoclose=autoclose, preselect=preselect,
useDetails=use_details)
class progress(xbmcgui.DialogProgress, object): # pylint: disable=invalid-name,useless-object-inheritance class progress(xbmcgui.DialogProgress, object): # pylint: disable=invalid-name,useless-object-inheritance
@ -503,3 +505,15 @@ def jsonrpc(*args, **kwargs):
if kwargs.get('jsonrpc') is None: if kwargs.get('jsonrpc') is None:
kwargs.update(jsonrpc='2.0') kwargs.update(jsonrpc='2.0')
return loads(xbmc.executeJSONRPC(dumps(kwargs))) return loads(xbmc.executeJSONRPC(dumps(kwargs)))
def listdir(path):
"""Return all files in a directory (using xbmcvfs)"""
from xbmcvfs import listdir as vfslistdir
return vfslistdir(path)
def delete(path):
"""Remove a file (using xbmcvfs)"""
from xbmcvfs import delete as vfsdelete
return vfsdelete(path)

View File

@ -18,11 +18,12 @@ class Metadata:
def update(self): def update(self):
""" Update the metadata with a foreground progress indicator """ """ Update the metadata with a foreground progress indicator """
# Create progress indicator # Create progress indicator
progress = kodiutils.progress(message=kodiutils.localize(30715)) # Updating metadata progress = kodiutils.progress(message=kodiutils.localize(30715)) # Updating metadata...
def update_status(i, total): def update_status(i, total):
""" Update the progress indicator """ """ Update the progress indicator """
progress.update(int(((i + 1) / total) * 100), kodiutils.localize(30716, index=i + 1, total=total)) # Updating metadata ({index}/{total}) progress.update(int(((i + 1) / total) * 100),
kodiutils.localize(30716, index=i + 1, total=total)) # Updating metadata ({index}/{total})...
return progress.iscanceled() return progress.iscanceled()
self.fetch_metadata(callback=update_status, refresh=True) self.fetch_metadata(callback=update_status, refresh=True)
@ -48,7 +49,18 @@ class Metadata:
# Run callback after every item # Run callback after every item
if callback and callback(index, count): if callback and callback(index, count):
# Stop when callback returns False # Stop when callback returns True
return False return False
return True return True
@staticmethod
def clean():
""" Clear metadata (called from settings) """
cache_path = kodiutils.get_cache_path()
_, files = kodiutils.listdir(cache_path)
for filename in files:
kodiutils.delete(cache_path + filename)
kodiutils.set_setting('metadata_last_updated', '0')
kodiutils.ok_dialog(message=kodiutils.localize(30714)) # Local metadata is cleared

View File

@ -213,7 +213,7 @@ class ContentApi:
programs = [] programs = []
for path in data: for path in data:
title = data[path] title = data[path]
program = self.get_program(channel, path, CACHE_ONLY) # Get program details, but from cache only program = self.get_program(channel, path, cache=CACHE_ONLY) # Get program details, but from cache only
if program: if program:
# Use program with metadata from cache # Use program with metadata from cache
programs.append(program) programs.append(program)
@ -228,6 +228,7 @@ class ContentApi:
""" Get a Program object from the specified page. """ Get a Program object from the specified page.
:type channel: str :type channel: str
:type path: str :type path: str
:type extract_clips: bool
:type cache: int :type cache: int
:rtype Program :rtype Program
""" """

View File

@ -6,13 +6,14 @@
<setting id="iptv.epg_uri" default="plugin://plugin.video.viervijfzes/iptv/epg" visible="false"/> <setting id="iptv.epg_uri" default="plugin://plugin.video.viervijfzes/iptv/epg" visible="false"/>
<category label="30800"> <!-- Credentials --> <category label="30800"> <!-- Credentials -->
<setting label="30801" type="lsep"/> <!-- Credentials --> <setting label="30801" type="lsep"/> <!-- Credentials -->
<setting label="30803" type="text" id="username"/> <setting label="30802" type="text" id="username"/>
<setting label="30805" type="text" id="password" option="hidden"/> <setting label="30803" type="text" id="password" option="hidden"/>
</category> </category>
<category label="30820"> <!-- Interface --> <category label="30820"> <!-- Interface -->
<setting label="30827" type="lsep"/> <!-- Metadata --> <setting label="30821" type="lsep"/> <!-- Metadata -->
<setting label="30829" type="bool" id="metadata_update" default="true" subsetting="true"/> <setting label="30822" type="bool" id="metadata_update" default="true" subsetting="true"/>
<setting label="30831" type="action" action="RunPlugin(plugin://plugin.video.viervijfzes/metadata/update)"/> <setting label="30823" type="action" action="RunPlugin(plugin://plugin.video.viervijfzes/metadata/update)"/>
<setting label="30824" type="action" action="RunPlugin(plugin://plugin.video.viervijfzes/metadata/clean)"/>
</category> </category>
<category label="30880"> <!-- Expert --> <category label="30880"> <!-- Expert -->
<setting label="30881" type="lsep"/> <!-- Logging --> <setting label="30881" type="lsep"/> <!-- Logging -->