diff --git a/plugin.video.alfa/addon.xml b/plugin.video.alfa/addon.xml index e2f84b33..2f0d41b5 100755 --- a/plugin.video.alfa/addon.xml +++ b/plugin.video.alfa/addon.xml @@ -1,5 +1,5 @@ - + @@ -19,17 +19,10 @@ [B]Estos son los cambios para esta versión:[/B] [COLOR green][B]Arreglos[/B][/COLOR] - ¤ PoseidonHD ¤ TuPelicula ¤ SeriesLan - ¤ danimados ¤ pelisgratis ¤ rexpelis - ¤ sipeliculas ¤ yape ¤ DivxTotal - ¤ EliteTorrent ¤ GranTorrent ¤ Newpct1 - ¤ pelispedia ¤ pepecine ¤ cuevana2 - ¤ cuevana2español - - [COLOR green][B]Novedades[/B][/COLOR] - ¤ AnimeBoom ¤ SeriesMetro ¤ Pack canales +18 - - Agradecimientos a @mrgaturus y @paeznet por colaborar en ésta versión + ¤ cinetux ¤ danimados ¤ xms + ¤ bitp ¤ descargacineclasico ¤ dostream + ¤ cinecalidad ¤ pelisplus ¤ Mejortorrent + ¤ Mejortorrent1 ¤ Newpc1 Navega con Kodi por páginas web para ver sus videos de manera fácil. diff --git a/plugin.video.alfa/channels/alfavorites.py b/plugin.video.alfa/channels/alfavorites.py index c52a1182..980f110e 100644 --- a/plugin.video.alfa/channels/alfavorites.py +++ b/plugin.video.alfa/channels/alfavorites.py @@ -1,12 +1,14 @@ # -*- coding: utf-8 -*- # ------------------------------------------------------------ -# Alfa favoritos (Mis enlaces) -# ============================ +# Alfa favoritos +# ============== # - Lista de enlaces guardados como favoritos, solamente en Alfa, no Kodi. -# - Los enlaces se organizan en carpetas que puede definir el usuario. -# - Se utiliza un sólo fichero para guardar todas las carpetas y enlaces: user_favorites.json -# - Se puede copiar user_favorites.json a otros dispositivos ya que la única dependencia local es el thumbnail asociado a los enlaces, +# - Los enlaces se organizan en carpetas (virtuales) que puede definir el usuario. +# - Se utiliza un sólo fichero para guardar todas las carpetas y enlaces: alfavorites-default.json +# - Se puede copiar alfavorites-default.json a otros dispositivos ya que la única dependencia local es el thumbnail asociado a los enlaces, # pero se detecta por código y se ajusta al dispositivo actual. +# - Se pueden tener distintos ficheros de alfavoritos y alternar entre ellos, pero solamente uno de ellos es la "lista activa". +# - Los ficheros deben estar en config.get_data_path() y empezar por alfavorites- y terminar en .json # Requerimientos en otros módulos para ejecutar este canal: # - Añadir un enlace a este canal en channelselector.py @@ -14,35 +16,106 @@ # ------------------------------------------------------------ import os, re +from datetime import datetime -from core import filetools -from core import jsontools from core.item import Item -from platformcode import config, logger -from platformcode import platformtools +from platformcode import config, logger, platformtools + +from core import filetools, jsontools + + +def fechahora_actual(): + return datetime.now().strftime('%Y-%m-%d %H:%M') + +# Helpers para listas +# ------------------- + +PREFIJO_LISTA = 'alfavorites-' + +# Devuelve el nombre de la lista activa (Ej: alfavorites-default.json) +def get_lista_activa(): + return config.get_setting('lista_activa', default = PREFIJO_LISTA + 'default.json') + +# Extrae nombre de la lista del fichero, quitando prefijo y sufijo (Ej: alfavorites-Prueba.json => Prueba) +def get_name_from_filename(filename): + return filename.replace(PREFIJO_LISTA, '').replace('.json', '') + +# Componer el fichero de lista a partir de un nombre, añadiendo prefijo y sufijo (Ej: Prueba => alfavorites-Prueba.json) +def get_filename_from_name(name): + return PREFIJO_LISTA + name + '.json' + +# Apuntar en un fichero de log los códigos de los ficheros que se hayan compartido +def save_log_lista_shared(msg): + msg = fechahora_actual() + ': ' + msg + os.linesep + fullfilename = os.path.join(config.get_data_path(), 'alfavorites_shared.log') + with open(fullfilename, 'a') as f: f.write(msg); f.close() + +# Limpiar texto para usar como nombre de fichero +def text_clean(txt, disallowed_chars = '[^a-zA-Z0-9\-_()\[\]. ]+', blank_char = ' '): + import unicodedata + try: + txt = unicode(txt, 'utf-8') + except NameError: # unicode is a default on python 3 + pass + txt = unicodedata.normalize('NFKD', txt).encode('ascii', 'ignore') + txt = txt.decode('utf-8').strip() + if blank_char != ' ': txt = txt.replace(' ', blank_char) + txt = re.sub(disallowed_chars, '', txt) + return str(txt) + # Clase para cargar y guardar en el fichero de Alfavoritos # -------------------------------------------------------- class AlfavoritesData: - def __init__(self): - self.user_favorites_file = os.path.join(config.get_data_path(), 'user_favorites.json') + def __init__(self, filename = None): + + # Si no se especifica ningún fichero se usa la lista_activa (si no la hay se crea) + if filename == None: + filename = get_lista_activa() + + self.user_favorites_file = os.path.join(config.get_data_path(), filename) if not os.path.exists(self.user_favorites_file): - self.user_favorites = [] - else: - try: - self.user_favorites = jsontools.load(filetools.read(self.user_favorites_file)) - except: + fichero_anterior = os.path.join(config.get_data_path(), 'user_favorites.json') + if os.path.exists(fichero_anterior): # formato anterior, convertir (a eliminar después de algunas versiones) + jsondata = jsontools.load(filetools.read(fichero_anterior)) + self.user_favorites = jsondata + self.info_lista = {} + self.save() + filetools.remove(fichero_anterior) + else: self.user_favorites = [] + else: + jsondata = jsontools.load(filetools.read(self.user_favorites_file)) + if not 'user_favorites' in jsondata or not 'info_lista' in jsondata: # formato incorrecto + self.user_favorites = [] + else: + self.user_favorites = jsondata['user_favorites'] + self.info_lista = jsondata['info_lista'] + if len(self.user_favorites) == 0: - self.user_favorites.append({ 'title': 'Carpeta por defecto', 'items': [] }) + self.info_lista = {} + + # Crear algunas carpetas por defecto + self.user_favorites.append({ 'title': 'Películas', 'items': [] }) + self.user_favorites.append({ 'title': 'Series', 'items': [] }) + self.user_favorites.append({ 'title': 'Otros', 'items': [] }) + self.save() def save(self): - filetools.write(self.user_favorites_file, jsontools.dump(self.user_favorites)) + if 'created' not in self.info_lista: + self.info_lista['created'] = fechahora_actual() + self.info_lista['updated'] = fechahora_actual() + + jsondata = {} + jsondata['user_favorites'] = self.user_favorites + jsondata['info_lista'] = self.info_lista + if not filetools.write(self.user_favorites_file, jsontools.dump(jsondata)): + platformtools.dialog_ok('Alfa', 'Error, no se puede grabar la lista!', os.path.basename(self.user_favorites_file)) # ============================ @@ -55,21 +128,21 @@ def addFavourite(item): # Si se llega aquí mediante el menú contextual, hay que recuperar los parámetros action y channel if item.from_action: - item.__dict__["action"] = item.__dict__.pop("from_action") + item.__dict__['action'] = item.__dict__.pop('from_action') if item.from_channel: - item.__dict__["channel"] = item.__dict__.pop("from_channel") + item.__dict__['channel'] = item.__dict__.pop('from_channel') - # Limpiar título y quitar color + # Limpiar título item.title = re.sub(r'\[COLOR [^\]]*\]', '', item.title.replace('[/COLOR]', '')).strip() if item.text_color: - item.__dict__.pop("text_color") + item.__dict__.pop('text_color') # Diálogo para escoger/crear carpeta i_perfil = _selecciona_perfil(alfav, 'Guardar enlace en:') if i_perfil == -1: return False # Detectar que el mismo enlace no exista ya en la carpeta - campos = ['channel','action','url','extra'] # si todos estos campos coinciden se considera que el enlace ya existe + campos = ['channel','action','url','extra','list_type'] # si todos estos campos coinciden se considera que el enlace ya existe for enlace in alfav.user_favorites[i_perfil]['items']: it = Item().fromurl(enlace) repe = True @@ -81,11 +154,14 @@ def addFavourite(item): platformtools.dialog_notification('Enlace repetido', 'Ya tienes este enlace en la carpeta') return False - # Si es una película, completar información de tmdb si no se tiene activado tmdb_plus_info - if item.contentType == 'movie' and not config.get_setting('tmdb_plus_info', default=False): + # Si es una película/serie, completar información de tmdb si no se tiene activado tmdb_plus_info (para season/episodio no hace falta pq ya se habrá hecho la "segunda pasada") + if (item.contentType == 'movie' or item.contentType == 'tvshow') and not config.get_setting('tmdb_plus_info', default=False): from core import tmdb tmdb.set_infoLabels(item, True) # obtener más datos en "segunda pasada" (actores, duración, ...) + # Añadir fecha en que se guarda + item.date_added = fechahora_actual() + # Guardar alfav.user_favorites[i_perfil]['items'].append(item.tourl()) alfav.save() @@ -102,6 +178,7 @@ def addFavourite(item): def mainlist(item): logger.info() alfav = AlfavoritesData() + item.category = get_name_from_filename(os.path.basename(alfav.user_favorites_file)) itemlist = [] last_i = len(alfav.user_favorites) - 1 @@ -128,11 +205,10 @@ def mainlist(item): plot = '%d enlaces en la carpeta' % len(perfil['items']) itemlist.append(Item(channel=item.channel, action='mostrar_perfil', title=perfil['title'], plot=plot, i_perfil=i_perfil, context=context)) - plot = '* Crea diferentes carpetas para guardar tus enlaces favoritos dentro de Alfa.[CR]' - plot += '* Para añadir enlaces a las carpetas accede al menú contextual desde cualquier punto de Alfa.[CR]' - plot += '* Los enlaces pueden ser canales, secciones dentro de los canales, búsquedas, e incluso películas y series aunque para esto último es preferible utilizar la videoteca.' - itemlist.append(item.clone(action='crear_perfil', title='Crear nueva carpeta ...', plot=plot, folder=False)) + itemlist.append(item.clone(action='crear_perfil', title='Crear nueva carpeta ...', folder=False)) + itemlist.append(item.clone(action='mainlist_listas', title='Gestionar listas de enlaces')) + return itemlist @@ -149,38 +225,15 @@ def mostrar_perfil(item): ruta_runtime = config.get_runtime_path() for i_enlace, enlace in enumerate(alfav.user_favorites[i_perfil]['items']): - context = [] - - if i_enlace > 0: - context.append({'title': 'Mover arriba del todo', 'channel': item.channel, 'action': 'mover_enlace', - 'i_enlace': i_enlace, 'i_perfil': i_perfil, 'direccion': 'top'}) - context.append({'title': 'Mover hacia arriba', 'channel': item.channel, 'action': 'mover_enlace', - 'i_enlace': i_enlace, 'i_perfil': i_perfil, 'direccion': 'arriba'}) - if i_enlace < last_i: - context.append({'title': 'Mover hacia abajo', 'channel': item.channel, 'action': 'mover_enlace', - 'i_enlace': i_enlace, 'i_perfil': i_perfil, 'direccion': 'abajo'}) - context.append({'title': 'Mover abajo del todo', 'channel': item.channel, 'action': 'mover_enlace', - 'i_enlace': i_enlace, 'i_perfil': i_perfil, 'direccion': 'bottom'}) - - if len(alfav.user_favorites) > 1: # si se tiene más de una carpeta permitir mover entre ellas - context.append({'title': 'Mover a otra carpeta', 'channel': item.channel, 'action': 'editar_enlace_carpeta', - 'i_enlace': i_enlace, 'i_perfil': i_perfil}) - - context.append({'title': 'Cambiar título', 'channel': item.channel, 'action': 'editar_enlace_titulo', - 'i_enlace': i_enlace, 'i_perfil': i_perfil}) - - context.append({'title': 'Cambiar color', 'channel': item.channel, 'action': 'editar_enlace_color', - 'i_enlace': i_enlace, 'i_perfil': i_perfil}) - - context.append({'title': 'Cambiar thumbnail', 'channel': item.channel, 'action': 'editar_enlace_thumbnail', - 'i_enlace': i_enlace, 'i_perfil': i_perfil}) - - context.append({'title': 'Eliminar enlace', 'channel': item.channel, 'action': 'eliminar_enlace', - 'i_enlace': i_enlace, 'i_perfil': i_perfil}) it = Item().fromurl(enlace) - it.context = context - it.plot = '[COLOR blue]Canal: ' + it.channel + '[/COLOR][CR]' + it.plot + it.context = [ {'title': '[COLOR blue]Modificar enlace[/COLOR]', 'channel': item.channel, 'action': 'acciones_enlace', + 'i_enlace': i_enlace, 'i_perfil': i_perfil} ] + + it.plot += '[CR][CR][COLOR blue]Canal:[/COLOR] ' + it.channel + ' [COLOR blue]Action:[/COLOR] ' + it.action + if it.extra != '': it.plot += ' [COLOR blue]Extra:[/COLOR] ' + it.extra + it.plot += '[CR][COLOR blue]Url:[/COLOR] ' + it.url if isinstance(it.url, str) else '...' + if it.date_added != '': it.plot += '[CR][COLOR blue]Added:[/COLOR] ' + it.date_added # Si no es una url, ni tiene la ruta del sistema, convertir el path ya que se habrá copiado de otro dispositivo. # Sería más óptimo que la conversión se hiciera con un menú de importar, pero de momento se controla en run-time. @@ -277,6 +330,37 @@ def eliminar_perfil(item): return True +def acciones_enlace(item): + logger.info() + + acciones = ['Cambiar título', 'Cambiar color', 'Cambiar thumbnail', 'Mover a otra carpeta', 'Mover a otra lista', 'Eliminar enlace', + 'Mover arriba del todo', 'Mover hacia arriba', 'Mover hacia abajo', 'Mover abajo del todo'] + + ret = platformtools.dialog_select('Acción a ejecutar', acciones) + if ret == -1: + return False # pedido cancel + elif ret == 0: + return editar_enlace_titulo(item) + elif ret == 1: + return editar_enlace_color(item) + elif ret == 2: + return editar_enlace_thumbnail(item) + elif ret == 3: + return editar_enlace_carpeta(item) + elif ret == 4: + return editar_enlace_lista(item) + elif ret == 5: + return eliminar_enlace(item) + elif ret == 6: + return mover_enlace(item.clone(direccion='top')) + elif ret == 7: + return mover_enlace(item.clone(direccion='arriba')) + elif ret == 8: + return mover_enlace(item.clone(direccion='abajo')) + elif ret == 9: + return mover_enlace(item.clone(direccion='bottom')) + + def editar_enlace_titulo(item): logger.info() alfav = AlfavoritesData() @@ -402,6 +486,44 @@ def editar_enlace_carpeta(item): return True +def editar_enlace_lista(item): + logger.info() + alfav = AlfavoritesData() + + if not alfav.user_favorites[item.i_perfil]: return False + if not alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]: return False + + # Diálogo para escoger lista + opciones = [] + itemlist_listas = mainlist_listas(item) + for it in itemlist_listas: + if it.lista != '' and '[lista activa]' not in it.title: # descarta item crear y lista activa + opciones.append(it.lista) + + if len(opciones) == 0: + platformtools.dialog_ok('Alfa', 'No hay otras listas dónde mover el enlace.', 'Puedes crearlas desde el menú Gestionar listas de enlaces') + return False + + ret = platformtools.dialog_select('Seleccionar lista destino', opciones) + + if ret == -1: + return False # pedido cancel + + alfav_destino = AlfavoritesData(opciones[ret]) + + # Diálogo para escoger/crear carpeta en la lista de destino + i_perfil = _selecciona_perfil(alfav_destino, 'Seleccionar carpeta destino', -1) + if i_perfil == -1: return False + + alfav_destino.user_favorites[i_perfil]['items'].append(alfav.user_favorites[item.i_perfil]['items'][item.i_enlace]) + del alfav.user_favorites[item.i_perfil]['items'][item.i_enlace] + alfav_destino.save() + alfav.save() + + platformtools.itemlist_refresh() + return True + + def eliminar_enlace(item): logger.info() alfav = AlfavoritesData() @@ -466,3 +588,339 @@ def _mover_item(lista, i_selected, direccion): lista.insert(last_i, lista.pop(i_selected)) return lista + + +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Gestionar diferentes listas de alfavoritos +# ------------------------------------------ + +def mainlist_listas(item): + logger.info() + itemlist = [] + item.category = 'Listas' + + lista_activa = get_lista_activa() + + import glob + + path = os.path.join(config.get_data_path(), PREFIJO_LISTA+'*.json') + for fichero in glob.glob(path): + lista = os.path.basename(fichero) + nombre = get_name_from_filename(lista) + titulo = nombre if lista != lista_activa else '[COLOR gold]%s[/COLOR] [lista activa]' % nombre + + itemlist.append(item.clone(action='acciones_lista', lista=lista, title=titulo, folder=False)) + + itemlist.append(item.clone(action='acciones_nueva_lista', title='Crear/descargar lista / Info ...', folder=False)) + + return itemlist + + +def acciones_lista(item): + logger.info() + + acciones = ['Establecer como lista activa', 'Cambiar nombre de la lista', + 'Compartir en tinyupload', 'Eliminar lista', 'Información de la lista'] + + ret = platformtools.dialog_select(item.lista, acciones) + + if ret == -1: + return False # pedido cancel + elif ret == 0: + return activar_lista(item) + elif ret == 1: + return renombrar_lista(item) + elif ret == 2: + return compartir_lista(item) + elif ret == 3: + return eliminar_lista(item) + elif ret == 4: + return informacion_lista(item) + + +def activar_lista(item): + logger.info() + + fullfilename = os.path.join(config.get_data_path(), item.lista) + if not os.path.exists(fullfilename): + platformtools.dialog_ok('Alfa', 'Error, no se encuentra la lista!', item.lista) + return False + + config.set_setting('lista_activa', item.lista) + + from channelselector import get_thumb + item_inicio = Item(title=config.get_localized_string(70527), channel="alfavorites", action="mainlist", + thumbnail=get_thumb("mylink.png"), + category=config.get_localized_string(70527), viewmode="thumbnails") + platformtools.itemlist_update(item_inicio, replace=True) + return True + + +def renombrar_lista(item): + logger.info() + + fullfilename_current = os.path.join(config.get_data_path(), item.lista) + if not os.path.exists(fullfilename_current): + platformtools.dialog_ok('Alfa', 'Error, no se encuentra la lista!', fullfilename_current) + return False + + nombre = get_name_from_filename(item.lista) + titulo = platformtools.dialog_input(default=nombre, heading='Nombre de la lista') + if titulo is None or titulo == '' or titulo == nombre: + return False + titulo = text_clean(titulo, blank_char='_') + + filename = get_filename_from_name(titulo) + fullfilename = os.path.join(config.get_data_path(), filename) + + # Comprobar que el nuevo nombre no exista + if os.path.exists(fullfilename): + platformtools.dialog_ok('Alfa', 'Error, ya existe una lista con este nombre!', fullfilename) + return False + + # Rename del fichero + if not filetools.rename(fullfilename_current, filename): + platformtools.dialog_ok('Alfa', 'Error, no se ha podido renombrar la lista!', fullfilename) + return False + + # Update settings si es la lista activa + if item.lista == get_lista_activa(): + config.set_setting('lista_activa', filename) + + + platformtools.itemlist_refresh() + return True + + +def eliminar_lista(item): + logger.info() + + fullfilename = os.path.join(config.get_data_path(), item.lista) + if not os.path.exists(fullfilename): + platformtools.dialog_ok('Alfa', 'Error, no se encuentra la lista!', item.lista) + return False + + if item.lista == get_lista_activa(): + platformtools.dialog_ok('Alfa', 'La lista activa no se puede eliminar', item.lista) + return False + + if not platformtools.dialog_yesno('Eliminar lista', '¿Estás seguro de querer borrar la lista %s ?' % item.lista): return False + filetools.remove(fullfilename) + + platformtools.itemlist_refresh() + return True + + +def informacion_lista(item): + logger.info() + + fullfilename = os.path.join(config.get_data_path(), item.lista) + if not os.path.exists(fullfilename): + platformtools.dialog_ok('Alfa', 'Error, no se encuentra la lista!', item.lista) + return False + + alfav = AlfavoritesData(item.lista) + + txt = 'Lista: [COLOR gold]%s[/COLOR]' % item.lista + txt += '[CR]Creada el %s y modificada el %s' % (alfav.info_lista['created'], alfav.info_lista['updated']) + + if 'downloaded_date' in alfav.info_lista: + txt += '[CR]Descargada el %s desde [COLOR blue]%s[/COLOR]' % (alfav.info_lista['downloaded_date'], alfav.info_lista['downloaded_from']) + + if 'tinyupload_date' in alfav.info_lista: + txt += '[CR]Compartida en tinyupload el %s con el código [COLOR blue]%s[/COLOR]' % (alfav.info_lista['tinyupload_date'], alfav.info_lista['tinyupload_code']) + + txt += '[CR]Número de carpetas: %d' % len(alfav.user_favorites) + for perfil in alfav.user_favorites: + txt += '[CR]- %s (%d enlaces)' % (perfil['title'], len(perfil['items'])) + + platformtools.dialog_textviewer('Información de la lista', txt) + return True + + +def compartir_lista(item): + logger.info() + + fullfilename = os.path.join(config.get_data_path(), item.lista) + if not os.path.exists(fullfilename): + platformtools.dialog_ok('Alfa', 'Error, no se encuentra la lista!', fullfilename) + return False + + try: + progreso = platformtools.dialog_progress_bg('Compartir lista', 'Conectando con tinyupload ...') + + # Acceso a la página principal de tinyupload para obtener datos necesarios + from core import httptools, scrapertools + data = httptools.downloadpage('http://s000.tinyupload.com/index.php').data + upload_url = scrapertools.find_single_match(data, 'form action="([^"]+)') + sessionid = scrapertools.find_single_match(upload_url, 'sid=(.+)') + + progreso.update(10, 'Subiendo fichero', 'Espera unos segundos a que acabe de subirse tu fichero de lista a tinyupload') + + # Envío del fichero a tinyupload mediante multipart/form-data + from lib import MultipartPostHandler + import urllib2 + opener = urllib2.build_opener(MultipartPostHandler.MultipartPostHandler) + params = { 'MAX_FILE_SIZE' : '52428800', 'file_description' : '', 'sessionid' : sessionid, 'uploaded_file' : open(fullfilename, 'rb') } + handle = opener.open(upload_url, params) + data = handle.read() + + progreso.close() + + if not 'File was uploaded successfuly' in data: + logger.debug(data) + platformtools.dialog_ok('Alfa', 'Error, no se ha podido subir el fichero a tinyupload.com!') + return False + + codigo = scrapertools.find_single_match(data, 'href="index\.php\?file_id=([^"]+)') + + except: + platformtools.dialog_ok('Alfa', 'Error, al intentar subir el fichero a tinyupload.com!', item.lista) + return False + + # Apuntar código en fichero de log y dentro de la lista + save_log_lista_shared('Subido fichero %s a tinyupload.com. El código para descargarlo es: %s' % (item.lista, codigo)) + + alfav = AlfavoritesData(item.lista) + alfav.info_lista['tinyupload_date'] = fechahora_actual() + alfav.info_lista['tinyupload_code'] = codigo + alfav.save() + + platformtools.dialog_ok('Alfa', 'Subida lista a tinyupload. Si quieres compartirla con alguien, pásale este código:', codigo) + return True + + + +def acciones_nueva_lista(item): + logger.info() + + acciones = ['Crear una nueva lista', + 'Descargar lista con código de tinyupload', + 'Descargar lista de una url directa', + 'Información sobre las listas'] + + ret = platformtools.dialog_select('Listas de enlaces', acciones) + + if ret == -1: + return False # pedido cancel + + elif ret == 0: + return crear_lista(item) + + elif ret == 1: + codigo = platformtools.dialog_input(default='', heading='Código de descarga de tinyupload') # 05370382084539519168 + if codigo is None or codigo == '': + return False + return descargar_lista(item, 'http://s000.tinyupload.com/?file_id=' + codigo) + + elif ret == 2: + url = platformtools.dialog_input(default='https://', heading='URL de dónde descargar la lista') + if url is None or url == '': + return False + return descargar_lista(item, url) + + elif ret == 3: + txt = '- Puedes tener diferentes listas, pero solamente una de ellas está activa. La lista activa es la que se muestra en "Mis enlaces" y dónde se guardan los enlaces que se vayan añadiendo.' + txt += '[CR]- Puedes ir cambiando la lista activa y alternar entre las que tengas.' + txt += '[CR]- Puedes compartir una lista a través de tinyupload y luego pasarle el código resultante a tus amistades para que se la puedan bajar.' + txt += '[CR]- Puedes descargar una lista si te pasan un código de tinyupload o una url dónde esté alojada.' + txt += '[CR]- Si lo quieres hacer manualmente, puedes copiar una lista alfavorites-*.json que te hayan pasado a la carpeta userdata del addon. Y puedes subir estos json a algún servidor y pasar sus urls a tus amigos para compartirlas.' + txt += '[CR]- Para compartir listas desde el addon se utiliza el servicio de tinyupload.com por ser gratuíto, privado y relativamente rápido. Los ficheros se guardan mientras no pasen 100 días sin que nadie lo descargue, son privados porque requieren un código para acceder a ellos, y la limitación de 50MB es suficiente para las listas.' + + platformtools.dialog_textviewer('Información sobre las listas', txt) + return False + + +def crear_lista(item): + logger.info() + + titulo = platformtools.dialog_input(default='', heading='Nombre de la lista') + if titulo is None or titulo == '': + return False + titulo = text_clean(titulo, blank_char='_') + + filename = get_filename_from_name(titulo) + fullfilename = os.path.join(config.get_data_path(), filename) + + # Comprobar que el fichero no exista ya + if os.path.exists(fullfilename): + platformtools.dialog_ok('Alfa', 'Error, ya existe una lista con este nombre!', fullfilename) + return False + + # Provocar que se guarde con las carpetas vacías por defecto + alfav = AlfavoritesData(filename) + + platformtools.itemlist_refresh() + return True + + +def descargar_lista(item, url): + logger.info() + from core import httptools, scrapertools + + if 'tinyupload.com/' in url: + try: + from urlparse import urlparse + data = httptools.downloadpage(url).data + logger.debug(data) + down_url, url_name = scrapertools.find_single_match(data, ' href="(download\.php[^"]*)">([^<]*)') + url_json = '{uri.scheme}://{uri.netloc}/'.format(uri=urlparse(url)) + down_url + except: + platformtools.dialog_ok('Alfa', 'Error, no se puede descargar la lista!', url) + return False + + elif 'zippyshare.com/' in url: + from core import servertools + video_urls, puedes, motivo = servertools.resolve_video_urls_for_playing('zippyshare', url) + + if not puedes: + platformtools.dialog_ok('Alfa', 'Error, no se puede descargar la lista!', motivo) + return False + url_json = video_urls[0][1] # https://www58.zippyshare.com/d/qPzzQ0UM/25460/alfavorites-testeanding.json + url_name = url_json[url_json.rfind('/')+1:] + + elif 'friendpaste.com/' in url: + url_json = url if url.endswith('/raw') else url + '/raw' + url_name = 'friendpaste' + + else: + url_json = url + url_name = url[url.rfind('/')+1:] + + + # Download json + data = httptools.downloadpage(url_json).data + + # Verificar formato json de alfavorites y añadir info de la descarga + jsondata = jsontools.load(data) + if 'user_favorites' not in jsondata or 'info_lista' not in jsondata: + logger.debug(data) + platformtools.dialog_ok('Alfa', 'Error, el fichero descargado no tiene el formato esperado!') + return False + + jsondata['info_lista']['downloaded_date'] = fechahora_actual() + jsondata['info_lista']['downloaded_from'] = url + data = jsontools.dump(jsondata) + + # Pedir nombre para la lista descargada + nombre = get_name_from_filename(url_name) + titulo = platformtools.dialog_input(default=nombre, heading='Nombre para guardar la lista') + if titulo is None or titulo == '': + return False + titulo = text_clean(titulo, blank_char='_') + + filename = get_filename_from_name(titulo) + fullfilename = os.path.join(config.get_data_path(), filename) + + # Si el nuevo nombre ya existe pedir confirmación para sobrescribir + if os.path.exists(fullfilename): + if not platformtools.dialog_yesno('Alfa', 'Ya existe una lista con este nombre.', '¿ Sobrescribir el fichero ?', filename): + return False + + if not filetools.write(fullfilename, data): + platformtools.dialog_ok('Alfa', 'Error, no se puede grabar la lista!', filename) + + platformtools.dialog_ok('Alfa', 'Ok, lista descargada correctamente', filename) + platformtools.itemlist_refresh() + return True diff --git a/plugin.video.alfa/channels/cinecalidad.py b/plugin.video.alfa/channels/cinecalidad.py index 912048a7..ec18bc95 100644 --- a/plugin.video.alfa/channels/cinecalidad.py +++ b/plugin.video.alfa/channels/cinecalidad.py @@ -433,7 +433,14 @@ def newest(categoria): def search(item, texto): logger.info() + itemlist = [] texto = texto.replace(" ", "-") - item.url = item.host + '?s=' + texto - if texto != '': - return peliculas(item) + if item.host != '': + host_list = [item.host] + else: + host_list = ['http://www.cinecalidad.to', 'http://cinecalidad.to/espana/'] + for host_name in host_list: + item.url = host_name + '?s=' + texto + if texto != '': + itemlist.extend(peliculas(item)) + return itemlist \ No newline at end of file diff --git a/plugin.video.alfa/channels/cinetux.py b/plugin.video.alfa/channels/cinetux.py index fcb6cb67..303616d2 100644 --- a/plugin.video.alfa/channels/cinetux.py +++ b/plugin.video.alfa/channels/cinetux.py @@ -1,6 +1,5 @@ # -*- coding: utf-8 -*- -import re from channels import autoplay from channels import filtertools from core import httptools @@ -176,11 +175,11 @@ def destacadas(item): item.text_color = color2 data = httptools.downloadpage(item.url).data bloque = scrapertools.find_single_match(data, 'peliculas_destacadas.*?class="letter_home"') - patron = '(?s)title="([^"]+)".*?' - patron += 'href="([^"]+)".*?' + patron = '(?s)href="([^"]+)".*?' + patron += 'alt="([^"]+)".*?' patron += 'src="([^"]+)' matches = scrapertools.find_multiple_matches(bloque, patron) - for scrapedtitle, scrapedurl, scrapedthumbnail in matches: + for scrapedurl, scrapedtitle, scrapedthumbnail in matches: scrapedurl = CHANNEL_HOST + scrapedurl itemlist.append(item.clone(action="findvideos", title=scrapedtitle, fulltitle=scrapedtitle, url=scrapedurl, thumbnail=scrapedthumbnail, @@ -219,173 +218,18 @@ def idioma(item): return itemlist -def findvideos(item): - logger.info() - itemlist = [] - try: - filtro_idioma = config.get_setting("filterlanguages", item.channel) - filtro_enlaces = config.get_setting("filterlinks", item.channel) - except: - filtro_idioma = 3 - filtro_enlaces = 2 - dict_idiomas = {'Español': 2, 'Latino': 1, 'Subtitulado': 0} - data = httptools.downloadpage(item.url).data - if filtro_enlaces != 0: - list_enlaces = bloque_enlaces(data, filtro_idioma, dict_idiomas, "online", item) - return - if list_enlaces: - itemlist.append(item.clone(action="", title="Enlaces Online", text_color=color1, - text_bold=True)) - itemlist.extend(list_enlaces) - if filtro_enlaces != 1: - list_enlaces = bloque_enlaces(data, filtro_idioma, dict_idiomas, "descarga", item) - if list_enlaces: - itemlist.append(item.clone(action="", title="Enlaces Descarga", text_color=color1, - text_bold=True)) - itemlist.extend(list_enlaces) - tmdb.set_infoLabels(item, __modo_grafico__) - - # Requerido para FilterTools - itemlist = filtertools.get_links(itemlist, item, list_language) - - # Requerido para AutoPlay - - autoplay.start(itemlist, item) - if itemlist: - itemlist.append(item.clone(channel="trailertools", title="Buscar Tráiler", action="buscartrailer", context="", - text_color="magenta")) - if item.extra != "library": - if config.get_videolibrary_support(): - itemlist.append(Item(channel=item.channel, title="Añadir a la videoteca", text_color="green", - action="add_pelicula_to_library", url=item.url, fulltitle = item.fulltitle - )) - return itemlist - - -# def bloque_enlaces(data, filtro_idioma, dict_idiomas, type, item): -# logger.info() -# lista_enlaces = [] -# matches = [] -# if type == "online": t_tipo = "Ver Online" -# if type == "descarga": t_tipo = "Descargar" -# data = data.replace("\n", "") -# if type == "online": -# patron = '(?is)class="playex.*?sheader' -# bloque1 = scrapertools.find_single_match(data, patron) -# patron = '(?is)#(option-[^"]+).*?png">([^<]+)' -# match = scrapertools.find_multiple_matches(data, patron) -# for scrapedoption, language in match: -# scrapedserver = "" -# lazy = "" -# if "lazy" in bloque1: -# lazy = "lazy-" -# patron = '(?s)id="%s".*?metaframe.*?%ssrc="([^"]+)' % (scrapedoption, lazy) -# url = scrapertools.find_single_match(bloque1, patron) -# if "goo.gl" in url: -# url = httptools.downloadpage(url, follow_redirects=False, only_headers=True).headers.get("location", "") -# if "drive.php" in url: -# scrapedserver = "gvideo" -# if "player" in url: -# scrapedserver = scrapertools.find_single_match(url, 'player/(\w+)') -# if "ok" in scrapedserver: scrapedserver = "okru" -# matches.append([url, scrapedserver, "", language.strip(), t_tipo]) -# bloque2 = scrapertools.find_single_match(data, '(?s)box_links.*?dt_social_single') -# bloque2 = bloque2.replace("\t", "").replace("\r", "") -# patron = '(?s)optn" href="([^"]+)' -# patron += '.*?alt="([^\.]+)' -# patron += '.*?src.*?src="[^>]+"?/>([^<]+)' -# patron += '.*?src="[^>]+"?/>([^<]+)' -# patron += '.*?/span>([^<]+)' -# matches.extend(scrapertools.find_multiple_matches(bloque2, patron)) -# filtrados = [] -# for match in matches: -# scrapedurl = match[0] -# scrapedserver = match[1] -# scrapedcalidad = match[2] -# language = match[3] -# scrapedtipo = match[4] -# if t_tipo.upper() not in scrapedtipo.upper(): -# continue -# title = " Mirror en %s (" + language + ")" -# if len(scrapedcalidad.strip()) > 0: -# title += " (Calidad " + scrapedcalidad.strip() + ")" -# -# if filtro_idioma == 3 or item.filtro: -# lista_enlaces.append(item.clone(title=title, action="play", text_color=color2, -# url=scrapedurl, server=scrapedserver, -# extra=item.url, contentThumbnail = item.thumbnail, -# language=language)) -# else: -# idioma = dict_idiomas[language] -# if idioma == filtro_idioma: -# lista_enlaces.append(item.clone(title=title, action="play", text_color=color2, -# url=scrapedurl, server=scrapedserver, -# extra=item.url, contentThumbnail = item.thumbnail, -# language=language)) -# else: -# if language not in filtrados: -# filtrados.append(language) -# lista_enlaces = servertools.get_servers_itemlist(lista_enlaces, lambda i: i.title % i.server.capitalize()) -# if filtro_idioma != 3: -# if len(filtrados) > 0: -# title = "Mostrar también enlaces filtrados en %s" % ", ".join(filtrados) -# lista_enlaces.append(item.clone(title=title, action="findvideos", url=item.url, text_color=color3, -# filtro=True)) -# return lista_enlaces -# -# -# def play(item): -# logger.info() -# itemlist = [] -# if "api.cinetux" in item.url or item.server == "okru" or "drive.php" in item.url or "youtube" in item.url: -# data = httptools.downloadpage(item.url, headers={'Referer': item.extra}).data.replace("\\", "") -# id = scrapertools.find_single_match(data, 'img src="[^#]+#(.*?)"') -# item.url = "http://docs.google.com/get_video_info?docid=" + id -# if item.server == "okru": -# item.url = "https://ok.ru/videoembed/" + id -# if item.server == "youtube": -# item.url = "https://www.youtube.com/embed/" + id -# elif "links" in item.url or "www.cinetux.me" in item.url: -# data = httptools.downloadpage(item.url).data -# scrapedurl = scrapertools.find_single_match(data, '|\s{2,}', "", data) - return data - def findvideos(item): import urllib logger.info() - itemlist=[] - - data = get_source(item.url) - - patron = 'class="title">([^>]+).*?data-type="([^"]+)" data-post="(\d+)" data-nume="(\d+)' - matches = re.compile(patron, re.DOTALL).findall(data) - - for language, tp, pt, nm in matches: - + data = httptools.downloadpage(item.url).data + patron = 'tooltipctx.*?data-type="([^"]+).*?' + patron += 'data-post="(\d+)".*?' + patron += 'data-nume="(\d+).*?' + patron += 'class="title">.*?src.*?/>([^<]+)' + matches = scrapertools.find_multiple_matches(data, patron) + for tp, pt, nm, language in matches: + language = language.strip() post = {'action':'doo_player_ajax', 'post':pt, 'nume':nm, 'type':tp} post = urllib.urlencode(post) new_data = httptools.downloadpage(CHANNEL_HOST+'wp-admin/admin-ajax.php', post=post, headers={'Referer':item.url}).data @@ -398,23 +242,45 @@ def findvideos(item): else: title = '' url = scrapertools.find_single_match(new_data, "src='([^']+)'") - itemlist.append(Item(channel=item.channel, title ='%s'+title, url=url, action='play', quality=item.quality, - language=IDIOMAS[language], infoLabels=item.infoLabels)) - + url = get_url(url.replace('\\/', '/')) + if url: + itemlist.append(Item(channel=item.channel, title ='%s'+title, url=url, action='play', quality=item.quality, + language=IDIOMAS[language], infoLabels=item.infoLabels)) patron = "([^<]+)<" - matches = re.compile(patron, re.DOTALL).findall(data) - + matches = scrapertools.find_multiple_matches(data, patron) for hidden_url, quality, language in matches: - if not config.get_setting('unify'): title = ' [%s][%s]' % (quality, IDIOMAS[language]) else: title = '' - new_data = get_source(hidden_url) - url = scrapertools.find_single_match(new_data, '"url":"([^"]+)"') - url = url.replace('\\/', '/') - itemlist.append(Item(channel=item.channel, title='%s'+title, url=url, action='play', quality=quality, - language=IDIOMAS[language], infoLabels=item.infoLabels)) - + new_data = httptools.downloadpage(hidden_url).data + url = scrapertools.find_single_match(new_data, 'id="link" href="([^"]+)"') + url = get_url(url.replace('\\/', '/')) + if url: + itemlist.append(Item(channel=item.channel, title='%s'+title, url=url, action='play', quality=quality, + language=IDIOMAS[language], infoLabels=item.infoLabels)) itemlist = servertools.get_servers_itemlist(itemlist, lambda i: i.title % i.server.capitalize()) - return itemlist \ No newline at end of file + itemlist.sort(key=lambda it: (it.language, it.server, it.quality)) + tmdb.set_infoLabels(itemlist, __modo_grafico__) + return itemlist + + +def get_url(url): + logger.info() + if "cinetux.me" in url: + d1 = httptools.downloadpage(url).data + if "mail" in url or "drive" in url or "ok.cinetux" in url or "mp4/" in url: + id = scrapertools.find_single_match(d1, ' 0 and item.contentType=="movie" and item.contentChannel!='videolibrary': diff --git a/plugin.video.alfa/channels/divxtotal.py b/plugin.video.alfa/channels/divxtotal.py index e22794a1..e03a3c1b 100644 --- a/plugin.video.alfa/channels/divxtotal.py +++ b/plugin.video.alfa/channels/divxtotal.py @@ -599,7 +599,7 @@ def findvideos(item): item_local.url = scrapedurl if host not in item_local.url and host.replace('https', 'http') not in item_local.url and not item.armagedon: item_local.url = host + item_local.url - if item_local.url and not item.armagedon: + if item_local.url and not item.armagedon and item.emergency_urls: item_local.torrent_alt = item.emergency_urls[0][0] #Guardamos la url del .Torrent ALTERNATIVA if item.armagedon: #Si es catastrófico, lo marcamos item_local.quality = '[/COLOR][COLOR hotpink][E] [COLOR limegreen]%s' % item_local.quality diff --git a/plugin.video.alfa/channels/elitetorrent.py b/plugin.video.alfa/channels/elitetorrent.py index 5e940626..f413c1bd 100644 --- a/plugin.video.alfa/channels/elitetorrent.py +++ b/plugin.video.alfa/channels/elitetorrent.py @@ -398,7 +398,7 @@ def findvideos(item): if item.armagedon: #Si es catastrófico, lo marcamos item_local.quality = '[/COLOR][COLOR hotpink][E] [COLOR limegreen]%s' % item_local.quality item_local.url = link_torrent - if item_local.url and not item.armagedon: + if item_local.url and item.emergency_urls and not item.armagedon: item_local.torrent_alt = item.emergency_urls[0][0] #Guardamos la url del .Torrent ALTERNATIVA item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent diff --git a/plugin.video.alfa/channels/estrenosgo.json b/plugin.video.alfa/channels/estrenosgo.json index 5ebbbafc..b7f0dc18 100755 --- a/plugin.video.alfa/channels/estrenosgo.json +++ b/plugin.video.alfa/channels/estrenosgo.json @@ -47,6 +47,28 @@ "VOSE" ] }, + { + "id": "emergency_urls", + "type": "list", + "label": "Se quieren guardar Enlaces de Emergencia por si se cae la Web?", + "default": 1, + "enabled": true, + "visible": true, + "lvalues": [ + "No", + "Guardar", + "Borrar", + "Actualizar" + ] + }, + { + "id": "emergency_urls_torrents", + "type": "bool", + "label": "Se quieren guardar Torrents de Emergencia por si se cae la Web?", + "default": true, + "enabled": true, + "visible": "!eq(-1,'No')" + }, { "id": "timeout_downloadpage", "type": "list", diff --git a/plugin.video.alfa/channels/estrenosgo.py b/plugin.video.alfa/channels/estrenosgo.py index 796c77e6..46c9e19d 100644 --- a/plugin.video.alfa/channels/estrenosgo.py +++ b/plugin.video.alfa/channels/estrenosgo.py @@ -657,7 +657,6 @@ def findvideos(item): if not data_torrent and not data_directo: logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url) 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 patron = '
Ver Online<\/a>.*?href="([^"]+)">') != url: #error - logger.error("ERROR 02: FINDVIDEOS: No hay enlaces o ha cambiado la estructura de la Web " + " / PATRON: " + patron) - itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: No hay enlaces o ha cambiado la estructura de la Web. Verificar en la Web esto último y reportar el error con el log')) - if data_torrent: - logger.error(data_torrent) - if data_directo: - logger.error(data_directo) - return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + + if item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia? + matches_torrent = item.emergency_urls[1] #Guardamos los matches de los .Torrents + try: + matches_directo = item.emergency_urls[3] #Guardamos los matches de Directos, si los hay + except: + pass + item.armagedon = True #Marcamos la situación como catastrófica + else: + if len(itemlist) == 0: + logger.error("ERROR 02: FINDVIDEOS: No hay enlaces o ha cambiado la estructura de la Web " + " / PATRON: " + patron) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: No hay enlaces o ha cambiado la estructura de la Web. Verificar en la Web esto último y reportar el error con el log')) + if data_torrent: + logger.error(data_torrent) + if data_directo: + logger.error(data_directo) + if item.videolibray_emergency_urls: + return item + else: + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos #logger.debug("PATRON: " + patron) #logger.debug(matches_torrent) @@ -679,8 +691,17 @@ def findvideos(item): #logger.debug(data_torrent) #logger.debug(data_directo) + if item.videolibray_emergency_urls: + item.emergency_urls = [] #Iniciamos emergency_urls + item.emergency_urls.append([]) #Reservamos el espacio para los .torrents locales + item.emergency_urls.append(matches_torrent) #Guardamos los matches_torrent iniciales + item.emergency_urls.append([]) #Reservamos el espacio para los matches_torrent finales + item.emergency_urls.append(matches_directo) #Guardamos los matches_directo iniciales + item.emergency_urls.append([]) #Reservamos el espacio para los matches_directo finales + #Llamamos al método para crear el título general del vídeo, con toda la información obtenida de TMDB - item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) + if not item.videolibray_emergency_urls: + item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) #Si es un Episodio suelto, tratamos de poner un enlace a la Serie completa if item.extra3 == 'completa': @@ -702,7 +723,7 @@ def findvideos(item): item_local.contentType = 'tvshow' item_local.extra = 'series' item_local.action = 'episodios' - item_local.season_colapse = True #Muestra las series agrupadas por temporadas + item_local.season_colapse = True #Muestra las series agrupadas por temporadas #Buscamos la url de la serie y verificamos que existe patron_serie = '
' @@ -741,106 +762,130 @@ def findvideos(item): item_local.language = ["%s" % IDIOMAS[scrapedlang]] #Leemos la página definitiva para el enlace al .torrent - try: - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item_local.url, timeout=timeout).data) - except: - pass - - patron = '
Descargar Torrent: <\/span>
»\s?(.*?)\s?«<\/a>' - matches = re.compile(patron, re.DOTALL).findall(data) + data = '' + if not item.armagedon: + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item_local.url, timeout=timeout).data) + except: + pass + + patron = '
Descargar Torrent: <\/span>
»\s?(.*?)\s?«<\/a>' + matches = re.compile(patron, re.DOTALL).findall(data) + else: + matches = item.emergency_urls[2][0] #Guardamos los matches de Directos, si los hay + del item.emergency_urls[2][0] #Una vez tratado lo limpiamos + data = 'xyz123' #iniciamos data para que no dé problemas + + if item.videolibray_emergency_urls: #Si esyamos añadiendo a Videoteca... + item.emergency_urls[2].append(matches) #Salvamos este matches if not data or not matches: logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / URL: " + item_local.url + " / DATA: " + data) - continue #si no hay más datos, algo no funciona, pasamos a Ver Online + continue #si no hay más datos, algo no funciona, pasamos a Ver Online #logger.debug(patron) #logger.debug(matches) #logger.debug(data) - + for scrapedtorrent, scrapedtitle in matches: - item_local = item_local.clone() - quality = item_local.quality - qualityscraped = '' - if not item_local.contentEpisodeNumber and item_local.contentType == 'episode': - item_local.contentEpisodeNumber = 0 - - #Si son episodios múltiples, los listamos con sus títulos - if len(matches) > 1 or len(itemlist_alt) > 1: - if item_local.contentType == 'episode' or item_local.contentType == 'season': - if scrapertools.find_single_match(scrapedtitle, '(\d+[x|X]\d+(?:-\d{1,2})?)'): - qualityscraped = '%s' % scrapertools.find_single_match(scrapedtitle, '(\d+[x|X]\d+(?:-\d{1,2})?)') - if scrapertools.find_single_match(scrapedtitle, '\d+[x|X](\d+)'): - item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtitle, '\d+[x|X](\d+)')) - elif scrapertools.find_single_match(scrapedtitle, '[c|C]ap.*?(\d+)'): - item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtitle, '[c|C]ap.*?(\d+)')) - elif scrapertools.find_single_match(scrapedtorrent, '[s|S]\d{1,2}[e|E](\d{1,2})'): - item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtorrent, '[s|S]\d{1,2}[e|E](\d{1,2})')) - if not qualityscraped: - qualityscraped = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2)) - else: - qualityscraped = '%s' % scrapedtitle - - #Si todavía no sabemos el num de Episodio, lo buscamos - if not item_local.contentEpisodeNumber and item_local.contentType == 'episode': - try: - if scrapertools.find_single_match(scrapedtitle, '(\d+)[x|X](\d+)'): - item_local.contentSeason, item_local.contentEpisodeNumber = scrapertools.find_single_match(scrapedtitle, '(\d+)[x|X](\d+)') - qualityscraped = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2)) - except: - pass - - #Buscamos calidades - if scrapertools.find_single_match(scrapedtitle, '(\d+p)'): - qualityscraped += ' ' + scrapertools.find_single_match(scrapedtitle, '(\d+p)') - if qualityscraped: - quality = '[%s] %s' % (qualityscraped, item_local.quality) + if item.videolibray_emergency_urls: + item.emergency_urls[0].append(host + scrapedtorrent) + else: + item_local = item_local.clone() + quality = item_local.quality + qualityscraped = '' + if not item_local.contentEpisodeNumber and item_local.contentType == 'episode': + item_local.contentEpisodeNumber = 0 + + #Si son episodios múltiples, los listamos con sus títulos + if len(matches) > 1 or len(itemlist_alt) > 1: + if item_local.contentType == 'episode' or item_local.contentType == 'season': + if scrapertools.find_single_match(scrapedtitle, '(\d+[x|X]\d+(?:-\d{1,2})?)'): + qualityscraped = '%s' % scrapertools.find_single_match(scrapedtitle, '(\d+[x|X]\d+(?:-\d{1,2})?)') + if scrapertools.find_single_match(scrapedtitle, '\d+[x|X](\d+)'): + item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtitle, '\d+[x|X](\d+)')) + elif scrapertools.find_single_match(scrapedtitle, '[c|C]ap.*?(\d+)'): + item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtitle, '[c|C]ap.*?(\d+)')) + elif scrapertools.find_single_match(scrapedtorrent, '[s|S]\d{1,2}[e|E](\d{1,2})'): + item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtorrent, '[s|S]\d{1,2}[e|E](\d{1,2})')) + if not qualityscraped: + qualityscraped = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2)) + else: + qualityscraped = '%s' % scrapedtitle + + #Si todavía no sabemos el num de Episodio, lo buscamos + if not item_local.contentEpisodeNumber and item_local.contentType == 'episode': + try: + if scrapertools.find_single_match(scrapedtitle, '(\d+)[x|X](\d+)'): + item_local.contentSeason, item_local.contentEpisodeNumber = scrapertools.find_single_match(scrapedtitle, '(\d+)[x|X](\d+)') + qualityscraped = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2)) + except: + pass + + #Buscamos calidades + if scrapertools.find_single_match(scrapedtitle, '(\d+p)'): + qualityscraped += ' ' + scrapertools.find_single_match(scrapedtitle, '(\d+p)') + if qualityscraped: + quality = '[%s] %s' % (qualityscraped, item_local.quality) - #Ahora pintamos el link del Torrent - item_local.url = host + scrapedtorrent - size = generictools.get_torrent_size(item_local.url) #Buscamos el tamaño en el .torrent - if size: - quality += ' [%s]' % size - item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (quality, str(item_local.language)) - - #Preparamos título y calidad, quitamos etiquetas vacías - item_local.title = re.sub(r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]', '', item_local.title) - item_local.title = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', item_local.title) - item_local.title = item_local.title.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip() - quality = re.sub(r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]', '', quality) - quality = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', quality) - quality = quality.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip() - - item_local.alive = "??" #Calidad del link sin verificar - item_local.action = "play" #Visualizar vídeo - item_local.server = "torrent" #Seridor Torrent - - itemlist_t.append(item_local.clone(quality=quality)) #Pintar pantalla, si no se filtran idiomas + #Ahora pintamos el link del Torrent + item_local.url = host + scrapedtorrent + if item.emergency_urls and not item.videolibray_emergency_urls: + item_local.torrent_alt = item.emergency_urls[0][0] #Guardamos la url del .Torrent ALTERNATIVA + if item.armagedon: + item_local.url = item.emergency_urls[0][0] #... ponemos la emergencia como primaria + del item.emergency_urls[0][0] #Una vez tratado lo limpiamos + + size = '' + if not item.armagedon: + size = generictools.get_torrent_size(item_local.url) #Buscamos el tamaño en el .torrent + if size: + quality += ' [%s]' % size + if item.armagedon: #Si es catastrófico, lo marcamos + quality = '[/COLOR][COLOR hotpink][E] [COLOR limegreen]%s' % quality + item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (quality, str(item_local.language)) + + #Preparamos título y calidad, quitamos etiquetas vacías + item_local.title = re.sub(r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]', '', item_local.title) + item_local.title = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', item_local.title) + item_local.title = item_local.title.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip() + quality = re.sub(r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]', '', quality) + quality = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', quality) + quality = quality.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip() + + item_local.alive = "??" #Calidad del link sin verificar + item_local.action = "play" #Visualizar vídeo + item_local.server = "torrent" #Seridor Torrent + + itemlist_t.append(item_local.clone(quality=quality)) #Pintar pantalla, si no se filtran idiomas + + # Requerido para FilterTools + if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra + item_local.quality = quality #Calidad + itemlist_f = filtertools.get_link(itemlist_f, item_local, list_language) #Pintar pantalla, si no está vacío + + #logger.debug("TORRENT: " + scrapedtorrent + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + scrapedsize + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) + #logger.debug(item_local) + + if not item.videolibray_emergency_urls: + if len(itemlist_f) > 0: #Si hay entradas filtradas... + itemlist_alt.extend(itemlist_f) #Pintamos pantalla filtrada + else: + if config.get_setting('filter_languages', channel) > 0 and len(itemlist_t) > 0: #Si no hay entradas filtradas ... + thumb_separador = get_thumb("next.png") #... pintamos todo con aviso + itemlist.append(Item(channel=item.channel, url=host, title="[COLOR red][B]NO hay elementos con el idioma seleccionado[/B][/COLOR]", thumbnail=thumb_separador)) + itemlist_alt.extend(itemlist_t) #Pintar pantalla con todo si no hay filtrado - # Requerido para FilterTools - if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra - itemlist_f = filtertools.get_link(itemlist_f, item_local, list_language) #Pintar pantalla, si no está vacío - - #logger.debug("TORRENT: " + scrapedtorrent + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + scrapedsize + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) - #logger.debug(item_local) - - if len(itemlist_f) > 0: #Si hay entradas filtradas... - itemlist_alt.extend(itemlist_f) #Pintamos pantalla filtrada - else: - if config.get_setting('filter_languages', channel) > 0 and len(itemlist_t) > 0: #Si no hay entradas filtradas ... - thumb_separador = get_thumb("next.png") #... pintamos todo con aviso - itemlist.append(Item(channel=item.channel, url=host, title="[COLOR red][B]NO hay elementos con el idioma seleccionado[/B][/COLOR]", thumbnail=thumb_separador)) - itemlist_alt.extend(itemlist_t) #Pintar pantalla con todo si no hay filtrado - - #Si son múltiples episodios, ordenamos - if len(itemlist_alt) > 1 and (item.contentType == 'episode' or item.contentType == 'season'): - itemlist_alt = sorted(itemlist_alt, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) #clasificamos - tmdb.set_infoLabels(itemlist_alt, True) #TMDB de la lista de episodios - itemlist.extend(itemlist_alt) + #Si son múltiples episodios, ordenamos + if len(itemlist_alt) > 1 and (item.contentType == 'episode' or item.contentType == 'season'): + itemlist_alt = sorted(itemlist_alt, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) #clasificamos + tmdb.set_infoLabels(itemlist_alt, True) #TMDB de la lista de episodios + itemlist.extend(itemlist_alt) #Ahora tratamos los servidores directo itemlist_alt = [] - itemlist_t = [] #Itemlist total de enlaces - itemlist_f = [] #Itemlist de enlaces filtrados + itemlist_t = [] #Itemlist total de enlaces + itemlist_f = [] #Itemlist de enlaces filtrados if matches_directo: for scrapedurl, scrapedquality, scrapedlang in matches_directo: #leemos los torrents con la diferentes calidades #Generamos una copia de Item para trabajar sobre ella @@ -861,13 +906,22 @@ def findvideos(item): item_local.language = ["%s" % IDIOMAS[scrapedlang]] #Salvamos el idioma, si lo hay #Leemos la página con el enlace al Servidor - try: - data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item_local.url, timeout=timeout).data) - except: - pass - - patron = '
Video Online:\s?([^<]+)?<\/span>

)", "", httptools.downloadpage(item_local.url, timeout=timeout).data) + except: + pass + + patron = '
Video Online:\s?([^<]+)?<\/span>

1 or len(itemlist_alt) > 1) and not servidor in scrapedtitle: - if not capitulo and (item_local.contentType == 'episode' or item_local.contentType == 'season'): - if scrapertools.find_single_match(scrapedtitle, '(\d+[x|X]\d+(?:-\d{1,2})?)'): - qualityscraped = '%s' % scrapertools.find_single_match(scrapedtitle, '(\d+[x|X]\d+(?:-\d{1,2})?)') - if scrapertools.find_single_match(scrapedtitle, '\d+[x|X](\d+)'): - item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtitle, '\d+[x|X](\d+)')) - elif scrapertools.find_single_match(scrapedtitle, '[c|C]ap.*?(\d+)'): - item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtitle, '[c|C]ap.*?(\d+)')) - elif scrapertools.find_single_match(scrapedtorrent, '[s|S]\d{1,2}[e|E](\d{1,2})'): - item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtorrent, '[s|S]\d{1,2}[e|E](\d{1,2})')) - if not qualityscraped: - qualityscraped = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2)) - elif capitulo: - if scrapertools.find_single_match(capitulo, '\d+[x|X](\d+)'): - item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtitle, '\d+[x|X](\d+)')) - qualityscraped = '%s' % capitulo - else: - qualityscraped = '%s' % scrapedtitle - - #Si todavía no sabemos el num de Episodio, lo buscamos - if not item_local.contentEpisodeNumber and item_local.contentType == 'episode': - try: - if scrapertools.find_single_match(scrapedtitle, '(\d+)[x|X](\d+)'): - item_local.contentSeason, item_local.contentEpisodeNumber = scrapertools.find_single_match(scrapedtitle, '(\d+)[x|X](\d+)') - qualityscraped = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2)) - except: - pass - - #Buscamos calidades - if scrapertools.find_single_match(scrapedenlace, '(\d+p)'): - qualityscraped += ' ' + scrapertools.find_single_match(scrapedenlace, '(\d+p)') - if qualityscraped: - quality = '[%s] %s' % (qualityscraped, item_local.quality) - - if scrapertools.find_single_match(item.url, '(\d+x\d+.*?\d+x\d+)') and not capitulo and not qualityscraped: - quality = '[%s] %s' % (scrapertools.find_single_match(scrapedenlace, '(\d+x\d+)'), quality) - elif capitulo and not qualityscraped: - quality = '[%s] %s' % (capitulo, quality) + if not item.videolibray_emergency_urls: + item_local = item_local.clone() + + enlace = '' + devuelve = '' + mostrar_server = '' + capitulo = '' + + servidor = scrapedtitle.strip() + servidor = servidor.replace("streamin", "streaminto") + if not servidor or "Capituo" in servidor or "Capitulo" in servidor or scrapertools.find_single_match(servidor, '(\d+[x|X]\d+)'): + capitulo = scrapertools.find_single_match(servidor, '(\d+[x|X]\d+)') + servidor = scrapertools.find_single_match(scrapedenlace, ':\/\/(.*?)\.') + quality = item_local.quality + + qualityscraped = '' + if not item_local.contentEpisodeNumber and item_local.contentType == 'episode': + item_local.contentEpisodeNumber = 0 + + #Si son episodios múltiples, los listamos con sus títulos + if (len(matches) > 1 or len(itemlist_alt) > 1) and not servidor in scrapedtitle: + if not capitulo and (item_local.contentType == 'episode' or item_local.contentType == 'season'): + if scrapertools.find_single_match(scrapedtitle, '(\d+[x|X]\d+(?:-\d{1,2})?)'): + qualityscraped = '%s' % scrapertools.find_single_match(scrapedtitle, '(\d+[x|X]\d+(?:-\d{1,2})?)') + if scrapertools.find_single_match(scrapedtitle, '\d+[x|X](\d+)'): + item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtitle, '\d+[x|X](\d+)')) + elif scrapertools.find_single_match(scrapedtitle, '[c|C]ap.*?(\d+)'): + item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtitle, '[c|C]ap.*?(\d+)')) + elif scrapertools.find_single_match(scrapedtorrent, '[s|S]\d{1,2}[e|E](\d{1,2})'): + item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtorrent, '[s|S]\d{1,2}[e|E](\d{1,2})')) + if not qualityscraped: + qualityscraped = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2)) + elif capitulo: + if scrapertools.find_single_match(capitulo, '\d+[x|X](\d+)'): + item_local.contentEpisodeNumber = int(scrapertools.find_single_match(scrapedtitle, '\d+[x|X](\d+)')) + qualityscraped = '%s' % capitulo + else: + qualityscraped = '%s' % scrapedtitle + + #Si todavía no sabemos el num de Episodio, lo buscamos + if not item_local.contentEpisodeNumber and item_local.contentType == 'episode': + try: + if scrapertools.find_single_match(scrapedtitle, '(\d+)[x|X](\d+)'): + item_local.contentSeason, item_local.contentEpisodeNumber = scrapertools.find_single_match(scrapedtitle, '(\d+)[x|X](\d+)') + qualityscraped = '%sx%s' % (str(item_local.contentSeason), str(item_local.contentEpisodeNumber).zfill(2)) + except: + pass + + #Buscamos calidades + if scrapertools.find_single_match(scrapedenlace, '(\d+p)'): + qualityscraped += ' ' + scrapertools.find_single_match(scrapedenlace, '(\d+p)') + if qualityscraped: + quality = '[%s] %s' % (qualityscraped, item_local.quality) + + if scrapertools.find_single_match(item.url, '(\d+x\d+.*?\d+x\d+)') and not capitulo and not qualityscraped: + quality = '[%s] %s' % (scrapertools.find_single_match(scrapedenlace, '(\d+x\d+)'), quality) + elif capitulo and not qualityscraped: + quality = '[%s] %s' % (capitulo, quality) + if item.armagedon: #Si es catastrófico, lo marcamos + quality = '[/COLOR][COLOR hotpink][E] [COLOR limegreen]%s' % quality - #Verificamos el si el enlace del servidor está activo - mostrar_server = True - if config.get_setting("hidepremium"): #Si no se aceptan servidore premium, se ignoran - mostrar_server = servertools.is_server_enabled(servidor) - - try: #Obtenemos el enlace - if mostrar_server: - devuelve = servertools.findvideosbyserver(scrapedenlace, servidor) #existe el link ? - if devuelve: - enlace = devuelve[0][1] #Se guarda el link - if not enlace: - continue + #Verificamos el si el enlace del servidor está activo + mostrar_server = True + if config.get_setting("hidepremium"): #Si no se aceptan servidore premium, se ignoran + mostrar_server = servertools.is_server_enabled(servidor) + + try: #Obtenemos el enlace + if mostrar_server: + devuelve = servertools.findvideosbyserver(scrapedenlace, servidor) #existe el link ? + if devuelve: + enlace = devuelve[0][1] #Se guarda el link + if not enlace: + continue + + item_local.alive = servertools.check_video_link(enlace, servidor, timeout=timeout) #activo el link ? + #Si el link no está activo se ignora + if "??" in item_local.alive: #dudoso + item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][%s][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (servidor.capitalize(), quality, str(item_local.language)) + elif "no" in item_local.alive.lower(): #No está activo. Lo preparo, pero no lo pinto + item_local.title = '[COLOR red][%s][/COLOR] [COLOR yellow][%s][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.alive, servidor.capitalize(), quality, str(item_local.language)) + logger.debug(item_local.alive + ": ALIVE / " + servidor + " / " + enlace) + raise + else: #Sí está activo + item_local.title = '[COLOR yellow][%s][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (servidor.capitalize(), quality, str(item_local.language)) + + #Ahora pintamos el link Directo + item_local.url = enlace - item_local.alive = servertools.check_video_link(enlace, servidor, timeout=timeout) #activo el link ? - #Si el link no está activo se ignora - if "??" in item_local.alive: #dudoso - item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][%s][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (servidor.capitalize(), quality, str(item_local.language)) - elif "no" in item_local.alive.lower(): #No está activo. Lo preparo, pero no lo pinto - item_local.title = '[COLOR red][%s][/COLOR] [COLOR yellow][%s][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.alive, servidor.capitalize(), quality, str(item_local.language)) - logger.debug(item_local.alive + ": ALIVE / " + servidor + " / " + enlace) - raise - else: #Sí está activo - item_local.title = '[COLOR yellow][%s][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (servidor.capitalize(), quality, str(item_local.language)) + #Preparamos título y calidad, quitamos etiquetas vacías + item_local.title = re.sub(r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]', '', item_local.title) + item_local.title = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', item_local.title) + item_local.title = item_local.title.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip() + quality = re.sub(r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]', '', quality) + quality = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', quality) + quality = quality.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip() - #Ahora pintamos el link Directo - item_local.url = enlace - - #Preparamos título y calidad, quitamos etiquetas vacías - item_local.title = re.sub(r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]', '', item_local.title) - item_local.title = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', item_local.title) - item_local.title = item_local.title.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip() - quality = re.sub(r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]', '', quality) - quality = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', quality) - quality = quality.replace("--", "").replace("[]", "").replace("()", "").replace("(/)", "").replace("[/]", "").strip() - - item_local.action = "play" #Visualizar vídeo - item_local.server = servidor #Seridor Directo - - itemlist_t.append(item_local.clone(quality=quality)) #Pintar pantalla, si no se filtran idiomas - - # Requerido para FilterTools - if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra - itemlist_f = filtertools.get_link(itemlist_f, item_local, list_language) #Pintar pantalla, si no está vacío - except: - logger.error('ERROR al procesar enlaces DIRECTOS: ' + servidor + ' / ' + scrapedenlace) + item_local.action = "play" #Visualizar vídeo + item_local.server = servidor #Servidor Directo + + itemlist_t.append(item_local.clone(quality=quality)) #Pintar pantalla, si no se filtran idiomas + + # Requerido para FilterTools + if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra + item_local.quality = quality #Calidad + itemlist_f = filtertools.get_link(itemlist_f, item_local, list_language) #Pintar pantalla, si no está vacío + except: + logger.error('ERROR al procesar enlaces DIRECTOS: ' + servidor + ' / ' + scrapedenlace) - #logger.debug("DIRECTO: " + scrapedenlace + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + scrapedsize + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) - #logger.debug(item_local) + #logger.debug("DIRECTO: " + scrapedenlace + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / tamaño: " + scrapedsize + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) + #logger.debug(item_local) + + if item.videolibray_emergency_urls: #Si estamos cargados emergency_urls, no vamos + return item if len(itemlist_f) > 0: #Si hay entradas filtradas... itemlist_alt.extend(itemlist_f) #Pintamos pantalla filtrada @@ -997,11 +1058,11 @@ def findvideos(item): #Si son múltiples episodios, ordenamos if len(itemlist_alt) > 1 and (item.contentType == 'episode' or item.contentType == 'season'): itemlist_alt = sorted(itemlist_alt, key=lambda it: (int(it.contentSeason), int(it.contentEpisodeNumber))) #clasificamos - tmdb.set_infoLabels(itemlist_alt, True) #TMDB de la lista de episodios + tmdb.set_infoLabels(itemlist_alt, True) #TMDB de la lista de episodios itemlist.extend(itemlist_alt) # Requerido para AutoPlay - autoplay.start(itemlist, item) #Lanzamos Autoplay + autoplay.start(itemlist, item) #Lanzamos Autoplay return itemlist diff --git a/plugin.video.alfa/channels/grantorrent.py b/plugin.video.alfa/channels/grantorrent.py index 47e1b781..6214ef38 100644 --- a/plugin.video.alfa/channels/grantorrent.py +++ b/plugin.video.alfa/channels/grantorrent.py @@ -428,15 +428,17 @@ def findvideos(item): #logger.debug(item) timeout_find = timeout + follow_redirects=True if item.videolibray_emergency_urls: #Si se están cacheando enlaces aumentamos el timeout timeout_find = timeout * 2 elif item.emergency_urls: #Si se llama desde la Videoteca con enlaces cacheados... timeout_find = timeout / 2 #reducimos el timeout antes de saltar a los enlaces cacheados + follow_redirects=False #Bajamos los datos de la página data = '' try: - data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url, timeout=timeout_find).data) + data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url, timeout=timeout_find, follow_redirects=follow_redirects).data) except: pass @@ -633,6 +635,8 @@ def episodios(item): temp_next = '' item.extra = "episodios" + #logger.debug(item) + # Obtener la información actualizada de la Serie. TMDB es imprescindible para Videoteca if not item.infoLabels['tmdb_id']: tmdb.set_infoLabels(item, True) @@ -716,6 +720,8 @@ def episodios(item): if item.ow_force == '1': #Si viene formazado la reconstrucción de la serie, lo hacemo item.contentType = "tvshow" + if not modo_ultima_temp: #Si se quiere actualiar toda la serie en vez de la última temporada... + item.contentType = "tvshow" temp_lista = [] temp_bucle = 0 diff --git a/plugin.video.alfa/channels/mejortorrent.py b/plugin.video.alfa/channels/mejortorrent.py index 722c559e..63e25330 100755 --- a/plugin.video.alfa/channels/mejortorrent.py +++ b/plugin.video.alfa/channels/mejortorrent.py @@ -265,8 +265,8 @@ def listado(item): del item.next_page #logger.debug(data) - logger.debug("PATRON1: " + patron + " / ") - logger.debug(matches) + #logger.debug("PATRON1: " + patron + " / ") + #logger.debug(matches) # Primera pasada # En la primera pasada se obtiene una información básica del título a partir de la url @@ -360,8 +360,8 @@ def listado(item): cnt_pag += cnt_tot cnt_pag_num += 1 - logger.debug("PATRON2: " + patron_title) - logger.debug(matches) + #logger.debug("PATRON2: " + patron_title) + #logger.debug(matches) cnt = 0 for scrapedtitle, notused, scrapedinfo in matches: item_local = itemlist[cnt] #Vinculamos item_local con la entrada de la lista itemlist (más fácil de leer) @@ -763,6 +763,12 @@ def findvideos(item): itemlist_f = [] #Itemlist de enlaces filtrados if not item.language: item.language = ['CAST'] #Castellano por defecto + matches = [] + + #Si es un lookup para cargar las urls de emergencia en la Videoteca... + if item.videolibray_emergency_urls: + item.emergency_urls = [] + item.emergency_urls.append([]) #Reservamos el espacio para los .torrents locales #Bajamos los datos de la página data = '' @@ -775,24 +781,47 @@ def findvideos(item): data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) patron = ")", "", httptools.downloadpage(url).data) - except: #error + except: #error + pass + + if not torrent_data: logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / URL: " + url + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log')) - return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + if item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia? + if len(item.emergency_urls[0]): + item_local.url = item.emergency_urls[0][0] #Restauramos la primera url + item.armagedon = True #Marcamos la situación como catastrófica + else: + if item.videolibray_emergency_urls: #Si es llamado desde creación de Videoteca... + return item #Devolvemos el Item de la llamada + else: + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + #logger.debug(torrent_data) - item_local.url = scrapertools.get_match(torrent_data, ">Pincha.*?Pincha.*? 1: + del item.emergency_urls[0][0] + if not item.armagedon and item.emergency_urls and not item.videolibray_emergency_urls: + if len(item.emergency_urls[0]): + item_local.torrent_alt = item.emergency_urls[0][0] #Guardamos la primera url del .Torrent ALTERNATIVA + + if item.videolibray_emergency_urls: + item.emergency_urls[0].append(item_local.url) #Salvamnos la url... # Poner la calidad, si es necesario if not item_local.quality: if "hdtv" in item_local.url.lower() or "720p" in item_local.url.lower() or "1080p" in item_local.url.lower() or "4k" in item_local.url.lower(): item_local.quality = scrapertools.find_single_match(item_local.url, '.*?_([H|7|1|4].*?)\.torrent') item_local.quality = item_local.quality.replace("_", " ") + if item.armagedon: #Si es catastrófico, lo marcamos + item_local.quality = '[/COLOR][COLOR hotpink][E] [COLOR limegreen]%s' % item_local.quality # Extrae la dimensión del vídeo size = scrapertools.find_single_match(item_local.url, '(\d{1,3},\d{1,2}?\w+)\.torrent') - size = size.upper().replace(".", ",").replace("G", " G ").replace("M", " M ") #sustituimos . por , porque Unify lo borra - if not size: + size = size.upper().replace(".", ",").replace("G", " G ").replace("M", " M ") #sustituimos . por , porque Unify lo borra + if not size and not item.armagedon: size = generictools.get_torrent_size(item_local.url) #Buscamos el tamaño en el .torrent if size: item_local.title = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item_local.title) #Quitamos size de título, si lo traía item_local.title = '%s [%s]' % (item_local.title, size) #Agregamos size al final del título item_local.quality = re.sub('\s\[\d+,?\d*?\s\w[b|B]\]', '', item_local.quality) #Quitamos size de calidad, si lo traía - item_local.quality = '%s [%s]' % (item.quality, size) #Agregamos size al final de calidad + item_local.quality = '%s [%s]' % (item.quality, size) #Agregamos size al final de calidad #Ahora pintamos el link del Torrent, si lo hay - if item_local.url: # Hay Torrent ? - item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent - + if item_local.url: # Hay Torrent ? + item_local.title = '[COLOR yellow][?][/COLOR] [COLOR yellow][Torrent][/COLOR] [COLOR limegreen][%s][/COLOR] [COLOR red]%s[/COLOR]' % (item_local.quality, str(item_local.language)) #Preparamos título de Torrent + #Preparamos título y calidad, quitamos etiquetas vacías item_local.title = re.sub(r'\s?\[COLOR \w+\]\[\[?\s?\]?\]\[\/COLOR\]', '', item_local.title) item_local.title = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', item_local.title) @@ -858,6 +915,9 @@ def findvideos(item): #logger.debug("title=[" + item.title + "], torrent=[ " + item_local.url + " ], url=[ " + url + " ], post=[" + item.post + "], thumbnail=[ " + item.thumbnail + " ]" + " size: " + size) + if item.videolibray_emergency_urls: + return item + if len(itemlist_f) > 0: #Si hay entradas filtradas... itemlist.extend(itemlist_f) #Pintamos pantalla filtrada else: diff --git a/plugin.video.alfa/channels/mejortorrent1.json b/plugin.video.alfa/channels/mejortorrent1.json index c17a3407..c5d2aa2f 100644 --- a/plugin.video.alfa/channels/mejortorrent1.json +++ b/plugin.video.alfa/channels/mejortorrent1.json @@ -54,6 +54,28 @@ "VOSE" ] }, + { + "id": "emergency_urls", + "type": "list", + "label": "Se quieren guardar Enlaces de Emergencia por si se cae la Web?", + "default": 1, + "enabled": true, + "visible": true, + "lvalues": [ + "No", + "Guardar", + "Borrar", + "Actualizar" + ] + }, + { + "id": "emergency_urls_torrents", + "type": "bool", + "label": "Se quieren guardar Torrents de Emergencia por si se cae la Web?", + "default": true, + "enabled": true, + "visible": "!eq(-1,'No')" + }, { "id": "seleccionar_ult_temporadda_activa", "type": "bool", diff --git a/plugin.video.alfa/channels/mejortorrent1.py b/plugin.video.alfa/channels/mejortorrent1.py index 6814d79e..23062782 100644 --- a/plugin.video.alfa/channels/mejortorrent1.py +++ b/plugin.video.alfa/channels/mejortorrent1.py @@ -165,8 +165,8 @@ def listado(item): item.contentType = "movie" pag = False #No hay paginación elif (item.extra == "peliculas" or item.extra == "varios") and not item.tipo: #Desde Menú principal - patron = '?' - patron_enlace = '\/\/.*?\/(.*?)\/$' + patron = ']+>?' + patron_enlace = '\/\/.*?\/(8.*?)\/$' patron_title = '([^<]+)<\/a>(\s*([^>]+)<\/b>)?' item.action = "findvideos" item.contentType = "movie" @@ -184,7 +184,7 @@ def listado(item): pag = False cnt_tot = 10 # Se reduce el numero de items por página porque es un proceso pesado elif item.extra == "series" and not item.tipo: - patron = '?' + patron = ']+>?' patron_enlace = '\/\/.*?\/(.*?)-[temporada]?\d+[-|x]' patron_title = '([^<]+)<\/a>(\s*([^>]+)<\/b>)?' patron_title_ep = '\/\/.*?\/(.*?)-(\d{1,2})x(\d{1,2})(?:-al-\d{1,2}x\d{1,2})?-?(\d+p)?\/$' @@ -203,7 +203,7 @@ def listado(item): item.contentType = "tvshow" pag = False else: - patron = '?' + patron = ']+>?' patron_enlace = '\/\/.*?\/(.*?)-[temporada]?\d+[-|x]' patron_title = '([^<]+)<\/a>(\s*([^>]+)<\/b>)?' patron_title_ep = '\/\/.*?\/(.*?)-(\d{1,2})x(\d{1,2})(?:-al-\d{1,2}x\d{1,2})?-?(\d+p)?\/$' @@ -813,6 +813,7 @@ def findvideos(item): itemlist_f = [] #Itemlist de enlaces filtrados if not item.language: item.language = ['CAST'] #Castellano por defecto + matches = [] #logger.debug(item) @@ -823,6 +824,11 @@ def findvideos(item): #Llamamos al método para crear el título general del vídeo, con toda la información obtenida de TMDB item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) + #Si es un lookup para cargar las urls de emergencia en la Videoteca... + if item.videolibray_emergency_urls: + item.emergency_urls = [] + item.emergency_urls.append([]) #Reservamos el espacio para los .torrents locales + #Bajamos los datos de la página de todo menos de Documentales y Varios if not item.post: try: @@ -836,34 +842,54 @@ def findvideos(item): 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 + if item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia? + matches = item.emergency_urls[1] #Restauramos matches + item.armagedon = True #Marcamos la situación como catastrófica + else: + if item.videolibray_emergency_urls: #Si es llamado desde creación de Videoteca... + return item #Devolvemos el Item de la llamada + else: + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos - matches = re.compile(patron, re.DOTALL).findall(data) + if not item.armagedon: #Si es un proceso normal, seguimos + matches = re.compile(patron, re.DOTALL).findall(data) if not matches: 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 + else: + logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.category + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log')) - logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) - itemlist.append(item.clone(action='', title=item.category + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log')) - return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + if item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia? + matches = item.emergency_urls[1] #Restauramos matches + item.armagedon = True #Marcamos la situación como catastrófica + else: + if item.videolibray_emergency_urls: #Si es llamado desde creación de Videoteca... + return item #Devolvemos el Item de la llamada + else: + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos #logger.debug("PATRON: " + patron) #logger.debug(matches) #logger.debug(data) - for scrapedurl, name1, value1, value2, name2 in matches: #Hacemos el FOR aunque solo habrá un item + #Si es un lookup para cargar las urls de emergencia en la Videoteca... + if item.videolibray_emergency_urls: + item.emergency_urls.append(matches) #Salvamnos matches... + + for scrapedurl, name1, value1, value2, name2 in matches: #Hacemos el FOR aunque solo habrá un item #Generamos una copia de Item para trabajar sobre ella item_local = item.clone() url = scrapedurl # Localiza el .torrent en el siguiente link con Post post = '%s=%s&%s=%s' % (name1, value1, name2, value2) - try: - torrent_data = httptools.downloadpage(url, post=post, headers=headers, follow_redirects=False) - except: #error - pass + if not item.armagedon: + try: + torrent_data = httptools.downloadpage(url, post=post, headers=headers, follow_redirects=False) + except: #error + pass else: #Viene de SERIES y DOCUMENTALES. Generamos una copia de Item para trabajar sobre ella @@ -874,19 +900,34 @@ def findvideos(item): except: pass - if not torrent_data: + if not torrent_data or not 'location' in torrent_data.headers or not torrent_data.headers['location']: 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 + elif not item.armagedon: + logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / URL: " + url + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log')) - logger.error("ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web " + " / URL: " + url + " / DATA: " + data) - itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: FINDVIDEOS: El archivo Torrent no existe o ha cambiado la estructura de la Web. Verificar en la Web y reportar el error con el log')) - return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + if item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia? + item_local.url = item.emergency_urls[0][0] #Restauramos la url del .torrent + item.armagedon = True #Marcamos la situación como catastrófica + else: + if item.videolibray_emergency_urls: #Si es llamado desde creación de Videoteca... + return item #Devolvemos el Item de la llamada + else: + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos #Capturamos la url del .torrent desde el Header - item_local.url = torrent_data.headers['location'] if 'location' in torrent_data.headers else item.url_post - item_local.url = item_local.url.replace(" ", "%20") #Quitamos espacios + if not item.armagedon: + item_local.url = torrent_data.headers['location'] if 'location' in torrent_data.headers else item.url_post + item_local.url = item_local.url.replace(" ", "%20") #Quitamos espacios + if item.emergency_urls: + item_local.torrent_alt = item.emergency_urls[0][0] #Guardamos la url del .Torrent ALTERNATIVA + + #Si es un lookup para cargar las urls de emergencia en la Videoteca... + if item.videolibray_emergency_urls: + item.emergency_urls[0].append(item_local.url) #Salvamnos la url... + return item #... y nos vamos # Poner la calidad, si es necesario if not item_local.quality: @@ -896,6 +937,8 @@ def findvideos(item): elif "hdtv" in item_local.url.lower() or "720p" in item_local.url.lower() or "1080p" in item_local.url.lower() or "4k" in item_local.url.lower(): item_local.quality = scrapertools.find_single_match(item_local.url, '.*?_([H|7|1|4].*?)\.torrent') item_local.quality = item_local.quality.replace("_", " ") + if item.armagedon: #Si es catastrófico, lo marcamos + item_local.quality = '[/COLOR][COLOR hotpink][E] [COLOR limegreen]%s' % item_local.quality # Extrae el tamaño del vídeo if scrapertools.find_single_match(data, 'Tama.*?:<\/b>&\w+;\s?([^<]+B) 0 or not clone_list_random: #Si el Clone por defecto no es Aleatorio, o hay ya un aleatorio sleccionado... + i = 1 + for active_clone, channel_clone, host_clone, contentType_clone, info_clone in clone_list: + if i == host_index: + channel_clone_name = channel_clone #Nombre del Canal elegido + host = host_clone #URL del Canal elegido + if active_clone == "1": #Comprueba que el clone esté activo break - i += 1 + channel_clone_name = "*** DOWN ***" #es un fallo masivo ??? + for active_clone, channel_clone, host_clone, contentType_clone, info_clone in clone_list: + if active_clone == "1": #Comprueba que el clone esté activo + channel_clone_name = channel_clone #Nombre del Canal elegido + host = host_clone #URL del Canal elegido + break + i += 1 item = Item() if item.channel != channel_py: @@ -114,8 +133,11 @@ def mainlist(item): thumbnail=thumb_docus, category=item.category, channel_host=item.channel_host)) itemlist.append( Item(channel=item.channel, action="search", title="Buscar", url=item.channel_host + "buscar", thumbnail=thumb_buscar, category=item.category, channel_host=item.channel_host)) - - itemlist.append(Item(channel=item.channel, url=host, title="[COLOR yellow]Configuración:[/COLOR]", folder=False, thumbnail=thumb_separador, category=item.category, channel_host=item.channel_host)) + + clone_act = 'Clone: ' + if config.get_setting('clonenewpct1_channel_default', channel_py) == 0: + clone_act = 'Aleatorio: ' + itemlist.append(Item(channel=item.channel, url=host, title="[COLOR yellow]Configuración:[/COLOR] (" + clone_act + item.category + ")", folder=False, thumbnail=thumb_separador, category=item.category, channel_host=item.channel_host)) itemlist.append(Item(channel=item.channel, action="settingCanal", title="Configurar canal", thumbnail=thumb_settings, category=item.category, channel_host=item.channel_host)) @@ -139,6 +161,11 @@ def submenu(item): itemlist = [] item.extra2 = '' + #Renombramos el canal al nombre de clone inicial desde la URL + host = scrapertools.find_single_match(item.url, '(http.?\:\/\/(?:www.)?\w+\.\w+\/)') + item.channel_host = host + item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() + data = '' try: data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) @@ -218,6 +245,10 @@ def submenu_novedades(item): itemlist_alt = [] item.extra2 = '' + #Renombramos el canal al nombre de clone inicial desde la URL + item.channel_host = host + item.category = channel_clone_name.capitalize() + data = '' timeout_search=timeout * 2 #Más tiempo para Novedades, que es una búsqueda thumb_settings = get_thumb("setting_0.png") @@ -315,6 +346,11 @@ def submenu_novedades(item): def alfabeto(item): logger.info() itemlist = [] + + #Renombramos el canal al nombre de clone inicial desde la URL + host = scrapertools.find_single_match(item.url, '(http.?\:\/\/(?:www.)?\w+\.\w+\/)') + item.channel_host = host + item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() data = '' data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) @@ -365,6 +401,12 @@ def alfabeto(item): def listado(item): logger.info() itemlist = [] + + #Renombramos el canal al nombre de clone inicial desde la URL + host = scrapertools.find_single_match(item.url, '(http.?\:\/\/(?:www.)?\w+\.\w+\/)') + item.channel_host = host + item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() + clase = "pelilist" # etiqueta para localizar zona de listado de contenidos url_next_page ='' # Control de paginación cnt_tot = 30 # Poner el num. máximo de items por página @@ -1249,7 +1291,7 @@ def findvideos(item): #Renombramos el canal al nombre de clone elegido. Actualizados URL host = scrapertools.find_single_match(item.url, '(http.?\:\/\/(?:www.)?\w+\.\w+\/)') item.channel_host = host - item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize() + item.category = host.capitalize() verify_fo = True #Verificamos si el clone a usar está activo item, data = generictools.fail_over_newpct1(item, verify_fo) @@ -1374,10 +1416,11 @@ def findvideos(item): pass patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent - patron_mult = 'torrent:check:status|' + patron - if 'planetatorrent' in item.channel_host: - patron = ' max_temp: + logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) + match['season'] = scrapertools.find_single_match(item_local.url, '\/[t|T]emp\w+-*(\d+)\/') + if not match['season']: + match['season'] = season_alt + else: + match['season'] = int(match['season']) except: logger.error("ERROR 07: EPISODIOS: Error en número de Temporada o Episodio: " + " / TEMPORADA/EPISODIO: " + str(match['season']) + " / " + str(match['episode']) + " / NUM_TEMPORADA: " + str(max_temp) + " / " + str(season) + " / MATCHES: " + str(matches)) @@ -2043,11 +2096,12 @@ def episodios(item): else: #Si es un solo episodio, se formatea ya item_local.title = "%sx%s -" % (match["season"], str(match["episode"]).zfill(2)) + if first: #Si es el primer episodio, comprobamos que ... + first = False + if item_local.contentSeason < max_temp: #... la temporada sea la última ... + modo_ultima_temp_alt = False #... si no, por seguridad leeremos toda la serie + if modo_ultima_temp_alt and item.library_playcounts: #Si solo se actualiza la última temporada de Videoteca - if first: #Si es el primer episodio, comprobamos que ... - first = False - if item_local.contentSeason < max_temp: #... la temporada sea la última ... - modo_ultima_temp_alt = False #... si no, por seguridad leeremos toda la serie if item_local.contentSeason < max_temp and modo_ultima_temp_alt: list_pages = [] #Sale del bucle de leer páginas break #Sale del bucle actual del FOR de episodios por página @@ -2055,7 +2109,7 @@ def episodios(item): # continue if season_display > 0: - if item_local.contentSeason > season_display: + if item_local.contentSeason > season_display or (not modo_ultima_temp_alt and item_local.contentSeason != season_display): continue elif item_local.contentSeason < season_display: list_pages = [] #Sale del bucle de leer páginas diff --git a/plugin.video.alfa/channels/pelisplusco.py b/plugin.video.alfa/channels/pelisplusco.py index 744de2ca..570a4082 100644 --- a/plugin.video.alfa/channels/pelisplusco.py +++ b/plugin.video.alfa/channels/pelisplusco.py @@ -143,10 +143,12 @@ def series_menu(item): return itemlist -def get_source(url): - +def get_source(url, referer=None): logger.info() - data = httptools.downloadpage(url).data + if referer is None: + data = httptools.downloadpage(url).data + else: + data = httptools.downloadpage(url, headers={'Referer':referer, 'x-requested-with': 'XMLHttpRequest'}).data data = re.sub(r'\n|\r|\t| |
|\s{2,}', "", data) return data @@ -173,7 +175,7 @@ def list_all (item): matches = scrapertools.find_multiple_matches(data, patron) for scrapedurl, scrapedthumbnail, scrapedyear, scrapedtitle in matches: - url = host+scrapedurl+'p001/' + url = host+scrapedurl thumbnail = scrapedthumbnail contentTitle=scrapedtitle title = contentTitle @@ -349,16 +351,15 @@ def season_episodes(item): def get_links_by_language(item, data): logger.info() - video_list = [] - language = scrapertools.find_single_match(data, 'ul id=level\d_(.*?)\s*class=') - patron = 'data-source=(.*?)data.*?srt=(.*?)data-iframe.*?Opci.*?<.*?hidden>[^\(]\((.*?)\)' + language = scrapertools.find_single_match(data, 'ul id="level\d_([^"]+)"\s*class=') + patron = 'data-source="([^"]+)"data-quality="([^"]+)"data-srt="([^"]+)"' matches = re.compile(patron, re.DOTALL).findall(data) if language in IDIOMAS: language = IDIOMAS[language] - for url, sub, quality in matches: + for url, quality, sub in matches: if 'http' not in url: new_url = 'https://onevideo.tv/api/player?key=90503e3de26d45e455b55e9dc54f015b3d1d4150&link' \ @@ -391,15 +392,19 @@ def findvideos(item): logger.info() itemlist = [] video_list = [] - data = httptools.downloadpage(item.url).data - data = re.sub(r'"|\n|\r|\t| |
|\s{2,}', "", data) + if item.contentType == 'movie': + new_url = new_url = item.url.replace('/pelicula/', '/player/%s/' % item.contentType) + else: + base_url = scrapertools.find_single_match(item.url, '(.*?)/temporada') + new_url = base_url.replace('/serie/', '/player/serie/') + new_url += '|%s|%s/' % (item.contentSeason, item.contentEpisodeNumber) + data = get_source(new_url, referer=item.url) - patron_language ='(
    )' + patron_language ='(
      )' matches = re.compile(patron_language, re.DOTALL).findall(data) for language in matches: video_list.extend(get_links_by_language(item, language)) - video_list = servertools.get_servers_itemlist(video_list, lambda i: i.title % (i.server.capitalize(), i.language, i.quality) ) # Requerido para FilterTools diff --git a/plugin.video.alfa/channels/planetadocumental.json b/plugin.video.alfa/channels/planetadocumental.json deleted file mode 100644 index ecc6eef7..00000000 --- a/plugin.video.alfa/channels/planetadocumental.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "id": "planetadocumental", - "name": "Planeta documental", - "language": ["*"], - "active": true, - "adult": false, - "thumbnail": "https://s8.postimg.cc/r6njedwdt/planeta_documental1.png", - "banner": "https://s8.postimg.cc/6za3m36m9/planeta_documental2.png", - "categories": [ - "documentary" - ], - "settings": [ - { - "id": "include_in_global_search", - "type": "bool", - "label": "Incluir en busqueda global", - "default": true, - "enabled": true, - "visible": true - } - ] -} diff --git a/plugin.video.alfa/channels/planetadocumental.py b/plugin.video.alfa/channels/planetadocumental.py deleted file mode 100644 index 52f973ae..00000000 --- a/plugin.video.alfa/channels/planetadocumental.py +++ /dev/null @@ -1,142 +0,0 @@ -# -*- coding: utf-8 -*- -# -*- Channel Planeta Documental -*- -# -*- Created for Alfa-addon -*- -# -*- By the Alfa Develop Group -*- - -from core import httptools -from core import jsontools -from core import scrapertools -from core import servertools -from core import tmdb -from core.item import Item -from channelselector import get_thumb -from platformcode import config, logger -from channels import autoplay -from channels import filtertools - - -IDIOMAS = {"Latino": "LAT"} -list_language = IDIOMAS.values() - -list_quality = [] - -list_servers = ['gvideo'] - -host = "https://www.planetadocumental.com" - -def mainlist(item): - logger.info() - itemlist = [] - autoplay.init(item.channel, list_servers, list_quality) - itemlist.append(item.clone(title="Últimos documentales", action="lista", - url= host, - thumbnail=get_thumb('lastest', auto=True))) - itemlist.append(item.clone(title="Por genero", action="generos", - url= host, thumbnail=get_thumb('genres', auto=True))) - itemlist.append(item.clone(title="", action="")) - itemlist.append(item.clone(title="Buscar...", action="search", thumbnail=get_thumb('search', auto=True))) - - return itemlist - - - -def generos(item): - logger.info() - itemlist = [] - data = httptools.downloadpage(item.url).data - bloque = scrapertools.find_single_match(data, 'sub-menu elementor-nav-menu--dropdown(.*?)HD<' in quality: @@ -83,7 +83,6 @@ def lista(item): itemlist.append(item.clone(action=action, title=scrapedtitle, url=scrapedurl, thumbnail=scrapedthumbnail, contentThumbnail=scrapedthumbnail, fanart=scrapedthumbnail)) - # Extrae la marca de siguiente página if item.extra: next_page = scrapertools.find_single_match(data, '