- Aggiorna Episodi da menu Contestuale (libreria)

- Selezione automatica path delle serie locali se presenti in libreria
This commit is contained in:
Alhaziel01
2020-07-17 17:42:49 +02:00
parent 5764ac6185
commit a5062e8ea3
9 changed files with 180 additions and 33 deletions

View File

@@ -6,6 +6,14 @@
<import addon="metadata.tvdb.com"/>
<import addon="script.module.web-pdb" />
</requires>
<extension point="kodi.context.item">
<menu id="kodi.core.main">
<item library="updatetvshow.py">
<label>70269</label>
<visible>String.IsEqual(ListItem.dbtype,tvshow)</visible>
</item>
</menu>
</extension>
<extension point="xbmc.python.pluginsource" library="default.py">
<provides>video</provides>
</extension>

View File

@@ -578,10 +578,11 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
update = False
nfo_path = filetools.join(path, "tvshow.nfo")
head_nfo, item_nfo = read_nfo(nfo_path)
if item_nfo.update_last:
local_episodes_path = item_nfo.local_episodes_path
elif config.get_setting("local_episodes", "videolibrary"):
done, local_episodes_path = config_local_episodes_path(path, serie.show)
done, local_episodes_path = config_local_episodes_path(path, serie)
if done < 0:
logger.info("An issue has occurred while configuring local episodes, going out without creating strm")
return 0, 0, done
@@ -884,23 +885,25 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True):
return insertados, sobreescritos, fallidos
def config_local_episodes_path(path, title, silent=False):
logger.info()
local_episodes_path = ''
if not silent:
silent = platformtools.dialog_yesno(config.get_localized_string(30131), config.get_localized_string(80044) % title)
if silent:
if config.is_xbmc() and not config.get_setting("videolibrary_kodi"):
platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(80043))
local_episodes_path = platformtools.dialog_browse(0, config.get_localized_string(80046))
if local_episodes_path == '':
logger.info("User has canceled the dialog")
return -2, local_episodes_path
elif path in local_episodes_path:
platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(80045))
logger.info("Selected folder is the same of the TV show one")
return -2, local_episodes_path
def config_local_episodes_path(path, item, silent=False):
logger.info(item)
from platformcode.xbmc_videolibrary import search_local_path
local_episodes_path=search_local_path(item)
if not local_episodes_path:
title = item.contentSerieName if item.contentSerieName else item.show
if not silent:
silent = platformtools.dialog_yesno(config.get_localized_string(30131), config.get_localized_string(80044) % title)
if silent:
if config.is_xbmc() and not config.get_setting("videolibrary_kodi"):
platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(80043))
local_episodes_path = platformtools.dialog_browse(0, config.get_localized_string(80046))
if local_episodes_path == '':
logger.info("User has canceled the dialog")
return -2, local_episodes_path
elif path in local_episodes_path:
platformtools.dialog_ok(config.get_localized_string(30131), config.get_localized_string(80045))
logger.info("Selected folder is the same of the TV show one")
return -2, local_episodes_path
if local_episodes_path:
# import artwork

View File

@@ -52,7 +52,7 @@ def dialog_notification(heading, message, icon=3, time=5000, sound=True):
dialog_ok(heading, message)
def dialog_yesno(heading, line1, line2="", line3="", nolabel="No", yeslabel="Si", autoclose=0, customlabel=None):
def dialog_yesno(heading, line1, line2="", line3="", nolabel=config.get_localized_string(70170), yeslabel=config.get_localized_string(30022), autoclose=0, customlabel=None):
# customlabel only on kodi 19
dialog = xbmcgui.Dialog()
if config.get_platform() == 'kodi-matrix':

View File

@@ -525,6 +525,21 @@ def search_library_path():
return None
def search_local_path(item):
ids = [item.infoLabels['imdb_id'], item.infoLabels['tmdb_id'], item.infoLabels['tvdb_id']]
for Id in ids:
nun_ids, ids = execute_sql_kodi('SELECT idShow FROM tvshow_view WHERE uniqueid_value LIKE "%s"' % Id)
if nun_ids >= 1:
nun_records, records = execute_sql_kodi('SELECT idPath FROM tvshowlinkpath WHERE idShow LIKE "%s"' % ids[0][0])
if nun_records >= 1:
for record in records:
num_path, path_records = execute_sql_kodi('SELECT strPath FROM path WHERE idPath LIKE "%s"' % record[0])
for path in path_records:
if config.get_setting('videolibrarypath') not in path[0]:
return path[0]
return ''
def set_content(content_type, silent=False, custom=False):
"""
Procedure to auto-configure the kodi video library with the default values

View File

@@ -6029,15 +6029,15 @@ msgstr ""
msgctxt "#70807"
msgid "Elementum does not support network folder downloads, do you want to change the download location?"
msgstr "Elementum non supporta i download su cartella di rete, vuoi cambiare il percorso di download?"
msgstr ""
msgctxt "#70808"
msgid "In order to view this content you need to install [B]Widevine CDM[/B]. Do you want to install it?"
msgstr "Per poter visionare questo contenuto devi installare [B]Widevine CDM[/B]. Vuoi installarlo?"
msgstr ""
msgctxt "#70809"
msgid "An update of [B]Widevine CDM[/B] is available. Do you want to install it?"
msgstr "È disponibile un aggiornamento di [B]Widevine CDM[/B]. Vuoi installarlo?"
msgstr ""
msgctxt "#70810"
msgid "Update available"
@@ -6045,27 +6045,31 @@ msgstr "Aggiornamento disponibile"
msgctxt "#70811"
msgid "Extracting Widevine CDM"
msgstr "Estrazione di Widevine CDM"
msgstr ""
msgctxt "#70812"
msgid "Preparing downloaded image..."
msgstr "Preparazione dell'immagine scaricata..."
msgstr ""
msgctxt "#70813"
msgid "Identifying wanted partition..."
msgstr "Identificazione della partizione desiderata..."
msgstr ""
msgctxt "#70814"
msgid "Scanning the filesystem for the Widevine CDM..."
msgstr "Scansione del filesystem per Widevine CDM..."
msgstr "."
msgctxt "#70815"
msgid "Widevine CDM found, analyzing..."
msgstr "Widevine CDM trovato, analisi..."
msgstr "W"
msgctxt "#70816"
msgid "Extracting Widevine CDM from image..."
msgstr "Estrazione di Widevine CDM dall'immagine..."
msgstr ""
msgctxt "#70817"
msgid "La Serie "%s" non è gestita da KoD, Vuoi cercarla?"
msgstr ""
# DNS start [ settings and declaration ]
msgctxt "#707401"

View File

@@ -6067,6 +6067,10 @@ msgctxt "#70816"
msgid "Extracting Widevine CDM from image..."
msgstr "Estrazione di Widevine CDM dall'immagine..."
msgctxt "#70817"
msgid "La Serie "%s" non è gestita da KoD, Vuoi cercarla?"
msgstr "La Serie "%s" non è gestita da KoD, Vuoi cercarla?"
# DNS start [ settings and declaration ]
msgctxt "#707401"
msgid "Enable DNS check alert"
@@ -6406,4 +6410,4 @@ msgstr "Rimuovi episodi in locale"
msgctxt "#80050"
msgid "Downloading..."
msgstr "Download in corso..."
msgstr "Download in corso..."

View File

@@ -21,10 +21,12 @@ from servers import torrent
def update(path, p_dialog, i, t, serie, overwrite):
logger.info("Updating " + path)
insertados_total = 0
nfo_file = xbmc.translatePath(filetools.join(path, 'tvshow.nfo'))
head_nfo, it = videolibrarytools.read_nfo(path + '/tvshow.nfo')
# videolibrarytools.check_renumber_options(it)
head_nfo, it = videolibrarytools.read_nfo(nfo_file)
videolibrarytools.update_renumber_options(it, head_nfo, path)
if not serie.library_url: serie = it
category = serie.category
# logger.debug("%s: %s" %(serie.contentSerieName,str(list_canales) ))
@@ -34,7 +36,7 @@ def update(path, p_dialog, i, t, serie, overwrite):
###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial
try:
head_nfo, it = videolibrarytools.read_nfo(path + '/tvshow.nfo') #Refresca el .nfo para recoger actualizaciones
head_nfo, it = videolibrarytools.read_nfo(nfo_file) #Refresca el .nfo para recoger actualizaciones
if it.emergency_urls:
serie.emergency_urls = it.emergency_urls
serie.category = category

View File

@@ -727,7 +727,7 @@ def update_tvshow(item):
def add_local_episodes(item):
logger.info()
done, local_episodes_path = videolibrarytools.config_local_episodes_path(item.path, item.contentSerieName, silent=True)
done, local_episodes_path = videolibrarytools.config_local_episodes_path(item.path, item, silent=True)
if done < 0:
logger.info("An issue has occurred while configuring local episodes")
elif local_episodes_path:

111
updatetvshow.py Normal file
View File

@@ -0,0 +1,111 @@
# -*- coding: utf-8 -*-
import xbmc, sys, base64, json, xbmcgui, os, xbmcvfs, traceback
from platformcode import config, logger
from lib.sambatools import libsmb as samba
from core import scrapertools
def exists(path, silent=False, vfs=True):
path = xbmc.translatePath(path)
try:
if vfs:
result = bool(xbmcvfs.exists(path))
if not result and not path.endswith('/') and not path.endswith('\\'):
result = bool(xbmcvfs.exists(join(path, ' ').rstrip()))
return result
elif path.lower().startswith("smb://"):
return samba.exists(path)
else:
return os.path.exists(path)
except:
logger.error("ERROR when checking the path: %s" % path)
if not silent:
logger.error(traceback.format_exc())
return False
def join(*paths):
list_path = []
if paths[0].startswith("/"):
list_path.append("")
for path in paths:
if path:
list_path += path.replace("\\", "/").strip("/").split("/")
if scrapertools.find_single_match(paths[0], r'(^\w+:\/\/)'):
return str("/".join(list_path))
else:
return str(os.sep.join(list_path))
def search_paths(Id):
records = execute_sql('SELECT idPath FROM tvshowlinkpath WHERE idShow LIKE "%s"' % Id)
if len(records) >= 1:
for record in records:
path_records = execute_sql('SELECT strPath FROM path WHERE idPath LIKE "%s"' % record[0])
for path in path_records:
if config.get_setting('videolibrarypath') in path[0] and exists(join(path[0], 'tvshow.nfo')):
return path[0]
return ''
def execute_sql(sql):
logger.info()
file_db = ""
records = None
# We look for the archive of the video database according to the version of kodi
video_db = config.get_platform(True)['video_db']
if video_db:
file_db = os.path.join(xbmc.translatePath("special://userdata/Database"), video_db)
# alternative method to locate the database
if not file_db or not os.path.exists(file_db):
file_db = ""
for f in os.path.listdir(xbmc.translatePath("special://userdata/Database")):
path_f = os.path.join(xbmc.translatePath("special://userdata/Database"), f)
if os.path.pathoos.pathols.isfile(path_f) and f.lower().startswith('myvideos') and f.lower().endswith('.db'):
file_db = path_f
break
if file_db:
logger.info("DB file: %s" % file_db)
conn = None
try:
import sqlite3
conn = sqlite3.connect(file_db)
cursor = conn.cursor()
logger.info("Running sql: %s" % sql)
cursor.execute(sql)
conn.commit()
records = cursor.fetchall()
if sql.lower().startswith("select"):
if len(records) == 1 and records[0][0] is None:
records = []
conn.close()
logger.info("Query executed. Records: %s" % nun_records)
except:
logger.error("Error executing sql query")
if conn:
conn.close()
else:
logger.debug("Database not found")
return records
if __name__ == '__main__':
path = search_paths(sys.listitem.getVideoInfoTag().getDbId())
if path:
item = {"action": "update_tvshow", "channel": "videolibrary", 'path':path}
xbmc.executebuiltin("RunPlugin(plugin://plugin.video.kod/?" + base64.b64encode(json.dumps(item).encode()) + ")")
else:
dialog = xbmcgui.Dialog()
title = sys.listitem.getVideoInfoTag().getTitle()
if dialog.yesno(title, config.get_localized_string(70817) % title, nolabel=config.get_localized_string(70170), yeslabel=config.get_localized_string(30022)):
item = {"action": "new_search", "channel": "search", "mode":"tvshow", "search_text": sys.listitem.getVideoInfoTag().getTitle()}
xbmc.executebuiltin("ActivateWindow(10025,plugin://plugin.video.kod/?" + base64.b64encode(json.dumps(item).encode()) + ")")