From 2764c488056b7f7371d105879b72c68c1abf651b Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Wed, 14 Jul 2021 19:19:32 +0200 Subject: [PATCH] Fix e migliorie Videoteca - aggiunti in settings: - Converti Videoteca - Ripristina Videoteca da DB --- channels.json | 4 +- channels/seriehd.json | 2 +- channels/seriehd.py | 6 +- core/videolibrarytools.py | 137 +++++++++++++++++- platformcode/dbconverter.py | 44 +++--- .../resource.language.en_gb/strings.po | 8 + .../resource.language.it_it/strings.po | 10 +- resources/settings.xml | 2 + service.py | 113 ++++++++------- specials/videolibrary.py | 5 + 10 files changed, 241 insertions(+), 90 deletions(-) diff --git a/channels.json b/channels.json index af78f550..832ebd4d 100644 --- a/channels.json +++ b/channels.json @@ -33,6 +33,7 @@ "piratestreaming": "https://www.piratestreaming.shop", "polpotv": "https://roma.polpo.tv", "raiplay": "https://www.raiplay.it", + "seriehd": "https://seriehd.cam", "serietvonline": "https://serietvonline.art", "serietvsubita": "http://serietvsubita.xyz", "serietvu": "https://www.serietvu.link", @@ -46,7 +47,6 @@ "findhost": { "altadefinizioneclick": "https://altadefinizione-nuovo.click", "animealtadefinizione": "https://www.animealtadefinizione.it", - "filmpertutti": "https://filmpertuttiii.nuovo.live", - "seriehd": "https://nuovoindirizzo.info/seriehd" + "filmpertutti": "https://filmpertuttiii.nuovo.live" } } \ No newline at end of file diff --git a/channels/seriehd.json b/channels/seriehd.json index 9c7ade33..eda29eb2 100644 --- a/channels/seriehd.json +++ b/channels/seriehd.json @@ -1,7 +1,7 @@ { "id": "seriehd", "name": "SerieHD", - "active": false, + "active": true, "language": ["ita"], "thumbnail": "seriehd.png", "banner": "seriehd.png", diff --git a/channels/seriehd.py b/channels/seriehd.py index 34294b76..29d47500 100644 --- a/channels/seriehd.py +++ b/channels/seriehd.py @@ -5,10 +5,10 @@ from core import support -def findhost(url): - return support.match(url, patron=r']+>]+> 0 and showid > 0: - xbmc.executebuiltin('ReloadSkin()') - else: - payload = { - "jsonrpc": "2.0", - "method": "VideoLibrary.Scan", - "directory": videolibrarytools.FOLDER_TVSHOWS, - "id": 1 - } - get_data(payload) - payload = { - "jsonrpc": "2.0", - "method": "VideoLibrary.Scan", - "directory": videolibrarytools.FOLDER_MOVIES, - "id": 1 - } - get_data(payload) + while xbmc.getCondVisibility('Library.IsScanningVideo()'): pass + + payload["directory"] = videolibrarytools.FOLDER_TVSHOWS + get_data(payload) + + while xbmc.getCondVisibility('Library.IsScanningVideo()'): pass + + payload["directory"] = videolibrarytools.FOLDER_MOVIES + get_data(payload) + + while xbmc.getCondVisibility('Library.IsScanningVideo()'): pass + + xbmc.executebuiltin('ReloadSkin()') def add_video(item): @@ -223,7 +223,7 @@ class addMovie(object): get_data(payload) else: xbmc.executebuiltin('ReloadSkin()') - conn.close() + conn.close() def get_id(self): Type = 'id' + self.item.contentType.replace('tv', '').capitalize() @@ -243,7 +243,9 @@ class addMovie(object): if records: self.idParentPath = records[0][0] else: - return + self.idParentPath = get_id('idPath', 'path') + sql = 'INSERT OR IGNORE INTO path (idPath, strPath, strContent, strScraper, noUpdate) VALUES ({}, "{}", "{}", "{}", {})'.format(self.idParentPath, self.parentPath, 'movies', 'meatadata.local', 0) + nun_records, records = execute_sql_kodi(sql, conn=conn) sql = 'select idPath from path where (strPath = "{}") limit 1'.format(self.strPath) nun_records, records = execute_sql_kodi(sql, conn=conn) @@ -559,7 +561,9 @@ class addTvShow(object): if records: self.idParentPath = records[0][0] else: - return + self.idParentPath = get_id('idPath', 'path') + sql = 'INSERT OR IGNORE INTO path (idPath, strPath, strContent, strScraper, noUpdate) VALUES ({}, "{}", "{}", "{}", {})'.format(self.idParentPath, self.parentPath, 'tvshows', 'meatadata.local', 0) + nun_records, records = execute_sql_kodi(sql, conn=conn) sql = 'select idPath from path where (strPath = "{}") limit 1'.format(self.strPath) nun_records, records = execute_sql_kodi(sql, conn=conn) diff --git a/resources/language/resource.language.en_gb/strings.po b/resources/language/resource.language.en_gb/strings.po index aa485641..d4a90150 100644 --- a/resources/language/resource.language.en_gb/strings.po +++ b/resources/language/resource.language.en_gb/strings.po @@ -6167,6 +6167,14 @@ msgctxt "#70838" msgid "There are no valid content for: %s" msgstr "" +msgctxt "#70839" +msgid "Convert Videolibrary" +msgstr "" + +msgctxt "#70840" +msgid "Restore Video Library from DB" +msgstr "" + # DNS start [ settings and declaration ] msgctxt "#707401" msgid "Enable DNS check alert" diff --git a/resources/language/resource.language.it_it/strings.po b/resources/language/resource.language.it_it/strings.po index b5ec203b..ec4a611f 100644 --- a/resources/language/resource.language.it_it/strings.po +++ b/resources/language/resource.language.it_it/strings.po @@ -6166,7 +6166,15 @@ msgstr "Abilita/Disabilita Canali" msgctxt "#70838" msgid "There are no valid content for: %s" -msgstr "Non ci sono contenti validi per: %s" +msgstr "Non ci sono contenuti validi per: %s" + +msgctxt "#70839" +msgid "Convert Videolibrary" +msgstr "Converti Videoteca" + +msgctxt "#70840" +msgid "Restore Video Library from DB" +msgstr "Ripristina Videoteca da DB" # DNS start [ settings and declaration ] msgctxt "#707401" diff --git a/resources/settings.xml b/resources/settings.xml index bdd935c6..76f1cec4 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -54,6 +54,8 @@ + + diff --git a/service.py b/service.py index 9f0c814f..348adfed 100644 --- a/service.py +++ b/service.py @@ -200,65 +200,66 @@ if __name__ == "__main__": config.get_setting('folder_tvshows')) + '/" and strScraper<>"metadata.local"') if nun_records: - dialog = platformtools.dialog_progress(config.get_localized_string(20000), 'Conversione videoteca in corso') - path_to_delete = [] - film_lst = glob.glob(xbmc.translatePath( - filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_movies'), - '*/*.json'))) - tvshow_lst = glob.glob(xbmc.translatePath( - filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows'), - '*/tvshow.nfo'))) - total = len(film_lst) + len(tvshow_lst) - progress = 0 + videolibrarytools.convert_videolibrary() + # dialog = platformtools.dialog_progress(config.get_localized_string(20000), 'Conversione videoteca in corso') + # path_to_delete = [] + # film_lst = glob.glob(xbmc.translatePath( + # filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_movies'), + # '*/*.json'))) + # tvshow_lst = glob.glob(xbmc.translatePath( + # filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows'), + # '*/tvshow.nfo'))) + # total = len(film_lst) + len(tvshow_lst) + # progress = 0 - # set local info only - xbmc_videolibrary.execute_sql_kodi( - 'update path set strScraper="metadata.local", strSettings="" where strPath = "' + - filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows')) + '/"') - xbmc_videolibrary.execute_sql_kodi( - 'update path set strScraper="metadata.local", strSettings="" where strPath = "' + - filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_movies')) + '/"') + # # set local info only + # xbmc_videolibrary.execute_sql_kodi( + # 'update path set strScraper="metadata.local", strSettings="" where strPath = "' + + # filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows')) + '/"') + # xbmc_videolibrary.execute_sql_kodi( + # 'update path set strScraper="metadata.local", strSettings="" where strPath = "' + + # filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_movies')) + '/"') - for film in film_lst: - path_to_delete.append(filetools.dirname(film)) - it = Item().fromjson(filetools.read(film)) - it.infoLabels = {'tmdb_id': it.infoLabels['tmdb_id'], 'mediatype':'movie'} - tmdb.find_and_set_infoLabels(it) - videolibrarytools.save_movie(it) - progress += 1 - dialog.update(int(progress / total * 100)) - for tvshow in tvshow_lst: - if not dialog: - dialog = platformtools.dialog_progress(config.get_localized_string(20000), 'Conversione videoteca in corso') - js = jsontools.load('\n'.join(filetools.read(tvshow).splitlines()[1:])) - channels_dict = js.get('library_urls') - if channels_dict: - for ch, url in channels_dict.items(): - dir = filetools.listdir(xbmc.translatePath(filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows'), js['path']))) - json_files = [f for f in dir if f.endswith('.json')] - if json_files: - path_to_delete.append(filetools.dirname(tvshow)) - nfo, it = videolibrarytools.read_nfo(tvshow) - it.infoLabels = {'tmdb_id': it.infoLabels['tmdb_id'], 'mediatype':'tvshow'} - it.contentType = 'tvshow' - it.channel = ch - it.url = channels_dict[ch] - tmdb.find_and_set_infoLabels(it) - try: - channel = __import__('channels.%s' % ch, fromlist=['channels.%s' % ch]) - except: - channel = __import__('specials.%s' % ch, fromlist=['specials.%s' % ch]) - it.host = channel.host - episodes = getattr(channel, 'episodios')(it) - for ep in episodes: - logger.debug('EPISODE URL',ep.url) + # for film in film_lst: + # path_to_delete.append(filetools.dirname(film)) + # it = Item().fromjson(filetools.read(film)) + # it.infoLabels = {'tmdb_id': it.infoLabels['tmdb_id'], 'mediatype':'movie'} + # tmdb.find_and_set_infoLabels(it) + # videolibrarytools.save_movie(it) + # progress += 1 + # dialog.update(int(progress / total * 100)) + # for tvshow in tvshow_lst: + # if not dialog: + # dialog = platformtools.dialog_progress(config.get_localized_string(20000), 'Conversione videoteca in corso') + # js = jsontools.load('\n'.join(filetools.read(tvshow).splitlines()[1:])) + # channels_dict = js.get('library_urls') + # if channels_dict: + # for ch, url in channels_dict.items(): + # dir = filetools.listdir(xbmc.translatePath(filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows'), js['path']))) + # json_files = [f for f in dir if f.endswith('.json')] + # if json_files: + # path_to_delete.append(filetools.dirname(tvshow)) + # nfo, it = videolibrarytools.read_nfo(tvshow) + # it.infoLabels = {'tmdb_id': it.infoLabels['tmdb_id'], 'mediatype':'tvshow'} + # it.contentType = 'tvshow' + # it.channel = ch + # it.url = channels_dict[ch] + # tmdb.find_and_set_infoLabels(it) + # try: + # channel = __import__('channels.%s' % ch, fromlist=['channels.%s' % ch]) + # except: + # channel = __import__('specials.%s' % ch, fromlist=['specials.%s' % ch]) + # it.host = channel.host + # episodes = getattr(channel, 'episodios')(it) + # for ep in episodes: + # logger.debug('EPISODE URL',ep.url) - videolibrarytools.save_tvshow(it, episodes, True) - progress += 1 - dialog.update(int(progress / total * 100)) - for path in path_to_delete: - filetools.rmdirtree(path, True) - dialog.close() + # videolibrarytools.save_tvshow(it, episodes, True) + # progress += 1 + # dialog.update(int(progress / total * 100)) + # for path in path_to_delete: + # filetools.rmdirtree(path, True) + # dialog.close() if config.get_setting('autostart'): xbmc.executebuiltin('RunAddon(plugin.video.' + config.PLUGIN_NAME + ')') diff --git a/specials/videolibrary.py b/specials/videolibrary.py index f64c3bcd..b4c89488 100644 --- a/specials/videolibrary.py +++ b/specials/videolibrary.py @@ -1325,3 +1325,8 @@ def get_results(nfo_path, root, Type, local=False): # platformtools.itemlist_refresh() +def convert_videolibrary(item): + videolibrarytools.convert_videolibrary() + +def restore_videolibrary(item): + videolibrarytools.restore_videolibrary()