diff --git a/plugin.video.alfa/channels/alltorrent.json b/plugin.video.alfa/channels/alltorrent.json index c627ebbb..e2188b7b 100755 --- a/plugin.video.alfa/channels/alltorrent.json +++ b/plugin.video.alfa/channels/alltorrent.json @@ -4,7 +4,8 @@ "active": true, "adult": false, "language": ["cast"], - "thumbnail": "http://imgur.com/sLaXHvp.png", + "thumbnail": "altorrent.png", + "fanart": "altorrent.jpg", "categories": [ "torrent", "movie" @@ -22,7 +23,7 @@ "id": "include_in_global_search", "type": "bool", "label": "Incluir en busqueda global", - "default": true, + "default": false, "enabled": true, "visible": true }, diff --git a/plugin.video.alfa/channels/alltorrent.py b/plugin.video.alfa/channels/alltorrent.py index 34869367..505f5059 100755 --- a/plugin.video.alfa/channels/alltorrent.py +++ b/plugin.video.alfa/channels/alltorrent.py @@ -1,93 +1,261 @@ # -*- coding: utf-8 -*- -import os import re -import unicodedata -from threading import Thread +import sys +import urllib +import urlparse +from channelselector import get_thumb from core import httptools from core import scrapertools from core import servertools -from core import tmdb from core.item import Item from platformcode import config, logger - -__modo_grafico__ = config.get_setting('modo_grafico', "ver-pelis") - - -# Para la busqueda en bing evitando baneos - - -def browser(url): - import mechanize - - # Utilizamos Browser mechanize para saltar problemas con la busqueda en bing - br = mechanize.Browser() - # Browser options - br.set_handle_equiv(False) - br.set_handle_gzip(True) - br.set_handle_redirect(True) - br.set_handle_referer(False) - br.set_handle_robots(False) - # Follows refresh 0 but not hangs on refresh > 0 - br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) - # Want debugging messages? - # br.set_debug_http(True) - # br.set_debug_redirects(True) - # br.set_debug_responses(True) - - # User-Agent (this is cheating, ok?) - # br.addheaders = [('User-agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/7.1.7 Safari/537.85.16')] - # br.addheaders =[('Cookie','SRCHD=AF=QBRE; domain=.bing.com; expires=25 de febrero de 2018 13:00:28 GMT+1; MUIDB=3B942052D204686335322894D3086911; domain=www.bing.com;expires=24 de febrero de 2018 13:00:28 GMT+1')] - # Open some site, let's pick a random one, the first that pops in mind - r = br.open(url) - response = r.read() - print response - if "img,divreturn" in response: - r = br.open("http://ssl-proxy.my-addr.org/myaddrproxy.php/" + url) - print "prooooxy" - response = r.read() - - return response - - -api_key = "2e2160006592024ba87ccdf78c28f49f" -api_fankey = "dffe90fba4d02c199ae7a9e71330c987" +from core import tmdb +from lib import generictools host = 'http://alltorrent.net/' +__modo_grafico__ = config.get_setting('modo_grafico', 'alltorrent') + def mainlist(item): logger.info() itemlist = [] - i = 0 - global i - itemlist.append(item.clone(title="[COLOR springgreen][B]Todas Las Películas[/B][/COLOR]", action="scraper", - url="http://alltorrent.net/", thumbnail="http://imgur.com/XLqPZoF.png", - fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie")) - itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 1080p[/COLOR]", action="scraper", - url="http://alltorrent.net/rezolucia/1080p/", thumbnail="http://imgur.com/XLqPZoF.png", - fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie")) - itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 720p[/COLOR]", action="scraper", - url="http://alltorrent.net/rezolucia/720p/", thumbnail="http://imgur.com/XLqPZoF.png", - fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie")) - itemlist.append(item.clone(title="[COLOR springgreen] Incluyen Hdrip[/COLOR]", action="scraper", - url="http://alltorrent.net/rezolucia/hdrip/", thumbnail="http://imgur.com/XLqPZoF.png", - fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie")) - itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 3D[/COLOR]", action="scraper", - url="http://alltorrent.net/rezolucia/3d/", thumbnail="http://imgur.com/XLqPZoF.png", - fanart="http://imgur.com/v3ChkZu.jpg", contentType="movie")) - itemlist.append(itemlist[-1].clone(title="[COLOR floralwhite][B]Buscar[/B][/COLOR]", action="search", - thumbnail="http://imgur.com/5EBwccS.png", fanart="http://imgur.com/v3ChkZu.jpg", - contentType="movie", extra="titulo")) - itemlist.append(itemlist[-1].clone(title="[COLOR oldlace] Por Título[/COLOR]", action="search", - thumbnail="http://imgur.com/5EBwccS.png", fanart="http://imgur.com/v3ChkZu.jpg", - contentType="movie", extra="titulo")) - itemlist.append(itemlist[-1].clone(title="[COLOR oldlace] Por Año[/COLOR]", action="search", - thumbnail="http://imgur.com/5EBwccS.png", fanart="http://imgur.com/v3ChkZu.jpg", - contentType="movie", extra="año")) - itemlist.append(itemlist[-1].clone(title="[COLOR oldlace] Por Rating Imdb[/COLOR]", action="search", - thumbnail="http://imgur.com/5EBwccS.png", fanart="http://imgur.com/v3ChkZu.jpg", - contentType="movie", extra="rating")) + + thumb_pelis = get_thumb("channels_movie.png") + thumb_pelis_hd = get_thumb("channels_movie_hd.png") + thumb_series = get_thumb("channels_tvshow.png") + thumb_series_hd = get_thumb("channels_tvshow_hd.png") + thumb_buscar = get_thumb("search.png") + + itemlist.append(item.clone(title="[COLOR springgreen][B]Todas Las Películas[/B][/COLOR]", action="listado", + url=host, thumbnail=thumb_pelis, extra="pelicula")) + itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 1080p[/COLOR]", action="listado", + url=host + "rezolucia/1080p/", thumbnail=thumb_pelis_hd, extra="pelicula")) + itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 720p[/COLOR]", action="listado", + url=host + "rezolucia/720p/", thumbnail=thumb_pelis_hd, extra="pelicula")) + itemlist.append(item.clone(title="[COLOR springgreen] Incluyen Hdrip[/COLOR]", action="listado", + url=host + "rezolucia/hdrip/", thumbnail=thumb_pelis, extra="pelicula")) + itemlist.append(item.clone(title="[COLOR springgreen] Incluyen 3D[/COLOR]", action="listado", + url=host + "rezolucia/3d/", thumbnail=thumb_pelis_hd, extra="pelicula")) + itemlist.append(item.clone(title="[COLOR floralwhite][B]Buscar[/B][/COLOR]", action="search", thumbnail=thumb_buscar, + extra="titulo")) + itemlist.append(item.clone(title="[COLOR oldlace] Por Título[/COLOR]", action="search", thumbnail=thumb_buscar, + extra="titulo")) + itemlist.append(item.clone(title="[COLOR oldlace] Por Año[/COLOR]", action="search", thumbnail=thumb_buscar, + extra="año")) + itemlist.append(item.clone(title="[COLOR oldlace] Por Rating Imdb[/COLOR]", action="search", thumbnail=thumb_buscar, + extra="rating")) + + return itemlist + + +def listado(item): + logger.info() + itemlist = [] + + # Descarga la página + data = '' + try: + data = re.sub(r"\n|\r|\t|\s{2}|()", "", httptools.downloadpage(item.url).data) + except: + pass + + if not data: #Si la web está caída salimos sin dar error + logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + data) + itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) + return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + + patron = '
([^"]+)<\/a>\s?<\/div>
(.*?)<\/div><\/div><\/div>' + #data = scrapertools.find_single_match(data, patron) + matches = re.compile(patron, re.DOTALL).findall(data) + if not matches and not '
') except: - logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + video_section) - itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: LISTADO:. La Web no responde o ha cambiado de URL. Si la Web está activa, reportar el error con el log')) - return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos + pass + cnt_next += 1 if not data: #Si la web está caída salimos sin dar error logger.error("ERROR 01: LISTADO: La Web no responde o ha cambiado de URL: " + item.url + " / DATA: " + video_section) @@ -178,6 +196,11 @@ def listado(item): matches_alt = re.compile(patron, re.DOTALL).findall(video_section) if not matches_alt and not '
0 resultados' in data: #error + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + item, itemlist = generictools.post_tmdb_listado(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + logger.error("ERROR 02: LISTADO: Ha cambiado la estructura de la Web " + " / PATRON: " + patron + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 02: LISTADO: Ha cambiado la estructura de la Web. Reportar el error con el log')) return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos @@ -349,9 +372,13 @@ def findvideos(item): itemlist = [] #Bajamos los datos de la página + data = '' try: data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url).data) except: + pass + + if not data: logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: FINDVIDEOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log')) return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos @@ -361,6 +388,11 @@ def findvideos(item): patron = '\/icono_.*?png" title="(?P.*?)?" [^>]+><\/td>(?P.*?)?.*?(?P.*?)?<\/td>)", "", httptools.downloadpage(item.url).data) data = data.replace('"', "'") except: #Algún error de proceso, salimos + pass + + if not data: logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea" + item.url) itemlist.append(item.clone(action='', title=item.channel.capitalize() + ': ERROR 01: EPISODIOS:. La Web no responde o la URL es erronea. Si la Web está activa, reportar el error con el log')) return itemlist diff --git a/plugin.video.alfa/channels/newpct1.py b/plugin.video.alfa/channels/newpct1.py index d0f6330f..89a6f77e 100644 --- a/plugin.video.alfa/channels/newpct1.py +++ b/plugin.video.alfa/channels/newpct1.py @@ -61,6 +61,11 @@ elif fecha_rango == 3: fecha_rango = 'Mes' elif fecha_rango == 4: fecha_rango = 'Siempre' episodio_serie = config.get_setting('clonenewpct1_serie_episodio_novedades', channel_py) #Episodio o serie para Novedades +#Temporal, sólo para actualizar newpct1_data.json con otro valor por defecto +channel_banned = config.get_setting('clonenewpct1_excluir1_enlaces_veronline', channel_py) #1er Canal baneado +if channel_banned == 9: + config.set_setting('clonenewpct1_excluir1_enlaces_veronline', 22, channel_py) #se pone el nuevo valor por defecto + def mainlist(item): logger.info() @@ -129,6 +134,13 @@ def submenu(item): patron = '
  • <\/i>.*Inicio<\/a><\/li>(.+)<\/ul>\s?<\/nav>' #Verificamos si se ha cargado una página, y si además tiene la estructura correcta if not data or not scrapertools.find_single_match(data, patron): + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + for clone_inter, autoridad in item.intervencion: + thumb_intervenido = get_thumb(autoridad) + itemlist.append(item.clone(action='', title="[COLOR yellow]" + clone_inter.capitalize() + ': [/COLOR]' + intervenido_judicial + '. Reportar el problema en el foro', thumbnail=thumb_intervenido)) + return itemlist #Salimos + logger.error("ERROR 01: SUBMENU: La Web no responde o ha cambiado de URL: " + item.url + data) #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú item, data = generictools.fail_over_newpct1(item, patron) @@ -206,6 +218,13 @@ def submenu_novedades(item): patron = '
    .*?
      (.*?)
    ' #seleccionamos el bloque que nos interesa if not data or (not scrapertools.find_single_match(data, patron) and not '

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

    ( 0 ) Resultados encontrados ' in data): + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + item, itemlist = generictools.post_tmdb_listado(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + logger.error("ERROR 01: LISTADO_BUSQUEDA: La Web no responde o ha cambiado de URL: " + item.url + item.post + " / DATA: " + data) #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el submenú item, data = generictools.fail_over_newpct1(item, pattern) @@ -1231,6 +1268,11 @@ def findvideos(item): patron = 'class="btn-torrent">.*?window.location.href = "(.*?)";' #Patron para .torrent #Verificamos si se ha cargado una página, y si además tiene la estructura correcta if not data or not scrapertools.find_single_match(data, patron): + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + item, itemlist = generictools.post_tmdb_findvideos(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + logger.error("ERROR 01: FINDVIDEOS: La Web no responde o la URL es erronea: " + item.url + " / DATA: " + data) #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el vídeo @@ -1526,6 +1568,11 @@ def episodios(item): #Verificamos si se ha cargado una página, y si además tiene la estructura correcta if not data_alt or not scrapertools.find_single_match(data_alt, pattern): + item = generictools.web_intervenida(item, data) #Verificamos que no haya sido clausurada + if item.intervencion: #Sí ha sido clausurada judicialmente + item, itemlist = generictools.post_tmdb_episodios(item, itemlist) #Llamamos al método para el pintado del error + return itemlist #Salimos + logger.error("ERROR 01: EPISODIOS: La Web no responde o la URL es erronea: " + item.url) logger.error(pattern + data) diff --git a/plugin.video.alfa/channels/videolibrary.py b/plugin.video.alfa/channels/videolibrary.py index 80ffdbe9..0ac027d6 100644 --- a/plugin.video.alfa/channels/videolibrary.py +++ b/plugin.video.alfa/channels/videolibrary.py @@ -9,6 +9,7 @@ from core import videolibrarytools from core.item import Item from platformcode import config, logger from platformcode import platformtools +from lib import generictools def mainlist(item): @@ -31,7 +32,7 @@ def channel_config(item): caption=config.get_localized_string(60598)) -def list_movies(item): +def list_movies(item, silent=False): logger.info() itemlist = [] @@ -39,6 +40,15 @@ def list_movies(item): for f in ficheros: if f.endswith(".nfo"): nfo_path = filetools.join(raiz, f) + + #Sincronizamos las películas vistas desde la videoteca de Kodi con la de Alfa + try: + if config.is_xbmc(): #Si es Kodi, lo hacemos + from platformcode import xbmc_videolibrary + xbmc_videolibrary.mark_content_as_watched_on_alfa(nfo_path) + except: + pass + head_nfo, new_item = videolibrarytools.read_nfo(nfo_path) new_item.nfo = nfo_path @@ -50,6 +60,12 @@ def list_movies(item): # Si se ha eliminado el strm desde la bilbioteca de kodi, no mostrarlo continue + ###### Redirección al canal NewPct1.py si es un clone, o a otro canal y url si ha intervención judicial + try: + new_item, new_item, overwrite = generictools.redirect_clone_newpct1(new_item, head_nfo, new_item, raiz) + except: + pass + # Menu contextual: Marcar como visto/no visto visto = new_item.library_playcounts.get(os.path.splitext(f)[0], 0) new_item.infoLabels["playcount"] = visto @@ -85,7 +101,10 @@ def list_movies(item): # logger.debug("new_item: " + new_item.tostring('\n')) itemlist.append(new_item) - return sorted(itemlist, key=lambda it: it.title.lower()) + if silent == False: + return sorted(itemlist, key=lambda it: it.title.lower()) + else: + return def list_tvshows(item): @@ -98,6 +117,15 @@ def list_tvshows(item): if f == "tvshow.nfo": tvshow_path = filetools.join(raiz, f) # logger.debug(tvshow_path) + + #Sincronizamos los episodios vistos desde la videoteca de Kodi con la de Alfa + try: + if config.is_xbmc(): #Si es Kodi, lo hacemos + from platformcode import xbmc_videolibrary + xbmc_videolibrary.mark_content_as_watched_on_alfa(tvshow_path) + except: + pass + head_nfo, item_tvshow = videolibrarytools.read_nfo(tvshow_path) item_tvshow.title = item_tvshow.contentTitle item_tvshow.path = raiz @@ -292,7 +320,6 @@ def get_episodes(item): def findvideos(item): logger.info() - from lib import generictools # logger.debug("item:\n" + item.tostring('\n')) itemlist = [] @@ -362,7 +389,7 @@ def findvideos(item): platformtools.play_video(item_local) elif index > 0: - filtro_canal = opciones[index].replace(config.get_localized_string(70078), "") + filtro_canal = opciones[index].replace(config.get_localized_string(70078), "").strip() itemlist = [] for nom_canal, json_path in list_canales.items(): @@ -552,7 +579,7 @@ def mark_content_as_watched2(item): # Guardamos los cambios en item.nfo if filetools.write(item.nfo, head_nfo + it.tojson()): item.infoLabels['playcount'] = item.playcount - logger.debug(item.playcount) + #logger.debug(item.playcount) # if item.contentType == 'episodesss': # Actualizar toda la serie @@ -569,7 +596,7 @@ def mark_content_as_watched2(item): def mark_content_as_watched(item): logger.info() - logger.debug("item:\n" + item.tostring('\n')) + #logger.debug("item:\n" + item.tostring('\n')) if filetools.exists(item.nfo): head_nfo, it = videolibrarytools.read_nfo(item.nfo) diff --git a/plugin.video.alfa/lib/generictools.py b/plugin.video.alfa/lib/generictools.py index 0142ea08..8027c314 100644 --- a/plugin.video.alfa/lib/generictools.py +++ b/plugin.video.alfa/lib/generictools.py @@ -27,6 +27,7 @@ channel_py = "newpct1" intervenido_judicial = 'Dominio intervenido por la Autoridad Judicial' intervenido_policia = '