Videolibrary: Borrado de Series y Películas de canales borrados
This commit is contained in:
@@ -35,7 +35,8 @@ def channel_config(item):
|
|||||||
def list_movies(item, silent=False):
|
def list_movies(item, silent=False):
|
||||||
logger.info()
|
logger.info()
|
||||||
itemlist = []
|
itemlist = []
|
||||||
|
dead_list = []
|
||||||
|
zombie_list = []
|
||||||
for raiz, subcarpetas, ficheros in filetools.walk(videolibrarytools.MOVIES_PATH):
|
for raiz, subcarpetas, ficheros in filetools.walk(videolibrarytools.MOVIES_PATH):
|
||||||
for f in ficheros:
|
for f in ficheros:
|
||||||
if f.endswith(".nfo"):
|
if f.endswith(".nfo"):
|
||||||
@@ -51,6 +52,53 @@ def list_movies(item, silent=False):
|
|||||||
|
|
||||||
head_nfo, new_item = videolibrarytools.read_nfo(nfo_path)
|
head_nfo, new_item = videolibrarytools.read_nfo(nfo_path)
|
||||||
|
|
||||||
|
if len(new_item.library_urls) > 1:
|
||||||
|
multicanal = True
|
||||||
|
else:
|
||||||
|
multicanal = False
|
||||||
|
|
||||||
|
## verifica la existencia de los canales, en caso de no existir el canal se pregunta si se quieren
|
||||||
|
## eliminar los enlaces de dicho canal
|
||||||
|
|
||||||
|
for canal_org in new_item.library_urls:
|
||||||
|
canal = generictools.verify_channel(canal_org)
|
||||||
|
logger.error(canal)
|
||||||
|
try:
|
||||||
|
channel_verify = __import__('channels.%s' % canal, fromlist=["channels.%s" % canal])
|
||||||
|
logger.debug('El canal %s parece correcto' % channel_verify)
|
||||||
|
except:
|
||||||
|
dead_item = Item(multicanal=multicanal,
|
||||||
|
contentType='movie',
|
||||||
|
dead=canal,
|
||||||
|
path=raiz,
|
||||||
|
nfo=nfo_path,
|
||||||
|
library_urls=new_item.library_urls,
|
||||||
|
infoLabels={'title': new_item.contentTitle})
|
||||||
|
if canal not in dead_list and canal not in zombie_list:
|
||||||
|
confirm = platformtools.dialog_yesno('Videoteca',
|
||||||
|
'Parece que el canal [COLOR red]%s[/COLOR] ya no existe.' % canal.upper(),
|
||||||
|
'Deseas eliminar los enlaces de este canal?')
|
||||||
|
|
||||||
|
elif canal in zombie_list:
|
||||||
|
confirm = False
|
||||||
|
else:
|
||||||
|
confirm = True
|
||||||
|
|
||||||
|
if confirm:
|
||||||
|
delete(dead_item)
|
||||||
|
if canal not in dead_list:
|
||||||
|
dead_list.append(canal)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
if canal not in zombie_list:
|
||||||
|
zombie_list.append(canal)
|
||||||
|
|
||||||
|
if len(dead_list) > 0:
|
||||||
|
for canal in dead_list:
|
||||||
|
if canal in new_item.library_urls:
|
||||||
|
del new_item.library_urls[canal]
|
||||||
|
|
||||||
|
|
||||||
new_item.nfo = nfo_path
|
new_item.nfo = nfo_path
|
||||||
new_item.path = raiz
|
new_item.path = raiz
|
||||||
new_item.thumbnail = new_item.contentThumbnail
|
new_item.thumbnail = new_item.contentThumbnail
|
||||||
@@ -85,10 +133,8 @@ def list_movies(item, silent=False):
|
|||||||
num_canales -= 1
|
num_canales -= 1
|
||||||
if num_canales > 1:
|
if num_canales > 1:
|
||||||
texto_eliminar = config.get_localized_string(60018)
|
texto_eliminar = config.get_localized_string(60018)
|
||||||
multicanal = True
|
|
||||||
else:
|
else:
|
||||||
texto_eliminar = config.get_localized_string(60019)
|
texto_eliminar = config.get_localized_string(60019)
|
||||||
multicanal = False
|
|
||||||
|
|
||||||
new_item.context = [{"title": texto_visto,
|
new_item.context = [{"title": texto_visto,
|
||||||
"action": "mark_content_as_watched",
|
"action": "mark_content_as_watched",
|
||||||
@@ -113,10 +159,12 @@ def list_movies(item, silent=False):
|
|||||||
def list_tvshows(item):
|
def list_tvshows(item):
|
||||||
logger.info()
|
logger.info()
|
||||||
itemlist = []
|
itemlist = []
|
||||||
|
dead_list = []
|
||||||
|
zombie_list = []
|
||||||
# Obtenemos todos los tvshow.nfo de la videoteca de SERIES recursivamente
|
# Obtenemos todos los tvshow.nfo de la videoteca de SERIES recursivamente
|
||||||
for raiz, subcarpetas, ficheros in filetools.walk(videolibrarytools.TVSHOWS_PATH):
|
for raiz, subcarpetas, ficheros in filetools.walk(videolibrarytools.TVSHOWS_PATH):
|
||||||
for f in ficheros:
|
for f in ficheros:
|
||||||
|
|
||||||
if f == "tvshow.nfo":
|
if f == "tvshow.nfo":
|
||||||
tvshow_path = filetools.join(raiz, f)
|
tvshow_path = filetools.join(raiz, f)
|
||||||
# logger.debug(tvshow_path)
|
# logger.debug(tvshow_path)
|
||||||
@@ -130,6 +178,54 @@ def list_tvshows(item):
|
|||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
|
|
||||||
head_nfo, item_tvshow = videolibrarytools.read_nfo(tvshow_path)
|
head_nfo, item_tvshow = videolibrarytools.read_nfo(tvshow_path)
|
||||||
|
|
||||||
|
if len(item_tvshow.library_urls) > 1:
|
||||||
|
multicanal = True
|
||||||
|
else:
|
||||||
|
multicanal = False
|
||||||
|
|
||||||
|
## verifica la existencia de los canales, en caso de no existir el canal se pregunta si se quieren
|
||||||
|
## eliminar los enlaces de dicho canal
|
||||||
|
|
||||||
|
for canal in item_tvshow.library_urls:
|
||||||
|
canal = generictools.verify_channel(canal)
|
||||||
|
try:
|
||||||
|
channel_verify = __import__('channels.%s' % canal, fromlist=["channels.%s" % canal])
|
||||||
|
logger.debug('El canal %s parece correcto' % channel_verify)
|
||||||
|
except:
|
||||||
|
dead_item = Item(multicanal=multicanal,
|
||||||
|
contentType='tvshow',
|
||||||
|
dead=canal,
|
||||||
|
path=raiz,
|
||||||
|
nfo=tvshow_path,
|
||||||
|
library_urls=item_tvshow.library_urls,
|
||||||
|
infoLabels={'title': item_tvshow.contentTitle})
|
||||||
|
if canal not in dead_list and canal not in zombie_list:
|
||||||
|
confirm = platformtools.dialog_yesno('Videoteca',
|
||||||
|
'Parece que el canal [COLOR red]%s[/COLOR] ya no existe.' % canal.upper(),
|
||||||
|
'Deseas eliminar los enlaces de este canal?')
|
||||||
|
|
||||||
|
elif canal in zombie_list:
|
||||||
|
confirm = False
|
||||||
|
else:
|
||||||
|
confirm = True
|
||||||
|
|
||||||
|
if confirm:
|
||||||
|
delete(dead_item)
|
||||||
|
if canal not in dead_list:
|
||||||
|
dead_list.append(canal)
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
if canal not in zombie_list:
|
||||||
|
zombie_list.append(canal)
|
||||||
|
|
||||||
|
if len(dead_list) > 0:
|
||||||
|
for canal in dead_list:
|
||||||
|
if canal in item_tvshow.library_urls:
|
||||||
|
del item_tvshow.library_urls[canal]
|
||||||
|
|
||||||
|
### continua la carga de los elementos de la videoteca
|
||||||
|
|
||||||
try: #A veces da errores aleatorios, por no encontrar el .nfo. Probablemente problemas de timing
|
try: #A veces da errores aleatorios, por no encontrar el .nfo. Probablemente problemas de timing
|
||||||
item_tvshow.title = item_tvshow.contentTitle
|
item_tvshow.title = item_tvshow.contentTitle
|
||||||
item_tvshow.path = raiz
|
item_tvshow.path = raiz
|
||||||
@@ -165,10 +261,8 @@ def list_tvshows(item):
|
|||||||
num_canales -= 1
|
num_canales -= 1
|
||||||
if num_canales > 1:
|
if num_canales > 1:
|
||||||
texto_eliminar = config.get_localized_string(60024)
|
texto_eliminar = config.get_localized_string(60024)
|
||||||
multicanal = True
|
|
||||||
else:
|
else:
|
||||||
texto_eliminar = config.get_localized_string(60025)
|
texto_eliminar = config.get_localized_string(60025)
|
||||||
multicanal = False
|
|
||||||
|
|
||||||
item_tvshow.context = [{"title": texto_visto,
|
item_tvshow.context = [{"title": texto_visto,
|
||||||
"action": "mark_content_as_watched",
|
"action": "mark_content_as_watched",
|
||||||
@@ -190,7 +284,14 @@ def list_tvshows(item):
|
|||||||
# "channel": "videolibrary"}]
|
# "channel": "videolibrary"}]
|
||||||
|
|
||||||
# logger.debug("item_tvshow:\n" + item_tvshow.tostring('\n'))
|
# logger.debug("item_tvshow:\n" + item_tvshow.tostring('\n'))
|
||||||
itemlist.append(item_tvshow)
|
|
||||||
|
## verifica la existencia de los canales ##
|
||||||
|
|
||||||
|
logger.debug(item_tvshow)
|
||||||
|
if len(item_tvshow.library_urls) > 0:
|
||||||
|
itemlist.append(item_tvshow)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if itemlist:
|
if itemlist:
|
||||||
itemlist = sorted(itemlist, key=lambda it: it.title.lower())
|
itemlist = sorted(itemlist, key=lambda it: it.title.lower())
|
||||||
@@ -805,41 +906,45 @@ def delete(item):
|
|||||||
heading = config.get_localized_string(70084)
|
heading = config.get_localized_string(70084)
|
||||||
else:
|
else:
|
||||||
heading = config.get_localized_string(70085)
|
heading = config.get_localized_string(70085)
|
||||||
|
|
||||||
if item.multicanal:
|
if item.multicanal:
|
||||||
# Obtener listado de canales
|
# Obtener listado de canales
|
||||||
opciones = [config.get_localized_string(70086) % k.capitalize() for k in item.library_urls.keys() if
|
if item.dead == '':
|
||||||
k != "downloads"]
|
opciones = [config.get_localized_string(70086) % k.capitalize() for k in item.library_urls.keys() if
|
||||||
opciones.insert(0, heading)
|
k != "downloads"]
|
||||||
|
opciones.insert(0, heading)
|
||||||
|
|
||||||
index = platformtools.dialog_select(config.get_localized_string(30163), opciones)
|
index = platformtools.dialog_select(config.get_localized_string(30163), opciones)
|
||||||
|
|
||||||
if index == 0:
|
if index == 0:
|
||||||
# Seleccionado Eliminar pelicula/serie
|
# Seleccionado Eliminar pelicula/serie
|
||||||
delete_all(item)
|
delete_all(item)
|
||||||
|
|
||||||
elif index > 0:
|
elif index > 0:
|
||||||
# Seleccionado Eliminar canal X
|
# Seleccionado Eliminar canal X
|
||||||
canal = opciones[index].replace(config.get_localized_string(70079), "").lower()
|
canal = opciones[index].replace(config.get_localized_string(70079), "").lower()
|
||||||
|
else:
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
canal = item.dead
|
||||||
|
|
||||||
num_enlaces = 0
|
num_enlaces = 0
|
||||||
for fd in filetools.listdir(item.path):
|
for fd in filetools.listdir(item.path):
|
||||||
if fd.endswith(canal + '].json') or scrapertools.find_single_match(fd, '%s]_\d+.torrent' % canal):
|
if fd.endswith(canal + '].json') or scrapertools.find_single_match(fd, '%s]_\d+.torrent' % canal):
|
||||||
if filetools.remove(filetools.join(item.path, fd)):
|
if filetools.remove(filetools.join(item.path, fd)):
|
||||||
num_enlaces += 1
|
num_enlaces += 1
|
||||||
|
|
||||||
if num_enlaces > 0:
|
if num_enlaces > 0:
|
||||||
# Actualizar .nfo
|
# Actualizar .nfo
|
||||||
head_nfo, item_nfo = videolibrarytools.read_nfo(item.nfo)
|
head_nfo, item_nfo = videolibrarytools.read_nfo(item.nfo)
|
||||||
del item_nfo.library_urls[canal]
|
del item_nfo.library_urls[canal]
|
||||||
if item_nfo.emergency_urls and item_nfo.emergency_urls.get(canal, False):
|
if item_nfo.emergency_urls and item_nfo.emergency_urls.get(canal, False):
|
||||||
del item_nfo.emergency_urls[canal]
|
del item_nfo.emergency_urls[canal]
|
||||||
filetools.write(item.nfo, head_nfo + item_nfo.tojson())
|
filetools.write(item.nfo, head_nfo + item_nfo.tojson())
|
||||||
|
|
||||||
msg_txt = config.get_localized_string(70087) % (num_enlaces, canal)
|
msg_txt = config.get_localized_string(70087) % (num_enlaces, canal)
|
||||||
logger.info(msg_txt)
|
logger.info(msg_txt)
|
||||||
platformtools.dialog_notification(heading, msg_txt)
|
platformtools.dialog_notification(heading, msg_txt)
|
||||||
platformtools.itemlist_refresh()
|
platformtools.itemlist_refresh()
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if platformtools.dialog_yesno(heading,
|
if platformtools.dialog_yesno(heading,
|
||||||
@@ -871,7 +976,6 @@ def check_season_playcount(item, season):
|
|||||||
|
|
||||||
def check_tvshow_playcount(item, season):
|
def check_tvshow_playcount(item, season):
|
||||||
logger.info()
|
logger.info()
|
||||||
# logger.debug(item)
|
|
||||||
if season:
|
if season:
|
||||||
temporadas_serie = 0
|
temporadas_serie = 0
|
||||||
temporadas_vistas_serie = 0
|
temporadas_vistas_serie = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user