diff --git a/plugin.video.alfa/channels/allcalidad.py b/plugin.video.alfa/channels/allcalidad.py index 0b629353..6c5930d8 100755 --- a/plugin.video.alfa/channels/allcalidad.py +++ b/plugin.video.alfa/channels/allcalidad.py @@ -34,12 +34,40 @@ def mainlist(item): itemlist.append(Item(channel = item.channel, title = "Novedades", action = "peliculas", url = host, thumbnail = get_thumb("newest", auto = True))) itemlist.append(Item(channel = item.channel, title = "Por género", action = "generos_years", url = host, extra = "Genero", thumbnail = get_thumb("genres", auto = True) )) itemlist.append(Item(channel = item.channel, title = "Por año", action = "generos_years", url = host, extra = ">Año<", thumbnail = get_thumb("year", auto = True))) - itemlist.append(Item(channel = item.channel, title = "Favoritas", action = "peliculas", url = host + "/favorites", thumbnail = get_thumb("favorites", auto = True) )) + itemlist.append(Item(channel = item.channel, title = "Favoritas", action = "favorites", url = host + "/favorites", thumbnail = get_thumb("favorites", auto = True) )) itemlist.append(Item(channel = item.channel, title = "")) itemlist.append(Item(channel = item.channel, title = "Buscar", action = "search", url = host + "?s=", thumbnail = get_thumb("search", auto = True))) autoplay.show_option(item.channel, itemlist) return itemlist +def favorites(item): + logger.info() + itemlist = [] + data = httptools.downloadpage(item.url).data + patron = '(?s)short_overlay.*?0: + itemlist.append(Item(channel = item.channel, + action = "peliculas", + page = item.page + 1, + title = "Página siguiente >>", + url = item.url + )) + return itemlist + + +def newest(categoria): + logger.info() + itemlist = [] + item = Item() + try: + if categoria in ['peliculas','latino']: + item.url = host + "/explorar?page=" + item.page=1 + elif categoria == 'infantiles': + item.url = host + '/genero/animacion-WYXS9?page' + item.page = 1 + elif categoria == 'terror': + item.url = host + 'genero/terror-dVbSb?page=' + item.page = 1 + itemlist = peliculas(item) + if "Pagina" in itemlist[-1].title: + itemlist.pop() + except: + import sys + for line in sys.exc_info(): + logger.error("{0}".format(line)) + return [] + + return itemlist + + +def search(item, texto): + logger.info() + item.url = item.url + texto + item.extra = "busca" + item.page = 1 + item.texto = texto + item.post = {"query":"\n query ($term: String) {\n movies: allMovies(search: $term) {\n id\n slug\n title\n rating\n releaseDate\n released\n poster\n nowPlaying\n }\n }\n ","variables":{"term":"%s" %texto}} + if texto != '': + return peliculas(item) + else: + return [] + + +def generos(item): + logger.info() + itemlist = [] + data = httptools.downloadpage(item.url).data + bloque = scrapertools.find_single_match(data, "Géneros.*?") + patron = 'href="([^"]+)"' + patron += '>([^<]+)' + matches = scrapertools.find_multiple_matches(bloque, patron) + for url, titulo in matches: + itemlist.append(Item(channel = item.channel, + action = "peliculas", + title = titulo, + url = host + url + "?page=", + page = 1 + )) + return itemlist + + +def findvideos(item): + itemlist = [] + data = httptools.downloadpage(item.url).data + bloque = scrapertools.find_single_match(data, ',"mirrors":(.*?\])') + if bloque == "[]": + return [] + dict = jsontools.load(bloque) + urlx = httptools.downloadpage(host + dict[0]["url"]) #Para que pueda saltar el cloudflare, se tiene que descargar la página completa + for datos in dict: + url1 = httptools.downloadpage(host + datos["url"], follow_redirects=False, only_headers=True).headers.get("location", "") + titulo = "Ver en: %s (" + cali[datos["quality"]] + ") (" + idio[datos["audio"]] + ")" + text_color = "white" + if "youtube" in url1: + titulo = "Ver trailer: %s" + text_color = "yellow" + itemlist.append( + item.clone(channel = item.channel, + action = "play", + language = idio[datos["audio"]], + quality = cali[datos["quality"]], + title = titulo, + url = url1 + )) + itemlist = servertools.get_servers_itemlist(itemlist, lambda i: i.title % i.server.capitalize()) + itemlist.sort(key=lambda it: (it.language, it.server)) + tmdb.set_infoLabels(itemlist, __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(channel = item.channel)) + itemlist.append(item.clone(channel="trailertools", title="Buscar Tráiler", action="buscartrailer", context="", + text_color="magenta")) + # Opción "Añadir esta película a la biblioteca de KODI" + 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, thumbnail = item.thumbnail, + contentTitle = item.contentTitle + )) + return itemlist + + +def play(item): + item.thumbnail = item.contentThumbnail + return [item] diff --git a/plugin.video.alfa/core/httptools.py b/plugin.video.alfa/core/httptools.py index 53b71b97..5f2f2355 100755 --- a/plugin.video.alfa/core/httptools.py +++ b/plugin.video.alfa/core/httptools.py @@ -242,8 +242,9 @@ def downloadpage(url, post=None, headers=None, timeout=None, follow_redirects=Tr server_cloudflare = "cloudflare" is_channel = inspect.getmodule(inspect.currentframe().f_back) - # error 4xx o 5xx se lanza excepcion - # response["code"] = 400 + # error 4xx o 5xx se lanza excepcion (menos para servidores) + # response["code"] = 400 # linea de código para probar + is_channel = str(is_channel).replace("/servers/","\\servers\\") # Para sistemas operativos diferente a Windows la ruta cambia if type(response["code"]) == int and "\\servers\\" not in str(is_channel): if response["code"] > 399 and (server_cloudflare == "cloudflare" and response["code"] != 503): raise WebErrorException(urlparse.urlparse(url)[1]) diff --git a/plugin.video.alfa/servers/rapidvideo.py b/plugin.video.alfa/servers/rapidvideo.py index 1b80d819..052bc9d0 100755 --- a/plugin.video.alfa/servers/rapidvideo.py +++ b/plugin.video.alfa/servers/rapidvideo.py @@ -7,22 +7,16 @@ from platformcode import config, logger def test_video_exists(page_url): logger.info("(page_url='%s')" % page_url) - try: - response = httptools.downloadpage(page_url) - except: - pass - + response = httptools.downloadpage(page_url) if response.code == 404: return False, config.get_localized_string(70449) % "RapidVideo" if not response.data or "urlopen error [Errno 1]" in str(response.code): - from platformcode import config if config.is_xbmc(): return False, config.get_localized_string(70302) % "RapidVideo" elif config.get_platform() == "plex": return False, config.get_localized_string(70303) % "RapidVideo" elif config.get_platform() == "mediaserver": return False, config.get_localized_string(70304) % "RapidVideo" - if "Object not found" in response.data: return False, config.get_localized_string(70449) % "RapidVideo" if response.code == 500: