From b51399e13222d7106ecc15c43958beb0885f23bb Mon Sep 17 00:00:00 2001 From: Kingbox <37674310+lopezvg@users.noreply.github.com> Date: Wed, 7 Nov 2018 14:21:13 +0100 Subject: [PATCH] Cacheo de enlace: nuevos canales y mejoras MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cacheo de enlaces: - Mejores controles para el cacheo de enlaces para el contenido existiente en la Videoteca. - Opción para cachear los archivos .torrent y almacenarlos en la Videoteca - Mejoras en el "play" de enlaces torrent: ahora descarga siempre los .torrent en local y pasa al cliente Torrent el .torret descargado - Usando la técnica anterior, permite al canal usar un enlace Torrent alternativo por si el enlace torrent principal no está activo. El "play" de enlaces torrent seleciona automáticamente el .torrent alternativo si el principal no funciona. Nuevos canales añadidos al cacheo de enlaces: - DivxTotal - EliteTorrent - GranTorrent Mejorado: - Newpct1 (mejorada la Alta Disponibilidad en Findvideos) --- plugin.video.alfa/channels/divxtotal.json | 22 ++ plugin.video.alfa/channels/divxtotal.py | 70 ++++-- plugin.video.alfa/channels/elitetorrent.json | 22 ++ plugin.video.alfa/channels/elitetorrent.py | 72 ++++-- plugin.video.alfa/channels/grantorrent.json | 22 ++ plugin.video.alfa/channels/grantorrent.py | 112 +++++++--- plugin.video.alfa/channels/newpct1.json | 14 +- plugin.video.alfa/channels/newpct1.py | 118 +++++----- plugin.video.alfa/channels/videolibrary.py | 5 +- plugin.video.alfa/core/videolibrarytools.py | 185 ++++++++++++++-- plugin.video.alfa/lib/generictools.py | 207 +++++++++++++----- .../platformcode/platformtools.py | 33 +++ plugin.video.alfa/videolibrary_service.py | 2 + 13 files changed, 689 insertions(+), 195 deletions(-) diff --git a/plugin.video.alfa/channels/divxtotal.json b/plugin.video.alfa/channels/divxtotal.json index 811b5e44..60183e92 100644 --- a/plugin.video.alfa/channels/divxtotal.json +++ b/plugin.video.alfa/channels/divxtotal.json @@ -43,6 +43,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/divxtotal.py b/plugin.video.alfa/channels/divxtotal.py index b5ed39f6..e22794a1 100644 --- a/plugin.video.alfa/channels/divxtotal.py +++ b/plugin.video.alfa/channels/divxtotal.py @@ -514,10 +514,10 @@ def listado(item): def findvideos(item): logger.info() itemlist = [] - 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 not item.language: - item.language = ['CAST'] #Castellano por defecto + item.language = ['CAST'] #Castellano por defecto matches = [] item.category = categoria @@ -526,7 +526,7 @@ def findvideos(item): #Bajamos los datos de la página data = '' patron = '' - if item.contentType == 'movie': + if item.contentType == 'movie': #Es una peli try: data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) data = unicode(data, "utf-8", errors="replace").encode("utf-8") @@ -536,43 +536,73 @@ def findvideos(item): if not data: 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 + if item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia? + matches = item.emergency_urls[0] #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: #error - logger.error("ERROR 02: FINDVIDEOS: No hay enlaces o ha cambiado la estructura de la Web " + " / PATRON: " + patron + data) - 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')) - return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos - else: + 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 + else: + logger.error("ERROR 02: FINDVIDEOS: No hay enlaces o ha cambiado la estructura de la Web " + " / PATRON: " + patron + data) + 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 item.emergency_urls and not item.videolibray_emergency_urls: #Hay urls de emergencia? + matches = item.emergency_urls[0] #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 + + else: #Es un episodio matches = [item.url] #logger.debug("PATRON: " + patron) #logger.debug(matches) #logger.debug(data) + #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(matches) #Salvamnos matches... + return item #... y nos vamos + #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) #Ahora tratamos los enlaces .torrent - for scrapedurl in matches: #leemos los torrents con la diferentes calidades + for scrapedurl in matches: #leemos los torrents con la diferentes calidades #Generamos una copia de Item para trabajar sobre ella item_local = item.clone() #Buscamos si ya tiene tamaño, si no, los buscamos en el archivo .torrent size = scrapertools.find_single_match(item_local.quality, '\s\[(\d+,?\d*?\s\w\s?[b|B])\]') - if not size: - size = generictools.get_torrent_size(item_local.url) #Buscamos el tamaño en el .torrent + 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(r'\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 size = size.replace('GB', 'G B').replace('Gb', 'G b').replace('MB', 'M B').replace('Mb', 'M b') item_local.quality = re.sub(r'\s\[\d+,?\d*?\s\w\s?[b|B]\]', '', item_local.quality) #Quitamos size de calidad, si lo traía - item_local.quality = '%s [%s]' % (item_local.quality, size) #Agregamos size al final de la calidad + item_local.quality = '%s [%s]' % (item_local.quality, size) #Agregamos size al final de la calidad #Ahora pintamos el link del Torrent item_local.url = scrapedurl - if host not in item_local.url and host.replace('https', 'http') not in item_local.url : + 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: + 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 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 y calidad, quitamos etiquetas vacías @@ -583,14 +613,14 @@ def findvideos(item): item_local.quality = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', item_local.quality) item_local.quality = item_local.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 + 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()) #Pintar pantalla, si no se filtran idiomas + itemlist_t.append(item_local.clone()) #Pintar pantalla, si no se filtran idiomas # Requerido para FilterTools - if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra + 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: " + scrapedurl + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality + " / content: " + item_local.contentTitle + " / " + item_local.contentSerieName) diff --git a/plugin.video.alfa/channels/elitetorrent.json b/plugin.video.alfa/channels/elitetorrent.json index 51604e55..7ab400bd 100644 --- a/plugin.video.alfa/channels/elitetorrent.json +++ b/plugin.video.alfa/channels/elitetorrent.json @@ -46,6 +46,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": "include_in_newest_peliculas", "type": "bool", diff --git a/plugin.video.alfa/channels/elitetorrent.py b/plugin.video.alfa/channels/elitetorrent.py index 2e2b6029..5e940626 100644 --- a/plugin.video.alfa/channels/elitetorrent.py +++ b/plugin.video.alfa/channels/elitetorrent.py @@ -309,10 +309,10 @@ def listado(item): def findvideos(item): logger.info() itemlist = [] - 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 not item.language: - item.language = ['CAST'] #Castellano por defecto + item.language = ['CAST'] #Castellano por defecto #Bajamos los datos de la página data = '' @@ -324,8 +324,35 @@ 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? + link_torrent = item.emergency_urls[0][0] #Guardamos la url del .Torrent + link_magnet = item.emergency_urls[1][0] #Guardamos la url del .Magnet + 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 #data = unicode(data, "utf-8", errors="replace") + + patron_t = '
]+>(.*?)
') #Seleccionamos la zona de links patron = '\/icono_.*?png" title="(?P.*?)?" [^>]+><\/td>(?P.*?)?.*?(?P.*?)?<\/td>
]*>(.*?)<\/font>\)') @@ -500,6 +525,12 @@ def findvideos(item): if (contentSeason != item.contentSeason or contentEpisodeNumber != item.contentEpisodeNumber) and item.contentEpisodeNumber != 0: continue #si no son iguales, lo ignoramos + #Si es un looup desde episodios para cachear enlaces, lo salvamos en este momento + if item.videolibray_emergency_urls: + emergency_torrents.append(scrapedurl) + emergency_urls.append(matches[i]) + continue + #Generamos una copia de Item para trabajar sobre ella item_local = item.clone() @@ -527,7 +558,7 @@ def findvideos(item): item_local.quality = '%s [/COLOR][COLOR white][%s h]' % (item_local.quality, scrapertools.find_single_match(item.quality, '(\d+:\d+)')) #if size and item_local.contentType != "episode": - if not size: + if not size and not item.armagedon: size = generictools.get_torrent_size(scrapedurl) #Buscamos el tamaño en el .torrent if size: size = size.replace(".", ",").replace("B,", " B").replace("b,", " b") @@ -544,8 +575,13 @@ def findvideos(item): #Salvamos la url del .torrent if scrapedurl: item_local.url = scrapedurl + if item_local.emergency_urls and not item.armagedon: + item_local = find_torrent_alt(item_local) #Si hay enlaces de emergencia los usamos como alternativos + if item.armagedon: #Si es catastrófico, lo marcamos + item_local.url = item.emergency_urls[0][i] + item_local.quality = '[/COLOR][COLOR hotpink][E] [COLOR limegreen]%s' % item_local.quality 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) @@ -554,19 +590,26 @@ def findvideos(item): item_local.quality = re.sub(r'\s?\[COLOR \w+\]\s?\[\/COLOR\]', '', item_local.quality) item_local.quality = item_local.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 + 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()) #Pintar pantalla, si no se filtran idiomas # Requerido para FilterTools - if config.get_setting('filter_languages', channel) > 0: #Si hay idioma seleccionado, se filtra + 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: " + item_local.url + " / title gen/torr: " + item.title + " / " + item_local.title + " / calidad: " + item_local.quality) #logger.debug(item_local) + if item.videolibray_emergency_urls: #Viene de un lookup desde episodios para cachear enlaces + if len(emergency_torrents) > 0: + item.emergency_urls = [] #Le damos el formato estandar: lista de listas de tuplas + item.emergency_urls.append(emergency_torrents) #Devolvemos las urls de .torrents cacheadas + item.emergency_urls.append(emergency_urls) #Devolvemos los matches cacheados + return item + if len(itemlist_f) > 0: #Si hay entradas filtradas... itemlist.extend(itemlist_f) #Pintamos pantalla filtrada else: @@ -651,26 +694,29 @@ def episodios(item): if item.library_playcounts["season %d" % s] < temp_actual_num: #Si menor que actual, es Temp. item.contentType = "season" else: - item.contentType = "tvshow" #No es Temporada 1, pero es más baja que la actual. Es Serie + item.contentType = "tvshow" #No es Temporada 1, pero es más baja que la actual. Es Serie break s += 1 - else: #Sí, es Serie + else: #Sí, es Serie item.contentType = "tvshow" - else: #Solo hay una temporada en la Videoteca - if temp_actual_num > 1: #es Temporada la actual? + else: #Solo hay una temporada en la Videoteca + if temp_actual_num > 1: #es Temporada la actual? if item.contentSeason: - item.contentType = "season" #Si está informado el num de Temp. se creó como Temporada + item.contentType = "season" #Si está informado el num de Temp. se creó como Temporada else: - item.contentType = "tvshow" #Si no, es Serie que no tiene Temp. 1 - else: #Si es Temp. 1, se procesa según el valor de configuración - if modo_serie_temp == 0: #Es Temporada + item.contentType = "tvshow" #Si no, es Serie que no tiene Temp. 1 + else: #Si es Temp. 1, se procesa según el valor de configuración + if modo_serie_temp == 0: #Es Temporada item.contentType = "season" - else: #Es Serie + else: #Es Serie item.contentType = "tvshow" else: item.contentType = "list" + if item.ow_force == '1': #Si viene formazado la reconstrucción de la serie, lo hacemo + item.contentType = "tvshow" + temp_lista = [] temp_bucle = 0 temp_next_alt = '' @@ -753,7 +799,7 @@ def episodios(item): break #si no hay más datos, algo no funciona, pintamos lo que tenemos if item.contentType == "season": - temp_advance = '' #Es la única temporada + temp_advance = '' #Es la últica temporada if temp_next and item.library_playcounts: #Permitimos en actualización de Videoteca añadir nuevas temporadas temp_advance = 'forw' #Si hay nueva temporada, pasamos a esa como actual temp_previous = '' #lo limpiamos, por control @@ -910,6 +956,22 @@ def episodios(item): return itemlist +def find_torrent_alt(item): + logger.info() + + if not item.emergency_urls: + return item + + i = 0 + for lang, quality, size, scrapedurl in item.emergency_urls[1]: #buscamos la url actual en la lista de matches cacheada + if item.url == scrapedurl: #si está ... + item.torrent_alt = item.emergency_urls[0][i] #... copiamos la url o la dirección de .torrent local + break #... y nos vamos + i += 1 + + return item + + def lookup_idiomas_paginacion(item, scrapedurl, title, lang, list_language): logger.info() estado = True diff --git a/plugin.video.alfa/channels/newpct1.json b/plugin.video.alfa/channels/newpct1.json index 49afc414..5dbb29b9 100644 --- a/plugin.video.alfa/channels/newpct1.json +++ b/plugin.video.alfa/channels/newpct1.json @@ -62,6 +62,14 @@ "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": "clonenewpct1_channel_default", "type": "list", @@ -70,11 +78,11 @@ "enabled": true, "visible": true, "lvalues": [ - "Torrentrapid", - "Tumejortorrent", "Torrentlocura", "Tvsinpagar", "Planetatorrent", + "Torrentrapid", + "Tumejortorrent", "Descargas2020", "Mispelisyseries" ] @@ -83,7 +91,7 @@ "id": "clonenewpct1_channels_list", "type": "text", "label": "Lista de clones de NewPct1 y orden de uso", - "default": "('1', 'torrentrapid', 'http://torrentrapid.com/', 'movie, tvshow, season, episode', 'serie_episodios'), ('1', 'tumejortorrent', 'http://tumejortorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'torrentlocura', 'http://torrentlocura.com/', 'movie, tvshow, season, episode', ''), ('1', 'tvsinpagar', 'http://www.tvsinpagar.com/', 'tvshow, season, episode', ''), ('1', 'planetatorrent', 'http://planetatorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'descargas2020', 'http://descargas2020.com/', 'movie, tvshow, season, episode', ''), ('1', 'mispelisyseries', 'http://mispelisyseries.com/', 'movie', 'search, listado_busqueda')", + "default": "('1', 'torrentlocura', 'http://torrentlocura.com/', 'movie, tvshow, season, episode', ''), ('1', 'tvsinpagar', 'http://www.tvsinpagar.com/', 'tvshow, season, episode', ''), ('1', 'planetatorrent', 'http://planetatorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'torrentrapid', 'http://torrentrapid.com/', 'movie, tvshow, season, episode', 'serie_episodios'), ('1', 'tumejortorrent', 'http://tumejortorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'descargas2020', 'http://descargas2020.com/', 'movie, tvshow, season, episode', ''), ('1', 'mispelisyseries', 'http://mispelisyseries.com/', 'movie', 'search, listado_busqueda')", "enabled": true, "visible": false }, diff --git a/plugin.video.alfa/channels/newpct1.py b/plugin.video.alfa/channels/newpct1.py index ceb0f102..9177fb26 100644 --- a/plugin.video.alfa/channels/newpct1.py +++ b/plugin.video.alfa/channels/newpct1.py @@ -1237,6 +1237,7 @@ def listado_busqueda(item): def findvideos(item): logger.info() + from core import videolibrarytools itemlist = [] itemlist_t = [] #Itemlist total de enlaces itemlist_f = [] #Itemlist de enlaces filtrados @@ -1361,38 +1362,46 @@ def findvideos(item): # Descarga la página data = '' data_servidores = '' + enlaces_ver = '' try: data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url, timeout=timeout).data) data = data.replace("$!", "#!").replace("'", "\"").replace("ñ", "ñ").replace("//pictures", "/pictures") url_servidores = item.url category_servidores = item.category - data_servidores = data #salvamos data para verificar servidores, si es necesario - except: #La web no responde. Probemos las urls de emergencia + data_servidores = data #salvamos data para verificar servidores, si es necesario + data_servidores_stat = False + except: #La web no responde. Probemos las urls de emergencia pass - patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent - if not scrapertools.find_single_match(data, patron): - patron = ' 0 and path != False and ow_force_def in ['force', 'auto']) or item.ow_force == '1' or len(json_path_list) > 0: diff --git a/plugin.video.alfa/platformcode/platformtools.py b/plugin.video.alfa/platformcode/platformtools.py index 960138db..d0781ef7 100644 --- a/plugin.video.alfa/platformcode/platformtools.py +++ b/plugin.video.alfa/platformcode/platformtools.py @@ -1061,6 +1061,9 @@ def torrent_client_installed(show_tuple=False): def play_torrent(item, xlistitem, mediaurl): logger.info() import time + from core import filetools + from core import httptools + from core import videolibrarytools # Opciones disponibles para Reproducir torrents torrent_options = list() @@ -1090,6 +1093,36 @@ def play_torrent(item, xlistitem, mediaurl): xbmcplugin.setResolvedUrl(int(sys.argv[1]), False, xlistitem) #Preparamos el entorno para evitar error Kod1 18 time.sleep(0.5) #Dejamos tiempo para que se ejecute + #Nuevo método de descarga previa del .torrent. Si da error, miramos si hay alternatica local. Si ya es local, lo usamos + url_stat = False + videolibrary_path = config.get_videolibrary_path() #Calculamos el path absoluto a partir de la Videoteca + if not filetools.exists(videolibrary_path): #Si no existe el path, pasamos al modo clásico + url_stat = True + elif not filetools.exists(videolibrary_path + 'temp_torrents_Alfa'): #Si no existe la carpeta temporal para .torrents, la creamos + filetools.mkdir(videolibrary_path + 'temp_torrents_Alfa') + torrents_path = filetools.join(videolibrary_path, 'temp_torrents_Alfa', 'cliente_torrent_Alfa.torrent') #path de descarga temporal + + #identificamos si es una url o un path de archivo. Los Magnets los tratamos de la forma clásica + if not item.url.startswith("\\") and not item.url.startswith("/") and not item.url.startswith("magnet:") and not url_stat: + timeout = 10 + if item.torrent_alt: + timeout = 5 + item.url = videolibrarytools.caching_torrents(item.url, torrents_path=torrents_path, timeout=timeout) #Descargamos el .torrent + if item.url: url_stat = True + + if not item.url and item.torrent_alt: #Si hay error, se busca un .torrent alternativo + item.url = item.torrent_alt #El .torrent alternativo puede estar en una url o en local + + #Si es un archivo .torrent local, actualizamos el path relativo a path absoluto + if item.url.startswith("\\") or item.url.startswith("/") and not url_stat: #.torrent alternativo local + movies = config.get_setting("folder_movies") + series = config.get_setting("folder_tvshows") + if item.contentType == 'movie': + folder = movies #películas + else: + folder = series #o series + item.url = filetools.join(videolibrary_path, folder, item.url) #dirección del .torrent local en la Videoteca + mediaurl = urllib.quote_plus(item.url) #Llamada con más parámetros para completar el título if ("quasar" in torrent_options[seleccion][1] or "elementum" in torrent_options[seleccion][1]) and item.infoLabels['tmdb_id']: diff --git a/plugin.video.alfa/videolibrary_service.py b/plugin.video.alfa/videolibrary_service.py index 187b2845..37c090b9 100644 --- a/plugin.video.alfa/videolibrary_service.py +++ b/plugin.video.alfa/videolibrary_service.py @@ -17,6 +17,7 @@ def update(path, p_dialog, i, t, serie, overwrite): insertados_total = 0 head_nfo, it = videolibrarytools.read_nfo(path + '/tvshow.nfo') + category = serie.category # logger.debug("%s: %s" %(serie.contentSerieName,str(list_canales) )) for channel, url in serie.library_urls.items(): @@ -28,6 +29,7 @@ def update(path, p_dialog, i, t, serie, overwrite): head_nfo, it = videolibrarytools.read_nfo(path + '/tvshow.nfo') #Refresca el .nfo para recoger actualizaciones if it.emergency_urls: serie.emergency_urls = it.emergency_urls + serie.category = category serie, it, overwrite = generictools.redirect_clone_newpct1(serie, head_nfo, it, path, overwrite) except: pass