From 44a8f0cad085dd0745ad58b6b3a2f0946e2aa054 Mon Sep 17 00:00:00 2001 From: Alhaziel01 Date: Mon, 5 Jul 2021 20:08:41 +0200 Subject: [PATCH] =?UTF-8?q?=20-=20Aggiungi=20alla=20videoteca=20se=20non?= =?UTF-8?q?=20si=20sa=20se=20=C3=A8=20un=20film=20o=20una=20serie?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/tmdb.py | 9 ++++++--- core/videolibrarytools.py | 10 ++++++++++ platformcode/launcher.py | 5 +++++ platformcode/platformtools.py | 3 +++ 4 files changed, 24 insertions(+), 3 deletions(-) diff --git a/core/tmdb.py b/core/tmdb.py index f709b555..6f3222c9 100644 --- a/core/tmdb.py +++ b/core/tmdb.py @@ -410,15 +410,18 @@ def set_infoLabels_item(item, seekTmdb=True, search_language=def_lang, lock=None # do it by title if search_type == 'tv': # Serial search by title and filtering your results if necessary - otmdb = Tmdb(searched_text=scrapertools.unescape(item.infoLabels['tvshowtitle']), search_type=search_type, + searched_title = scrapertools.unescape(item.infoLabels['tvshowtitle']) + searched_title = searched_title.split('-')[0].strip() + otmdb = Tmdb(searched_text=searched_title, search_type=search_type, search_language=search_language, filtro=item.infoLabels.get('filtro', {}), year=item.infoLabels['year']) else: # Movie search by title ... # if item.infoLabels['year'] or item.infoLabels['filtro']: # ...and year or filter - searched_title = item.contentTitle if item.contentTitle else item.fulltitle - otmdb = Tmdb(searched_text=scrapertools.unescape(searched_title), search_type=search_type, search_language=search_language, + searched_title = scrapertools.unescape(item.contentTitle if item.contentTitle else item.fulltitle) + searched_title = searched_title.split('-')[0].strip() + otmdb = Tmdb(searched_text=searched_title, search_type=search_type, search_language=search_language, filtro=item.infoLabels.get('filtro', {}), year=item.infoLabels['year']) if otmdb is not None: if otmdb.get_id() and config.get_setting("tmdb_plus_info", default=False): diff --git a/core/videolibrarytools.py b/core/videolibrarytools.py index 0d793db6..2daf2093 100644 --- a/core/videolibrarytools.py +++ b/core/videolibrarytools.py @@ -949,6 +949,14 @@ def get_local_content(path): return local_episodelist +def add_to_videolibrary(item, channel): + itemlist = getattr(channel, item.from_action)(item) + if itemlist and itemlist[0].contentType == 'episode': + return add_tvshow(item, channel) + else: + return add_movie(item) + + def add_movie(item): """ Keep a movie at the movie library. The movie can be a link within a channel or a previously downloaded video. @@ -966,6 +974,7 @@ def add_movie(item): """ logger.debug() from platformcode.launcher import set_search_temp; set_search_temp(item) + item.contentType = 'movie' # To disambiguate titles, TMDB is caused to ask for the really desired title # The user can select the title among those offered on the first screen @@ -1012,6 +1021,7 @@ def add_tvshow(item, channel=None): """ logger.debug("show=#" + item.show + "#") + item.contentType = 'tvshow' from platformcode.launcher import set_search_temp; set_search_temp(item) if item.channel == "downloads": diff --git a/platformcode/launcher.py b/platformcode/launcher.py index da9379cc..693bdd67 100644 --- a/platformcode/launcher.py +++ b/platformcode/launcher.py @@ -237,6 +237,11 @@ def run(item=None): from core import videolibrarytools videolibrarytools.add_tvshow(item, channel) + # Special action for adding a undefined to the library + elif item.action == "add_to_library": + from core import videolibrarytools + videolibrarytools.add_to_videolibrary(item, channel) + # Special action for downloading all episodes from a serie elif item.action == "download_all_episodes": from specials import downloads diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index 58cca5cc..cad27a11 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -621,6 +621,9 @@ def set_context_commands(item, item_url, parent_item, **kwargs): # Add Movie to Video Library elif item.action in ["detail", "findvideos"] and item.contentType == 'movie' and item.contentTitle: context_commands.append((config.get_localized_string(60353), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'action=add_pelicula_to_library&from_action=' + item.action))) + # Add to Video Library + elif item.action in ['check'] and item.contentTitle: + context_commands.append((config.get_localized_string(30161), "RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'action=add_to_library&from_action=' + item.action))) if not item.local and item.channel not in ["downloads", "filmontv", "search"] and item.server != 'torrent' and parent_item.action != 'mainlist' and config.get_setting('downloadenabled'): # Download movie