diff --git a/plugin.video.alfa/channels/newpct1.json b/plugin.video.alfa/channels/newpct1.json index 5dbb29b9..24a47145 100644 --- a/plugin.video.alfa/channels/newpct1.json +++ b/plugin.video.alfa/channels/newpct1.json @@ -78,12 +78,13 @@ "enabled": true, "visible": true, "lvalues": [ + "Aleatorio", + "Descargas2020", + "Tumejortorrent", + "Torrentrapid", "Torrentlocura", "Tvsinpagar", "Planetatorrent", - "Torrentrapid", - "Tumejortorrent", - "Descargas2020", "Mispelisyseries" ] }, @@ -91,7 +92,7 @@ "id": "clonenewpct1_channels_list", "type": "text", "label": "Lista de clones de NewPct1 y orden de uso", - "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')", + "default": "('1', 'descargas2020', 'http://descargas2020.com/', 'movie, tvshow, season, episode', ''), ('1', 'tumejortorrent', 'http://tumejortorrent.com/', 'movie, tvshow, season, episode', ''), ('1', 'torrentrapid', 'http://torrentrapid.com/', 'movie, tvshow, season, episode', 'serie_episodios'), ('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', '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 9177fb26..1bdba2d3 100644 --- a/plugin.video.alfa/channels/newpct1.py +++ b/plugin.video.alfa/channels/newpct1.py @@ -6,6 +6,7 @@ import urllib import urlparse import datetime import ast +import random from channelselector import get_thumb from core import httptools @@ -31,27 +32,45 @@ channel_py = 'newpct1' #Código para permitir usar un único canal para todas las webs clones de NewPct1 #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 +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 +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 -i = 0 -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 +host_index = config.get_setting('clonenewpct1_channel_default', channel_py) #Clone por defecto + +clone_list_random = [] #Iniciamos la lista aleatoria de clones + +if host_index == 0: #Si el clones es "Aleatorio"... + i = 0 + j = 2 #... marcamos el último de los clones "buenos" + for active_clone, channel_clone, host_clone, contentType_clone, info_clone in clone_list: + if i <= j and active_clone == "1": + clone_list_random += [clone_list[i]] #... añadimos el clone activo "bueno" a la lista + else: break - 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 + i += 1 + if clone_list_random: #Si hay clones en la lista aleatoria... + clone_list = [random.choice(clone_list_random)] #Seleccionamos un clone aleatorio + #logger.debug(clone_list) + host_index = 1 #mutamos el num. de clone para que se procese en el siguiente loop + +if host_index > 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: @@ -139,6 +158,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 +242,11 @@ def submenu_novedades(item): itemlist_alt = [] 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 = '' timeout_search=timeout * 2 #Más tiempo para Novedades, que es una búsqueda thumb_settings = get_thumb("setting_0.png") @@ -315,6 +344,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 +399,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 +1289,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 +1414,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 = ' 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