From 3d8998988155d609fac888c702f561e62a2c2a2c Mon Sep 17 00:00:00 2001
From: Kingbox <37674310+lopezvg@users.noreply.github.com>
Date: Tue, 10 Jul 2018 19:26:43 +0200
Subject: [PATCH] =?UTF-8?q?NewPct1:=20implantaci=C3=B3n=20de=20apartado=20?=
=?UTF-8?q?de=20Novedades?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
plugin.video.alfa/channels/newpct1.json | 29 +-
plugin.video.alfa/channels/newpct1.py | 336 +++++++++++++++++++-----
plugin.video.alfa/lib/generictools.py | 167 ++++++++----
3 files changed, 405 insertions(+), 127 deletions(-)
diff --git a/plugin.video.alfa/channels/newpct1.json b/plugin.video.alfa/channels/newpct1.json
index a121e330..8be41cb8 100644
--- a/plugin.video.alfa/channels/newpct1.json
+++ b/plugin.video.alfa/channels/newpct1.json
@@ -53,7 +53,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', ''), ('1', 'torrentlocura', 'http://torrentlocura.com/', 'movie, tvshow, season, episode', ''), ('1', 'tumejortorrent', 'http://tumejortorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'tvsinpagar', 'http://www.tvsinpagar.com/', 'tvshow, season, episode', ''), ('1', 'descargas2020', 'http://descargas2020.com/', 'movie, tvshow, season, episode', ''), ('1', 'mispelisyseries', 'http://mispelisyseries.com/', 'movie', 'search')",
+ "default": "('1', 'torrentrapid', 'http://torrentrapid.com/', 'movie, tvshow, season, episode', 'serie_episodios'), ('1', 'torrentlocura', 'http://torrentlocura.com/', 'movie, tvshow, season, episode', ''), ('1', 'tumejortorrent', 'http://tumejortorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'tvsinpagar', 'http://www.tvsinpagar.com/', '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
},
@@ -560,6 +560,33 @@
"9",
"10"
]
+ },
+ {
+ "id": "clonenewpct1_rango_fechas_novedades",
+ "type": "list",
+ "label": "Rango de fechas para búsquedas en Novedades",
+ "default": 2,
+ "enabled": true,
+ "visible": true,
+ "lvalues": [
+ "Hoy",
+ "Ayer",
+ "Semana",
+ "Mes",
+ "Siempre"
+ ]
+ },
+ {
+ "id": "clonenewpct1_serie_episodio_novedades",
+ "type": "list",
+ "label": "Ver en Novedades las series como episodios sueltos o serie completa",
+ "default": 1,
+ "enabled": true,
+ "visible": true,
+ "lvalues": [
+ "Episodios sueltos",
+ "Serie completa"
+ ]
}
]
}
\ No newline at end of file
diff --git a/plugin.video.alfa/channels/newpct1.py b/plugin.video.alfa/channels/newpct1.py
index f0d577f7..5b36dfd9 100644
--- a/plugin.video.alfa/channels/newpct1.py
+++ b/plugin.video.alfa/channels/newpct1.py
@@ -11,6 +11,7 @@ from channelselector import get_thumb
from core import httptools
from core import scrapertools
from core import servertools
+from core import channeltools
from core.item import Item
from platformcode import config, logger
from core import tmdb
@@ -19,7 +20,12 @@ from lib import generictools
channel_py = 'newpct1'
#Código para permitir usar un único canal para todas las webs clones de NewPct1
-clone_list = config.get_setting('clonenewpct1_channels_list', channel_py) #Carga lista de clones
+#Cargamos en .json del canal para ver las listas de valores en settings
+clone_list = channeltools.get_channel_json(channel_py)
+for settings in clone_list['settings']: #Se recorren todos los settings
+ if settings['id'] == "clonenewpct1_channels_list": #Encontramos en setting
+ clone_list = settings['default'] #Carga lista de clones
+ break
clone_list = ast.literal_eval(clone_list) #la convierte en array
host_index = 0
host_index = config.get_setting('clonenewpct1_channel_default', channel_py) #Clone por defecto
@@ -39,6 +45,13 @@ __modo_grafico__ = config.get_setting('modo_grafico', channel_py)
modo_ultima_temp = config.get_setting('seleccionar_ult_temporadda_activa', channel_py) #Actualización sólo últ. Temporada?
timeout = config.get_setting('clonenewpct1_timeout_downloadpage', channel_py) #Timeout downloadpage
if timeout == 0: timeout = None
+fecha_rango = config.get_setting('clonenewpct1_rango_fechas_novedades', channel_py) #Rango fechas para Novedades
+if fecha_rango == 0: fecha_rango = 'Hoy'
+elif fecha_rango == 1: fecha_rango = 'Ayer'
+elif fecha_rango == 2: fecha_rango = 'Semana'
+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
def mainlist(item):
@@ -60,6 +73,8 @@ def mainlist(item):
thumb_buscar = get_thumb("search.png")
thumb_settings = get_thumb("setting_0.png")
+ itemlist.append(Item(channel=item.channel, action="submenu_novedades", title="Novedades", url=item.channel_host + "ultimas-descargas/", extra="novedades", thumbnail=thumb_pelis, category=item.category, channel_host=item.channel_host))
+
itemlist.append(Item(channel=item.channel, action="submenu", title="Películas", url=item.channel_host,
extra="peliculas", thumbnail=thumb_pelis, category=item.category, channel_host=item.channel_host))
@@ -88,6 +103,7 @@ def settingCanal(item):
def submenu(item):
logger.info()
+
itemlist = []
data = ''
@@ -148,6 +164,82 @@ def submenu(item):
return itemlist
+def submenu_novedades(item):
+ logger.info()
+
+ itemlist = []
+ itemlist_alt = []
+
+ data = ''
+ timeout_search=timeout * 2 #Más tiempo para Novedades, que es una búsqueda
+
+ #Establecer los valores del .json por si se entra directamente desde un favorito
+ item.channel_host = host
+ item.url = host + "ultimas-descargas/"
+ item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').capitalize()
+ item.extra = "novedades"
+
+ try:
+ data = re.sub(r"\n|\r|\t|\s{2,}", "", httptools.downloadpage(item.url, timeout=timeout_search).data)
+ except:
+ pass
+
+ patron = '
' in data):
+ logger.error("ERROR 01: LISTADO_BUSQUEDA: La Web no responde o ha cambiado de URL: " + item_local.url + " / DATA: " + data_serie)
+ #Si no hay datos consistentes, llamamos al método de fail_over para que encuentre un canal que esté activo y pueda gestionar el cambio de episodio por serie
+ item_local, data_serie = generictools.fail_over_newpct1(item_local, pattern)
+
+ if not data_serie: #Si no ha logrado encontrar nada, salimos
+ title_subs += ["ERR"]
+
+ elif item_local.channel_alt: #Si ha habido fail-over, lo comento
+ scrapedurl = scrapedurl.replace(item_local.channel_alt, item_local.category.lower())
+ title_subs += ["ALT"]
+
+ try:
+ pattern = '