From 69cb2849822339ea29f87a20986bc5dc77c1efc8 Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Fri, 20 Jul 2018 11:57:26 +0200 Subject: [PATCH 01/29] Videolibrary: error al seleccionar canal en ventana flotante MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Por un error en la traducción de los tres idiomas españoles en el mensaje 70089 (itainao e inglés estaban bien), añadía un espacio al final del mensaje. Esto hacía que el nombre del canal también tuviera un espacio al final y no igualara las comparaciones. Mensaje corregido en los tres idiomas, y .strip() añadido en línea 365 de Videolíbrary.py para evitar futuros "accidentes" --- plugin.video.alfa/channels/videolibrary.py | 2 +- .../resources/language/Spanish (Argentina)/strings.po | 2 +- .../resources/language/Spanish (Mexico)/strings.po | 2 +- plugin.video.alfa/resources/language/Spanish/strings.po | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin.video.alfa/channels/videolibrary.py b/plugin.video.alfa/channels/videolibrary.py index 80ffdbe9..5d91693a 100644 --- a/plugin.video.alfa/channels/videolibrary.py +++ b/plugin.video.alfa/channels/videolibrary.py @@ -362,7 +362,7 @@ def findvideos(item): platformtools.play_video(item_local) elif index > 0: - filtro_canal = opciones[index].replace(config.get_localized_string(70078), "") + filtro_canal = opciones[index].replace(config.get_localized_string(70078), "").strip() itemlist = [] for nom_canal, json_path in list_canales.items(): diff --git a/plugin.video.alfa/resources/language/Spanish (Argentina)/strings.po b/plugin.video.alfa/resources/language/Spanish (Argentina)/strings.po index f52b1490..eb986820 100644 --- a/plugin.video.alfa/resources/language/Spanish (Argentina)/strings.po +++ b/plugin.video.alfa/resources/language/Spanish (Argentina)/strings.po @@ -3071,7 +3071,7 @@ msgstr "¿Realmente desea eliminar '%s' de su videoteca?" msgctxt "#70089" msgid "Show only links of %s" -msgstr "Mostrar solo los enlaces de %s " +msgstr "Mostrar solo los enlaces de %s" msgctxt "#70090" msgid " Exclude all streams with specific words" diff --git a/plugin.video.alfa/resources/language/Spanish (Mexico)/strings.po b/plugin.video.alfa/resources/language/Spanish (Mexico)/strings.po index f52b1490..eb986820 100644 --- a/plugin.video.alfa/resources/language/Spanish (Mexico)/strings.po +++ b/plugin.video.alfa/resources/language/Spanish (Mexico)/strings.po @@ -3071,7 +3071,7 @@ msgstr "¿Realmente desea eliminar '%s' de su videoteca?" msgctxt "#70089" msgid "Show only links of %s" -msgstr "Mostrar solo los enlaces de %s " +msgstr "Mostrar solo los enlaces de %s" msgctxt "#70090" msgid " Exclude all streams with specific words" diff --git a/plugin.video.alfa/resources/language/Spanish/strings.po b/plugin.video.alfa/resources/language/Spanish/strings.po index f52b1490..eb986820 100644 --- a/plugin.video.alfa/resources/language/Spanish/strings.po +++ b/plugin.video.alfa/resources/language/Spanish/strings.po @@ -3071,7 +3071,7 @@ msgstr "¿Realmente desea eliminar '%s' de su videoteca?" msgctxt "#70089" msgid "Show only links of %s" -msgstr "Mostrar solo los enlaces de %s " +msgstr "Mostrar solo los enlaces de %s" msgctxt "#70090" msgid " Exclude all streams with specific words" From 27f0375e4e5355c8c02744ae9c18bda10de1cbd8 Mon Sep 17 00:00:00 2001 From: pipcat Date: Fri, 20 Jul 2018 21:48:32 +0200 Subject: [PATCH 02/29] =?UTF-8?q?Correcci=C3=B3n=20vidoza=20y=20platformto?= =?UTF-8?q?ols?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platformcode/platformtools.py | 18 ++++----------- plugin.video.alfa/servers/vidoza.py | 23 ++++++++++++++----- 2 files changed, 22 insertions(+), 19 deletions(-) diff --git a/plugin.video.alfa/platformcode/platformtools.py b/plugin.video.alfa/platformcode/platformtools.py index 506a6676..54459dba 100644 --- a/plugin.video.alfa/platformcode/platformtools.py +++ b/plugin.video.alfa/platformcode/platformtools.py @@ -127,13 +127,12 @@ def render_items(itemlist, parent_item): if 'anime' in channeltools.get_channel_parameters(parent_item.channel)['categories']: anime = True - # Recorremos el itemlist + unify_enabled = config.get_setting('unify') + #logger.debug('unify_enabled: %s' % unify_enabled) + + # Recorremos el itemlist for item in itemlist: - try: - channel_parameters = channeltools.get_channel_parameters(item.channel) - except: - pass #logger.debug(item) # Si el item no contiene categoria, le ponemos la del item padre if item.category == "": @@ -143,9 +142,7 @@ def render_items(itemlist, parent_item): if item.fanart == "": item.fanart = parent_item.fanart - if genre: - valid_genre = True thumb = get_thumb(item.title, auto=True) if thumb != '': @@ -155,12 +152,7 @@ def render_items(itemlist, parent_item): valid_genre = True - unify_enabled = config.get_setting('unify') - - #logger.debug('unify_enabled: %s' % unify_enabled) - - - if unify_enabled and not channel_parameters['adult'] and 'skip_unify' not in channel_parameters: + if unify_enabled: # Formatear titulo con unify item = unify.title_format(item) else: diff --git a/plugin.video.alfa/servers/vidoza.py b/plugin.video.alfa/servers/vidoza.py index a7b55f11..85da6413 100755 --- a/plugin.video.alfa/servers/vidoza.py +++ b/plugin.video.alfa/servers/vidoza.py @@ -20,13 +20,24 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= logger.info("(page_url='%s')" % page_url) data = httptools.downloadpage(page_url).data video_urls = [] - matches = scrapertools.find_multiple_matches(data, 'src\s*:\s*"([^"]+)".*?label:\'([^\']+)\'') - for media_url, calidad in matches: - ext = media_url[-4:] - video_urls.append(["%s %s [vidoza]" % (ext, calidad), media_url]) + + s = scrapertools.find_single_match(data, 'sourcesCode\s*:\s*(\[\{.*?\}\])') + s = s.replace('src:', '"src":').replace('type:', '"type":').replace('label:', '"label":').replace('res:', '"res":') + try: + data = json.loads(str(s)) + for enlace in data: + if 'src' in enlace: + tit = '' + if 'label' in enlace: tit += '[%s]' % enlace['label'] + if 'res' in enlace: tit += '[%s]' % enlace['res'] + if tit == '' and 'type' in enlace: tit = enlace['type'] + if tit == '': tit = '.mp4' + + video_urls.append(["%s [vidoza]" % tit, enlace['src']]) + except: + logger.debug('No se detecta json %s' % s) + pass video_urls.reverse() - for video_url in video_urls: - logger.info("%s - %s" % (video_url[0], video_url[1])) return video_urls From 982974d7f4bd0f87c4b010a93f4aed02f97897ab Mon Sep 17 00:00:00 2001 From: pipcat Date: Sat, 21 Jul 2018 18:43:34 +0200 Subject: [PATCH 03/29] =?UTF-8?q?Correcci=C3=B3n=20vidoza?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.video.alfa/servers/vidoza.py | 1 + 1 file changed, 1 insertion(+) diff --git a/plugin.video.alfa/servers/vidoza.py b/plugin.video.alfa/servers/vidoza.py index 85da6413..3d71ec35 100755 --- a/plugin.video.alfa/servers/vidoza.py +++ b/plugin.video.alfa/servers/vidoza.py @@ -3,6 +3,7 @@ from core import httptools from core import scrapertools from platformcode import logger +import json def test_video_exists(page_url): From 22cb47a8c34dd10385bfeec51469859679ec75e0 Mon Sep 17 00:00:00 2001 From: pipcat Date: Sat, 21 Jul 2018 18:54:29 +0200 Subject: [PATCH 04/29] =?UTF-8?q?Correcci=C3=B3n=20powvideo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.video.alfa/servers/powvideo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.video.alfa/servers/powvideo.py b/plugin.video.alfa/servers/powvideo.py index 2696c972..1ccfd16b 100755 --- a/plugin.video.alfa/servers/powvideo.py +++ b/plugin.video.alfa/servers/powvideo.py @@ -39,5 +39,5 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= def decode_powvideo_url(url): tria = re.compile('[0-9a-z]{40,}', re.IGNORECASE).findall(url)[0] gira = tria[::-1] - x = gira[:1] + gira[2:] + x = gira[:2] + gira[3:] return re.sub(tria, x, url) From e68e6d8a4c49213e8c3b7258b48cfaf9977d9df1 Mon Sep 17 00:00:00 2001 From: Intel1 Date: Sat, 21 Jul 2018 11:58:34 -0500 Subject: [PATCH 05/29] seriesverde: desactivado --- plugin.video.alfa/channels/seriesverde.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.video.alfa/channels/seriesverde.json b/plugin.video.alfa/channels/seriesverde.json index 8a9a8aeb..a407338a 100644 --- a/plugin.video.alfa/channels/seriesverde.json +++ b/plugin.video.alfa/channels/seriesverde.json @@ -1,7 +1,7 @@ { "id": "seriesverde", "name": "SeriesVerde", - "active": true, + "active": false, "adult": false, "language": ["cast", "lat"], "thumbnail": "https://s33.postimg.cc/96dhv4trj/seriesverde.png", From f22dbac329b0a41f0e3fbce95e3c96cfc16cb01d Mon Sep 17 00:00:00 2001 From: pipcat Date: Sat, 21 Jul 2018 20:27:45 +0200 Subject: [PATCH 06/29] Vidoza con jsontools para que no falle en windows --- plugin.video.alfa/servers/vidoza.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.video.alfa/servers/vidoza.py b/plugin.video.alfa/servers/vidoza.py index 3d71ec35..91f18fce 100755 --- a/plugin.video.alfa/servers/vidoza.py +++ b/plugin.video.alfa/servers/vidoza.py @@ -3,7 +3,7 @@ from core import httptools from core import scrapertools from platformcode import logger -import json +from core import jsontools def test_video_exists(page_url): @@ -25,7 +25,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= s = scrapertools.find_single_match(data, 'sourcesCode\s*:\s*(\[\{.*?\}\])') s = s.replace('src:', '"src":').replace('type:', '"type":').replace('label:', '"label":').replace('res:', '"res":') try: - data = json.loads(str(s)) + data = jsontools.load(s) for enlace in data: if 'src' in enlace: tit = '' From 2f973a75eb89edf188ef3d8d1810c857d5fb8c98 Mon Sep 17 00:00:00 2001 From: pipcat Date: Sat, 21 Jul 2018 21:15:54 +0200 Subject: [PATCH 07/29] =?UTF-8?q?Powvideo=20m=C3=A1s=20variable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.video.alfa/servers/powvideo.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plugin.video.alfa/servers/powvideo.py b/plugin.video.alfa/servers/powvideo.py index 1ccfd16b..74336d7c 100755 --- a/plugin.video.alfa/servers/powvideo.py +++ b/plugin.video.alfa/servers/powvideo.py @@ -30,14 +30,24 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= packed = scrapertools.find_single_match(data, "") unpacked = jsunpack.unpack(packed) - + url = scrapertools.find_single_match(unpacked, "(?:src):\\\\'([^\\\\]+.mp4)\\\\'") - itemlist.append([".mp4" + " [powvideo]", decode_powvideo_url(url)]) + + a, b = scrapertools.find_single_match(data, "\['splice'\]\(0x([0-9a-fA-F]*),0x([0-9a-fA-F]*)\);") + if a and b: + url = decode_powvideo_url(url, int(a, 16), int(b, 16)) + else: + logger.debug('No detectado splice! Revisar sistema de decode...') + + itemlist.append([".mp4" + " [powvideo]", url]) itemlist.sort(key=lambda x: x[0], reverse=True) return itemlist -def decode_powvideo_url(url): +def decode_powvideo_url(url, desde, num): tria = re.compile('[0-9a-z]{40,}', re.IGNORECASE).findall(url)[0] gira = tria[::-1] - x = gira[:2] + gira[3:] + if desde == 0: + x = gira[num:] + else: + x = gira[:desde] + gira[(desde+num):] return re.sub(tria, x, url) From 31bbe6aa485dc0b385e45c88cb11978cdd0dbf60 Mon Sep 17 00:00:00 2001 From: pipcat Date: Sun, 22 Jul 2018 12:45:35 +0200 Subject: [PATCH 08/29] Vidoza, detectar tb file: --- plugin.video.alfa/servers/vidoza.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugin.video.alfa/servers/vidoza.py b/plugin.video.alfa/servers/vidoza.py index 91f18fce..934b902d 100755 --- a/plugin.video.alfa/servers/vidoza.py +++ b/plugin.video.alfa/servers/vidoza.py @@ -23,18 +23,19 @@ def get_video_url(page_url, premium=False, user="", password="", video_password= video_urls = [] s = scrapertools.find_single_match(data, 'sourcesCode\s*:\s*(\[\{.*?\}\])') - s = s.replace('src:', '"src":').replace('type:', '"type":').replace('label:', '"label":').replace('res:', '"res":') + s = s.replace('src:', '"src":').replace('file:', '"file":').replace('type:', '"type":').replace('label:', '"label":').replace('res:', '"res":') try: data = jsontools.load(s) for enlace in data: - if 'src' in enlace: + if 'src' in enlace or 'file' in enlace: + url = enlace['src'] if 'src' in enlace else enlace['file'] tit = '' if 'label' in enlace: tit += '[%s]' % enlace['label'] if 'res' in enlace: tit += '[%s]' % enlace['res'] if tit == '' and 'type' in enlace: tit = enlace['type'] if tit == '': tit = '.mp4' - video_urls.append(["%s [vidoza]" % tit, enlace['src']]) + video_urls.append(["%s [vidoza]" % tit, url]) except: logger.debug('No se detecta json %s' % s) pass From 48bbe3beecf4d937be20a5890981c7a5a6e5ec7b Mon Sep 17 00:00:00 2001 From: pipcat Date: Sun, 22 Jul 2018 14:06:44 +0200 Subject: [PATCH 09/29] =?UTF-8?q?Correcci=C3=B3n=20gamovideo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.video.alfa/servers/gamovideo.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin.video.alfa/servers/gamovideo.py b/plugin.video.alfa/servers/gamovideo.py index cbb32783..5058b59c 100755 --- a/plugin.video.alfa/servers/gamovideo.py +++ b/plugin.video.alfa/servers/gamovideo.py @@ -7,12 +7,12 @@ from core import scrapertools from lib import jsunpack from platformcode import logger -headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:58.0) Gecko/20100101 Firefox/58.0'} +headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36'} def test_video_exists(page_url): logger.info("(page_url='%s')" % page_url) - data = httptools.downloadpage(page_url).data + data = httptools.downloadpage(page_url, headers=headers).data if "File was deleted" in data or "Not Found" in data or "File was locked by administrator" in data: return False, "[Gamovideo] El archivo no existe o ha sido borrado" @@ -25,7 +25,7 @@ def test_video_exists(page_url): def get_video_url(page_url, premium=False, user="", password="", video_password=""): logger.info("(page_url='%s')" % page_url) - data = httptools.downloadpage(page_url).data + data = httptools.downloadpage(page_url, headers=headers).data packer = scrapertools.find_single_match(data, "") if packer != "": From b1a0dbba34bf352a241a46f9072581965ecd32d3 Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Mon, 23 Jul 2018 12:02:51 +0200 Subject: [PATCH 10/29] =?UTF-8?q?Sincronizado=20de=20marcado=20de=20v?= =?UTF-8?q?=C3=ADdeos=20visto=20desde=20Kodi=20a=20Alfa?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.video.alfa/channels/videolibrary.py | 34 +++++++- .../platformcode/xbmc_videolibrary.py | 83 +++++++++++++++++++ plugin.video.alfa/videolibrary_service.py | 41 +++++++-- 3 files changed, 148 insertions(+), 10 deletions(-) diff --git a/plugin.video.alfa/channels/videolibrary.py b/plugin.video.alfa/channels/videolibrary.py index 5d91693a..c03bbf5f 100644 --- a/plugin.video.alfa/channels/videolibrary.py +++ b/plugin.video.alfa/channels/videolibrary.py @@ -31,14 +31,23 @@ def channel_config(item): caption=config.get_localized_string(60598)) -def list_movies(item): +def list_movies(item, silent=False): logger.info() itemlist = [] + from platformcode import xbmc_videolibrary + from lib import generictools for raiz, subcarpetas, ficheros in filetools.walk(videolibrarytools.MOVIES_PATH): for f in ficheros: if f.endswith(".nfo"): nfo_path = filetools.join(raiz, f) + + #Sincronizamos las películas vistas desde la videoteca de Kodi con la de Alfa + try: + xbmc_videolibrary.mark_content_as_watched_on_alfa(nfo_path) + except: + pass + head_nfo, new_item = videolibrarytools.read_nfo(nfo_path) new_item.nfo = nfo_path @@ -50,6 +59,12 @@ def list_movies(item): # Si se ha eliminado el strm desde la bilbioteca de kodi, no mostrarlo continue + ###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial + try: + new_item, new_item, overwrite = generictools.redirect_clone_newpct1(new_item, head_nfo, new_item, raiz) + except: + pass + # Menu contextual: Marcar como visto/no visto visto = new_item.library_playcounts.get(os.path.splitext(f)[0], 0) new_item.infoLabels["playcount"] = visto @@ -85,12 +100,16 @@ def list_movies(item): # logger.debug("new_item: " + new_item.tostring('\n')) itemlist.append(new_item) - return sorted(itemlist, key=lambda it: it.title.lower()) + if silent == False: + return sorted(itemlist, key=lambda it: it.title.lower()) + else: + return def list_tvshows(item): logger.info() itemlist = [] + from platformcode import xbmc_videolibrary # Obtenemos todos los tvshow.nfo de la videoteca de SERIES recursivamente for raiz, subcarpetas, ficheros in filetools.walk(videolibrarytools.TVSHOWS_PATH): @@ -98,6 +117,13 @@ def list_tvshows(item): if f == "tvshow.nfo": tvshow_path = filetools.join(raiz, f) # logger.debug(tvshow_path) + + #Sincronizamos los episodios vistos desde la videoteca de Kodi con la de Alfa + try: + xbmc_videolibrary.mark_content_as_watched_on_alfa(tvshow_path) + except: + pass + head_nfo, item_tvshow = videolibrarytools.read_nfo(tvshow_path) item_tvshow.title = item_tvshow.contentTitle item_tvshow.path = raiz @@ -552,7 +578,7 @@ def mark_content_as_watched2(item): # Guardamos los cambios en item.nfo if filetools.write(item.nfo, head_nfo + it.tojson()): item.infoLabels['playcount'] = item.playcount - logger.debug(item.playcount) + #logger.debug(item.playcount) # if item.contentType == 'episodesss': # Actualizar toda la serie @@ -569,7 +595,7 @@ def mark_content_as_watched2(item): def mark_content_as_watched(item): logger.info() - logger.debug("item:\n" + item.tostring('\n')) + #logger.debug("item:\n" + item.tostring('\n')) if filetools.exists(item.nfo): head_nfo, it = videolibrarytools.read_nfo(item.nfo) diff --git a/plugin.video.alfa/platformcode/xbmc_videolibrary.py b/plugin.video.alfa/platformcode/xbmc_videolibrary.py index e5f7c982..be643879 100755 --- a/plugin.video.alfa/platformcode/xbmc_videolibrary.py +++ b/plugin.video.alfa/platformcode/xbmc_videolibrary.py @@ -325,6 +325,89 @@ def mark_season_as_watched_on_kodi(item, value=1): execute_sql_kodi(sql) +def mark_content_as_watched_on_alfa(path): + from channels import videolibrary + from core import videolibrarytools + from core import scrapertools + import re + """ + marca toda la serie o película como vista o no vista en la Videoteca de Alfa basado en su estado en la Videoteca de Kodi + @type str: path + @param path: carpeta de contenido a marcar + """ + logger.info() + #logger.debug("path: " + path) + + FOLDER_MOVIES = config.get_setting("folder_movies") + FOLDER_TVSHOWS = config.get_setting("folder_tvshows") + VIDEOLIBRARY_PATH = config.get_videolibrary_config_path() + + # Solo podemos marcar el contenido como vista en la BBDD de Kodi si la BBDD es local, + # en caso de compartir BBDD esta funcionalidad no funcionara + #if config.get_setting("db_mode", "videolibrary"): + # return + + path2 = '' + if "special://" in VIDEOLIBRARY_PATH: + if FOLDER_TVSHOWS in path: + path2 = re. sub(r'.*?%s' % FOLDER_TVSHOWS, VIDEOLIBRARY_PATH + "/" + FOLDER_TVSHOWS, path).replace("\\", "/") + if FOLDER_MOVIES in path: + path2 = re. sub(r'.*?%s' % FOLDER_MOVIES, VIDEOLIBRARY_PATH + "/" + FOLDER_MOVIES, path).replace("\\", "/") + + if "\\" in path: + path = path.replace("/", "\\") + head_nfo, item = videolibrarytools.read_nfo(path) #Leo el .nfo del contenido + + if FOLDER_TVSHOWS in path: #Compruebo si es CINE o SERIE + contentType = "episode_view" #Marco la tabla de BBDD de Kodi Video + nfo_name = "tvshow.nfo" #Construyo el nombre del .nfo + path1 = path.replace("\\\\", "\\").replace(nfo_name, '') #para la SQL solo necesito la carpeta + if not path2: + path2 = path1.replace("\\", "/") #Formato no Windows + else: + path2 = path2.replace(nfo_name, '') + + else: + contentType = "movie_view" #Marco la tabla de BBDD de Kodi Video + path1 = path.replace("\\\\", "\\") #Formato Windows + if not path2: + path2 = path1.replace("\\", "/") #Formato no Windows + nfo_name = scrapertools.find_single_match(path2, '\]\/(.*?)$') #Construyo el nombre del .nfo + path1 = path1.replace(nfo_name, '') #para la SQL solo necesito la carpeta + path2 = path2.replace(nfo_name, '') #para la SQL solo necesito la carpeta + + #Ejecutmos la sentencia SQL + sql = 'select strFileName, playCount from %s where (strPath like "%s" or strPath like "%s")' % (contentType, path1, path2) + nun_records = 0 + records = None + nun_records, records = execute_sql_kodi(sql) #ejecución de la SQL + if nun_records == 0: #hay error? + logger.error("Error en la SQL: " + sql + ": 0 registros") + return #salimos: o no está catalogado en Kodi, o hay un error en la SQL + + for title, playCount in records: #Ahora recorremos todos los registros obtenidos + if contentType == "episode_view": + title_plain = title.replace('.strm', '') #Si es Serie, quitamos el sufijo .strm + else: + title_plain = scrapertools.find_single_match(item.strm_path, '.(.*?\s\[.*?\])') #si es peli, quitamos el título + if playCount is None or playCount == 0: #todavía no se ha visto, lo ponemos a 0 + playCount_final = 0 + elif playCount >= 1: + playCount_final = 1 + title_plain = title_plain.decode("utf-8").encode("utf-8") #Hacemos esto porque si no genera esto: u'title_plain' + item.library_playcounts.update({title_plain: playCount_final}) #actualizamos el playCount del .nfo + + if item.infoLabels['mediatype'] == "tvshow": #Actualizamos los playCounts de temporadas y Serie + for season in item.library_playcounts: + if "season" in season: #buscamos las etiquetas "season" dentro de playCounts + season_num = int(scrapertools.find_single_match(season, 'season (\d+)')) #salvamos el núm, de Temporada + item = videolibrary.check_season_playcount(item, season_num) #llamamos al método que actualiza Temps. y Series + + filetools.write(path, head_nfo + item.tojson()) + + #logger.debug(item) + + def get_data(payload): """ obtiene la información de la llamada JSON-RPC con la información pasada en payload diff --git a/plugin.video.alfa/videolibrary_service.py b/plugin.video.alfa/videolibrary_service.py index f5dfb8f9..97a64523 100644 --- a/plugin.video.alfa/videolibrary_service.py +++ b/plugin.video.alfa/videolibrary_service.py @@ -14,8 +14,9 @@ from channels import videolibrary def update(path, p_dialog, i, t, serie, overwrite): logger.info("Actualizando " + path) from lib import generictools + from platformcode import xbmc_videolibrary insertados_total = 0 - + head_nfo, it = videolibrarytools.read_nfo(path + '/tvshow.nfo') # logger.debug("%s: %s" %(serie.contentSerieName,str(list_canales) )) @@ -25,7 +26,7 @@ def update(path, p_dialog, i, t, serie, overwrite): ###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial try: - serie, it, overwrite = generictools.redirect_clone_newpct1(serie, head_nfo, it, overwrite, path) + serie, it, overwrite = generictools.redirect_clone_newpct1(serie, head_nfo, it, path, overwrite) except: pass @@ -46,8 +47,6 @@ def update(path, p_dialog, i, t, serie, overwrite): obj = imp.load_source(serie.channel, pathchannels) itemlist = obj.episodios(serie) - - serie.channel = channel #Restauramos el valor incial del clone de NewPct1 try: if int(overwrite) == 3: @@ -80,11 +79,19 @@ def update(path, p_dialog, i, t, serie, overwrite): else: logger.debug("Canal %s no activo no se actualiza" % serie.channel) + #Sincronizamos los episodios vistos desde la videoteca de Kodi con la de Alfa + try: + xbmc_videolibrary.mark_content_as_watched_on_alfa(path + '/tvshow.nfo') + except: + pass + return insertados_total > 0 def check_for_update(overwrite=True): logger.info("Actualizando series...") + from lib import generictools + from platformcode import xbmc_videolibrary p_dialog = None serie_actualizada = False update_when_finished = False @@ -108,7 +115,17 @@ def check_for_update(overwrite=True): for i, tvshow_file in enumerate(show_list): head_nfo, serie = videolibrarytools.read_nfo(tvshow_file) path = filetools.dirname(tvshow_file) - + + ###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial + overwrite_forced = False + try: + serie, serie, overwrite_forced = generictools.redirect_clone_newpct1(serie, head_nfo, serie, path, overwrite, lookup=True) + except: + pass + if overwrite_forced == True: + overwrite = True + serie.update_next = '' + logger.info("serie=" + serie.contentSerieName) p_dialog.update(int(math.ceil((i + 1) * t)), heading, serie.contentSerieName) @@ -116,7 +133,14 @@ def check_for_update(overwrite=True): if not serie.active: # si la serie no esta activa descartar - continue + if overwrite_forced == False: + #Sincronizamos los episodios vistos desde la videoteca de Kodi con la de Alfa, aunque la serie esté desactivada + try: + xbmc_videolibrary.mark_content_as_watched_on_alfa(path + '/tvshow.nfo') + except: + pass + + continue # obtenemos las fecha de actualizacion y de la proxima programada para esta serie update_next = serie.update_next @@ -162,6 +186,7 @@ def check_for_update(overwrite=True): if not serie_actualizada: update_next += datetime.timedelta(days=interval) + head_nfo, serie = videolibrarytools.read_nfo(tvshow_file) #Vuelve a leer el.nfo, que ha sido modificado if interval != int(serie.active) or update_next.strftime('%Y-%m-%d') != serie.update_next: serie.active = interval serie.update_next = update_next.strftime('%Y-%m-%d') @@ -197,6 +222,10 @@ def check_for_update(overwrite=True): if p_dialog: p_dialog.close() + + from core.item import Item + item_dummy = Item() + videolibrary.list_movies(item_dummy, silent=True) def start(thread=True): From e7a17abced0cae08dd38f3f0d64932a4ce34f46d Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Mon, 23 Jul 2018 12:03:54 +0200 Subject: [PATCH 11/29] =?UTF-8?q?Migracion=20de=20canales=20intervenidos:?= =?UTF-8?q?=20soporta=20migraci=C3=B3n=20de=20peliculas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugin.video.alfa/channels/mejortorrent.json | 26 ++-- plugin.video.alfa/lib/generictools.py | 131 +++++++++++++------ 2 files changed, 100 insertions(+), 57 deletions(-) diff --git a/plugin.video.alfa/channels/mejortorrent.json b/plugin.video.alfa/channels/mejortorrent.json index f8a27b94..7cc93f83 100755 --- a/plugin.video.alfa/channels/mejortorrent.json +++ b/plugin.video.alfa/channels/mejortorrent.json @@ -1,18 +1,17 @@ { - "active": true, - "adult": false, - "banner": "mejortorrent.png", + "id": "mejortorrent", + "name": "Mejor Torrent", + "active": true, + "adult": false, + "language": ["*"], + "thumbnail": "thumb_intervenido_pn.jpeg", + "banner": "mejortorrent.png", "categories": [ - "torrent", - "movie", - "tvshow", + "torrent", + "movie", + "tvshow", "documentary" - ], - "id": "mejortorrent", - "language": [ - "*" - ], - "name": "Mejor Torrent", + ], "settings": [ { "default": "http://www.mejortorrent.com/", @@ -62,6 +61,5 @@ "type": "bool", "visible": true } - ], - "thumbnail": ", thumb_intervenido_pn.jpeg" + ] } \ No newline at end of file diff --git a/plugin.video.alfa/lib/generictools.py b/plugin.video.alfa/lib/generictools.py index 0142ea08..29311d93 100644 --- a/plugin.video.alfa/lib/generictools.py +++ b/plugin.video.alfa/lib/generictools.py @@ -991,11 +991,12 @@ def web_intervenida(item, data, desactivar=True): break else: - json_data['active'] = False #Se desactiva el canal + #json_data['active'] = False #Se desactiva el canal json_data['thumbnail'] = ', thumb_%s' % judicial #Guardamos el thumb de la autoridad judicial #Guardamos los cambios hechos en el .json try: + disabled = config.set_setting('enabled', False, item.channel) channel_path = filetools.join(config.get_runtime_path(), "channels", item.channel + ".json") with open(channel_path, 'w') as outfile: #Grabamos el .json actualizado json.dump(json_data, outfile, sort_keys = True, indent = 2, ensure_ascii = False) @@ -1007,7 +1008,7 @@ def web_intervenida(item, data, desactivar=True): return item -def redirect_clone_newpct1(item, head_nfo=None, it=None, overwrite=False, path=False): +def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=False, lookup=False): logger.info() """ @@ -1043,7 +1044,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, overwrite=False, path=F - no: no acción para videolibrary_service, solo redirige en visionado de videolibrary ejemplo: ('1', 'mejortorrent', 'mejortorrent1', 'http://www.mejortorrent.com/', 'https://mejortorrent1.com/', 'auto') - La llamada recibe el parámetro Item, el .nfo y los devuleve actualizados, así como opcionalmente el parámetro "overwrite· que puede forzar la reescritura de todos los archivos de la serie, y el parámetro "path" si viene de videolibrary_service + La llamada recibe el parámetro Item, el .nfo y los devuleve actualizados, así como opcionalmente el parámetro "overwrite· que puede forzar la reescritura de todos los archivos de la serie, y el parámetro "path" si viene de videolibrary_service. Por último, recibe opcionalmente el parámetro "lookup" si se quiere solo averigurar si habrá migración para ese título, pero sin realizarla. """ if not it: @@ -1060,7 +1061,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, overwrite=False, path=F if settings['id'] == "clonenewpct1_channels_list": #Encontramos en setting fail_over_list = settings['default'] #Carga lista de clones if settings['id'] == "intervenidos_channels_list": #Encontramos en setting - intervencion = settings['default'] #Carga lista de clones y canales intervenidos + intervencion = settings['default'] #Carga lista de clones y canales intervenidos #primero tratamos los clones de Newpct1 channel_alt = item.channel #Salvamos en nombre del canal o clone @@ -1069,16 +1070,25 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, overwrite=False, path=F item.channel = channel_py #Ahora tratamos las webs intervenidas, tranformamos la url, el nfo y borramos los archivos obsoletos de la serie - if channel not in intervencion: #Hacemos una lookup para ver si... + if channel not in intervencion and channel_alt != 'videolibrary': #Hacemos una lookup para ver si... return (item, it, overwrite) #... el canal/clone está listado import ast intervencion_list = ast.literal_eval(intervencion) #Convertir a Array el string #logger.debug(intervencion_list) - if item.channel != channel_py: - channel_enabled = channeltools.is_enabled(item.channel) #Verificamos que el canal esté inactivo + + if lookup == True: + overwrite = False #Solo avisamos si hay cambios for activo, canal_org, canal_des, url_org, url_des, patron1, patron2, patron3, patron4, patron5, content_inc, content_exc, ow_force in intervencion_list: - if activo == '1' and canal_org == channel_alt: #Es esta nuestra entrada? + if activo == '1' and (canal_org == channel_alt or channel_alt == 'videolibrary'): #Es esta nuestra entrada? + if channel_alt == 'videolibrary': #Viene de videolibrary.list_movies + for canal_vid, url_vid in item.library_urls.items(): + if canal_org != canal_vid: #Miramos si canal_org de la regla está en item.library_urls + continue + else: + channel_alt = canal_org #Sí, ponermos el nombre del canal/clone de origen + if channel_alt == 'videolibrary': + continue if item.contentType == "list": #Si viene de Videolibrary, le cambiamos ya el canal if item.channel != channel_py: item.channel = canal_des #Cambiamos el canal. Si es clone, lo hace el canal @@ -1087,60 +1097,95 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, overwrite=False, path=F continue if item.contentType in content_exc: #Está el contenido excluido? continue - if channel_enabled and canal_org != canal_des: #Si el canal está activo, puede ser solo... + if item.channel != channel_py: + channel_enabled = channeltools.is_enabled(channel_alt) #Verificamos que el canal esté inactivo + channel_enabled_alt = config.get_setting('enabled', channel_alt) + channel_enabled = channel_enabled * channel_enabled_alt #Si está inactivo en algún sitio, tomamos eso + if channel_enabled == 1 and canal_org != canal_des: #Si el canal está activo, puede ser solo... continue #... una intervención que afecte solo a una región - if ow_force == 'no' and path != False: #Queremos que el canal solo visualice sin migración? - continue #Salimos sin tocas archivos - item.url = item.url.replace(url_org, url_des) #reemplzamos una parte de url + if ow_force == 'no' and it.library_urls: #Esta regla solo vale para findvideos... + continue #... salidmos si estamos actualizando + if lookup == True: #Queremos que el canal solo visualice sin migración? + if ow_force != 'no': + overwrite = True #Avisamos que hay cambios + continue #Salimos sin tocar archivos + url_total = '' + if item.url: + url_total = item.url + elif not item.url and item.library_urls: + url_total = item.library_urls[canal_org] + url_total = url_total.replace(url_org, url_des) #reemplazamos una parte de url + url = '' if patron1: #Hay expresión regex? - url = scrapertools.find_single_match(item.url, patron1) #La aplicamos a url + url += scrapertools.find_single_match(url_total, patron1) #La aplicamos a url if patron2: #Hay más expresión regex? - url += scrapertools.find_single_match(item.url, patron2) #La aplicamos a url + url += scrapertools.find_single_match(url_total, patron2) #La aplicamos a url if patron3: #Hay más expresión regex? - url += scrapertools.find_single_match(item.url, patron3) #La aplicamos a url + url += scrapertools.find_single_match(url_total, patron3) #La aplicamos a url if patron4: #Hay más expresión regex? - url += scrapertools.find_single_match(item.url, patron4) #La aplicamos a url + url += scrapertools.find_single_match(url_total, patron4) #La aplicamos a url if patron5: #Hay más expresión regex? - url += scrapertools.find_single_match(item.url, patron5) #La aplicamos a url - item.url = url #Guardamos la suma de los resultados intermedios + url += scrapertools.find_single_match(url_total, patron5) #La aplicamos a url + if url: + url_total = url #Guardamos la suma de los resultados intermedios update_stat += 1 #Ya hemos actualizado algo + canal_org_def = canal_org + canal_des_def = canal_des + ow_force_def = ow_force if update_stat > 0: #Ha habido alguna actualización? Entonces salvamos - if item.channel == channel_py: #Si es Newpct1... + if item.channel == channel_py or channel in fail_over_list: #Si es Newpct1... if item.contentType == "tvshow": - item.url = re.sub(r'\/\d+\/?$', '', item.url) #parece que con el título ecuentra la serie, normalmente... - if it.url: - it.url = item.url #reemplazamos una parte de url en .nfo, aunque no suele haberla + url_total = re.sub(r'\/\d+\/?$', '', url_total) #parece que con el título ecuentra la serie, normalmente... + if item.url: + item.url = url_total #Salvamos la url convertida if item.library_urls: - item.library_urls.pop(canal_org, None) - item.library_urls = {canal_des: item.url} + item.library_urls.pop(canal_org_def, None) + item.library_urls = {canal_des_def: url_total} it.library_urls = item.library_urls - if item.channel != channel_py: - item.channel = canal_des #Cambiamos el canal. Si es clone, lo hace el canal + if item.channel != channel_py and item.channel != 'videolibrary': + item.channel = canal_des_def #Cambiamos el canal. Si es clone, lo hace el canal if channel_alt == item.category.lower(): #Actualizamos la Categoría y si la tenía item.category = item.channel.capitalize() - if ow_force == 'force': #Queremos que el canal revise la serie entera? - item.ow_force = "1" #Se lo decimos - if ow_force in ['force', 'auto']: #Sobreescribir la series? - overwrite = ow_force_param #Sí, lo marcamos + if ow_force_def == 'force' and item.contentType != "movie": #Queremos que el canal revise la serie entera? + item.ow_force = '1' #Se lo decimos + if ow_force_def in ['force', 'auto']: #Sobreescribir la series? + overwrite = True #Sí, lo marcamos - - if item.contentType in ['tvshow', 'season'] and it.library_urls: - if path == False: - TVSHOWS_PATH = item.path - else: - TVSHOWS_PATH = path + #logger.debug(canal_org_def + canal_des_def + ow_force_def) + if it.library_urls and path != False and ow_force_def != 'no': #Continuamos si hay .nfo, path, y queremos actualizarlo + if item.update_next: + del item.update_next #Borramos estos campos para forzar la actualización ya + if it.update_next: + del it.update_next # Listamos todos los ficheros de la serie, asi evitamos tener que comprobar si existe uno por uno - raiz, carpetas_series, ficheros = filetools.walk(TVSHOWS_PATH).next() - ficheros = [filetools.join(TVSHOWS_PATH, f) for f in ficheros] #Almacenamos la lista de archivos de la carpeta - canal_erase = '[%s]' % canal_org + raiz, carpetas_series, ficheros = filetools.walk(path).next() + ficheros = [filetools.join(path, f) for f in ficheros] #Almacenamos la lista de archivos de la carpeta + canal_erase = '[%s]' % canal_org_def for archivo in ficheros: - if canal_erase in archivo: #Borramos los .json que sean del canal intervenido + if canal_erase in archivo: #Borramos los .json que sean del canal intervenido + json_path = archivo.replace(canal_org_def, canal_des_def) #Salvamos el path del .json para luego crearlo filetools.remove(archivo) - if "tvshow.nfo" in archivo: - filetools.write(archivo, head_nfo + it.tojson()) #escribo el .nfo por si aborta update + if item.contentType == "movie" and ".nfo" in archivo: + filetools.write(archivo, head_nfo + it.tojson()) #escribo el .nfo de la peli por si aborta update + if item.contentType != "movie" and "tvshow.nfo" in archivo: + filetools.write(archivo, head_nfo + it.tojson()) #escribo el tvshow.nfo por si aborta update + + #Aquí convertimos las películas. Después de borrado el .json, dejamos que videolibrarytools lo regenere + if item.contentType == "movie": #Dejamos que regenere el archivo .json + item_movie = item.clone() + item_movie.channel = canal_des_def #mombre del canal migrado + del item_movie.library_playcounts #Borramos lo que no es necesario en el .json + del item_movie.library_urls + item_movie.url = url_total #url migrada + del item_movie.nfo + del item_movie.path + del item_movie.strm_path + del item_movie.text_color + filetools.write(json_path, item_movie.tojson()) #Salvamos el nuevo .json de la película - #logger.debug(item) + if update_stat > 0 and path != False and ow_force_def != 'no': + logger.debug(item) return (item, it, overwrite) \ No newline at end of file From 8a125825cc54e5b85aa257a2575986f568e7109f Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Mon, 23 Jul 2018 14:59:05 +0200 Subject: [PATCH 12/29] Resuelto problema de que al marcar una temporada como vista/no vista en la Videoteca de Alfa en Windows, marcara toda la serie el Kodi MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Faltaba un paréntesis en el Where: sql = 'update files set playCount= %s where idFile in ' \ '(select idfile from episode_view where (strPath like "%s" or strPath like "%s")%s)' % \ (value, item_path1, item_path2, request_season) --- plugin.video.alfa/platformcode/xbmc_videolibrary.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.video.alfa/platformcode/xbmc_videolibrary.py b/plugin.video.alfa/platformcode/xbmc_videolibrary.py index be643879..a5948d5b 100755 --- a/plugin.video.alfa/platformcode/xbmc_videolibrary.py +++ b/plugin.video.alfa/platformcode/xbmc_videolibrary.py @@ -319,7 +319,7 @@ def mark_season_as_watched_on_kodi(item, value=1): item_path2 = item_path1.replace("\\", "/") sql = 'update files set playCount= %s where idFile in ' \ - '(select idfile from episode_view where strPath like "%s" or strPath like "%s"%s)' % \ + '(select idfile from episode_view where (strPath like "%s" or strPath like "%s")%s)' % \ (value, item_path1, item_path2, request_season) execute_sql_kodi(sql) From 0c0f160b71c8a80b0d1b2bcf4ee48436e7cc5f47 Mon Sep 17 00:00:00 2001 From: thedoctor66 <37449358+thedoctor66@users.noreply.github.com> Date: Mon, 23 Jul 2018 19:23:22 +0200 Subject: [PATCH 13/29] Update search.py --- plugin.video.alfa/channels/search.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin.video.alfa/channels/search.py b/plugin.video.alfa/channels/search.py index c2fd5e9c..3a9332cd 100644 --- a/plugin.video.alfa/channels/search.py +++ b/plugin.video.alfa/channels/search.py @@ -22,12 +22,12 @@ def mainlist(item): "action": "setting_channel", "channel": item.channel}] itemlist.append(Item(channel=item.channel, action="search", - title=config.get_localized_string(70276), context=context, + title=config.get_localized_string(30980), context=context, thumbnail=get_thumb("search.png"))) thumbnail = get_thumb("search_star.png") - itemlist.append(Item(channel='tvmoviedb', title=config.get_localized_string(59999), action="search_", + itemlist.append(Item(channel='tvmoviedb', title=config.get_localized_string(70036), action="search_", search={'url': 'search/person', 'language': 'es', 'page': 1}, star=True, thumbnail=thumbnail)) From 8e7140f4aa06d8b26ff5bd74968c015b0d349e59 Mon Sep 17 00:00:00 2001 From: Intel1 Date: Mon, 23 Jul 2018 17:46:38 -0500 Subject: [PATCH 14/29] Actualizados bajui: eliminado, web ya no existe divxtotal: eliminado, web ya no existe guaridavalencianista: eliminado, web ya no existe lacajita: eliminado, web ya no existe doom: fix locopelis: fix retroseriestv: nuevo canal veseriesonline: agregado json hdfull: fix para aparecer infoplus en findvideos --- plugin.video.alfa/channels/bajui.json | 26 - plugin.video.alfa/channels/bajui.py | 247 --------- plugin.video.alfa/channels/divxtotal.json | 39 -- plugin.video.alfa/channels/divxtotal.py | 500 ------------------ plugin.video.alfa/channels/doomtv.py | 62 +-- .../channels/guaridavalencianista.json | 12 - .../channels/guaridavalencianista.py | 177 ------- plugin.video.alfa/channels/hdfull.py | 152 +----- plugin.video.alfa/channels/lacajita.json | 69 --- plugin.video.alfa/channels/lacajita.py | 297 ----------- plugin.video.alfa/channels/locopelis.py | 49 +- plugin.video.alfa/channels/retroseriestv.json | 22 + plugin.video.alfa/channels/retroseriestv.py | 214 ++++++++ .../channels/veseriesonline.json | 37 ++ plugin.video.alfa/channels/veseriesonline.pyo | Bin 8550 -> 0 bytes 15 files changed, 340 insertions(+), 1563 deletions(-) delete mode 100644 plugin.video.alfa/channels/bajui.json delete mode 100644 plugin.video.alfa/channels/bajui.py delete mode 100755 plugin.video.alfa/channels/divxtotal.json delete mode 100644 plugin.video.alfa/channels/divxtotal.py delete mode 100755 plugin.video.alfa/channels/guaridavalencianista.json delete mode 100755 plugin.video.alfa/channels/guaridavalencianista.py delete mode 100755 plugin.video.alfa/channels/lacajita.json delete mode 100644 plugin.video.alfa/channels/lacajita.py create mode 100644 plugin.video.alfa/channels/retroseriestv.json create mode 100644 plugin.video.alfa/channels/retroseriestv.py create mode 100644 plugin.video.alfa/channels/veseriesonline.json delete mode 100644 plugin.video.alfa/channels/veseriesonline.pyo diff --git a/plugin.video.alfa/channels/bajui.json b/plugin.video.alfa/channels/bajui.json deleted file mode 100644 index 98d9be1f..00000000 --- a/plugin.video.alfa/channels/bajui.json +++ /dev/null @@ -1,26 +0,0 @@ -{ - "id": "bajui", - "name": "Bajui", - "active": false, - "adult": false, - "language": ["cast"], - "thumbnail": "bajui.png", - "banner": "bajui.png", - "fanart": "bajui.png", - "categories": [ - "movie", - "tvshow", - "documentary", - "vos" - ], - "settings": [ - { - "id": "include_in_global_search", - "type": "bool", - "label": "Incluir en busqueda global", - "default": false, - "enabled": true, - "visible": true - } - ] -} diff --git a/plugin.video.alfa/channels/bajui.py b/plugin.video.alfa/channels/bajui.py deleted file mode 100644 index fde86422..00000000 --- a/plugin.video.alfa/channels/bajui.py +++ /dev/null @@ -1,247 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -import urlparse - -from core import httptools -from core import scrapertools -from core import servertools -from core.item import Item -from platformcode import logger -from channelselector import get_thumb - - -def mainlist(item): - logger.info() - itemlist = [] - itemlist.append(Item(channel=item.channel, title="Películas", action="menupeliculas", - url="http://www.bajui.org/descargas/categoria/2/peliculas", - fanart=item.fanart, thumbnail=get_thumb('movies', auto=True))) - itemlist.append(Item(channel=item.channel, title="Series", action="menuseries", - fanart=item.fanart, thumbnail=get_thumb('tvshows', auto=True))) - itemlist.append(Item(channel=item.channel, title="Documentales", action="menudocumentales", - fanart=item.fanart, thumbnail=get_thumb('documentaries', auto=True))) - itemlist.append(Item(channel=item.channel, title="Buscar", action="search", - fanart=item.fanart, thumbnail=get_thumb('search', auto=True))) - return itemlist - - -def menupeliculas(item): - logger.info() - itemlist = [] - itemlist.append(Item(channel=item.channel, title="Películas - Novedades", action="peliculas", url=item.url, - fanart=item.fanart, viewmode="movie_with_plot")) - itemlist.append( - Item(channel=item.channel, title="Películas - A-Z", action="peliculas", url=item.url + "/orden:nombre", - fanart=item.fanart, viewmode="movie_with_plot")) - - data = httptools.downloadpage(item.url).data - data = scrapertools.get_match(data, '') - patron = '([^<]+)' - matches = re.compile(patron, re.DOTALL).findall(data) - for url, title in matches: - scrapedurl = urlparse.urljoin(item.url, url) - itemlist.append(Item(channel=item.channel, title="Películas en " + title, action="peliculas", url=scrapedurl, - fanart=item.fanart, viewmode="movie_with_plot")) - - itemlist.append(Item(channel=item.channel, title="Buscar", action="search", url="", fanart=item.fanart)) - return itemlist - - -def menuseries(item): - logger.info() - itemlist = [] - itemlist.append(Item(channel=item.channel, title="Series - Novedades", action="peliculas", - url="http://www.bajui.org/descargas/categoria/3/series", - fanart=item.fanart, viewmode="movie_with_plot")) - itemlist.append(Item(channel=item.channel, title="Series - A-Z", action="peliculas", - url="http://www.bajui.org/descargas/categoria/3/series/orden:nombre", - fanart=item.fanart, viewmode="movie_with_plot")) - itemlist.append(Item(channel=item.channel, title="Series - HD", action="peliculas", - url="http://www.bajui.org/descargas/subcategoria/11/hd/orden:nombre", - fanart=item.fanart, viewmode="movie_with_plot")) - itemlist.append(Item(channel=item.channel, title="Buscar", action="search", url="", - fanart=item.fanart)) - return itemlist - - -def menudocumentales(item): - logger.info() - itemlist = [] - itemlist.append(Item(channel=item.channel, title="Documentales - Novedades", action="peliculas", - url="http://www.bajui.org/descargas/categoria/7/docus-y-tv", - fanart=item.fanart, viewmode="movie_with_plot")) - itemlist.append(Item(channel=item.channel, title="Documentales - A-Z", action="peliculas", - url="http://www.bajui.org/descargas/categoria/7/docus-y-tv/orden:nombre", - fanart=item.fanart, viewmode="movie_with_plot")) - itemlist.append(Item(channel=item.channel, title="Buscar", action="search", url="", - fanart=item.fanart)) - return itemlist - - -def search(item, texto, categoria=""): - logger.info(item.url + " search " + texto) - itemlist = [] - url = item.url - texto = texto.replace(" ", "+") - logger.info("categoria: " + categoria + " url: " + url) - try: - item.url = "http://www.bajui.org/descargas/busqueda/%s" - item.url = item.url % texto - itemlist.extend(peliculas(item)) - return itemlist - # Se captura la excepción, para no interrumpir al buscador global si un canal falla - except: - import sys - for line in sys.exc_info(): - logger.error("%s" % line) - return [] - - -def peliculas(item, paginacion=True): - logger.info() - url = item.url - data = httptools.downloadpage(url).data - patron = '
  • 0: - scrapedurl = urlparse.urljoin("http://www.bajui.org/", matches[0]) - pagitem = Item(channel=item.channel, action="peliculas", title=">> Página siguiente", url=scrapedurl, - fanart=item.fanart, viewmode="movie_with_plot") - if not paginacion: - itemlist.extend(peliculas(pagitem)) - else: - itemlist.append(pagitem) - - return itemlist - - -def clean_plot(scrapedplot): - scrapedplot = scrapedplot.replace("\n", "").replace("\r", "") - scrapedplot = re.compile("TÍTULO ORIGINAL[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("AÑO[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Año[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("DURACIÓN[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Duración[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("PAIS[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("PAÍS[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Pais[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("País[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("DIRECTOR[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("DIRECCIÓN[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Dirección[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("REPARTO[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Reparto[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Interpretación[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("GUIÓN[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Guión[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("MÚSICA[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Música[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("FOTOGRAFÍA[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Fotografía[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("PRODUCTORA[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Producción[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Montaje[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Vestuario[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("GÉNERO[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("GENERO[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Genero[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Género[^<]+
    ", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("PREMIOS[^<]+
    ", re.DOTALL).sub("", scrapedplot) - - scrapedplot = re.compile("SINOPSIS", re.DOTALL).sub("", scrapedplot) - scrapedplot = re.compile("Sinopsis", re.DOTALL).sub("", scrapedplot) - scrapedplot = scrapertools.htmlclean(scrapedplot) - return scrapedplot - - -def enlaces(item): - logger.info() - itemlist = [] - - data = httptools.downloadpage(item.url).data - - try: - item.plot = scrapertools.get_match(data, '(.*?)') - item.plot = clean_plot(item.plot) - except: - pass - - try: - item.thumbnail = scrapertools.get_match(data, '
    ]+>Mostrar enlaces
    [^<]+' - patron += '
    (.*?)
    ' - - matches = re.compile(patron, re.DOTALL).findall(data) - scrapertools.printMatches(matches) - - for thumbnail, usuario, fecha, id, id2, servidores in matches: - patronservidores = '.*?\(current\).*?href='([^']+)'") - if len(next) > 0: - url = next - itemlist.append(item.clone(title="[COLOR springgreen][B]Siguiente >>[/B][/COLOR]", action="buscador", url=url)) - try: - from core import tmdb - tmdb.set_infoLabels_itemlist(itemlist, __modo_grafico__) - for item in itemlist: - if not "Siguiente >>" in item.title: - if "0." in str(item.infoLabels['rating']): - item.infoLabels['rating'] = "[COLOR indianred]Sin puntuacíon[/COLOR]" - else: - item.infoLabels['rating'] = "[COLOR springgreen]" + str(item.infoLabels['rating']) + "[/COLOR]" - item.title = item.title + " " + str(item.infoLabels['rating']) - except: - pass - return itemlist - - -def scraper(item): - logger.info() - itemlist = [] - data = httptools.downloadpage(item.url, headers=header, cookies=False).data - data = re.sub(r"\n|\r|\t|\s{2}| ", "", data) - if item.contentType == "movie": - patron = '' - matches = scrapertools.find_multiple_matches(data, patron) - for url, title, year in matches: - titulo = re.sub(r"\d+\d+\d+\d+|\(.*?\).*", "", title) - title = re.sub(r"!|¡|HD|\d+\d+\d+\d+|\(.*?\).*", "", title) - title = title.replace("Autosia", "Autopsia") - title = re.sub(r"’|PRE-Estreno", "'", title) - new_item = item.clone(action="findvideos", title="[COLOR orange]" + titulo + "[/COLOR]", url=url, - fulltitle=title, contentTitle=title, contentType="movie", extra=year, library=True) - new_item.infoLabels['year'] = get_year(url) - itemlist.append(new_item) - else: - patron = '(?s)

    .*?\(current\).*?href='([^']+)'") - if len(next) > 0: - url = next - - itemlist.append( - item.clone(title="[COLOR springgreen][B]Siguiente >>[/B][/COLOR]", thumbnail="http://imgur.com/a7lQAld.png", - url=url)) - try: - from core import tmdb - tmdb.set_infoLabels_itemlist(itemlist, __modo_grafico__) - for item in itemlist: - if not "Siguiente >>" in item.title: - if "0." in str(item.infoLabels['rating']): - item.infoLabels['rating'] = "[COLOR indianred]Sin puntuacíon[/COLOR]" - else: - item.infoLabels['rating'] = "[COLOR springgreen]" + str(item.infoLabels['rating']) + "[/COLOR]" - item.title = item.title + " " + str(item.infoLabels['rating']) - - except: - pass - return itemlist - - -def findtemporadas(item): - logger.info() - itemlist = [] - data = httptools.downloadpage(item.url).data - data = re.sub(r"\n|\r|\t|\s{2}| ", "", data) - if len(item.extra.split("|")): - if len(item.extra.split("|")) >= 4: - fanart = item.extra.split("|")[2] - extra = item.extra.split("|")[3] - try: - fanart_extra = item.extra.split("|")[4] - except: - fanart_extra = item.extra.split("|")[3] - try: - fanart_info = item.extra.split("|")[5] - except: - fanart_extra = item.extra.split("|")[3] - elif len(item.extra.split("|")) == 3: - fanart = item.extra.split("|")[2] - extra = item.extra.split("|")[0] - fanart_extra = item.extra.split("|")[0] - fanart_info = item.extra.split("|")[1] - elif len(item.extra.split("|")) == 2: - fanart = item.extra.split("|")[1] - extra = item.extra.split("|")[0] - fanart_extra = item.extra.split("|")[0] - fanart_info = item.extra.split("|")[1] - else: - extra = item.extra - fanart_extra = item.extra - fanart_info = item.extra - try: - logger.info(fanart_extra) - logger.info(fanart_info) - except: - fanart_extra = item.fanart - fanart_info = item.fanart - bloque_episodios = scrapertools.find_multiple_matches(data, 'Temporada (\d+).*?<\/a>(.*?)<\/table>') - for temporada, bloque_epis in bloque_episodios: - item.infoLabels = item.InfoLabels - item.infoLabels['season'] = temporada - itemlist.append(item.clone(action="epis", - title="[COLOR saddlebrown][B]Temporada [/B][/COLOR]" + "[COLOR sandybrown][B]" + temporada + "[/B][/COLOR]", - url=bloque_epis, contentType=item.contentType, contentTitle=item.contentTitle, - show=item.show, extra=item.extra, fanart_extra=fanart_extra, fanart_info=fanart_info, - datalibrary=data, folder=True)) - tmdb.set_infoLabels_itemlist(itemlist, __modo_grafico__) - for item in itemlist: - item.fanart = fanart - item.extra = extra - if config.get_videolibrary_support() and itemlist: - if len(bloque_episodios) == 1: - extra = "epis" - else: - extra = "epis###serie_add" - - infoLabels = {'tmdb_id': item.infoLabels['tmdb_id'], 'tvdb_id': item.infoLabels['tvdb_id'], - 'imdb_id': item.infoLabels['imdb_id']} - itemlist.append(Item(channel=item.channel, title="Añadir esta serie a la videoteca", text_color="0xFFe5ffcc", - action="add_serie_to_library", extra=extra, url=item.url, - contentSerieName=item.fulltitle, infoLabels=infoLabels, - thumbnail='http://imgur.com/xQNTqqy.png', datalibrary=data)) - return itemlist - - -def epis(item): - logger.info() - itemlist = [] - if item.extra == "serie_add": - item.url = item.datalibrary - patron = '.*?(\d+x\d+).*?td>' - matches = scrapertools.find_multiple_matches(item.url, patron) - for idioma, url, epi in matches: - episodio = scrapertools.find_single_match(epi, '\d+x(\d+)') - item.infoLabels['episode'] = episodio - itemlist.append( - item.clone(title="[COLOR orange]" + epi + "[/COLOR]" + "[COLOR sandybrown] " + idioma + "[/COLOR]", url=url, - action="findvideos", show=item.show, fanart=item.extra, extra=item.extra, - fanart_extra=item.fanart_extra, fanart_info=item.fanart_info, folder=True)) - if item.extra != "serie_add": - tmdb.set_infoLabels_itemlist(itemlist, __modo_grafico__) - for item in itemlist: - item.fanart = item.extra - if item.infoLabels['title']: title = "[COLOR burlywood]" + item.infoLabels['title'] + "[/COLOR]" - item.title = item.title + " -- \"" + title + "\"" - return itemlist - - -def findvideos(item): - logger.info() - itemlist = [] - data = httptools.downloadpage(item.url).data - if item.contentType != "movie": - if not item.infoLabels['episode']: - capitulo = scrapertools.find_single_match(item.title, '(\d+x\d+)') - patron = '= 2: - extra = item.extra - else: - extra = item.fanart - else: - capitulo = item.title - url_capitulo = item.url - - ext_v, size = ext_size(url_capitulo) - try: - fanart = item.fanart_extra - except: - fanart = item.extra.split("|")[0] - itemlist.append(Item(channel=item.channel, - title="[COLOR chocolate][B]Ver capítulo " + capitulo + "[/B][/COLOR]" + "-" + "[COLOR khaki] ( Video" + "[/COLOR]" + " " + "[COLOR khaki]" + ext_v + "[/COLOR]" + " " + "[COLOR khaki] " + size + " )" + "[/COLOR]", - url=url_capitulo, action="play", server="torrent", fanart=fanart, thumbnail=item.thumbnail, - extra=item.extra, fulltitle=item.fulltitle, folder=False)) - if item.infoLabels['episode'] and item.library: - thumbnail = scrapertools.find_single_match(item.extra, 'http://assets.fanart.tv/.*jpg') - if thumbnail == "": - thumbnail = item.thumbnail - if not "assets.fanart" in item.fanart_info: - fanart = item.fanart_info - else: - fanart = item.fanart - itemlist.append(Item(channel=item.channel, title="[COLOR darksalmon][B] info[/B][/COLOR]", - action="info_capitulos", fanart=fanart, thumbnail=item.thumb_art, - thumb_info=item.thumb_info, extra=item.extra, show=item.show, - InfoLabels=item.infoLabels, folder=False)) - if not item.infoLabels['episode']: - itemlist.append( - Item(channel=item.channel, title="[COLOR moccasin][B]Todos los episodios[/B][/COLOR]", url=item.url, - action="findtemporadas", server="torrent", - thumbnail=item.thumbnail, extra=item.extra + "|" + item.thumbnail, contentType=item.contentType, - contentTitle=item.contentTitle, InfoLabels=item.infoLabels, thumb_art=item.thumb_art, - thumb_info=item.thumbnail, fulltitle=item.fulltitle, library=item.library, folder=True)) - else: - url = scrapertools.find_single_match(data, '

    .*?href="([^"]+)"') - item.infoLabels['year'] = None - ext_v, size = ext_size(url) - itemlist.append(Item(channel=item.channel, - title="[COLOR saddlebrown][B]Torrent [/B][/COLOR]" + "-" + "[COLOR khaki] ( Video" + "[/COLOR]" + " " + "[COLOR khaki]" + ext_v + "[/COLOR]" + " " + "[COLOR khaki] " + size + " )" + "[/COLOR]", - url=url, action="play", server="torrent", fanart=item.fanart, thumbnail=item.thumbnail, - extra=item.extra, InfoLabels=item.infoLabels, folder=False)) - - if item.library and config.get_videolibrary_support() and len(itemlist) > 0: - infoLabels = {'tmdb_id': item.infoLabels['tmdb_id'], - 'title': item.infoLabels['title']} - itemlist.append(Item(channel=item.channel, title="Añadir esta película a la videoteca", - action="add_pelicula_to_library", url=item.url, infoLabels=infoLabels, - text_color="0xFFe5ffcc", - thumbnail='http://imgur.com/xQNTqqy.png')) - return itemlist - - -def info_capitulos(item, images={}): - logger.info() - try: - url = "http://thetvdb.com/api/1D62F2F90030C444/series/" + str(item.InfoLabels['tvdb_id']) + "/default/" + str( - item.InfoLabels['season']) + "/" + str(item.InfoLabels['episode']) + "/es.xml" - if "/0" in url: - url = url.replace("/0", "/") - from core import jsontools - data = httptools.downloadpage(url).data - if "episodes" in data: - image = scrapertools.find_single_match(data, '.*?(.*?)') - image = "http://thetvdb.com/banners/" + image - else: - try: - image = item.InfoLabels['episodio_imagen'] - except: - image = "http://imgur.com/ZiEAVOD.png" - - foto = item.thumb_info - if not ".png" in foto: - foto = "http://imgur.com/PRiEW1D.png" - try: - title = item.InfoLabels['episodio_titulo'] - except: - title = "" - title = "[COLOR red][B]" + title + "[/B][/COLOR]" - - try: - plot = "[COLOR peachpuff]" + str(item.InfoLabels['episodio_sinopsis']) + "[/COLOR]" - except: - plot = scrapertools.find_single_match(data, '(.*?)') - if plot == "": - plot = "Sin información todavia" - try: - rating = item.InfoLabels['episodio_vote_average'] - except: - rating = 0 - try: - if rating >= 5 and rating < 8: - rating = "[COLOR yellow]Puntuación[/COLOR] " + "[COLOR springgreen][B]" + str(rating) + "[/B][/COLOR]" - elif rating >= 8 and rating < 10: - rating = "[COLOR yellow]Puntuación[/COLOR] " + "[COLOR yellow][B]" + str(rating) + "[/B][/COLOR]" - elif rating == 10: - rating = "[COLOR yellow]Puntuación[/COLOR] " + "[COLOR orangered][B]" + str(rating) + "[/B][/COLOR]" - else: - rating = "[COLOR yellow]Puntuación[/COLOR] " + "[COLOR crimson][B]" + str(rating) + "[/B][/COLOR]" - except: - rating = "[COLOR yellow]Puntuación[/COLOR] " + "[COLOR crimson][B]" + str(rating) + "[/B][/COLOR]" - if "10." in rating: - rating = re.sub(r'10\.\d+', '10', rating) - except: - title = "[COLOR red][B]LO SENTIMOS...[/B][/COLOR]" - plot = "Este capitulo no tiene informacion..." - plot = "[COLOR yellow][B]" + plot + "[/B][/COLOR]" - image = "http://s6.postimg.cc/ub7pb76c1/noinfo.png" - foto = "http://s6.postimg.cc/nm3gk1xox/noinfosup2.png" - rating = "" - ventana = TextBox2(title=title, plot=plot, thumbnail=image, fanart=foto, rating=rating) - ventana.doModal() - - -def tokenize(text, match=re.compile("([idel])|(\d+):|(-?\d+)").match): - i = 0 - while i < len(text): - m = match(text, i) - s = m.group(m.lastindex) - i = m.end() - if m.lastindex == 2: - yield "s" - yield text[i:i + int(s)] - i = i + int(s) - else: - yield s - - -def decode_item(next, token): - if token == "i": - # integer: "i" value "e" - data = int(next()) - if next() != "e": - raise ValueError - elif token == "s": - # string: "s" value (virtual tokens) - data = next() - elif token == "l" or token == "d": - # container: "l" (or "d") values "e" - data = [] - tok = next() - while tok != "e": - data.append(decode_item(next, tok)) - tok = next() - if token == "d": - data = dict(zip(data[0::2], data[1::2])) - else: - raise ValueError - return data - - -def decode(text): - try: - src = tokenize(text) - data = decode_item(src.next, src.next()) - for token in src: # look for more tokens - raise SyntaxError("trailing junk") - except (AttributeError, ValueError, StopIteration): - try: - data = data - except: - data = src - return data - - -def convert_size(size): - import math - if (size == 0): - return '0B' - size_name = ("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB") - i = int(math.floor(math.log(size, 1024))) - p = math.pow(1024, i) - s = round(size / p, 2) - return '%s %s' % (s, size_name[i]) - - -def get_year(url): - data = httptools.downloadpage(url, headers=header, cookies=False).data - data = re.sub(r"\n|\r|\t|\s{2}| ", "", data) - year = scrapertools.find_single_match(data, '

    .*?(\d+\d+\d+\d+)') - if year == "": - year = " " - return year - - -def ext_size(url): - torrents_path = config.get_videolibrary_path() + '/torrents' - if not os.path.exists(torrents_path): - os.mkdir(torrents_path) - try: - urllib.urlretrieve("http://anonymouse.org/cgi-bin/anon-www.cgi/" + url, torrents_path + "/temp.torrent") - pepe = open(torrents_path + "/temp.torrent", "rb").read() - except: - pepe = "" - torrent = decode(pepe) - try: - name = torrent["info"]["name"] - sizet = torrent["info"]['length'] - sizet = convert_size(sizet) - except: - name = "no disponible" - try: - check_video = scrapertools.find_multiple_matches(str(torrent["info"]["files"]), "'length': (\d+)}") - size = max([int(i) for i in check_video]) - for file in torrent["info"]["files"]: - manolo = "%r - %d bytes" % ("/".join(file["path"]), file["length"]) - if str(size) in manolo: - video = manolo - size = convert_size(size) - ext_v = re.sub(r"-.*? bytes|.*?\[.*?\].|'|.*?COM.|.*?\[.*?\]|\(.*?\)|.*?\.", "", video) - try: - os.remove(torrents_path + "/temp.torrent") - except: - pass - except: - try: - size = sizet - ext_v = re.sub(r"-.*? bytes|.*?\[.*?\].|'|.*?COM.|.*?\.es.|.*?\[.*?\]|.*?\(.*?\)\.|.*?\.", "", name) - except: - size = "NO REPRODUCIBLE" - ext_v = "" - try: - os.remove(torrents_path + "/temp.torrent") - except: - pass - if "rar" in ext_v: - ext_v = ext_v + " -- No reproducible" - size = "" - return ext_v, size - - -def newest(categoria): - logger.info() - itemlist = [] - item = Item() - try: - if categoria == 'torrent': - item.url = host + '/peliculas/' - item.contentType="movie" - itemlist = scraper(item) - if itemlist[-1].title == "[COLOR springgreen][B]Siguiente >>[/B][/COLOR]": - itemlist.pop() - # Se captura la excepción, para no interrumpir al canal novedades si un canal falla - except: - import sys - for line in sys.exc_info(): - logger.error("{0}".format(line)) - return [] - return itemlist diff --git a/plugin.video.alfa/channels/doomtv.py b/plugin.video.alfa/channels/doomtv.py index 4a9d5a38..d8c4907d 100644 --- a/plugin.video.alfa/channels/doomtv.py +++ b/plugin.video.alfa/channels/doomtv.py @@ -35,7 +35,9 @@ def mainlist(item): action="lista", thumbnail=get_thumb('all', auto=True), fanart='https://s18.postimg.cc/fwvaeo6qh/todas.png', - url='%s%s'%(host,'peliculas/page/1') + url='%s%s'%(host,'peliculas/'), + first=0 + )) itemlist.append( @@ -43,7 +45,7 @@ def mainlist(item): action="seccion", thumbnail=get_thumb('genres', auto=True), fanart='https://s3.postimg.cc/5s9jg2wtf/generos.png', - url='%s%s' % (host, 'peliculas/page/1'), + url='%s%s' % (host, 'peliculas/'), )) itemlist.append( @@ -51,7 +53,8 @@ def mainlist(item): action="lista", thumbnail=get_thumb('more watched', auto=True), fanart='https://s9.postimg.cc/wmhzu9d7z/vistas.png', - url='%s%s'%(host,'top-imdb/page/1'), + url='%s%s'%(host,'top-imdb/'), + first=0 )) itemlist.append( @@ -69,9 +72,7 @@ def lista(item): logger.info() itemlist = [] - max_items = 20 - next_page_url = '' - + next = False data = httptools.downloadpage(item.url).data data = re.sub(r'"|\n|\r|\t| |
    |\s{2,}', "", data) @@ -80,23 +81,13 @@ def lista(item): matches = re.compile(patron, re.DOTALL).findall(data) - if item.next_page != 'b': - if len(matches) > max_items: - next_page_url = item.url - matches = matches[:max_items] - next_page = 'b' - else: - matches = matches[max_items:] - next_page = 'a' - next_page_str = scrapertools.find_single_match(data,"
  • (\d+)") - next_page_num = int(next_page_str)+1 - page_base = re.sub(r'(page\/\d+)','', item.url) - next_page_url = '%s%s%s'%(page_base,'page/',next_page_num) + first = item.first + last = first + 19 + if last > len(matches): + last = len(matches) + next = True - if next_page_url: - next_page_url = next_page_url - - for scrapedurl, quality, scrapedthumbnail, scrapedtitle, plot in matches: + for scrapedurl, quality, scrapedthumbnail, scrapedtitle, plot in matches[first:last]: url = scrapedurl thumbnail = scrapedthumbnail @@ -118,17 +109,17 @@ def lista(item): contentTitle=title )) tmdb.set_infoLabels_itemlist(itemlist, seekTmdb = True) - # Paginacion - if next_page_url != '': - itemlist.append( - Item(channel=item.channel, - action="lista", - title='Siguiente >>>', - url=next_page_url, - thumbnail='https://s16.postimg.cc/9okdu7hhx/siguiente.png', - extra=item.extra, - next_page=next_page - )) + + if not next: + url_next_page = item.url + first = last + else: + url_next_page = scrapertools.find_single_match(data, "") + first = 0 + + if url_next_page: + itemlist.append(item.clone(title="Siguiente >>", url=url_next_page, action='lista', first=first)) + return itemlist @@ -153,7 +144,8 @@ def seccion(item): action='lista', title=title, url=url, - thumbnail=thumbnail + thumbnail=thumbnail, + first=0 )) return itemlist @@ -162,6 +154,7 @@ def search(item, texto): logger.info() texto = texto.replace(" ", "+") item.url = item.url + texto + item.first=0 if texto != '': return lista(item) @@ -178,6 +171,7 @@ def newest(categoria): item.url = host + 'categoria/animacion/' elif categoria == 'terror': item.url = host + '/categoria/terror/' + item.first=0 itemlist = lista(item) if itemlist[-1].title == 'Siguiente >>>': itemlist.pop() diff --git a/plugin.video.alfa/channels/guaridavalencianista.json b/plugin.video.alfa/channels/guaridavalencianista.json deleted file mode 100755 index 30e2e9d2..00000000 --- a/plugin.video.alfa/channels/guaridavalencianista.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "id": "guaridavalencianista", - "name": "La Guarida valencianista", - "active": false, - "adult": false, - "language": ["cast"], - "thumbnail": "guaridavalencianista.png", - "banner": "guaridavalencianista.png", - "categories": [ - "documentary" - ] -} diff --git a/plugin.video.alfa/channels/guaridavalencianista.py b/plugin.video.alfa/channels/guaridavalencianista.py deleted file mode 100755 index aa52d5da..00000000 --- a/plugin.video.alfa/channels/guaridavalencianista.py +++ /dev/null @@ -1,177 +0,0 @@ -# -*- coding: utf-8 -*- - -import re -import urlparse - -from core import scrapertools -from core import servertools -from core.item import Item -from platformcode import logger - - -def mainlist(item): - logger.info() - itemlist = [] - - itemlist.append(Item(channel=item.channel, title="Novedades", action="listvideos", - url="http://guaridavalencia.blogspot.com.es")) - # itemlist.append( Item(channel=item.channel, title="Documentales - Series Disponibles" , action="DocuSeries" , url="http://guaridavalencia.blogspot.com/")) - itemlist.append( - Item(channel=item.channel, title="Categorias", action="DocuTag", url="http://guaridavalencia.blogspot.com.es")) - itemlist.append(Item(channel=item.channel, title="Partidos de liga (Temporada 2014/2015)", action="listvideos", - url="http://guaridavalencia.blogspot.com.es/search/label/PARTIDOS%20DEL%20VCF%20%28TEMPORADA%202014-15%29")) - - return itemlist - - -def DocuSeries(item): - logger.info() - itemlist = [] - - # Descarga la página - data = scrapertools.cache_page(item.url) - - # Extrae las entradas (carpetas) - patronvideos = '
  • ([^<]+)
  • ' - matches = re.compile(patronvideos, re.DOTALL).findall(data) - scrapertools.printMatches(matches) - - for match in matches: - scrapedurl = match[0] - scrapedtitle = match[1] - scrapedthumbnail = "" - scrapedplot = "" - logger.debug("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]") - itemlist.append(Item(channel=item.channel, action="listvideos", title=scrapedtitle, url=scrapedurl, - thumbnail=scrapedthumbnail, plot=scrapedplot, folder=True)) - - return itemlist - - -def DocuTag(item): - logger.info() - itemlist = [] - # Descarga la página - data = scrapertools.cache_page(item.url) - # ~ patronvideos = "([^<]+)[^<]+(.+?)" - patronvideos = "([^<]+)[^0-9]+([0-9]+)[^<]+(.+?)" - matches = re.compile(patronvideos, re.DOTALL).findall(data) - scrapertools.printMatches(matches) - - for match in matches: - scrapedurl = match[0] - # Se debe quitar saltos de linea en match[1] - scrapedtitle = match[1][1:-1] + " (" + match[2] + ")" - # ~ scrapedtitle = match[1] - scrapedthumbnail = "" - scrapedplot = "" - logger.debug("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]") - itemlist.append(Item(channel=item.channel, action="listvideos", title=scrapedtitle, url=scrapedurl, - thumbnail=scrapedthumbnail, plot=scrapedplot, folder=True)) - - return itemlist - - -def DocuARCHIVO(item): - logger.info() - itemlist = [] - - # Descarga la página - data = scrapertools.cache_page(item.url) - patronvideos = "([^<]+)[^<]+" - patronvideos += "(.+?)" - matches = re.compile(patronvideos, re.DOTALL).findall(data) - scrapertools.printMatches(matches) - - for match in matches: - scrapedurl = match[0] - scrapedtitle = match[1] + " " + match[2] - scrapedthumbnail = "" - scrapedplot = "" - logger.debug("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]") - itemlist.append(Item(channel=item.channel, action="listvideos", title=scrapedtitle, url=scrapedurl, - thumbnail=scrapedthumbnail, plot=scrapedplot, folder=True)) - - return itemlist - - -def listvideos(item): - logger.info() - itemlist = [] - - scrapedthumbnail = "" - scrapedplot = "" - - # Descarga la página - data = scrapertools.cache_page(item.url) - patronvideos = "

    ]+>", " ", scrapedtitle) - scrapedtitle = scrapertools.unescape(scrapedtitle)[1:-1] - scrapedurl = match[0] - regexp = re.compile(r'src="(http[^"]+)"') - - matchthumb = regexp.search(match[2]) - if matchthumb is not None: - scrapedthumbnail = matchthumb.group(1) - matchplot = re.compile('
    (
    ', re.DOTALL).findall(match[2]) - - if len(matchplot) > 0: - scrapedplot = matchplot[0] - # print matchplot - else: - scrapedplot = "" - - scrapedplot = re.sub("<[^>]+>", " ", scrapedplot) - scrapedplot = scrapertools.unescape(scrapedplot) - logger.debug("title=[" + scrapedtitle + "], url=[" + scrapedurl + "], thumbnail=[" + scrapedthumbnail + "]") - itemlist.append(Item(channel=item.channel, action="findvideos", title=scrapedtitle, url=scrapedurl, - thumbnail=scrapedthumbnail, plot=scrapedplot, folder=True)) - - # Extrae la marca de siguiente página - patronvideos = " 0: - scrapedtitle = "Página siguiente" - scrapedurl = urlparse.urljoin(item.url, matches[0]) - scrapedthumbnail = "" - scrapedplot = "" - itemlist.append(Item(channel=item.channel, action="listvideos", title=scrapedtitle, url=scrapedurl, - thumbnail=scrapedthumbnail, plot=scrapedplot, folder=True)) - - return itemlist - - # ~ return itemlist - - -def findvideos(item): - logger.info() - data = scrapertools.cachePage(item.url) - - # Busca los enlaces a los videos - - listavideos = servertools.findvideos(data) - - if item is None: - item = Item() - - itemlist = [] - for video in listavideos: - scrapedtitle = video[0].strip() + " - " + item.title.strip() - scrapedurl = video[1] - server = video[2] - - itemlist.append(Item(channel=item.channel, title=scrapedtitle, action="play", server=server, url=scrapedurl, - thumbnail=item.thumbnail, show=item.show, plot=item.plot, folder=False)) - - return itemlist diff --git a/plugin.video.alfa/channels/hdfull.py b/plugin.video.alfa/channels/hdfull.py index f02dff6f..a05cd914 100644 --- a/plugin.video.alfa/channels/hdfull.py +++ b/plugin.video.alfa/channels/hdfull.py @@ -28,16 +28,12 @@ def settingCanal(item): def login(): logger.info() - data = agrupa_datos(httptools.downloadpage(host).data) - patron = "" sid = scrapertools.find_single_match(data, patron) - post = urllib.urlencode({'__csrf_magic': sid}) + "&username=" + config.get_setting('hdfulluser', 'hdfull') + "&password=" + config.get_setting( 'hdfullpassword', 'hdfull') + "&action=login" - httptools.downloadpage(host, post=post) @@ -56,15 +52,12 @@ def mainlist(item): else: login() itemlist.append(Item(channel=item.channel, action="settingCanal", title="Configuración...", url="")) - return itemlist def menupeliculas(item): logger.info() - itemlist = [] - if account: itemlist.append(Item(channel=item.channel, action="items_usuario", title="[COLOR orange][B]Favoritos[/B][/COLOR]", @@ -72,7 +65,6 @@ def menupeliculas(item): itemlist.append(Item(channel=item.channel, action="items_usuario", title="[COLOR orange][B]Pendientes[/B][/COLOR]", url=host + "/a/my?target=movies&action=pending&start=-28&limit=28", folder=True)) - itemlist.append(Item(channel=item.channel, action="fichas", title="ABC", url=host + "/peliculas/abc", folder=True)) itemlist.append( Item(channel=item.channel, action="fichas", title="Últimas películas", url=host + "/peliculas", folder=True)) @@ -89,15 +81,12 @@ def menupeliculas(item): itemlist.append(Item(channel=item.channel, action="items_usuario", title="[COLOR orange][B]Vistas[/B][/COLOR]", url=host + "/a/my?target=movies&action=seen&start=-28&limit=28", folder=True)) - return itemlist def menuseries(item): logger.info() - itemlist = [] - if account: itemlist.append(Item(channel=item.channel, action="items_usuario", title="[COLOR orange][B]Siguiendo[/B][/COLOR]", @@ -105,9 +94,7 @@ def menuseries(item): itemlist.append(Item(channel=item.channel, action="items_usuario", title="[COLOR orange][B]Para Ver[/B][/COLOR]", url=host + "/a/my?target=shows&action=watch&start=-28&limit=28", folder=True)) - itemlist.append(Item(channel=item.channel, action="series_abc", title="A-Z", folder=True)) - itemlist.append(Item(channel=item.channel, action="novedades_episodios", title="Últimos Emitidos", url=host + "/a/episodes?action=latest&start=-24&limit=24&elang=ALL", folder=True)) itemlist.append(Item(channel=item.channel, action="novedades_episodios", title="Episodios Estreno", @@ -132,20 +119,16 @@ def menuseries(item): itemlist.append(Item(channel=item.channel, action="items_usuario", title="[COLOR orange][B]Vistas[/B][/COLOR]", url=host + "/a/my?target=shows&action=seen&start=-28&limit=28", folder=True)) - return itemlist def search(item, texto): logger.info() - data = agrupa_datos(httptools.downloadpage(host).data) - sid = scrapertools.get_match(data, '.__csrf_magic. value="(sid:[^"]+)"') item.extra = urllib.urlencode({'__csrf_magic': sid}) + '&menu=search&query=' + texto item.title = "Buscar..." item.url = host + "/buscar" - try: return fichas(item) # Se captura la excepción, para no interrumpir al buscador global si un canal falla @@ -158,59 +141,44 @@ def search(item, texto): def series_abc(item): logger.info() - itemlist = [] - az = "ABCDEFGHIJKLMNOPQRSTUVWXYZ#" - for l in az: itemlist.append( Item(channel=item.channel, action='fichas', title=l, url=host + "/series/abc/" + l.replace('#', '9'))) - return itemlist def items_usuario(item): logger.info() - itemlist = [] ## Carga estados status = jsontools.load(httptools.downloadpage(host + '/a/status/all').data) - ## Fichas usuario url = item.url.split("?")[0] post = item.url.split("?")[1] - old_start = scrapertools.get_match(post, 'start=([^&]+)&') limit = scrapertools.get_match(post, 'limit=(\d+)') start = "%s" % (int(old_start) + int(limit)) - post = post.replace("start=" + old_start, "start=" + start) next_page = url + "?" + post - ## Carga las fichas de usuario data = httptools.downloadpage(url, post=post).data fichas_usuario = jsontools.load(data) - for ficha in fichas_usuario: - try: title = ficha['title']['es'].strip() except: title = ficha['title']['en'].strip() - try: title = title.encode('utf-8') except: pass - show = title - try: thumbnail = host + "/thumbs/" + ficha['thumbnail'] except: thumbnail = host + "/thumbs/" + ficha['thumb'] - try: url = urlparse.urljoin(host, '/serie/' + ficha['permalink']) + "###" + ficha['id'] + ";1" action = "episodios" @@ -237,37 +205,26 @@ def items_usuario(item): action = "findvideos" str = get_status(status, 'movies', ficha['id']) if str != "": title += str - - # try: title = title.encode('utf-8') - # except: pass - itemlist.append( Item(channel=item.channel, action=action, title=title, fulltitle=title, url=url, thumbnail=thumbnail, show=show, folder=True)) - if len(itemlist) == int(limit): itemlist.append( Item(channel=item.channel, action="items_usuario", title=">> Página siguiente", url=next_page, folder=True)) - return itemlist def listado_series(item): logger.info() - itemlist = [] - data = agrupa_datos(httptools.downloadpage(item.url).data) - patron = '' matches = re.compile(patron, re.DOTALL).findall(data) - for scrapedurl, scrapedtitle in matches: url = scrapedurl + "###0;1" itemlist.append( Item(channel=item.channel, action="episodios", title=scrapedtitle, fulltitle=scrapedtitle, url=url, show=scrapedtitle, contentType="tvshow")) - return itemlist @@ -278,22 +235,19 @@ def fichas(item): infoLabels=dict() ## Carga estados status = jsontools.load(httptools.downloadpage(host + '/a/status/all').data) - if item.title == "Buscar...": data = agrupa_datos(httptools.downloadpage(item.url, post=item.extra).data) s_p = scrapertools.get_match(data, '

    (.*?)') except: - logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + video_section) - itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) - return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + pass + cnt_next += 1 if not data: #Si la web está caída salimos sin dar error logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + video_section) @@ -178,6 +196,11 @@ def listado(item): matches_alt = re.compile(patron, re.DOTALL).findall(video_section) if not matches_alt and not '
    0 resultados' in data: #error + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + item, itemlist = generictools.post_tmdb_listado(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + logger.error("ERROR 02: LISTADO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: LISTADO: Ha cambiado la estructura de la Web. Reportar el error con el log')) return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos @@ -349,9 +372,13 @@ def findvideos(item): itemlist = [] #Bajamos los datos de la página + data = '' try: data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) except: + pass + + if not data: logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: FINDVIDEOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log')) return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos @@ -361,6 +388,11 @@ def findvideos(item): patron = '\/icono_.*?png" title="(?P.*?)?" [^>]+><\/td>(?P.*?)?.*?(?P.*?)?<\/td>)", "", httptools.downloadpage(item.url).data) data = data.replace('"', "'") except: #Algún error de proceso, salimos + pass + + if not data: logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea" + item.url) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: EPISODIOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log')) return itemlist diff --git a/plugin.video.alfa/channels/newpct1.py b/plugin.video.alfa/channels/newpct1.py index 9cae9612..89a6f77e 100644 --- a/plugin.video.alfa/channels/newpct1.py +++ b/plugin.video.alfa/channels/newpct1.py @@ -134,6 +134,13 @@ def submenu(item): patron = '
  • <\/i>.*Inicio<\/a><\/li>(.+)<\/ul>\s?<\/nav>' #Verificamos si se ha cargado una página, y si además tiene la estructura correcta if not data or not scrapertools.find_single_match(data, patron): + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + for clone_inter, autoridad in item.intervencion: + thumb_intervenido = get_thumb(autoridad) + itemlist.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido)) + return itemlist #Salimos + logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url + data) #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú item, data = generictools.fail_over_newpct1(item, patron) @@ -211,6 +218,13 @@ def submenu_novedades(item): patron = '
    .*?
      (.*?)
    ' #seleccionamos el bloque que nos interesa if not data or (not scrapertools.find_single_match(data, patron) and not '

    ( 0 ) Resultados encontrados ' in data): + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + item, itemlist = generictools.post_tmdb_listado(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data) #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú item, data = generictools.fail_over_newpct1(item, patron) @@ -650,6 +676,7 @@ def listado_busqueda(item): #Máximo num. de líneas permitidas por TMDB. Máx de 5 páginas por Itemlist para no degradar el rendimiento while cnt_title <= cnt_tot and cnt_next < 5: + data = '' try: data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url, post=item.post, timeout=timeout_search).data) except: @@ -661,6 +688,11 @@ def listado_busqueda(item): else: pattern = '
      (.*?)
    ' % item.pattern #seleccionamos el bloque que nos interesa if not data or (not scrapertools.find_single_match(data, pattern) and not '

    ( 0 ) Resultados encontrados ' in data): + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + item, itemlist = generictools.post_tmdb_listado(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + logger.error("ERROR 01: LISTADO_BUSQUEDA: La Web no responde o ha cambiado de URL: " + item.url + item.post + " / DATA: " + data) #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú item, data = generictools.fail_over_newpct1(item, pattern) @@ -1236,6 +1268,11 @@ def findvideos(item): patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent #Verificamos si se ha cargado una página, y si además tiene la estructura correcta if not data or not scrapertools.find_single_match(data, patron): + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data) #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el vídeo @@ -1531,6 +1568,11 @@ def episodios(item): #Verificamos si se ha cargado una página, y si además tiene la estructura correcta if not data_alt or not scrapertools.find_single_match(data_alt, pattern): + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + item, itemlist = generictools.post_tmdb_episodios(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea: " + item.url) logger.error(pattern + data) diff --git a/plugin.video.alfa/lib/generictools.py b/plugin.video.alfa/lib/generictools.py index 57fda526..8027c314 100644 --- a/plugin.video.alfa/lib/generictools.py +++ b/plugin.video.alfa/lib/generictools.py @@ -665,6 +665,7 @@ def post_tmdb_findvideos(item, itemlist): En Itemlist devuelve un Item con el pseudotítulo. Ahí el canal irá agregando el resto. """ + #logger.debug(item) #Creción de título general del vídeo a visualizar en Findvideos itemlist = [] @@ -684,11 +685,12 @@ def post_tmdb_findvideos(item, itemlist): if item.infoLabels['temporada_num_episodios'] and item.contentEpisodeNumber <= item.infoLabels['temporada_num_episodios']: num_episodios = item.infoLabels['temporada_num_episodios'] - # Obtener la información actualizada del Episodio, si no la hay. Siempre cuando viene de Videoteca - if not item.infoLabels['tmdb_id'] or (not item.infoLabels['episodio_titulo'] and item.contentType == 'episode'): - tmdb.set_infoLabels(item, True) - elif (not item.infoLabels['tvdb_id'] and item.contentType == 'episode') or item.contentChannel == "videolibrary": - tmdb.set_infoLabels(item, True) + # Obtener la información actualizada del vídeo. En una segunda lectura de TMDB da más información que en la primera + #if not item.infoLabels['tmdb_id'] or (not item.infoLabels['episodio_titulo'] and item.contentType == 'episode'): + # tmdb.set_infoLabels(item, True) + #elif (not item.infoLabels['tvdb_id'] and item.contentType == 'episode') or item.contentChannel == "videolibrary": + # tmdb.set_infoLabels(item, True) + tmdb.set_infoLabels(item, True) #Restauramos la información de max num. de episodios por temporada despues de TMDB try: if item.infoLabels['temporada_num_episodios']: @@ -698,7 +700,7 @@ def post_tmdb_findvideos(item, itemlist): item.infoLabels['temporada_num_episodios'] = num_episodios except: pass - + #Quitamos el la categoría o nombre del título, si lo tiene if item.contentTitle: item.contentTitle = re.sub(r' -%s-' % item.category, '', item.contentTitle) @@ -722,27 +724,34 @@ def post_tmdb_findvideos(item, itemlist): if item.quality.lower() in ['gb', 'mb']: item.quality = item.quality.replace('GB', 'G B').replace('Gb', 'G b').replace('MB', 'M B').replace('Mb', 'M b') + + #busco "duration" en infoLabels + tiempo = 0 + if item.infoLabels['duration']: + tiempo = item.infoLabels['duration'] + elif item.contentChannel == 'videolibrary': #No hay, viene de la Videoteca? buscamos en la DB #Leo de la BD de Kodi la duración de la película o episodio. En "from_fields" se pueden poner las columnas que se quiera - nun_records = 0 - if item.contentType == 'movie': - nun_records, records = get_field_from_kodi_DB(item, from_fields='c11') #Leo de la BD de Kodi la duración de la película - else: - nun_records, records = get_field_from_kodi_DB(item, from_fields='c09') #Leo de la BD de Kodi la duración del episodio - if nun_records > 0: #Hay registros? - for strFileName, field1 in records: #Es un array, busco el campo del registro: añadir en el FOR un fieldX por nueva columna - tiempo_final = 0 - try: - tiempo_final = int(field1) #lo convierto a int, pero puede se null - if tiempo_final == 0: #en episodios suele estar a 0 - continue #pasamos - if tiempo_final > 700: #Si está en segundos - tiempo_final = tiempo_final / 60 #Lo transformo a minutos - horas = tiempo_final / 60 #Lo transformo a horas - resto = tiempo_final - (horas * 60) #guardo el resto de minutos de la hora - item.quality += ' [%s:%s]' % (str(horas).zfill(2), str(resto).zfill(2)) #Lo agrego a Calidad del Servidor - except: - pass + nun_records = 0 + if item.contentType == 'movie': + nun_records, records = get_field_from_kodi_DB(item, from_fields='c11') #Leo de la BD de Kodi la duración de la película + else: + nun_records, records = get_field_from_kodi_DB(item, from_fields='c09') #Leo de la BD de Kodi la duración del episodio + if nun_records > 0: #Hay registros? + #Es un array, busco el campo del registro: añadir en el FOR un fieldX por nueva columna + for strFileName, field1 in records: + tiempo = field1 + + try: #calculamos el timepo en hh:mm + tiempo_final = int(tiempo) #lo convierto a int, pero puede se null + if tiempo_final > 0: #Si el tiempo está a 0, pasamos + if tiempo_final > 700: #Si está en segundos + tiempo_final = tiempo_final / 60 #Lo transformo a minutos + horas = tiempo_final / 60 #Lo transformo a horas + resto = tiempo_final - (horas * 60) #guardo el resto de minutos de la hora + item.quality += ' [%s:%s]' % (str(horas).zfill(2), str(resto).zfill(2)) #Lo agrego a Calidad del Servidor + except: + pass #Ajustamos el nombre de la categoría if item.channel != channel_py: @@ -1078,7 +1087,7 @@ def web_intervenida(item, data, desactivar=True): if item.channel == channel_py: #Si es un clone de Newpct1, lo desactivamos for settings in json_data['settings']: #Se recorren todos los settings if settings['id'] == "clonenewpct1_channels_list": #Encontramos en setting - action_excluded = scrapertools.find_single_match(settings['default'], "\('\d', '%s', '[^']+', '[^']*', '([^']*)'\)" % item.category.lower()) #extraemos el valor de action_excluded + action_excluded = scrapertools.find_single_match(settings['default'], "\('\d', '%s', '[^']+', '[^']*', '([^']*)'\)" % item.category.lower()) #extraemos el valor de action_excluded if action_excluded: if "intervenido" not in action_excluded: action_excluded += ', %s' % judicial #Agregamos el thumb de la autoridad judicial @@ -1095,7 +1104,8 @@ def web_intervenida(item, data, desactivar=True): #Guardamos los cambios hechos en el .json try: - disabled = config.set_setting('enabled', False, item.channel) + if item.channel != channel_py: + disabled = config.set_setting('enabled', False, item.channel) channel_path = filetools.join(config.get_runtime_path(), "channels", item.channel + ".json") with open(channel_path, 'w') as outfile: #Grabamos el .json actualizado json.dump(json_data, outfile, sort_keys = True, indent = 2, ensure_ascii = False) From 7f2e37ec12e7a4c07b1fe8472b6d213cebf165de Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Wed, 25 Jul 2018 18:51:15 +0200 Subject: [PATCH 21/29] =?UTF-8?q?Alltorrent:=20reestrucuturaci=C3=B3n=20in?= =?UTF-8?q?terna?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Estandariza su estructura y deja de usar librerías obsoletas. Se basa en TMDB --- plugin.video.alfa/channels/alltorrent.json | 5 +- plugin.video.alfa/channels/alltorrent.py | 628 +++++++----------- .../media/channels/fanart/altorrent.jpg | Bin 0 -> 592684 bytes .../media/channels/thumb/altorrent.png | Bin 0 -> 64119 bytes 4 files changed, 257 insertions(+), 376 deletions(-) create mode 100644 plugin.video.alfa/resources/media/channels/fanart/altorrent.jpg create mode 100644 plugin.video.alfa/resources/media/channels/thumb/altorrent.png diff --git a/plugin.video.alfa/channels/alltorrent.json b/plugin.video.alfa/channels/alltorrent.json index c627ebbb..e2188b7b 100755 --- a/plugin.video.alfa/channels/alltorrent.json +++ b/plugin.video.alfa/channels/alltorrent.json @@ -4,7 +4,8 @@ "active": true, "adult": false, "language": ["cast"], - "thumbnail": "http://imgur.com/sLaXHvp.png", + "thumbnail": "altorrent.png", + "fanart": "altorrent.jpg", "categories": [ "torrent", "movie" @@ -22,7 +23,7 @@ "id": "include_in_global_search", "type": "bool", "label": "Incluir en busqueda global", - "default": true, + "default": false, "enabled": true, "visible": true }, diff --git a/plugin.video.alfa/channels/alltorrent.py b/plugin.video.alfa/channels/alltorrent.py index 34869367..505f5059 100755 --- a/plugin.video.alfa/channels/alltorrent.py +++ b/plugin.video.alfa/channels/alltorrent.py @@ -1,93 +1,261 @@ # -*- coding: utf-8 -*- -import os import re -import unicodedata -from threading import Thread +import sys +import urllib +import urlparse +from channelselector import get_thumb from core import httptools from core import scrapertools from core import servertools -from core import tmdb from core.item import Item from platformcode import config, logger - -__modo_grafico__ = config.get_setting('modo_grafico', "ver-pelis") - - -# Para la busqueda en bing evitando baneos - - -def browser(url): - import mechanize - - # Utilizamos Browser mechanize para saltar problemas con la busqueda en bing - br = mechanize.Browser() - # Browser options - br.set_handle_equiv(False) - br.set_handle_gzip(True) - br.set_handle_redirect(True) - br.set_handle_referer(False) - br.set_handle_robots(False) - # Follows refresh 0 but not hangs on refresh > 0 - br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) - # Want debugging messages? - # br.set_debug_http(True) - # br.set_debug_redirects(True) - # br.set_debug_responses(True) - - # User-Agent (this is cheating, ok?) - # br.addheaders = [('User-agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/7.1.7 Safari/537.85.16')] - # br.addheaders =[('Cookie','SRCHD=AF=QBRE; domain=.bing.com; expires=25 de febrero de 2018 13:00:28 GMT+1; MUIDB=3B942052D204686335322894D3086911; domain=www.bing.com;expires=24 de febrero de 2018 13:00:28 GMT+1')] - # Open some site, let's pick a random one, the first that pops in mind - r = br.open(url) - response = r.read() - print response - if "img,divreturn" in response: - r = br.open("http://ssl-proxy.my-addr.org/myaddrproxy.php/" + url) - print "prooooxy" - response = r.read() - - return response - - -api_key = "2e2160006592024ba87ccdf78c28f49f" -api_fankey = "dffe90fba4d02c199ae7a9e71330c987" +from core import tmdb +from lib import generictools host = 'http://alltorrent.net/' +__modo_grafico__ = config.get_setting('modo_grafico', 'alltorrent') + def mainlist(item): logger.info() itemlist = [] - i = 0 - global i - itemlist.append(item.clone(title="[COLOR springgreen][B]Todas Las Películas[/B][/COLOR]", action="scraper", - url="http://alltorrent.net/", thumbnail="http://imgur.com/XLqPZoF.png", - fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie")) - itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 1080p[/COLOR]", action="scraper", - url="http://alltorrent.net/rezolucia/1080p/", thumbnail="http://imgur.com/XLqPZoF.png", - fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie")) - itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 720p[/COLOR]", action="scraper", - url="http://alltorrent.net/rezolucia/720p/", thumbnail="http://imgur.com/XLqPZoF.png", - fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie")) - itemlist.append(item.clone(title="[COLOR springgreen] Incluyen Hdrip[/COLOR]", action="scraper", - url="http://alltorrent.net/rezolucia/hdrip/", thumbnail="http://imgur.com/XLqPZoF.png", - fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie")) - itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 3D[/COLOR]", action="scraper", - url="http://alltorrent.net/rezolucia/3d/", thumbnail="http://imgur.com/XLqPZoF.png", - fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie")) - itemlist.append(itemlist[-1].clone(title="[COLOR floralwhite][B]Buscar[/B][/COLOR]", action="search", - thumbnail="http://imgur.com/5EBwccS.png", fanart="http://imgur.com/v3ChkZu.jpg", - contentType="movie", extra="titulo")) - itemlist.append(itemlist[-1].clone(title="[COLOR oldlace] Por Título[/COLOR]", action="search", - thumbnail="http://imgur.com/5EBwccS.png", fanart="http://imgur.com/v3ChkZu.jpg", - contentType="movie", extra="titulo")) - itemlist.append(itemlist[-1].clone(title="[COLOR oldlace] Por Año[/COLOR]", action="search", - thumbnail="http://imgur.com/5EBwccS.png", fanart="http://imgur.com/v3ChkZu.jpg", - contentType="movie", extra="año")) - itemlist.append(itemlist[-1].clone(title="[COLOR oldlace] Por Rating Imdb[/COLOR]", action="search", - thumbnail="http://imgur.com/5EBwccS.png", fanart="http://imgur.com/v3ChkZu.jpg", - contentType="movie", extra="rating")) + + thumb_pelis = get_thumb("channels_movie.png") + thumb_pelis_hd = get_thumb("channels_movie_hd.png") + thumb_series = get_thumb("channels_tvshow.png") + thumb_series_hd = get_thumb("channels_tvshow_hd.png") + thumb_buscar = get_thumb("search.png") + + itemlist.append(item.clone(title="[COLOR springgreen][B]Todas Las Películas[/B][/COLOR]", action="listado", + url=host, thumbnail=thumb_pelis, extra="pelicula")) + itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 1080p[/COLOR]", action="listado", + url=host + "rezolucia/1080p/", thumbnail=thumb_pelis_hd, extra="pelicula")) + itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 720p[/COLOR]", action="listado", + url=host + "rezolucia/720p/", thumbnail=thumb_pelis_hd, extra="pelicula")) + itemlist.append(item.clone(title="[COLOR springgreen] Incluyen Hdrip[/COLOR]", action="listado", + url=host + "rezolucia/hdrip/", thumbnail=thumb_pelis, extra="pelicula")) + itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 3D[/COLOR]", action="listado", + url=host + "rezolucia/3d/", thumbnail=thumb_pelis_hd, extra="pelicula")) + itemlist.append(item.clone(title="[COLOR floralwhite][B]Buscar[/B][/COLOR]", action="search", thumbnail=thumb_buscar, + extra="titulo")) + itemlist.append(item.clone(title="[COLOR oldlace] Por Título[/COLOR]", action="search", thumbnail=thumb_buscar, + extra="titulo")) + itemlist.append(item.clone(title="[COLOR oldlace] Por Año[/COLOR]", action="search", thumbnail=thumb_buscar, + extra="año")) + itemlist.append(item.clone(title="[COLOR oldlace] Por Rating Imdb[/COLOR]", action="search", thumbnail=thumb_buscar, + extra="rating")) + + return itemlist + + +def listado(item): + logger.info() + itemlist = [] + + # Descarga la página + data = '' + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + pass + + if not data: #Si la web está caída salimos sin dar error + logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + + patron = '
    ([^"]+)<\/a>\s?<\/div>
    (.*?)<\/div><\/div><\/div>' + #data = scrapertools.find_single_match(data, patron) + matches = re.compile(patron, re.DOTALL).findall(data) + if not matches and not '