From 5a679b6fa8e8a897161b3a65bc96b9a05c4435a4 Mon Sep 17 00:00:00 2001 From: mac12m99 <10120390+mac12m99@users.noreply.github.com> Date: Sun, 17 Jan 2021 17:04:29 +0100 Subject: [PATCH] =?UTF-8?q?controllo=20validit=C3=A0=20canali=20in=20video?= =?UTF-8?q?teca=20spostato=20in=20findvideos,=20eliminazione=20da=20tutta?= =?UTF-8?q?=20la=20videoteca=20invece=20che=20dal=20singolo=20film/serie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- channels/casacinema.py | 1 - platformcode/platformtools.py | 14 +-- .../resource.language.en_gb/strings.po | 4 +- .../resource.language.it_it/strings.po | 8 +- specials/videolibrary.py | 94 ++++++++++--------- 5 files changed, 61 insertions(+), 60 deletions(-) diff --git a/channels/casacinema.py b/channels/casacinema.py index df59d713..375d4ff7 100644 --- a/channels/casacinema.py +++ b/channels/casacinema.py @@ -6,7 +6,6 @@ from core import support - host = support.config.get_channel_url() headers = [['Referer', host]] diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index 2a9b6a14..10e84a28 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -48,18 +48,12 @@ def dialog_notification(heading, message, icon=3, time=5000, sound=True): def dialog_yesno(heading, message, 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 PY3: - if autoclose: - return dialog.yesno(heading, message, nolabel=nolabel, yeslabel=yeslabel, customlabel=customlabel, autoclose=autoclose) - else: - return dialog.yesno(heading, message, nolabel=nolabel, yeslabel=yeslabel, customlabel=customlabel) + # customlabel only work on kodi 19 + if PY3 and customlabel: + return dialog.yesno(heading, message, customlabel, nolabel=nolabel, yeslabel=yeslabel, autoclose=autoclose) else: - if autoclose: - return dialog.yesno(heading, message, nolabel=nolabel, yeslabel=yeslabel, autoclose=autoclose) - else: - return dialog.yesno(heading, message, nolabel=nolabel, yeslabel=yeslabel) + return dialog.yesno(heading, message, nolabel=nolabel, yeslabel=yeslabel, autoclose=autoclose) def dialog_select(heading, _list, preselect=0, useDetails=False): diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index f098276c..170e15eb 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -320,7 +320,7 @@ msgid "It seems that the Channel %s no longer exists." msgstr "" msgctxt "#30133" -msgid "Do you want to remove links from this channel?" +msgid "Do you want to remove ALL links from this channel?" msgstr "" msgctxt "#30135" @@ -665,7 +665,7 @@ msgid "No connector for the server %s" msgstr "" msgctxt "#60005" -msgid "" +msgid "Deleting all links from channel %s" msgstr "" msgctxt "#60006" diff --git a/resources/language/resource.language.it_it/strings.po b/resources/language/resource.language.it_it/strings.po index fd0f8ba8..e8d7196d 100644 --- a/resources/language/resource.language.it_it/strings.po +++ b/resources/language/resource.language.it_it/strings.po @@ -320,8 +320,8 @@ msgid "It seems that the Channel %s no longer exists." msgstr "Sembra che il canale %s non esista più." msgctxt "#30133" -msgid "Do you want to remove links from this channel?" -msgstr "Vuoi rimuovere i collegamenti da questo canale?" +msgid "Do you want to remove ALL links from this channel?" +msgstr "Vuoi rimuovere TUTTI i collegamenti da questo canale?" msgctxt "#30135" msgid "The movie "%s" has been added to the video library" @@ -664,8 +664,8 @@ msgid "No connector for the server %s" msgstr "Non c'è nessun connettore per il server %s" msgctxt "#60005" -msgid "" -msgstr "" +msgid "Deleting all links from channel %s" +msgstr "Eliminando tutti i link del canale %s" msgctxt "#60006" msgid "[B]An error has occurred in %s:[/B]" diff --git a/specials/videolibrary.py b/specials/videolibrary.py index 115cb460..69ee043e 100644 --- a/specials/videolibrary.py +++ b/specials/videolibrary.py @@ -87,8 +87,6 @@ def list_tvshows(item): def get_results(nfo_path, root, Type, local=False): - dead_list = [] - zombie_list = [] value = 0 if Type == 'movie': folder = "folder_movies" else: folder = "folder_tvshows" @@ -107,40 +105,6 @@ def get_results(nfo_path, root, Type, local=False): if len(item.library_urls) > 1: multichannel = True else: multichannel = False - # Verify the existence of the channels. If the channel does not exist, ask yourself if you want to remove the links from that channel. - - for canal in item.library_urls: - try: - if canal in ['community', 'downloads']: channel_verify = __import__('specials.%s' % canal, fromlist=["channels.%s" % canal]) - else: channel_verify = __import__('channels.%s' % canal, fromlist=["channels.%s" % canal]) - logger.debug('Channel %s seems correct' % channel_verify) - except: - dead_item = Item(multichannel=multichannel, - contentType='tvshow', - dead=canal, - path=filetools.split(nfo_path)[0], - nfo=nfo_path, - library_urls=item.library_urls, - infoLabels={'title': item.contentTitle}) - - if canal not in dead_list and canal not in zombie_list: confirm = platformtools.dialog_yesno(config.get_localized_string(30131), config.get_localized_string(30132) % canal.upper() + '\n' + config.get_localized_string(30133)) - 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.library_urls: - del item.library_urls[canal] - # continue loading the elements of the video library if Type == 'movie': item.path = filetools.split(nfo_path)[0] @@ -377,6 +341,8 @@ def get_episodes(item): def findvideos(item): from core import autoplay + from platformcode import platformtools + logger.debug() # logger.debug("item:\n" + item.tostring('\n')) videolibrarytools.check_renumber_options(item) @@ -436,7 +402,6 @@ def findvideos(item): if item_local: opciones.append(item_local.title) - from platformcode import platformtools index = platformtools.dialog_select(config.get_localized_string(30163), opciones) if index < 0: return [] @@ -449,6 +414,7 @@ def findvideos(item): filtro_canal = opciones[index].replace(config.get_localized_string(70078), "").strip() itemlist = [] + all_videolibrary = [] for nom_canal, json_path in list(list_canales.items()): if filtro_canal and filtro_canal != nom_canal.capitalize(): continue @@ -463,6 +429,50 @@ def findvideos(item): channel = __import__('channels.%s' % nom_canal, fromlist=["channels.%s" % nom_canal]) except ImportError: exec("import channels." + nom_canal + " as channel") + except: + dead_list = [] + zombie_list = [] + + if nom_canal not in dead_list and nom_canal not in zombie_list: confirm = platformtools.dialog_yesno(config.get_localized_string(30131), config.get_localized_string(30132) % nom_canal.upper() + '\n' + config.get_localized_string(30133)) + elif nom_canal in zombie_list: confirm = False + else: confirm = True + + if confirm: + # delete the channel from all movie and tvshow + from past.utils import old_div + num_enlaces = 0 + dialog = platformtools.dialog_progress(config.get_localized_string(30131), config.get_localized_string(60005) % nom_canal) + if not all_videolibrary: + all_videolibrary = list_movies(Item()) + list_tvshows(Item()) + for n, it in enumerate(all_videolibrary): + if nom_canal in it.library_urls: + dead_item = Item(multichannel=len(item.library_urls) > 1, + contentType=it.contentType, + dead=nom_canal, + path=filetools.split(it.nfo)[0], + nfo=it.nfo, + library_urls=it.library_urls, + infoLabels={'title': it.contentTitle}) + num_enlaces += delete(dead_item) + dialog.update(old_div(100*n, len(all_videolibrary))) + + dialog.close() + msg_txt = config.get_localized_string(70087) % (num_enlaces, nom_canal) + logger.info(msg_txt) + platformtools.dialog_notification(config.get_localized_string(30131), msg_txt) + platformtools.itemlist_refresh() + + if nom_canal not in dead_list: + dead_list.append(nom_canal) + continue + else: + if nom_canal not in zombie_list: + zombie_list.append(nom_canal) + + if len(dead_list) > 0: + for nom_canal in dead_list: + if nom_canal in item.library_urls: + del item.library_urls[nom_canal] item_json = Item().fromjson(filetools.read(json_path)) list_servers = [] @@ -1048,15 +1058,13 @@ def delete(item): if item_nfo.emergency_urls and item_nfo.emergency_urls.get(canal, False): del item_nfo.emergency_urls[canal] filetools.write(item.nfo, head_nfo + item_nfo.tojson()) - - msg_txt = config.get_localized_string(70087) % (num_enlaces, canal) - logger.info(msg_txt) - platformtools.dialog_notification(heading, msg_txt) - platformtools.itemlist_refresh() - + return num_enlaces else: if platformtools.dialog_yesno(heading, config.get_localized_string(70088) % item.infoLabels['title']): delete_all(item) + return 1 + else: + return 0 def check_season_playcount(item, season):