Backup Rinumerazione in tvshow.info
This commit is contained in:
@@ -234,12 +234,54 @@ def save_movie(item):
|
||||
p_dialog.close()
|
||||
return 0, 0, -1
|
||||
|
||||
def update_renumber_options(item, head_nfo, path):
|
||||
from core import jsontools
|
||||
# from core.support import dbg;dbg()
|
||||
tvshow_path = filetools.join(path, 'tvshow.nfo')
|
||||
for channel in item.channel_prefs:
|
||||
filename = filetools.join(config.get_data_path(), "settings_channels", channel + '_data.json')
|
||||
|
||||
json_file = jsontools.load(filetools.read(filename))
|
||||
if 'TVSHOW_AUTORENUMBER' in json_file:
|
||||
json = json_file['TVSHOW_AUTORENUMBER']
|
||||
if item.fulltitle in json:
|
||||
item.channel_prefs[channel]['TVSHOW_AUTORENUMBER'] = json[item.fulltitle]
|
||||
logger.info('UPDATED=\n' + str(item.channel_prefs))
|
||||
filetools.write(tvshow_path, head_nfo + item.tojson())
|
||||
|
||||
def add_renumber_options(item, head_nfo, path):
|
||||
from core import jsontools
|
||||
# from core.support import dbg;dbg()
|
||||
ret = None
|
||||
filename = filetools.join(config.get_data_path(), "settings_channels", item.channel + '_data.json')
|
||||
json_file = jsontools.load(filetools.read(filename))
|
||||
if 'TVSHOW_AUTORENUMBER' in json_file:
|
||||
json = json_file['TVSHOW_AUTORENUMBER']
|
||||
if item.fulltitle in json:
|
||||
ret = json[item.fulltitle]
|
||||
return ret
|
||||
|
||||
def check_renumber_options(item):
|
||||
from specials.autorenumber import load, write
|
||||
for key in item.channel_prefs:
|
||||
if 'TVSHOW_AUTORENUMBER' in item.channel_prefs[key]:
|
||||
item.channel = key
|
||||
json = load(item)
|
||||
if not json or item.fulltitle not in json:
|
||||
json[item.fulltitle] = item.channel_prefs[key]['TVSHOW_AUTORENUMBER']
|
||||
write(item, json)
|
||||
|
||||
# head_nfo, tvshow_item = read_nfo(filetools.join(item.context[0]['nfo']))
|
||||
# if tvshow_item['channel_prefs'][item.fullti]
|
||||
|
||||
|
||||
def filter_list(episodelist, action=None, path=None):
|
||||
# if path: path = path.decode('utf8')
|
||||
# import xbmc
|
||||
# if xbmc.getCondVisibility('system.platform.windows') > 0: path = path.replace('smb:','').replace('/','\\')
|
||||
channel_prefs = {}
|
||||
lang_sel = quality_sel = show_title = channel =''
|
||||
# from core.support import dbg;dbg()
|
||||
if action:
|
||||
tvshow_path = filetools.join(path, "tvshow.nfo")
|
||||
head_nfo, tvshow_item = read_nfo(tvshow_path)
|
||||
@@ -253,8 +295,13 @@ def filter_list(episodelist, action=None, path=None):
|
||||
filetools.remove(filetools.join(path, File))
|
||||
if channel not in tvshow_item.channel_prefs:
|
||||
tvshow_item.channel_prefs[channel] = {}
|
||||
|
||||
channel_prefs = tvshow_item.channel_prefs[channel]
|
||||
|
||||
renumber = add_renumber_options(episodelist[0], head_nfo, tvshow_path)
|
||||
if renumber:
|
||||
channel_prefs['TVSHOW_AUTORENUMBER'] = renumber
|
||||
|
||||
if action == 'get_seasons':
|
||||
if 'favourite_language' not in channel_prefs:
|
||||
channel_prefs['favourite_language'] = ''
|
||||
|
||||
@@ -57,6 +57,11 @@ def renumber(itemlist, item='', typography=''):
|
||||
if item:
|
||||
item.channel = item.from_channel if item.from_channel else item.channel
|
||||
title = item.fulltitle.rstrip()
|
||||
if item.channel in item.channel_prefs and TAG_TVSHOW_RENUMERATE in item.channel_prefs[item.channel] and title not in dict_series:
|
||||
from core.videolibrarytools import check_renumber_options
|
||||
from specials.videolibrary import update_videolibrary
|
||||
check_renumber_options(item)
|
||||
update_videolibrary(item)
|
||||
|
||||
if inspect.stack()[2][3] == 'find_episodes':
|
||||
return itemlist
|
||||
|
||||
@@ -318,6 +318,8 @@ def get_seasons(item):
|
||||
itemlist = []
|
||||
dict_temp = {}
|
||||
|
||||
videolibrarytools.check_renumber_options(item)
|
||||
|
||||
raiz, carpetas_series, ficheros = next(filetools.walk(item.path))
|
||||
|
||||
# Menu contextual: Releer tvshow.nfo
|
||||
@@ -441,6 +443,7 @@ def findvideos(item):
|
||||
from specials import autoplay
|
||||
logger.info()
|
||||
# logger.debug("item:\n" + item.tostring('\n'))
|
||||
videolibrarytools.check_renumber_options(item)
|
||||
|
||||
itemlist = []
|
||||
list_canales = {}
|
||||
|
||||
@@ -26,17 +26,19 @@ from platformcode import updater
|
||||
|
||||
|
||||
def update(path, p_dialog, i, t, serie, overwrite):
|
||||
logger.info("Actualizando " + path)
|
||||
logger.info("Updating " + path)
|
||||
insertados_total = 0
|
||||
|
||||
|
||||
head_nfo, it = videolibrarytools.read_nfo(path + '/tvshow.nfo')
|
||||
# videolibrarytools.check_renumber_options(it)
|
||||
videolibrarytools.update_renumber_options(it, head_nfo, path)
|
||||
category = serie.category
|
||||
|
||||
# logger.debug("%s: %s" %(serie.contentSerieName,str(list_canales) ))
|
||||
for channel, url in serie.library_urls.items():
|
||||
serie.channel = channel
|
||||
serie.url = url
|
||||
|
||||
|
||||
###### 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
|
||||
@@ -102,18 +104,18 @@ def update(path, p_dialog, i, t, serie, overwrite):
|
||||
xbmc_videolibrary.mark_content_as_watched_on_alfa(path + '/tvshow.nfo')
|
||||
except:
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
return insertados_total > 0
|
||||
|
||||
|
||||
def check_for_update(overwrite=True):
|
||||
logger.info("Actualizando series...")
|
||||
logger.info("Update Series...")
|
||||
p_dialog = None
|
||||
serie_actualizada = False
|
||||
update_when_finished = False
|
||||
hoy = datetime.date.today()
|
||||
estado_verify_playcount_series = False
|
||||
|
||||
|
||||
try:
|
||||
if config.get_setting("update", "videolibrary") != 0 or overwrite:
|
||||
config.set_setting("updatelibrary_last_check", hoy.strftime('%Y-%m-%d'), "videolibrary")
|
||||
@@ -132,10 +134,10 @@ def check_for_update(overwrite=True):
|
||||
for i, tvshow_file in enumerate(show_list):
|
||||
head_nfo, serie = videolibrarytools.read_nfo(tvshow_file)
|
||||
path = filetools.dirname(tvshow_file)
|
||||
|
||||
|
||||
logger.info("serie=" + serie.contentSerieName)
|
||||
p_dialog.update(int(math.ceil((i + 1) * t)), heading, serie.contentSerieName)
|
||||
|
||||
|
||||
#Verificamos el estado del serie.library_playcounts de la Serie por si está incompleto
|
||||
try:
|
||||
estado = False
|
||||
@@ -161,7 +163,7 @@ def check_for_update(overwrite=True):
|
||||
xbmc_videolibrary.mark_content_as_watched_on_alfa(path + '/tvshow.nfo')
|
||||
except:
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
continue
|
||||
|
||||
# obtenemos las fecha de actualizacion y de la proxima programada para esta serie
|
||||
@@ -209,7 +211,7 @@ def check_for_update(overwrite=True):
|
||||
serie_actualizada = update(path, p_dialog, i, t, serie, overwrite)
|
||||
if not serie_actualizada:
|
||||
update_next += datetime.timedelta(days=interval)
|
||||
|
||||
|
||||
if serie_actualizada:
|
||||
update_last = hoy
|
||||
update_next = hoy + datetime.timedelta(days=interval)
|
||||
@@ -235,7 +237,7 @@ def check_for_update(overwrite=True):
|
||||
|
||||
if estado_verify_playcount_series: #Si se ha cambiado algún playcount, ...
|
||||
estado = config.set_setting("verify_playcount", True, "videolibrary") #... actualizamos la opción de Videolibrary
|
||||
|
||||
|
||||
if config.get_setting("search_new_content", "videolibrary") == 1 and update_when_finished:
|
||||
# Actualizamos la videoteca de Kodi: Buscar contenido en todas las series
|
||||
if config.is_xbmc():
|
||||
@@ -255,7 +257,7 @@ def check_for_update(overwrite=True):
|
||||
|
||||
if p_dialog:
|
||||
p_dialog.close()
|
||||
|
||||
|
||||
from core.item import Item
|
||||
item_dummy = Item()
|
||||
videolibrary.list_movies(item_dummy, silent=True)
|
||||
@@ -409,7 +411,7 @@ if __name__ == "__main__":
|
||||
|
||||
if not config.get_setting("update", "videolibrary") == 2:
|
||||
check_for_update(overwrite=False)
|
||||
|
||||
|
||||
|
||||
# Se ejecuta ciclicamente
|
||||
if config.get_platform(True)['num_version'] >= 14:
|
||||
|
||||
Reference in New Issue
Block a user