From e7b4feae5e605f00d6d838e0fa76ab5f60382587 Mon Sep 17 00:00:00 2001 From: mac12m99 <10120390+mac12m99@users.noreply.github.com> Date: Sat, 6 Mar 2021 15:36:58 +0100 Subject: [PATCH] Limite thread tmdb eliminato --- core/tmdb.py | 15 ++++++++++----- platformcode/launcher.py | 4 ++-- resources/settings.xml | 2 +- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/core/tmdb.py b/core/tmdb.py index 1b9046ce..34db4fca 100644 --- a/core/tmdb.py +++ b/core/tmdb.py @@ -66,6 +66,10 @@ otmdb_global = None from core import db +def clean_cache(): + db['tmdb_cache'].clear() + + # The function name is the name of the decorator and receives the function that decorates. def cache_response(fn): logger.debug() @@ -180,7 +184,8 @@ def set_infoLabels_itemlist(item_list, seekTmdb=False, idioma_busqueda=def_lang, """ Concurrently, it gets the data of the items included in the item_list. - The API has a limit of 40 requests per IP every 10 '' and that is why the list should not have more than 30 items to ensure the proper functioning of this function. + The API in the past had a limit of 40 requests per IP every 10 '', now there's no limit (https://developers.themoviedb.org/3/getting-started/request-rate-limiting) + If a limit will be re-added uncomment "tmdb_threads" and related code @param item_list: list of Item objects that represent movies, series or chapters. The infoLabels attribute of each Item object will be modified including the extra localized data. @type item_list: list @@ -197,18 +202,18 @@ def set_infoLabels_itemlist(item_list, seekTmdb=False, idioma_busqueda=def_lang, return import threading - threads_num = config.get_setting("tmdb_threads", default=20) - semaforo = threading.Semaphore(threads_num) + # threads_num = config.get_setting("tmdb_threads", default=20) + # semaforo = threading.Semaphore(threads_num) lock = threading.Lock() r_list = list() i = 0 l_hilo = list() def sub_thread(_item, _i, _seekTmdb): - semaforo.acquire() + # semaforo.acquire() ret = set_infoLabels_item(_item, _seekTmdb, idioma_busqueda, lock) # logger.debug(str(ret) + "item: " + _item.tostring()) - semaforo.release() + # semaforo.release() r_list.append((_i, _item, ret)) for item in item_list: diff --git a/platformcode/launcher.py b/platformcode/launcher.py index 58645b7f..be990434 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -134,8 +134,8 @@ def run(item=None): elif item.action == "script": from core import tmdb - if tmdb.drop_bd(): - platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60011), time=2000, sound=False) + tmdb.clean_cache() + platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60011), time=2000, sound=False) elif item.action == "itemInfo": platformtools.dialog_textviewer('Item info', item.parent) elif item.action == "open_browser": diff --git a/resources/settings.xml b/resources/settings.xml index e5e726ec..523accb4 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -90,7 +90,7 @@ - +