From 3fe4f99e402f18d919b22d2de3b9b25fde52990a Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 27 May 2018 19:53:55 +0200 Subject: [PATCH 1/4] Add files via upload --- plugin.video.alfa/channels/videolibrary.json | 24 +++++++++++++++++++- plugin.video.alfa/channels/videolibrary.py | 7 +++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/plugin.video.alfa/channels/videolibrary.json b/plugin.video.alfa/channels/videolibrary.json index b2c541da..e0caf59c 100755 --- a/plugin.video.alfa/channels/videolibrary.json +++ b/plugin.video.alfa/channels/videolibrary.json @@ -70,11 +70,33 @@ "Toda la videoteca" ] }, + { + "id": "addition", + "type": "label", + "label": "Añadir a la videoteca", + "enabled": true, + "visible": true + }, + { + "id": "enable_filter", + "type": "bool", + "label": " Excluir los streams que contienen etiquetas específicas", + "enabled": true, + "visible": true, + "default": false + }, + { + "id": "filters", + "type": "text", + "label": " Etiquetas", + "visible": true, + "enabled": "eq(-1,true)" + }, { "id": "window_type", "type": "list", "label": "Mostrar los enlaces en", - "default": 0, + "default": 1, "enabled": true, "visible": true, "lvalues": [ diff --git a/plugin.video.alfa/channels/videolibrary.py b/plugin.video.alfa/channels/videolibrary.py index c173eb0c..2374362b 100644 --- a/plugin.video.alfa/channels/videolibrary.py +++ b/plugin.video.alfa/channels/videolibrary.py @@ -596,7 +596,12 @@ def mark_tvshow_as_updatable(item): def delete(item): def delete_all(_item): - filetools.rmdirtree(_item.path) + for file in filetools.listdir(_item.path): + if file.endswith(".strm") or file.endswith(".nfo") or file.endswith(".json"): + filetools.remove(filetools.join(_item.path, file)) + raiz, carpeta_serie, ficheros = filetools.walk(_item.path).next() + if ficheros == []: + filetools.rmdir(_item.path) if config.is_xbmc(): import xbmc From 5e49b8b6e1042ce2f2eaba67e8e61187727e6faa Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 27 May 2018 19:54:52 +0200 Subject: [PATCH 2/4] Add files via upload --- plugin.video.alfa/core/scraper.py | 1 + plugin.video.alfa/core/scrapertools.py | 6 +++--- plugin.video.alfa/core/videolibrarytools.py | 20 ++++++++++++++++++-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/plugin.video.alfa/core/scraper.py b/plugin.video.alfa/core/scraper.py index 1dcef673..897270f3 100755 --- a/plugin.video.alfa/core/scraper.py +++ b/plugin.video.alfa/core/scraper.py @@ -263,6 +263,7 @@ def get_nfo(item): def sort_episode_list(episodelist): + episodelist.sort(key=lambda e: e.title, reverse=True) scraper_actual = ['tmdb', 'tvdb'][config.get_setting("scraper_tvshows", "videolibrary")] if scraper_actual == "tmdb": diff --git a/plugin.video.alfa/core/scrapertools.py b/plugin.video.alfa/core/scrapertools.py index 5682ae82..faa20dde 100755 --- a/plugin.video.alfa/core/scrapertools.py +++ b/plugin.video.alfa/core/scrapertools.py @@ -458,14 +458,14 @@ def get_season_and_episode(title): """ filename = "" - patrons = ["(\d+)x(\d+)", "(\d+)×(\d+)", "(?:s|t)(\d+)e(\d+)", - "(?:season|temp\w*)\s*(\d+)\s*(?:capitulo|epi\w*)\s*(\d+)"] + patrons = ["(\d+)\s*[x-]\s*(\d+)", "(\d+)\s*×\s*(\d+)", "(?:s|t)(\d+)e(\d+)", + "(?:season|temp\w*)\s*(\d+)\s*(?:capitulo|epi|episode\w*)\s*(\d+)"] for patron in patrons: try: matches = re.compile(patron, re.I).search(title) if matches: - filename = matches.group(1) + "x" + matches.group(2).zfill(2) + filename = matches.group(1).lstrip('0') + "x" + matches.group(2).zfill(2) break except: pass diff --git a/plugin.video.alfa/core/videolibrarytools.py b/plugin.video.alfa/core/videolibrarytools.py index 2fcae901..eae0b8e7 100644 --- a/plugin.video.alfa/core/videolibrarytools.py +++ b/plugin.video.alfa/core/videolibrarytools.py @@ -123,7 +123,7 @@ def save_movie(item): else: base_name = item.contentTitle - base_name = unicode(filetools.validate_path(base_name.replace('/', '-')), "utf8").lower().encode("utf8") + base_name = unicode(filetools.validate_path(base_name.replace('/', '-')), "utf8").encode("utf8") for raiz, subcarpetas, ficheros in filetools.walk(MOVIES_PATH): for c in subcarpetas: @@ -244,7 +244,7 @@ def save_tvshow(item, episodelist): else: base_name = item.contentSerieName - base_name = unicode(filetools.validate_path(base_name.replace('/', '-')), "utf8").lower().encode("utf8") + base_name = unicode(filetools.validate_path(base_name.replace('/', '-')), "utf8").encode("utf8") for raiz, subcarpetas, ficheros in filetools.walk(TVSHOWS_PATH): for c in subcarpetas: @@ -348,6 +348,15 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): raiz, carpetas_series, ficheros = filetools.walk(path).next() ficheros = [filetools.join(path, f) for f in ficheros] + nostrm_episodelist = [] + for root, folders, files in filetools.walk(path): + for file in files: + season_episode = scrapertools.get_season_and_episode(file) + if season_episode == "" or filetools.exists(filetools.join(path, "%s.strm" % season_episode)): + continue + nostrm_episodelist.append(season_episode) + nostrm_episodelist = sorted(set(nostrm_episodelist)) + # Silent es para no mostrar progreso (para videolibrary_service) if not silent: # progress dialog @@ -356,7 +365,12 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): new_episodelist = [] # Obtenemos el numero de temporada y episodio y descartamos los q no lo sean + tags = [] + if config.get_setting("enable_filter", "videolibrary"): + tags = [x.strip() for x in config.get_setting("filters", "videolibrary").lower().split(",")] for e in episodelist: + if tags != [] and tags != None and any(tag in e.title.lower() for tag in tags): + continue try: season_episode = scrapertools.get_season_and_episode(e.title) @@ -383,6 +397,8 @@ def save_episodes(path, episodelist, serie, silent=False, overwrite=True): nfo_path = filetools.join(path, "%s.nfo" % season_episode) json_path = filetools.join(path, ("%s [%s].json" % (season_episode, e.channel)).lower()) + if season_episode in nostrm_episodelist: + continue strm_exists = strm_path in ficheros nfo_exists = nfo_path in ficheros json_exists = json_path in ficheros From 1afe4b750d6e97cb37a779ded34a9f3333dd5c42 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 27 May 2018 19:55:48 +0200 Subject: [PATCH 3/4] Add files via upload --- plugin.video.alfa/platformcode/config.py | 7 +- plugin.video.alfa/platformcode/launcher.py | 4 +- .../platformcode/xbmc_videolibrary.py | 222 ++++++++++-------- 3 files changed, 124 insertions(+), 109 deletions(-) diff --git a/plugin.video.alfa/platformcode/config.py b/plugin.video.alfa/platformcode/config.py index 2ca5f15f..ac49a136 100644 --- a/plugin.video.alfa/platformcode/config.py +++ b/plugin.video.alfa/platformcode/config.py @@ -352,7 +352,6 @@ def verify_directories_created(): config_paths = [["folder_movies", "CINE"], ["folder_tvshows", "SERIES"]] - flag_call = True for path, default in config_paths: saved_path = get_setting(path) @@ -365,11 +364,7 @@ def verify_directories_created(): logger.debug("Creating %s: %s" % (path, content_path)) # si se crea el directorio - if filetools.mkdir(content_path): - if flag_call: - # le pasamos el valor para que sepamos que se ha pasado por creación de directorio - xbmc_videolibrary.ask_set_content(1) - flag_call = False + filetools.mkdir(content_path) try: from core import scrapertools diff --git a/plugin.video.alfa/platformcode/launcher.py b/plugin.video.alfa/platformcode/launcher.py index cc62f933..c775d746 100644 --- a/plugin.video.alfa/platformcode/launcher.py +++ b/plugin.video.alfa/platformcode/launcher.py @@ -52,8 +52,8 @@ def run(item=None): else: item = Item(channel="channelselector", action="getmainlist", viewmode="movie") if not config.get_setting('show_once'): - platformtools.dialog_ok('Alfa', 'Alfa recomienda para mejorar tu experiencia:', - 'Palomitas, relajate y disfruta.') + from platformcode import xbmc_videolibrary + xbmc_videolibrary.ask_set_content(1) config.set_setting('show_once', True) logger.info(item.tostring()) diff --git a/plugin.video.alfa/platformcode/xbmc_videolibrary.py b/plugin.video.alfa/platformcode/xbmc_videolibrary.py index 8650dc70..38358fdb 100755 --- a/plugin.video.alfa/platformcode/xbmc_videolibrary.py +++ b/plugin.video.alfa/platformcode/xbmc_videolibrary.py @@ -440,102 +440,115 @@ def set_content(content_type, silent=False): videolibrarypath = config.get_setting("videolibrarypath") if content_type == 'movie': - if not xbmc.getCondVisibility('System.HasAddon(metadata.themoviedb.org)'): - if not silent: - # Preguntar si queremos instalar metadata.themoviedb.org - install = platformtools.dialog_yesno("The Movie Database", - "No se ha encontrado el Scraper de películas de TheMovieDB.", - "¿Desea instalarlo ahora?") - else: - install = True + scraper = ["The Movie Database", "Universal Movie Scraper"] + seleccion = platformtools.dialog_select("Seleccione el scraper para las películas", scraper) - if install: - try: - # Instalar metadata.themoviedb.org - xbmc.executebuiltin('xbmc.installaddon(metadata.themoviedb.org)', True) - logger.info("Instalado el Scraper de películas de TheMovieDB") - except: - pass + # Instalar The Movie Database + if seleccion == -1 or seleccion == 0: + if not xbmc.getCondVisibility('System.HasAddon(metadata.themoviedb.org)'): + if not silent: + # Preguntar si queremos instalar metadata.themoviedb.org + install = platformtools.dialog_yesno("The Movie Database", + "No se ha encontrado el Scraper de películas de TheMovieDB.", + "¿Desea instalarlo ahora?") + else: + install = True - continuar = (install and xbmc.getCondVisibility('System.HasAddon(metadata.themoviedb.org)')) - if not continuar: - msg_text = "The Movie Database no instalado." + if install: + try: + # Instalar metadata.themoviedb.org + xbmc.executebuiltin('xbmc.installaddon(metadata.themoviedb.org)', True) + logger.info("Instalado el Scraper de películas de TheMovieDB") + except: + pass + + continuar = (install and xbmc.getCondVisibility('System.HasAddon(metadata.themoviedb.org)')) + if not continuar: + msg_text = "The Movie Database no instalado." + if continuar: + xbmc.executebuiltin('xbmc.addon.opensettings(metadata.themoviedb.org)', True) + + # Instalar Universal Movie Scraper + elif seleccion == 1: + if continuar and not xbmc.getCondVisibility('System.HasAddon(metadata.universal)'): + continuar = False + if not silent: + # Preguntar si queremos instalar metadata.universal + install = platformtools.dialog_yesno("Universal Movie Scraper", + "No se ha encontrado el Scraper de series de TheMovieDB.", + "¿Desea instalarlo ahora?") + else: + install = True + + if install: + try: + xbmc.executebuiltin('xbmc.installaddon(metadata.universal)', True) + if xbmc.getCondVisibility('System.HasAddon(metadata.universal)'): + continuar = True + except: + pass + + continuar = (install and continuar) + if not continuar: + msg_text = "Universal Movie Scraper no instalado." + if continuar: + xbmc.executebuiltin('xbmc.addon.opensettings(metadata.universal)', True) else: # SERIES + scraper = ["The TVDB", "The Movie Database"] + seleccion = platformtools.dialog_select("Seleccione el scraper para las series", scraper) + # Instalar The TVDB - if not xbmc.getCondVisibility('System.HasAddon(metadata.tvdb.com)'): - if not silent: - # Preguntar si queremos instalar metadata.tvdb.com - install = platformtools.dialog_yesno("The TVDB", - "No se ha encontrado el Scraper de series de The TVDB.", - "¿Desea instalarlo ahora?") - else: - install = True + if seleccion == -1 or seleccion == 0: + if not xbmc.getCondVisibility('System.HasAddon(metadata.tvdb.com)'): + if not silent: + # Preguntar si queremos instalar metadata.tvdb.com + install = platformtools.dialog_yesno("The TVDB", + "No se ha encontrado el Scraper de series de The TVDB.", + "¿Desea instalarlo ahora?") + else: + install = True - if install: - try: - # Instalar metadata.tvdb.com - xbmc.executebuiltin('xbmc.installaddon(metadata.tvdb.com)', True) - logger.info("Instalado el Scraper de series de The TVDB") - except: - pass + if install: + try: + # Instalar metadata.tvdb.com + xbmc.executebuiltin('xbmc.installaddon(metadata.tvdb.com)', True) + logger.info("Instalado el Scraper de series de The TVDB") + except: + pass - continuar = (install and xbmc.getCondVisibility('System.HasAddon(metadata.tvdb.com)')) - if not continuar: - msg_text = "The TVDB no instalado." + continuar = (install and xbmc.getCondVisibility('System.HasAddon(metadata.tvdb.com)')) + if not continuar: + msg_text = "The TVDB no instalado." + if continuar: + xbmc.executebuiltin('xbmc.addon.opensettings(metadata.tvdb.com)', True) - # Instalar TheMovieDB - if continuar and not xbmc.getCondVisibility('System.HasAddon(metadata.tvshows.themoviedb.org)'): - continuar = False - if not silent: - # Preguntar si queremos instalar metadata.tvshows.themoviedb.org - install = platformtools.dialog_yesno("The Movie Database", - "No se ha encontrado el Scraper de series de TheMovieDB.", - "¿Desea instalarlo ahora?") - else: - install = True + # Instalar The Movie Database + elif seleccion == 1: + if continuar and not xbmc.getCondVisibility('System.HasAddon(metadata.tvshows.themoviedb.org)'): + continuar = False + if not silent: + # Preguntar si queremos instalar metadata.tvshows.themoviedb.org + install = platformtools.dialog_yesno("The Movie Database", + "No se ha encontrado el Scraper de series de TheMovieDB.", + "¿Desea instalarlo ahora?") + else: + install = True - if install: - try: - # Instalar metadata.tvshows.themoviedb.org - # 1º Probar desde el repositorio ... - xbmc.executebuiltin('xbmc.installaddon(metadata.tvshows.themoviedb.org)', True) - if not xbmc.getCondVisibility('System.HasAddon(metadata.tvshows.themoviedb.org)'): - # ...si no funciona descargar e instalar desde la web - url = "http://mirrors.kodi.tv/addons/jarvis/metadata.tvshows.themoviedb.org/metadata.tvshows.themoviedb.org-1.3.1.zip" - path_down = xbmc.translatePath( - "special://home/addons/packages/metadata.tvshows.themoviedb.org-1.3.1.zip") - path_unzip = xbmc.translatePath("special://home/addons/") - header = ("User-Agent", - "Kodi/15.2 (Windows NT 10.0; WOW64) App_Bitness/32 Version/15.2-Git:20151019-02e7013") + if install: + try: + # Instalar metadata.tvshows.themoviedb.org + xbmc.executebuiltin('xbmc.installaddon(metadata.tvshows.themoviedb.org)', True) + if xbmc.getCondVisibility('System.HasAddon(metadata.tvshows.themoviedb.org)'): + continuar = True + except: + pass - from core import downloadtools - from core import ziptools - - downloadtools.downloadfile(url, path_down, continuar=True, headers=[header]) - unzipper = ziptools.ziptools() - unzipper.extract(path_down, path_unzip) - xbmc.executebuiltin('UpdateLocalAddons') - - strSettings = '\n' \ - ' \n' \ - ' \n' \ - ' \n' \ - '' - path_settings = xbmc.translatePath( - "special://profile/addon_data/metadata.tvshows.themoviedb.org/settings.xml") - tv_themoviedb_addon_path = filetools.dirname(path_settings) - if not filetools.exists(tv_themoviedb_addon_path): - filetools.mkdir(tv_themoviedb_addon_path) - if filetools.write(path_settings, strSettings): - continuar = True - - except: - pass - - continuar = (install and continuar) - if not continuar: - msg_text = "The Movie Database no instalado." + continuar = (install and continuar) + if not continuar: + msg_text = "The Movie Database no instalado." + if continuar: + xbmc.executebuiltin('xbmc.addon.opensettings(metadata.tvshows.themoviedb.org)', True) idPath = 0 idParentPath = 0 @@ -589,26 +602,32 @@ def set_content(content_type, silent=False): # Fijamos strContent, strScraper, scanRecursive y strSettings if content_type == 'movie': strContent = 'movies' - strScraper = 'metadata.themoviedb.org' scanRecursive = 2147483647 - strSettings = "" \ - "" \ - "" \ - "" + if seleccion == -1 or seleccion == 0: + strScraper = 'metadata.themoviedb.org' + path_settings = xbmc.translatePath("special://profile/addon_data/metadata.themoviedb.org/settings.xml") + elif seleccion == 1: + strScraper = 'metadata.universal' + path_settings = xbmc.translatePath("special://profile/addon_data/metadata.universal/settings.xml") + settings_data = filetools.read(path_settings) + strSettings = ' '.join(settings_data.split()).replace("> <", "><") + strSettings = strSettings.replace("\"","\'") strActualizar = "¿Desea configurar este Scraper en español como opción por defecto para películas?" if not videolibrarypath.endswith(sep): videolibrarypath += sep strPath = videolibrarypath + config.get_setting("folder_movies") + sep else: strContent = 'tvshows' - strScraper = 'metadata.tvdb.com' scanRecursive = 0 - strSettings = "" \ - "" \ - "" \ - "" \ - "" \ - "" + if seleccion == -1 or seleccion == 0: + strScraper = 'metadata.tvdb.com' + path_settings = xbmc.translatePath("special://profile/addon_data/metadata.tvdb.com/settings.xml") + elif seleccion == 1: + strScraper = 'metadata.tvshows.themoviedb.org' + path_settings = xbmc.translatePath("special://profile/addon_data/metadata.tvshows.themoviedb.org/settings.xml") + settings_data = filetools.read(path_settings) + strSettings = ' '.join(settings_data.split()).replace("> <", "><") + strSettings = strSettings.replace("\"","\'") strActualizar = "¿Desea configurar este Scraper en español como opción por defecto para series?" if not videolibrarypath.endswith(sep): videolibrarypath += sep @@ -655,7 +674,8 @@ def set_content(content_type, silent=False): else: heading = "Videoteca %s configurada" % content_type msg_text = "Felicidades la videoteca de Kodi ha sido configurada correctamente." - platformtools.dialog_notification(heading, msg_text, icon=1, time=10000) + platformtools.dialog_notification(heading, msg_text, icon=1, time=3000) + logger.info("%s: %s" % (heading, msg_text)) @@ -805,8 +825,8 @@ def ask_set_content(flag, silent=False): if not silent: heading = "Alfa Auto-configuración" - linea1 = "¿Desea que Alfa auto-configure la videoteca de Kodi?" - linea2 = "Si pulsa 'No' podra hacerlo desde 'Configuración > Preferencia > Rutas'." + linea1 = "¿Desea que Alfa auto-configure la videoteca de Kodi? Se le pedirá que configure los scrapers para las películas y las series." + linea2 = "Si pulsa 'No', podra hacerlo desde 'Configuración > Preferencia > Rutas'." if platformtools.dialog_yesno(heading, linea1, linea2): do_config() else: From 834984b9d88ee33e495a393c7f74562bec450569 Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 27 May 2018 19:56:23 +0200 Subject: [PATCH 4/4] Add files via upload --- plugin.video.alfa/resources/settings.xml | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/plugin.video.alfa/resources/settings.xml b/plugin.video.alfa/resources/settings.xml index 950bf63b..33f103ab 100644 --- a/plugin.video.alfa/resources/settings.xml +++ b/plugin.video.alfa/resources/settings.xml @@ -23,13 +23,9 @@ - - - - - - - + + +