Merge pull request #4 from alfa-addon/master

v2.7.31
This commit is contained in:
Intel1
2019-03-21 08:14:01 -05:00
committed by GitHub
22 changed files with 926 additions and 575 deletions

69
cuevana3.json Normal file
View File

@@ -0,0 +1,69 @@
{
"id": "cuevana3",
"name": "Cuevana 3",
"active": true,
"adult": false,
"language": ["lat", "cast"],
"thumbnail": "https://www.cuevana3.co/wp-content/themes/cuevana3/public/img/cnt/cuevana3.png",
"banner": "",
"version": 1,
"categories": [
"movie"
],
"settings": [
{
"id": "include_in_global_search",
"type": "bool",
"label": "Incluir en busqueda global",
"default": false,
"enabled": false,
"visible": false
},
{
"id": "filter_languages",
"type": "list",
"label": "Mostrar enlaces en idioma...",
"default": 0,
"enabled": true,
"visible": true,
"lvalues": [
"No filtrar",
"LAT",
"CAST",
"VOSE"
]
},
{
"id": "include_in_newest_peliculas",
"type": "bool",
"label": "Incluir en Novedades - Peliculas",
"default": true,
"enabled": true,
"visible": true
},
{
"id": "include_in_newest_infantiles",
"type": "bool",
"label": "Incluir en Novedades - Infantiles",
"default": true,
"enabled": true,
"visible": true
},
{
"id": "include_in_newest_terror",
"type": "bool",
"label": "Incluir en Novedades - Terror",
"default": true,
"enabled": true,
"visible": true
},
{
"id": "include_in_newest_documentales",
"type": "bool",
"label": "Incluir en Novedades - Documentales",
"default": true,
"enabled": true,
"visible": true
}
]
}

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.alfa" name="Alfa" version="2.7.30" provider-name="Alfa Addon">
<addon id="plugin.video.alfa" name="Alfa" version="2.7.31" provider-name="Alfa Addon">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.libtorrent" optional="true"/>
@@ -19,9 +19,14 @@
</assets>
<news>[B]Estos son los cambios para esta versión:[/B]
[COLOR green][B]Arreglos[/B][/COLOR]
¤ newpct1 ¤ inkapelis ¤ mp4upload
¤ maxipelis24 ¤ cuevana3 ¤ pelisplusco
¤ mejortorrent ¤ newpct1
[COLOR green][B]Novedades[/B][/COLOR]
¤ Mundopelis ¤ thevideobee ¤ tusfiles
¤ vup
¤ Agradecimientos a @mac12m99 por colaborar con ésta versión
¤ Agradecimientos a @mac12m99 y @chivmalev por colaborar con ésta versión
</news>
<description lang="es">Navega con Kodi por páginas web para ver sus videos de manera fácil.</description>

View File

@@ -9,6 +9,7 @@ from platformcode import config, logger
from platformcode import platformtools
from platformcode import launcher
from time import sleep
from platformcode.config import get_setting
__channel__ = "autoplay"
@@ -117,7 +118,7 @@ def start(itemlist, item):
# Obtiene los ajustes des autoplay para este canal
settings_node = channel_node.get('settings', {})
if settings_node['active']:
if get_setting('autoplay') or settings_node['active']:
url_list_valid = []
autoplay_list = []
autoplay_b = []
@@ -142,7 +143,7 @@ def start(itemlist, item):
# 2: Solo servidores
# 3: Solo calidades
# 4: No ordenar
if settings_node['custom_servers'] and settings_node['custom_quality']:
if (settings_node['custom_servers'] and settings_node['custom_quality']) or get_setting('autoplay'):
priority = settings_node['priority'] # 0: Servidores y calidades o 1: Calidades y servidores
elif settings_node['custom_servers']:
priority = 2 # Solo servidores
@@ -391,14 +392,15 @@ def init(channel, list_servers, list_quality, reset=False):
# Se comprueba que no haya calidades ni servidores duplicados
if 'default' not in list_quality:
list_quality.append('default')
list_servers = list(set(list_servers))
list_quality = list(set(list_quality))
# list_servers = list(set(list_servers))
# list_quality = list(set(list_quality))
# Creamos el nodo del canal y lo añadimos
channel_node = {"servers": list_servers,
"quality": list_quality,
"settings": {
"active": False,
"plan_b": True,
"custom_servers": False,
"custom_quality": False,
"priority": 0}}
@@ -455,7 +457,7 @@ def check_value(channel, itemlist):
for item in itemlist:
if item.server.lower() not in server_list and item.server !='':
server_list.append(item.server)
server_list.append(item.server.lower())
change = True
if item.quality not in quality_list and item.quality !='':
quality_list.append(item.quality)
@@ -672,7 +674,7 @@ def is_active(channel):
# Obtiene los ajustes des autoplay para este canal
settings_node = channel_node.get('settings', {})
return settings_node.get('active', False)
return settings_node.get('active', False) or get_setting('autoplay')
def reset(item, dict):

View File

@@ -31,23 +31,29 @@ def mainlist(item):
itemlist = list()
itemlist.append(Item(channel=item.channel, title="Ultimas", action="list_all", url=host,
thumbnail=get_thumb('last', auto=True)))
itemlist.append(Item(channel=item.channel, title="Todas", action="list_all", url=host+'peliculas',
thumbnail=get_thumb('all', auto=True)))
itemlist.append(Item(channel=item.channel, title="Estrenos", action="list_all", url=host+'estrenos',
thumbnail=get_thumb('premieres', auto=True)))
itemlist.append(Item(channel=item.channel, title="Mas vistas", action="list_all", url=host+'peliculas-mas-vistas',
thumbnail=get_thumb('more watched', auto=True)))
itemlist.append(Item(channel=item.channel, title="Mas votadas", action="list_all", url=host+'peliculas-mas-valoradas',
thumbnail=get_thumb('more voted', auto=True)))
itemlist.append(Item(channel=item.channel, title="Generos", action="section", section='genre',
thumbnail=get_thumb('genres', auto=True)))
itemlist.append(Item(channel=item.channel, title="Castellano", action="list_all", url= host+'espanol',
thumbnail=get_thumb('audio', auto=True)))
itemlist.append(Item(channel=item.channel, title="Latino", action="list_all", url=host + 'latino',
thumbnail=get_thumb('audio', auto=True)))
itemlist.append(Item(channel=item.channel, title="VOSE", action="list_all", url=host + 'subtitulado',
thumbnail=get_thumb('audio', auto=True)))
itemlist.append(Item(channel=item.channel, title="Alfabetico", action="section", section='alpha',
thumbnail=get_thumb('alphabet', auto=True)))
# itemlist.append(Item(channel=item.channel, title="Castellano", action="list_all", url= host+'espanol',
# thumbnail=get_thumb('audio', auto=True)))
#
# itemlist.append(Item(channel=item.channel, title="Latino", action="list_all", url=host + 'latino',
# thumbnail=get_thumb('audio', auto=True)))
#
# itemlist.append(Item(channel=item.channel, title="VOSE", action="list_all", url=host + 'subtitulado',
# thumbnail=get_thumb('audio', auto=True)))
#
# itemlist.append(Item(channel=item.channel, title="Alfabetico", action="section", section='alpha',
# thumbnail=get_thumb('alphabet', auto=True)))
itemlist.append(Item(channel=item.channel, title="Buscar", action="search", url=host+'?s=',
thumbnail=get_thumb('search', auto=True)))
@@ -69,17 +75,16 @@ def list_all(item):
itemlist = []
try:
data = get_source(item.url)
if item.section == 'alpha':
patron = '<span class="Num">\d+.*?<a href="([^"]+)" class.*?'
patron += 'src="([^"]+)" class.*?<strong>([^<]+)</strong>.*?<td>(\d{4})</td>'
else:
patron = '<article id="post-\d+".*?<a href="([^"]+)">.*?'
patron += 'src="([^"]+)".*?<h2 class="Title">([^<]+)<\/h2>.*?<span class="Year">([^<]+)<\/span>'
# if item.section == 'alpha':
# patron = '<span class="Num">\d+.*?<a href="([^"]+)" class.*?'
# patron += 'src="([^"]+)" class.*?<strong>([^<]+)</strong>.*?<td>(\d{4})</td>'
# else:
patron = '<article class="TPost C post-\d+.*?<a href="([^"]+)">.*?'
patron +='"Year">(\d{4})<.*?src="([^"]+)".*?"Title">([^"]+)</h2>'
data = get_source(item.url)
matches = re.compile(patron, re.DOTALL).findall(data)
for scrapedurl, scrapedthumbnail, scrapedtitle, year in matches:
for scrapedurl, year, scrapedthumbnail, scrapedtitle in matches:
url = scrapedurl
if "|" in scrapedtitle:
@@ -103,7 +108,7 @@ def list_all(item):
# Paginación
url_next_page = scrapertools.find_single_match(data,'<a class="next.*?" rel="next" href="([^"]+)"')
url_next_page = scrapertools.find_single_match(data,'<a href="([^"]+)" class="next page-numbers">')
if url_next_page:
itemlist.append(Item(channel=item.channel, title="Siguiente >>", url=url_next_page, action='list_all',
section=item.section))

View File

@@ -59,9 +59,8 @@ def lista(item):
title = scrapedtitle
thumbnail = scrapedthumbnail
plot = ""
year = ""
itemlist.append( Item(channel=item.channel, action="play", title=title, url=scrapedurl, thumbnail=thumbnail,
plot=plot, contentTitle=contentTitle, infoLabels={'year':year} ))
plot=plot, fanart=scrapedthumbnail, contentTitle=contentTitle ))
next_page = scrapertools.find_single_match(data,'<a class="nextpostslink" rel="next" href="([^"]+)">')
if next_page!="":
next_page = urlparse.urljoin(item.url,next_page)
@@ -71,11 +70,10 @@ def lista(item):
def play(item):
logger.info()
data = scrapertools.cachePage(item.url)
data = httptools.downloadpage(item.url).data
itemlist = servertools.find_video_items(data=data)
for videoitem in itemlist:
videoitem.title = item.title
videoitem.fulltitle = item.fulltitle
videoitem.thumbnail = item.thumbnail
videochannel=item.channel
return itemlist

View File

@@ -55,7 +55,7 @@ def categorias(item):
def lista(item):
logger.info()
itemlist = []
data = scrapertools.cachePage(item.url)
data = httptools.downloadpage(item.url).data
data = re.sub(r"\n|\r|\t|&nbsp;|<br>", "", data)
patron = '<a href="([^"]+)" itemprop="url">.*?'
patron += '<img src="([^"]+)" alt="([^"]+)">.*?'
@@ -64,12 +64,11 @@ def lista(item):
for scrapedurl,scrapedthumbnail,scrapedtitle,duracion in matches:
url = scrapedurl
title = "[COLOR yellow]" + duracion + "[/COLOR] " + scrapedtitle
contentTitle = title
contentTitle = scrapedtitle
thumbnail = scrapedthumbnail
plot = ""
year = ""
itemlist.append( Item(channel=item.channel, action="play", title=title, url=url, thumbnail=thumbnail,
plot=plot, contentTitle = contentTitle, infoLabels={'year':year} ))
plot=plot, fanart=scrapedthumbnail, contentTitle = contentTitle ))
next_page = scrapertools.find_single_match(data,'<li><a data=\'\d+\' href="([^"]+)" title="Next">')
if next_page!="":
next_page = urlparse.urljoin(item.url,next_page)
@@ -80,11 +79,11 @@ def lista(item):
def play(item):
logger.info()
itemlist = []
data = scrapertools.cachePage(item.url)
data = httptools.downloadpage(item.url).data
patron = 'video_url: \'([^\']+)\''
matches = scrapertools.find_multiple_matches(data, patron)
for scrapedurl in matches:
itemlist.append(Item(channel=item.channel, action="play", title=item.title, fulltitle=item.fulltitle, url=scrapedurl,
itemlist.append(Item(channel=item.channel, action="play", title=item.title, url=scrapedurl,
thumbnail=item.thumbnail, plot=item.plot, show=item.title, server="directo", folder=False))
return itemlist

View File

@@ -26,7 +26,7 @@ def mainlist(item):
thumbnail = scrapedthumbnail
plot = ""
itemlist.append( Item(channel=item.channel, action="play", title=title, url=scrapedurl,
thumbnail=thumbnail, plot=plot, contentTitle=contentTitle))
thumbnail=thumbnail, fanart=thumbnail, plot=plot, contentTitle=contentTitle))
next_page_url = scrapertools.find_single_match(data,'<a class="nextpostslink" rel="next" href="([^"]+)">')
if next_page_url!="":
next_page_url = urlparse.urljoin(item.url,next_page_url)
@@ -36,7 +36,7 @@ def mainlist(item):
def play(item):
logger.info()
data = scrapertools.cachePage(item.url)
data = httptools.downloadpage(item.url).data
itemlist = servertools.find_video_items(data=data)
for videoitem in itemlist:
videoitem.title = item.title

View File

@@ -14,10 +14,10 @@ from channelselector import get_thumb
host = "https://maxipelis24.tv"
IDIOMAS = {'Latino': 'Latino', 'Subtitulado': 'VOSE', 'Español': 'CAST'}
IDIOMAS = {'Latino': 'Latino', 'Sub':'VOSE', 'Subtitulado': 'VOSE', 'Español': 'CAST', 'Castellano':'CAST'}
list_language = IDIOMAS.values()
list_quality = []
list_servers = ['rapidvideo', 'vidoza', 'openload', 'streamango']
list_servers = ['rapidvideo', 'vidoza', 'openload', 'streamango', 'okru']
def mainlist(item):
@@ -53,7 +53,6 @@ def category(item):
itemlist = []
data = httptools.downloadpage(item.url).data
data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data)
if item.cat == 'genre':
data = scrapertools.find_single_match(
data, '<h3>Géneros <span class="icon-sort">.*?</ul>')
@@ -106,7 +105,6 @@ def movies(item):
if next_page:
itemlist.append(item.clone(url=next_page, page=0,
title=" Siguiente »"))
return itemlist
@@ -115,16 +113,28 @@ def findvideos(item):
itemlist = []
data = httptools.downloadpage(item.url).data
data = re.sub(r"\n|\r|\t|\s{2}|&nbsp;", "", data)
data1 = scrapertools.find_single_match(
data, '<ul class="idTabs">.*?</ul></div>')
patron = "li>.*?href=.*?>([^\s]+)"
matches1 = re.compile(patron, re.DOTALL).findall(data1)
for lang in matches1:
idioma = lang
patron = '<div id="div.*?<div class="movieplay".*?(?:iframe.*?src|IFRAME SRC)="([^&]+)&'
patron = '<div id="div(\d+)".*?<div class="movieplay".*?(?:iframe.*?src|IFRAME SRC)="([^&]+)&'
matches = re.compile(patron, re.DOTALL).findall(data)
for link in matches:
for ot, link in matches:
data1 = scrapertools.find_single_match(data, '<ul class="idTabs">.*?</ul></div>')
patron = 'li>.*?href="#div%s.*?>.*?([^<|\s]+)' % ot
matches1 = re.compile(patron, re.DOTALL).findall(data1)
for lang in matches1:
if "VIP" in lang:
continue
idioma = lang
if 'ok.ru' in link:
patron = '<div id="div.*?<div class="movieplay".*?(?:iframe.*?src|IFRAME SRC)="([^"]+)"'
matches = re.compile(patron, re.DOTALL).findall(data)
for link in matches:
if not link.startswith("https"):
url = "https:%s" % link
title = '%s'
new_item = Item(channel=item.channel, title=title, url=url,
action='play', language=IDIOMAS[idioma], infoLabels=item.infoLabels)
itemlist.append(new_item)
if 'maxipelis24.tv/hideload/?' in link:
id_letter = scrapertools.find_single_match(link, '?(\w)d')
id_type = '%sd' % id_letter
@@ -138,7 +148,6 @@ def findvideos(item):
follow_redirects=False)
url = video_data.headers['location']
title = '%s'
else:
patron = '<div id="div.*?<div class="movieplay".*?(?:iframe.*?src|IFRAME SRC)="([^"]+)"'
matches = re.compile(patron, re.DOTALL).findall(data)

View File

@@ -18,7 +18,7 @@
"id": "domain_name",
"type": "text",
"label": "URL actual de la Web Mejor Torrent",
"default": "http://www.mejortorrent.org/",
"default": "http://www.mejortorrent.tv/",
"enabled": true,
"visible": true
},

View File

@@ -26,7 +26,8 @@ list_servers = ['torrent']
channel = "mejortorrent"
host = 'http://www.mejortorrent.org/'
host = 'http://www.mejortorrent.tv/'
host_sufix = '.tv'
#host = config.get_setting('domain_name', channel)
categoria = channel.capitalize()
@@ -296,8 +297,8 @@ def listado(item):
item_local.title = scrapertools.get_match(scrapedurl, patron_enlace)
item_local.title = item_local.title.replace("-", " ")
item_local.url = urlparse.urljoin(item_local.url, scrapedurl)
item_local.thumbnail = host + urllib.quote(scrapedthumbnail)
item_local.url = verificar_url(urlparse.urljoin(item_local.url, scrapedurl))
item_local.thumbnail = verificar_url(host + urllib.quote(scrapedthumbnail))
item_local.contentThumbnail = item_local.thumbnail
item_local.infoLabels['year'] = '-' # Al no saber el año, le ponemos "-" y TmDB lo calcula automáticamente
@@ -660,7 +661,7 @@ def listado_busqueda(item):
item_local.quality = scrapertools.remove_htmltags(scrapedinfo).decode('iso-8859-1').encode('utf8')
item_local.quality = item_local.quality.replace("(", "").replace(")", "").replace("[", "").replace("]", "").replace("Documental", "").replace("documental", "")
item_local.url = urlparse.urljoin(item.url, scrapedurl)
item_local.url = verificar_url(urlparse.urljoin(item.url, scrapedurl))
#Preparamos la información básica para TMDB
if "/serie-" in scrapedurl or "/doc-" in scrapedurl:
@@ -829,10 +830,10 @@ def findvideos(item):
for scrapedurl in matches:
#Generamos una copia de Item para trabajar sobre ella
item_local = item.clone()
url = urlparse.urljoin(item.url, scrapedurl)
url = verificar_url(urlparse.urljoin(item.url, scrapedurl))
# Localiza el .torrent en el siguiente link
if not item.post and not item.armagedon: # Si no es llamada con Post, hay que bajar un nivel más
if not item.post and not item.armagedon: # Si no es llamada con Post, hay que bajar un nivel más
try:
torrent_data = re.sub(r"\n|\r|\t|\s{2}|(<!--.*?-->)", "", httptools.downloadpage(url).data)
except: #error
@@ -849,15 +850,15 @@ def findvideos(item):
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
return itemlist #si no hay más datos, algo no funciona, pintamos lo que tenemos
#logger.debug(torrent_data)
if not item.armagedon:
item_local.url = scrapertools.get_match(torrent_data, ">Pincha.*?<a href='(.*?\/uploads\/torrents\/\w+\/.*?\.torrent)'")
item_local.url = urlparse.urljoin(url, item_local.url)
item_local.url = verificar_url(urlparse.urljoin(url, item_local.url))
elif not item.armagedon:
item_local.url = url # Ya teníamos el link desde el primer nivel (documentales)
item_local.url = url # Ya teníamos el link desde el primer nivel (documentales)
item_local.url = item_local.url.replace(" ", "%20")
if item.armagedon and item.emergency_urls and not item.videolibray_emergency_urls:
@@ -867,10 +868,10 @@ def findvideos(item):
del item.emergency_urls[0][0]
if not item.armagedon and item.emergency_urls and not item.videolibray_emergency_urls:
if len(item.emergency_urls[0]):
item_local.torrent_alt = item.emergency_urls[0][0] #Guardamos la primera url del .Torrent ALTERNATIVA
item_local.torrent_alt = item.emergency_urls[0][0] #Guardamos la primera url del .Torrent ALTERNATIVA
if item.videolibray_emergency_urls:
item.emergency_urls[0].append(item_local.url) #Salvamnos la url...
item.emergency_urls[0].verificar_url(append(item_local.url)) #Salvamnos la url...
# Poner la calidad, si es necesario
if not item_local.quality:
@@ -1003,7 +1004,7 @@ def episodios(item):
item_local.title = ''
item_local.context = "['buscar_trailer']"
item_local.url = urlparse.urljoin(host, scrapedurl)
item_local.url = verificar_url(urlparse.urljoin(host, scrapedurl))
scrapedtitle = re.sub('\r\n', '', scrapedtitle).decode('iso-8859-1').encode('utf8').strip()
if scrapedtitle.endswith('.'):
@@ -1030,7 +1031,7 @@ def episodios(item):
else: #Se prepara el Post para documentales
item_local.contentSeason = 1
item_local.contentEpisodeNumber = 1
item_local.url = host + "/secciones.php?sec=descargas&ap=contar_varios"
item_local.url = verificar_url(host + "/secciones.php?sec=descargas&ap=contar_varios")
item_local.post = urllib.urlencode({name: value, "total_capis": total_capis, "tabla": tabla, "titulo": titulo_post})
if year:
@@ -1050,6 +1051,15 @@ def episodios(item):
item, itemlist = generictools.post_tmdb_episodios(item, itemlist)
return itemlist
def verificar_url(url):
if '.com' in url or '.net' in url or '.org' in url:
url = url.replace('.com', '.tv').replace('.net', '.tv').replace('.org', '.tv')
url = url.replace('torrents/tmp/torrent.php?table=peliculas/&name=', 'torrents/peliculas/')
url = url.replace('torrents/tmp/torrent.php?table=series/&name=', 'torrents/series/')
url = url.replace('torrents/tmp/torrent.php?table=documentales/&name=', 'torrents/documentales/')
return url
def actualizar_titulos(item):

View File

@@ -0,0 +1,50 @@
{
"id": "mundopelis",
"name": "mundopelis",
"active": true,
"adult": false,
"language": ["vos"],
"thumbnail": "https://mundopelis.xyz/images/logo.png",
"banner": "",
"categories": [
"movie",
"vos"
],
"settings": [
{
"id": "modo_grafico",
"type": "bool",
"label": "Buscar información extra",
"default": true,
"enabled": true,
"visible": true
},
{
"id": "include_in_global_search",
"type": "bool",
"label": "Incluir en busqueda global",
"default": true,
"enabled": true,
"visible": true
},
{
"id": "comprueba_enlaces",
"type": "bool",
"label": "Verificar si los enlaces existen",
"default": false,
"enabled": true,
"visible": true
},
{
"id": "comprueba_enlaces_num",
"type": "list",
"label": "Número de enlaces a verificar",
"default": 1,
"enabled": true,
"visible": "eq(-1,true)",
"lvalues": [ "5", "10", "15", "20" ]
}
]
}

View File

@@ -0,0 +1,145 @@
# -*- coding: utf-8 -*-
#------------------------------------------------------------
import re, urllib, urlparse
from channels import autoplay
from platformcode import config, logger, platformtools
from core.item import Item
from core import httptools, scrapertools, jsontools, tmdb
from core import servertools
from channels import filtertools
host = 'https://mundopelis.xyz'
list_language = []
list_servers = ['Rapidvideo', 'Vidoza', 'Openload', 'Youtube']
list_quality = []
__channel__='mundopelis'
__comprueba_enlaces__ = config.get_setting('comprueba_enlaces', __channel__)
__comprueba_enlaces_num__ = config.get_setting('comprueba_enlaces_num', __channel__)
try:
__modo_grafico__ = config.get_setting('modo_grafico', __channel__)
except:
__modo_grafico__ = True
def mainlist(item):
logger.info()
itemlist = []
autoplay.init(item.channel, list_servers, list_quality)
itemlist.append(item.clone(title="Novedades" , action="lista", url= host + "/todos-los-estrenos", first=0))
itemlist.append(item.clone(title="Categorias" , action="categorias", url= host))
itemlist.append(item.clone(title="Buscar", action="search"))
itemlist.append(item.clone(title="Configurar canal...", text_color="gold", action="configuracion", folder=False))
autoplay.show_option(item.channel, itemlist)
return itemlist
def configuracion(item):
ret = platformtools.show_channel_settings()
platformtools.itemlist_refresh()
return ret
def search(item, texto):
logger.info()
texto = texto.replace(" ", "+")
item.url = host + "/?option=com_spmoviedb&view=searchresults&searchword=%s&type=movies&Itemid=544" % texto
item.first = 0
try:
return lista(item)
except:
import sys
for line in sys.exc_info():
logger.error("%s" % line)
return []
def categorias(item):
logger.info()
itemlist = []
data = httptools.downloadpage(item.url).data
patron = '<a class="btn btn-xs btn-primary" href="/index.php([^"]+)".*?</i> ([^"]+)</a>'
matches = re.compile(patron,re.DOTALL).findall(data)
for scrapedurl, scrapedtitle in matches:
scrapedplot = ""
scrapedthumbnail = ""
url = urlparse.urljoin(item.url,scrapedurl)
title = scrapedtitle
itemlist.append(item.clone(channel=item.channel, action="lista", title=title , url=url, first=0,
thumbnail=scrapedthumbnail, plot=scrapedplot) )
return itemlist
def lista(item):
logger.info()
itemlist = []
next = False
data = httptools.downloadpage(item.url).data
patron = '<div class="movie-poster">.*?'
patron += '<img src="([^"]+)".*?'
patron += '<a href="/index.php([^"]+)"><h4 class="movie-title">([^<]+)</h4>'
matches = re.compile(patron, re.DOTALL).findall(data)
first = item.first
last = first+20
if last > len(matches):
last = len(matches)
next = True
scrapertools.printMatches(matches)
for scrapedthumbnail, scrapedurl, scrapedtitle in matches[first:last]:
scrapedyear = "-"
title = scrapedtitle.replace(" (2018)", "")
url = urlparse.urljoin(item.url,scrapedurl)
itemlist.append(item.clone(channel=item.channel, action = 'findvideos', title=title, contentTitle = scrapedtitle,
url=url, thumbnail=scrapedthumbnail, infoLabels={'year':scrapedyear} ))
tmdb.set_infoLabels(itemlist, True)
# Paginación
if not next:
url_next_page = item.url
first = last
else:
url_next_page = scrapertools.find_single_match(data, '<a title="Siguiente" href="([^"]+)"')
url_next_page = urlparse.urljoin(item.url,url_next_page)
first = 0
if url_next_page:
itemlist.append(item.clone(title="Siguiente >>", url=url_next_page, action='lista', first=first))
return itemlist
def findvideos(item):
logger.info()
itemlist = []
data = httptools.downloadpage(item.url).data
data = re.sub(r"\n|\r|\t|&nbsp;|<br>", "", data)
patron = '<(?:iframe|IFRAME).*?(?:src|SRC)="([^"]+)"'
matches = scrapertools.find_multiple_matches(data, patron)
for url in matches:
lang = "VOSE"
if not config.get_setting('unify'):
title = ' (%s)' % (lang)
else:
title = ''
if url != '':
itemlist.append(item.clone(action="play", title='%s'+title, url=url, language=lang ))
itemlist = servertools.get_servers_itemlist(itemlist, lambda i: i.title % i.server.capitalize())
# Requerido para Filtrar enlaces
if __comprueba_enlaces__:
itemlist = servertools.check_list_links(itemlist, __comprueba_enlaces_num__)
# Requerido para FilterTools
itemlist = filtertools.get_links(itemlist, item, list_language)
# Requerido para AutoPlay
autoplay.start(itemlist, item)
if config.get_videolibrary_support() and len(itemlist) > 0 and item.extra !='findvideos' and not "/episodios/" in item.url :
itemlist.append(Item(channel=item.channel, action="add_pelicula_to_library",
title='[COLOR yellow]Añadir esta pelicula a la videoteca[/COLOR]', url=item.url,
extra="findvideos", contentTitle=item.contentTitle))
return itemlist

View File

@@ -7,6 +7,7 @@ import urlparse
import datetime
import ast
import random
import traceback
from channelselector import get_thumb
from core import httptools
@@ -700,8 +701,12 @@ def listado(item):
#Guardamos el resto de variables del vídeo
item_local.url = scrapedurl
if not item_local.url.startswith("http"): #Si le falta el http.: lo ponemos
item_local.url = scrapertools.find_single_match(item_local.channel_host, '(\w+:)//') + item_local.url
item_local.thumbnail = scrapedthumbnail
item_local.contentThumbnail = scrapedthumbnail
if not item_local.thumbnail.startswith("http"): #Si le falta el http.: lo ponemos
item_local.thumbnail = scrapertools.find_single_match(item_local.channel_host, '(\w+:)//') + item_local.thumbnail
item_local.contentThumbnail = item_local.thumbnail
#Guardamos el año que puede venir en la url, por si luego no hay resultados desde TMDB
year = ''
@@ -1008,7 +1013,7 @@ def listado_busqueda(item):
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
elif item_local.channel_alt: #Si ha habido fail-over, lo comento
url = url.replace(item_local.channel_alt, item_local.category.lower())
title_subs += ["ALT"]
@@ -1029,8 +1034,10 @@ def listado_busqueda(item):
title_subs += ["Episodio %sx%s" % (scrapertools.find_single_match(url, '\/temp.*?-(\d+)-?\/cap.*?-(\d+(?:-al-\d+)?)-?\/'))]
url = item_local.url
except:
pass
logger.error(traceback.format_exc())
#logger.debug(item_local.url)
if item.extra == "novedades" and "/serie" in url:
if not item_local.url or episodio_serie == 0:
item_local.url = url
@@ -1204,8 +1211,12 @@ def listado_busqueda(item):
#Guardamos el resto de variables del vídeo
item_local.url = url
if not item_local.url.startswith("http"): #Si le falta el http.: lo ponemos
item_local.url = scrapertools.find_single_match(item_local.channel_host, '(\w+:)//') + item_local.url
item_local.thumbnail = scrapedthumbnail
item_local.contentThumbnail = scrapedthumbnail
if not item_local.thumbnail.startswith("http"): #Si le falta el http.: lo ponemos
item_local.thumbnail = scrapertools.find_single_match(item_local.channel_host, '(\w+:)//') + item_local.thumbnail
item_local.contentThumbnail = item_local.thumbnail
#Guardamos el año que puede venir en la url, por si luego no hay resultados desde TMDB
try:
@@ -2019,7 +2030,12 @@ def episodios(item):
item_local = item.clone() #Creamos copia local de Item por episodio
item_local.url = url
item_local.contentThumbnail = thumb
if not item_local.url.startswith("http"): #Si le falta el http.: lo ponemos
item_local.url = scrapertools.find_single_match(item_local.channel_host, '(\w+:)//') + item_local.url
item_local.thumbnail = thumb
if not item_local.thumbnail.startswith("http"): #Si le falta el http.: lo ponemos
item_local.thumbnail = scrapertools.find_single_match(item_local.channel_host, '(\w+:)//') + item_local.thumbnail
item_local.contentThumbnail = item_local.thumbnail
estado = True #Buena calidad de datos por defecto
if "<span" in info: # new style

View File

@@ -324,14 +324,15 @@ def season_episodes(item):
logger.info()
itemlist = []
full_data = httptools.downloadpage(item.url).data
full_data = httptools.downloadpage(item.url+'/').data
full_data = re.sub(r'\n|\r|\t|&nbsp;|<br>|\s{2,}', "", full_data)
season = str(item.infoLabels['season'])
if int(season) <= 9:
season = '0'+season
data = scrapertools.find_single_match(full_data, '</i>Temporada %s</div>(.*?)(?:down arrow|cuadre_comments)' % season)
patron = '<a href="([^"]+)" title=".*?i-play"><\/i> (.*?)<\/a>'
matches = matches = re.compile(patron, re.DOTALL).findall(data)
matches = re.compile(patron, re.DOTALL).findall(data)
infoLabels = item.infoLabels
for url, episode in matches:
episodenumber = re.sub('C.* ','',episode)
@@ -354,7 +355,7 @@ def get_links_by_language(item, data):
video_list = []
language = scrapertools.find_single_match(data, 'ul id="level\d_([^"]+)"\s*class=')
patron = 'data-source="([^"]+)"data-quality="([^"]+)"data-srt="([^"]+)"'
patron = 'data-source="([^"]+)"data-quality="([^"]+)"data-srt="([^"]+)?"'
matches = re.compile(patron, re.DOTALL).findall(data)
if language in IDIOMAS:
language = IDIOMAS[language]
@@ -399,7 +400,6 @@ def findvideos(item):
new_url = base_url.replace('/serie/', '/player/serie/')
new_url += '|%s|%s/' % (item.contentSeason, item.contentEpisodeNumber)
data = get_source(new_url, referer=item.url)
patron_language ='(<ul id="level\d_.*?"*class=.*?ul>)'
matches = re.compile(patron_language, re.DOTALL).findall(data)

View File

@@ -26,7 +26,7 @@ def find_in_text(regex, text, flags=re.IGNORECASE | re.DOTALL):
class UnshortenIt(object):
_adfly_regex = r'adf\.ly|j\.gs|q\.gs|u\.bb|ay\.gy|atominik\.com|tinyium\.com|microify\.com|threadsphere\.bid|clearload\.bid|activetect\.net|swiftviz\.net|briskgram\.net|activetect\.net|baymaleti\.net|thouth\.net'
_adfly_regex = r'adf\.ly|j\.gs|q\.gs|u\.bb|ay\.gy|atominik\.com|tinyium\.com|microify\.com|threadsphere\.bid|clearload\.bid|activetect\.net|swiftviz\.net|briskgram\.net|activetect\.net|baymaleti\.net|thouth\.net|uclaut.net'
_linkbucks_regex = r'linkbucks\.com|any\.gs|cash4links\.co|cash4files\.co|dyo\.gs|filesonthe\.net|goneviral\.com|megaline\.co|miniurls\.co|qqc\.co|seriousdeals\.net|theseblogs\.com|theseforums\.com|tinylinks\.co|tubeviral\.com|ultrafiles\.net|urlbeat\.net|whackyvidz\.com|yyv\.co'
_adfocus_regex = r'adfoc\.us'
_lnxlu_regex = r'lnx\.lu'
@@ -76,7 +76,7 @@ class UnshortenIt(object):
if re.search(self._cryptmango_regex, uri, re.IGNORECASE):
return self._unshorten_cryptmango(uri)
return uri, 200
return uri, 0
def unwrap_30x(self, uri, timeout=10):
def unwrap_30x(uri, timeout=10):
@@ -442,12 +442,15 @@ class UnshortenIt(object):
r = httptools.downloadpage(uri, timeout=self._timeout, cookies=False)
html = r.data
uri = re.findall(r'<a class="push_button blue" href=([^>]+)>', html)[0]
if 'embed' in uri:
uri = re.findall(r'<a class="play-btn" href=([^">]*)>', html)[0]
else:
uri = re.findall(r'<a class="push_button blue" href=([^>]+)>', html)[0]
return uri, r.code
except Exception as e:
return uri, str(e)
return uri, 0
def _unshorten_cryptmango(self, uri):
try:

View File

@@ -1,476 +1,478 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------
# XBMC Launcher (xbmc / kodi)
# ------------------------------------------------------------
import os
import sys
import urllib2
import time
from core import channeltools
from core import scrapertools
from core import servertools
from core import videolibrarytools
from core import trakt_tools
from core.item import Item
from platformcode import config, logger
from platformcode import platformtools
from platformcode.logger import WebErrorException
def start():
""" Primera funcion que se ejecuta al entrar en el plugin.
Dentro de esta funcion deberian ir todas las llamadas a las
funciones que deseamos que se ejecuten nada mas abrir el plugin.
"""
logger.info()
#config.set_setting('show_once', True)
# Test if all the required directories are created
config.verify_directories_created()
def run(item=None):
logger.info()
if not item:
# Extract item from sys.argv
if sys.argv[2]:
item = Item().fromurl(sys.argv[2])
# If no item, this is mainlist
else:
if config.get_setting("start_page"):
if not config.get_setting("custom_start"):
category = config.get_setting("category").lower()
item = Item(channel="news", action="novedades", extra=category, mode = 'silent')
else:
from channels import side_menu
item= Item()
item = side_menu.check_user_home(item)
item.start = True;
else:
item = Item(channel="channelselector", action="getmainlist", viewmode="movie")
if not config.get_setting('show_once'):
from platformcode import xbmc_videolibrary
xbmc_videolibrary.ask_set_content(1)
config.set_setting('show_once', True)
logger.info(item.tostring())
try:
# If item has no action, stops here
if item.action == "":
logger.info("Item sin accion")
return
# Action for main menu in channelselector
elif item.action == "getmainlist":
import channelselector
itemlist = channelselector.getmainlist()
platformtools.render_items(itemlist, item)
# Action for channel types on channelselector: movies, series, etc.
elif item.action == "getchanneltypes":
import channelselector
itemlist = channelselector.getchanneltypes()
platformtools.render_items(itemlist, item)
# Action for channel listing on channelselector
elif item.action == "filterchannels":
import channelselector
itemlist = channelselector.filterchannels(item.channel_type)
platformtools.render_items(itemlist, item)
# Special action for playing a video from the library
elif item.action == "play_from_library":
play_from_library(item)
return
elif item.action == "keymap":
from platformcode import keymaptools
if item.open:
return keymaptools.open_shortcut_menu()
else:
return keymaptools.set_key()
elif item.action == "script":
from core import tmdb
if tmdb.drop_bd():
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60011), time=2000, sound=False)
# Action in certain channel specified in "action" and "channel" parameters
else:
# Entry point for a channel is the "mainlist" action, so here we check parental control
if item.action == "mainlist":
# Parental control
# If it is an adult channel, and user has configured pin, asks for it
if channeltools.is_adult(item.channel) and config.get_setting("adult_request_password"):
tecleado = platformtools.dialog_input("", config.get_localized_string(60334), True)
if tecleado is None or tecleado != config.get_setting("adult_password"):
return
# # Actualiza el canal individual
# if (item.action == "mainlist" and item.channel != "channelselector" and
# config.get_setting("check_for_channel_updates") == True):
# from core import updater
# updater.update_channel(item.channel)
# Checks if channel exists
channel_file = os.path.join(config.get_runtime_path(),
'channels', item.channel + ".py")
logger.info("channel_file=%s" % channel_file)
channel = None
if os.path.exists(channel_file):
try:
channel = __import__('channels.%s' % item.channel, None,
None, ["channels.%s" % item.channel])
except ImportError:
exec "import channels." + item.channel + " as channel"
logger.info("Running channel %s | %s" % (channel.__name__, channel.__file__))
# Special play action
if item.action == "play":
#define la info para trakt
try:
trakt_tools.set_trakt_info(item)
except:
pass
logger.info("item.action=%s" % item.action.upper())
# logger.debug("item_toPlay: " + "\n" + item.tostring('\n'))
# First checks if channel has a "play" function
if hasattr(channel, 'play'):
logger.info("Executing channel 'play' method")
itemlist = channel.play(item)
b_favourite = item.isFavourite
# Play should return a list of playable URLS
if len(itemlist) > 0 and isinstance(itemlist[0], Item):
item = itemlist[0]
if b_favourite:
item.isFavourite = True
platformtools.play_video(item)
# Permitir varias calidades desde play en el canal
elif len(itemlist) > 0 and isinstance(itemlist[0], list):
item.video_urls = itemlist
platformtools.play_video(item)
# If not, shows user an error message
else:
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(60339))
# If player don't have a "play" function, not uses the standard play from platformtools
else:
logger.info("Executing core 'play' method")
platformtools.play_video(item)
# Special action for findvideos, where the plugin looks for known urls
elif item.action == "findvideos":
# First checks if channel has a "findvideos" function
if hasattr(channel, 'findvideos'):
itemlist = getattr(channel, item.action)(item)
itemlist = servertools.filter_servers(itemlist)
# If not, uses the generic findvideos function
else:
logger.info("No channel 'findvideos' method, "
"executing core method")
itemlist = servertools.find_video_items(item)
if config.get_setting("max_links", "videolibrary") != 0:
itemlist = limit_itemlist(itemlist)
from platformcode import subtitletools
subtitletools.saveSubtitleName(item)
platformtools.render_items(itemlist, item)
# Special action for adding a movie to the library
elif item.action == "add_pelicula_to_library":
videolibrarytools.add_movie(item)
# Special action for adding a serie to the library
elif item.action == "add_serie_to_library":
videolibrarytools.add_tvshow(item, channel)
# Special action for downloading all episodes from a serie
elif item.action == "download_all_episodes":
from channels import downloads
item.action = item.extra
del item.extra
downloads.save_download(item)
# Special action for searching, first asks for the words then call the "search" function
elif item.action == "search":
logger.info("item.action=%s" % item.action.upper())
last_search = ""
last_search_active = config.get_setting("last_search", "search")
if last_search_active:
try:
current_saved_searches_list = list(config.get_setting("saved_searches_list", "search"))
last_search = current_saved_searches_list[0]
except:
pass
tecleado = platformtools.dialog_input(last_search)
if tecleado is not None:
if last_search_active and not tecleado.startswith("http"):
from channels import search
search.save_search(tecleado)
itemlist = channel.search(item, tecleado)
else:
return
platformtools.render_items(itemlist, item)
# For all other actions
else:
logger.info("Executing channel '%s' method" % item.action)
itemlist = getattr(channel, item.action)(item)
if config.get_setting('trakt_sync'):
token_auth = config.get_setting("token_trakt", "trakt")
if not token_auth:
trakt_tools.auth_trakt()
else:
import xbmc
if not xbmc.getCondVisibility('System.HasAddon(script.trakt)') and config.get_setting(
'install_trakt'):
trakt_tools.ask_install_script()
itemlist = trakt_tools.trakt_check(itemlist)
else:
config.set_setting('install_trakt', True)
platformtools.render_items(itemlist, item)
except urllib2.URLError, e:
import traceback
logger.error(traceback.format_exc())
# Grab inner and third party errors
if hasattr(e, 'reason'):
logger.error("Razon del error, codigo: %s | Razon: %s" % (str(e.reason[0]), str(e.reason[1])))
texto = config.get_localized_string(30050) # "No se puede conectar con el sitio web"
platformtools.dialog_ok("alfa", texto)
# Grab server response errors
elif hasattr(e, 'code'):
logger.error("Codigo de error HTTP : %d" % e.code)
# "El sitio web no funciona correctamente (error http %d)"
platformtools.dialog_ok("alfa", config.get_localized_string(30051) % e.code)
except WebErrorException, e:
import traceback
logger.error(traceback.format_exc())
patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\",
"\\\\") + '([^.]+)\.py"'
canal = scrapertools.find_single_match(traceback.format_exc(), patron)
platformtools.dialog_ok(
config.get_localized_string(59985) + canal,
config.get_localized_string(60013) %(e))
except:
import traceback
logger.error(traceback.format_exc())
patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\",
"\\\\") + '([^.]+)\.py"'
canal = scrapertools.find_single_match(traceback.format_exc(), patron)
try:
import xbmc
if config.get_platform(True)['num_version'] < 14:
log_name = "xbmc.log"
else:
log_name = "kodi.log"
log_message = config.get_localized_string(50004) + xbmc.translatePath("special://logpath") + log_name
except:
log_message = ""
if canal:
platformtools.dialog_ok(
config.get_localized_string(60087) %canal,
config.get_localized_string(60014),
log_message)
else:
platformtools.dialog_ok(
config.get_localized_string(60038),
config.get_localized_string(60015),
log_message)
def reorder_itemlist(itemlist):
logger.info()
# logger.debug("Inlet itemlist size: %i" % len(itemlist))
new_list = []
mod_list = []
not_mod_list = []
modified = 0
not_modified = 0
to_change = [[config.get_localized_string(60335), '[V]'],
[config.get_localized_string(60336), '[D]']]
for item in itemlist:
old_title = unicode(item.title, "utf8").lower().encode("utf8")
for before, after in to_change:
if before in item.title:
item.title = item.title.replace(before, after)
break
new_title = unicode(item.title, "utf8").lower().encode("utf8")
if old_title != new_title:
mod_list.append(item)
modified += 1
else:
not_mod_list.append(item)
not_modified += 1
# logger.debug("OLD: %s | NEW: %s" % (old_title, new_title))
new_list.extend(mod_list)
new_list.extend(not_mod_list)
logger.info("Titulos modificados:%i | No modificados:%i" % (modified, not_modified))
if len(new_list) == 0:
new_list = itemlist
# logger.debug("Outlet itemlist size: %i" % len(new_list))
return new_list
def limit_itemlist(itemlist):
logger.info()
# logger.debug("Inlet itemlist size: %i" % len(itemlist))
try:
opt = config.get_setting("max_links", "videolibrary")
if opt == 0:
new_list = itemlist
else:
i_max = 30 * opt
new_list = itemlist[:i_max]
# logger.debug("Outlet itemlist size: %i" % len(new_list))
return new_list
except:
return itemlist
def play_from_library(item):
"""
Los .strm al reproducirlos desde kodi, este espera que sea un archivo "reproducible" asi que no puede contener
más items, como mucho se puede colocar un dialogo de seleccion.
Esto lo solucionamos "engañando a kodi" y haciendole creer que se ha reproducido algo, asi despues mediante
"Container.Update()" cargamos el strm como si un item desde dentro del addon se tratara, quitando todas
las limitaciones y permitiendo reproducir mediante la funcion general sin tener que crear nuevos métodos para
la videoteca.
@type item: item
@param item: elemento con información
"""
logger.info()
#logger.debug("item: \n" + item.tostring('\n'))
import xbmcgui
import xbmcplugin
import xbmc
# Intentamos reproducir una imagen (esto no hace nada y ademas no da error)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True,
xbmcgui.ListItem(
path=os.path.join(config.get_runtime_path(), "resources", "subtitle.mp4")))
# Por si acaso la imagen hiciera (en futuras versiones) le damos a stop para detener la reproduccion
xbmc.Player().stop()
# modificamos el action (actualmente la videoteca necesita "findvideos" ya que es donde se buscan las fuentes
item.action = "findvideos"
window_type = config.get_setting("window_type", "videolibrary")
# y volvemos a lanzar kodi
if xbmc.getCondVisibility('Window.IsMedia') and not window_type == 1:
# Ventana convencional
xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ")")
else:
# Ventana emergente
from channels import videolibrary
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(70004))
p_dialog.update(0, '')
itemlist = videolibrary.findvideos(item)
while platformtools.is_playing():
# Ventana convencional
from time import sleep
sleep(5)
p_dialog.update(50, '')
'''# Se filtran los enlaces segun la lista negra
if config.get_setting('filter_servers', "servers"):
itemlist = servertools.filter_servers(itemlist)'''
# Se limita la cantidad de enlaces a mostrar
if config.get_setting("max_links", "videolibrary") != 0:
itemlist = limit_itemlist(itemlist)
# Se "limpia" ligeramente la lista de enlaces
if config.get_setting("replace_VD", "videolibrary") == 1:
itemlist = reorder_itemlist(itemlist)
import time
p_dialog.update(100, '')
time.sleep(0.5)
p_dialog.close()
if len(itemlist) > 0:
while not xbmc.Monitor().abortRequested():
# El usuario elige el mirror
opciones = []
for item in itemlist:
opciones.append(item.title)
# Se abre la ventana de seleccion
if (item.contentSerieName != "" and
item.contentSeason != "" and
item.contentEpisodeNumber != ""):
cabecera = ("%s - %sx%s -- %s" %
(item.contentSerieName,
item.contentSeason,
item.contentEpisodeNumber,
config.get_localized_string(30163)))
else:
cabecera = config.get_localized_string(30163)
seleccion = platformtools.dialog_select(cabecera, opciones)
if seleccion == -1:
return
else:
item = videolibrary.play(itemlist[seleccion])[0]
platformtools.play_video(item)
from channels import autoplay
if (platformtools.is_playing() and item.action) or item.server == 'torrent' or autoplay.is_active(item.contentChannel):
break
# -*- coding: utf-8 -*-
# ------------------------------------------------------------
# XBMC Launcher (xbmc / kodi)
# ------------------------------------------------------------
import os
import sys
import urllib2
import time
from core import channeltools
from core import scrapertools
from core import servertools
from core import videolibrarytools
from core import trakt_tools
from core.item import Item
from platformcode import config, logger
from platformcode import platformtools
from platformcode.logger import WebErrorException
def start():
""" Primera funcion que se ejecuta al entrar en el plugin.
Dentro de esta funcion deberian ir todas las llamadas a las
funciones que deseamos que se ejecuten nada mas abrir el plugin.
"""
logger.info()
#config.set_setting('show_once', True)
# Test if all the required directories are created
config.verify_directories_created()
def run(item=None):
logger.info()
if not item:
# Extract item from sys.argv
if sys.argv[2]:
item = Item().fromurl(sys.argv[2])
# If no item, this is mainlist
else:
if config.get_setting("start_page"):
if not config.get_setting("custom_start"):
category = config.get_setting("category").lower()
item = Item(channel="news", action="novedades", extra=category, mode = 'silent')
else:
from channels import side_menu
item= Item()
item = side_menu.check_user_home(item)
item.start = True;
else:
item = Item(channel="channelselector", action="getmainlist", viewmode="movie")
if not config.get_setting('show_once'):
from platformcode import xbmc_videolibrary
xbmc_videolibrary.ask_set_content(1)
config.set_setting('show_once', True)
logger.info(item.tostring())
try:
# If item has no action, stops here
if item.action == "":
logger.info("Item sin accion")
return
# Action for main menu in channelselector
elif item.action == "getmainlist":
import channelselector
itemlist = channelselector.getmainlist()
platformtools.render_items(itemlist, item)
# Action for channel types on channelselector: movies, series, etc.
elif item.action == "getchanneltypes":
import channelselector
itemlist = channelselector.getchanneltypes()
platformtools.render_items(itemlist, item)
# Action for channel listing on channelselector
elif item.action == "filterchannels":
import channelselector
itemlist = channelselector.filterchannels(item.channel_type)
platformtools.render_items(itemlist, item)
# Special action for playing a video from the library
elif item.action == "play_from_library":
play_from_library(item)
return
elif item.action == "keymap":
from platformcode import keymaptools
if item.open:
return keymaptools.open_shortcut_menu()
else:
return keymaptools.set_key()
elif item.action == "script":
from core import tmdb
if tmdb.drop_bd():
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60011), time=2000, sound=False)
# Action in certain channel specified in "action" and "channel" parameters
else:
# Entry point for a channel is the "mainlist" action, so here we check parental control
if item.action == "mainlist":
# Parental control
# If it is an adult channel, and user has configured pin, asks for it
if channeltools.is_adult(item.channel) and config.get_setting("adult_request_password"):
tecleado = platformtools.dialog_input("", config.get_localized_string(60334), True)
if tecleado is None or tecleado != config.get_setting("adult_password"):
return
# # Actualiza el canal individual
# if (item.action == "mainlist" and item.channel != "channelselector" and
# config.get_setting("check_for_channel_updates") == True):
# from core import updater
# updater.update_channel(item.channel)
# Checks if channel exists
channel_file = os.path.join(config.get_runtime_path(),
'channels', item.channel + ".py")
logger.info("channel_file=%s" % channel_file)
channel = None
if os.path.exists(channel_file):
try:
channel = __import__('channels.%s' % item.channel, None,
None, ["channels.%s" % item.channel])
except ImportError:
exec "import channels." + item.channel + " as channel"
logger.info("Running channel %s | %s" % (channel.__name__, channel.__file__))
# Special play action
if item.action == "play":
#define la info para trakt
try:
trakt_tools.set_trakt_info(item)
except:
pass
logger.info("item.action=%s" % item.action.upper())
# logger.debug("item_toPlay: " + "\n" + item.tostring('\n'))
# First checks if channel has a "play" function
if hasattr(channel, 'play'):
logger.info("Executing channel 'play' method")
itemlist = channel.play(item)
b_favourite = item.isFavourite
# Play should return a list of playable URLS
if len(itemlist) > 0 and isinstance(itemlist[0], Item):
item = itemlist[0]
if b_favourite:
item.isFavourite = True
platformtools.play_video(item)
# Permitir varias calidades desde play en el canal
elif len(itemlist) > 0 and isinstance(itemlist[0], list):
item.video_urls = itemlist
platformtools.play_video(item)
# If not, shows user an error message
else:
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(60339))
# If player don't have a "play" function, not uses the standard play from platformtools
else:
logger.info("Executing core 'play' method")
platformtools.play_video(item)
# Special action for findvideos, where the plugin looks for known urls
elif item.action == "findvideos":
# First checks if channel has a "findvideos" function
if hasattr(channel, 'findvideos'):
itemlist = getattr(channel, item.action)(item)
itemlist = servertools.filter_servers(itemlist)
# If not, uses the generic findvideos function
else:
logger.info("No channel 'findvideos' method, "
"executing core method")
itemlist = servertools.find_video_items(item)
if config.get_setting("max_links", "videolibrary") != 0:
itemlist = limit_itemlist(itemlist)
from platformcode import subtitletools
subtitletools.saveSubtitleName(item)
platformtools.render_items(itemlist, item)
# Special action for adding a movie to the library
elif item.action == "add_pelicula_to_library":
videolibrarytools.add_movie(item)
# Special action for adding a serie to the library
elif item.action == "add_serie_to_library":
videolibrarytools.add_tvshow(item, channel)
# Special action for downloading all episodes from a serie
elif item.action == "download_all_episodes":
from channels import downloads
item.action = item.extra
del item.extra
downloads.save_download(item)
# Special action for searching, first asks for the words then call the "search" function
elif item.action == "search":
logger.info("item.action=%s" % item.action.upper())
last_search = ""
last_search_active = config.get_setting("last_search", "search")
if last_search_active:
try:
current_saved_searches_list = list(config.get_setting("saved_searches_list", "search"))
last_search = current_saved_searches_list[0]
except:
pass
tecleado = platformtools.dialog_input(last_search)
if tecleado is not None:
if last_search_active and not tecleado.startswith("http"):
from channels import search
search.save_search(tecleado)
itemlist = channel.search(item, tecleado)
else:
return
platformtools.render_items(itemlist, item)
# For all other actions
else:
logger.info("Executing channel '%s' method" % item.action)
itemlist = getattr(channel, item.action)(item)
if config.get_setting('trakt_sync'):
token_auth = config.get_setting("token_trakt", "trakt")
if not token_auth:
trakt_tools.auth_trakt()
else:
import xbmc
if not xbmc.getCondVisibility('System.HasAddon(script.trakt)') and config.get_setting(
'install_trakt'):
trakt_tools.ask_install_script()
itemlist = trakt_tools.trakt_check(itemlist)
else:
config.set_setting('install_trakt', True)
platformtools.render_items(itemlist, item)
except urllib2.URLError, e:
import traceback
logger.error(traceback.format_exc())
# Grab inner and third party errors
if hasattr(e, 'reason'):
logger.error("Razon del error, codigo: %s | Razon: %s" % (str(e.reason[0]), str(e.reason[1])))
texto = config.get_localized_string(30050) # "No se puede conectar con el sitio web"
platformtools.dialog_ok("alfa", texto)
# Grab server response errors
elif hasattr(e, 'code'):
logger.error("Codigo de error HTTP : %d" % e.code)
# "El sitio web no funciona correctamente (error http %d)"
platformtools.dialog_ok("alfa", config.get_localized_string(30051) % e.code)
except WebErrorException, e:
import traceback
logger.error(traceback.format_exc())
patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\",
"\\\\") + '([^.]+)\.py"'
canal = scrapertools.find_single_match(traceback.format_exc(), patron)
platformtools.dialog_ok(
config.get_localized_string(59985) + canal,
config.get_localized_string(60013) %(e))
except:
import traceback
logger.error(traceback.format_exc())
patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\",
"\\\\") + '([^.]+)\.py"'
canal = scrapertools.find_single_match(traceback.format_exc(), patron)
try:
import xbmc
if config.get_platform(True)['num_version'] < 14:
log_name = "xbmc.log"
else:
log_name = "kodi.log"
log_message = config.get_localized_string(50004) + xbmc.translatePath("special://logpath") + log_name
except:
log_message = ""
if canal:
platformtools.dialog_ok(
config.get_localized_string(60087) %canal,
config.get_localized_string(60014),
log_message)
else:
platformtools.dialog_ok(
config.get_localized_string(60038),
config.get_localized_string(60015),
log_message)
def reorder_itemlist(itemlist):
logger.info()
# logger.debug("Inlet itemlist size: %i" % len(itemlist))
new_list = []
mod_list = []
not_mod_list = []
modified = 0
not_modified = 0
to_change = [[config.get_localized_string(60335), '[V]'],
[config.get_localized_string(60336), '[D]']]
for item in itemlist:
old_title = unicode(item.title, "utf8").lower().encode("utf8")
for before, after in to_change:
if before in item.title:
item.title = item.title.replace(before, after)
break
new_title = unicode(item.title, "utf8").lower().encode("utf8")
if old_title != new_title:
mod_list.append(item)
modified += 1
else:
not_mod_list.append(item)
not_modified += 1
# logger.debug("OLD: %s | NEW: %s" % (old_title, new_title))
new_list.extend(mod_list)
new_list.extend(not_mod_list)
logger.info("Titulos modificados:%i | No modificados:%i" % (modified, not_modified))
if len(new_list) == 0:
new_list = itemlist
# logger.debug("Outlet itemlist size: %i" % len(new_list))
return new_list
def limit_itemlist(itemlist):
logger.info()
# logger.debug("Inlet itemlist size: %i" % len(itemlist))
try:
opt = config.get_setting("max_links", "videolibrary")
if opt == 0:
new_list = itemlist
else:
i_max = 30 * opt
new_list = itemlist[:i_max]
# logger.debug("Outlet itemlist size: %i" % len(new_list))
return new_list
except:
return itemlist
def play_from_library(item):
"""
Los .strm al reproducirlos desde kodi, este espera que sea un archivo "reproducible" asi que no puede contener
más items, como mucho se puede colocar un dialogo de seleccion.
Esto lo solucionamos "engañando a kodi" y haciendole creer que se ha reproducido algo, asi despues mediante
"Container.Update()" cargamos el strm como si un item desde dentro del addon se tratara, quitando todas
las limitaciones y permitiendo reproducir mediante la funcion general sin tener que crear nuevos métodos para
la videoteca.
@type item: item
@param item: elemento con información
"""
logger.info()
#logger.debug("item: \n" + item.tostring('\n'))
import xbmcgui
import xbmcplugin
import xbmc
from time import sleep
# Intentamos reproducir una imagen (esto no hace nada y ademas no da error)
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True,
xbmcgui.ListItem(
path=os.path.join(config.get_runtime_path(), "resources", "subtitle.mp4")))
# Por si acaso la imagen hiciera (en futuras versiones) le damos a stop para detener la reproduccion
sleep(0.5) ### Si no se pone esto se bloquea Kodi
xbmc.Player().stop()
# modificamos el action (actualmente la videoteca necesita "findvideos" ya que es donde se buscan las fuentes
item.action = "findvideos"
window_type = config.get_setting("window_type", "videolibrary")
# y volvemos a lanzar kodi
if xbmc.getCondVisibility('Window.IsMedia') and not window_type == 1:
# Ventana convencional
xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ")")
else:
# Ventana emergente
from channels import videolibrary
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(70004))
p_dialog.update(0, '')
itemlist = videolibrary.findvideos(item)
while platformtools.is_playing():
# Ventana convencional
sleep(5)
p_dialog.update(50, '')
'''# Se filtran los enlaces segun la lista negra
if config.get_setting('filter_servers', "servers"):
itemlist = servertools.filter_servers(itemlist)'''
# Se limita la cantidad de enlaces a mostrar
if config.get_setting("max_links", "videolibrary") != 0:
itemlist = limit_itemlist(itemlist)
# Se "limpia" ligeramente la lista de enlaces
if config.get_setting("replace_VD", "videolibrary") == 1:
itemlist = reorder_itemlist(itemlist)
import time
p_dialog.update(100, '')
time.sleep(0.5)
p_dialog.close()
if len(itemlist) > 0:
while not xbmc.Monitor().abortRequested():
# El usuario elige el mirror
opciones = []
for item in itemlist:
opciones.append(item.title)
# Se abre la ventana de seleccion
if (item.contentSerieName != "" and
item.contentSeason != "" and
item.contentEpisodeNumber != ""):
cabecera = ("%s - %sx%s -- %s" %
(item.contentSerieName,
item.contentSeason,
item.contentEpisodeNumber,
config.get_localized_string(30163)))
else:
cabecera = config.get_localized_string(30163)
seleccion = platformtools.dialog_select(cabecera, opciones)
if seleccion == -1:
return
else:
item = videolibrary.play(itemlist[seleccion])[0]
platformtools.play_video(item)
from channels import autoplay
if (platformtools.is_playing() and item.action) or item.server == 'torrent' or autoplay.is_active(item.contentChannel):
break

View File

@@ -19,7 +19,7 @@ import xbmcplugin
from channelselector import get_thumb
from platformcode import unify
from core import channeltools
from core import trakt_tools
from core import trakt_tools, scrapertoolsV2
from core.item import Item
from platformcode import logger
@@ -739,15 +739,53 @@ def get_seleccion(default_action, opciones, seleccion, video_urls):
seleccion = dialog_select(config.get_localized_string(30163), opciones)
# Ver en calidad baja
elif default_action == 1:
seleccion = 0
resolutions = []
for url in video_urls:
res = calcResolution(url[0])
if res:
resolutions.append(res)
if resolutions:
seleccion = resolutions.index(min(resolutions))
else:
seleccion = 0
# Ver en alta calidad
elif default_action == 2:
seleccion = len(video_urls) - 1
resolutions = []
for url in video_urls:
res = calcResolution(url[0])
if res:
resolutions.append(res)
if resolutions:
seleccion = resolutions.index(max(resolutions))
else:
seleccion = len(video_urls) - 1
else:
seleccion = 0
return seleccion
def calcResolution(option):
match = scrapertoolsV2.find_single_match(option, '([0-9]{2,4})x([0-9]{2,4})')
resolution = False
if match:
resolution = int(match[0])*int(match[1])
else:
if '240p' in option:
resolution = 320 * 240
elif '360p' in option:
resolution = 480 * 360
elif ('480p' in option) or ('480i' in option):
resolution = 720 * 480
elif ('576p' in option) or ('576p' in option):
resolution = 720 * 576
elif ('720p' in option) or ('HD' in option):
resolution = 1280 * 720
elif ('1080p' in option) or ('1080i' in option) or ('Full HD' in option):
resolution = 1920 * 1080
return resolution
def show_channel_settings(**kwargs):
"""
Muestra un cuadro de configuracion personalizado para cada canal y guarda los datos al cerrarlo.

View File

@@ -4931,3 +4931,6 @@ msgctxt "#70561"
msgid "Search Similar
msgstr ""
msgctxt "#70562"
msgid "autoplay"
msgstr "Enable autoplay in all channels"

View File

@@ -4920,3 +4920,6 @@ msgid "Search Similar
msgstr "Cerca Simili"
msgctxt "#70562"
msgid "autoplay"
msgstr "Abilita autoplay in tutti i canali"

View File

@@ -4931,7 +4931,9 @@ msgctxt "#70561"
msgid "Search Similar"
msgstr "Buscar Similares"
msgctxt "#70562"
msgid "autoplay"
msgstr "Habilitar reproducción automática en todos los canales"

View File

@@ -3,6 +3,7 @@
<category label="70168">
<setting id="player_mode" type="enum" values="Direct|SetResolvedUrl|Built-In|Download and Play" label="30044" default="0"/>
<setting id="default_action" type="enum" lvalues="30006|30007|30008" label="30005" default="0"/>
<setting id="autoplay" type="bool" label="70562" default="false" visible="true"/>
<setting id="thumbnail_type" type="enum" lvalues="30011|30012|30200" label="30010" default="2"/>
<setting id="channel_language" type="labelenum" values="all|cast|lat" label="30019" default="all"/>
<setting id="trakt_sync" type="bool" label="70109" default="false"/>

View File

@@ -1,23 +1,14 @@
# -*- coding: utf-8 -*-
import urlparse
from lib import unshortenit
SERVICES_SHORT = ["adf.ly", "sh.st", "bit.ly", "ul.to"]
def expand_url(url):
e = unshortenit.UnshortenIt()
estado = 200
while Es_Corto(url):
while estado != 0:
long_url, estado = e.unshorten(url)
url = long_url
return long_url
def Es_Corto(url):
server = urlparse.urlsplit(url).netloc
Corto = (server in SERVICES_SHORT)
return Corto