507 lines
18 KiB
Python
507 lines
18 KiB
Python
# -*- coding: utf-8 -*-
|
|
# ------------------------------------------------------------
|
|
# Ringraziamo Icarus crew
|
|
# Canale piratestreaming
|
|
# ------------------------------------------------------------
|
|
import re
|
|
import urlparse
|
|
|
|
from channels import autoplay
|
|
from channels import filtertools
|
|
from core import scrapertools, servertools, httptools
|
|
from core.item import Item
|
|
from core import tmdb
|
|
from lib.unshortenit import unshorten_only
|
|
from platformcode import config
|
|
from platformcode import logger
|
|
|
|
IDIOMAS = {'Italiano': 'IT'}
|
|
list_language = IDIOMAS.values()
|
|
list_servers = ['verystream', 'openload', 'streamango', 'vidlox', 'youtube']
|
|
list_quality = ['default']
|
|
|
|
__comprueba_enlaces__ = config.get_setting('comprueba_enlaces', 'tantifilm')
|
|
__comprueba_enlaces_num__ = config.get_setting('comprueba_enlaces_num', 'tantifilm')
|
|
|
|
host = "https://www.tantifilm.club" ### <-- Cambiato Host da .gratis a .club --> Continua riga 233
|
|
|
|
headers = [['Referer', host]]
|
|
|
|
|
|
def mainlist(item):
|
|
logger.info("kod.tantifilm mainlist")
|
|
|
|
autoplay.init(item.channel, list_servers, list_quality)
|
|
itemlist = [Item(channel=item.channel,
|
|
title="[COLOR azure]Novita'[/COLOR]",
|
|
action="peliculas",
|
|
url="%s/watch-genre/recommended/" % host,
|
|
thumbnail="http://orig03.deviantart.net/6889/f/2014/079/7/b/movies_and_popcorn_folder_icon_by_matheusgrilo-d7ay4tw.png"),
|
|
Item(channel=item.channel,
|
|
title="[COLOR azure]HD - Alta Definizione[/COLOR]",
|
|
action="peliculas",
|
|
url="%s/watch-genre/altadefinizione/" % host,
|
|
thumbnail="http://jcrent.com/apple%20tv%20final/HD.png"),
|
|
Item(channel=item.channel,
|
|
title="[COLOR azure]Film Per Categoria[/COLOR]",
|
|
action="categorias",
|
|
url=host,
|
|
thumbnail="http://orig03.deviantart.net/6889/f/2014/079/7/b/movies_and_popcorn_folder_icon_by_matheusgrilo-d7ay4tw.png"),
|
|
Item(channel=item.channel,
|
|
title="[COLOR yellow]Cerca...[/COLOR]",
|
|
action="search",
|
|
extra="movie",
|
|
thumbnail="http://dc467.4shared.com/img/fEbJqOum/s7/13feaf0c8c0/Search"),
|
|
Item(channel=item.channel,
|
|
title="[COLOR azure]Serie TV[/COLOR]",
|
|
extra="tvshow",
|
|
action="peliculas_tv",
|
|
url="%s/watch-genre/serie-tv" % host,
|
|
thumbnail="http://orig03.deviantart.net/6889/f/2014/079/7/b/movies_and_popcorn_folder_icon_by_matheusgrilo-d7ay4tw.png"),
|
|
Item(channel=item.channel,
|
|
title="[COLOR yellow]Cerca Serie TV...[/COLOR]",
|
|
action="search",
|
|
extra="tvshow",
|
|
thumbnail="http://dc467.4shared.com/img/fEbJqOum/s7/13feaf0c8c0/Search")]
|
|
|
|
autoplay.show_option(item.channel, itemlist)
|
|
|
|
return itemlist
|
|
|
|
|
|
def newest(categoria):
|
|
logger.info("kod.tantifilm newest" + categoria)
|
|
itemlist = []
|
|
item = Item()
|
|
try:
|
|
if categoria == "film":
|
|
item.url = host
|
|
item.action = "latest"
|
|
itemlist = latest(item)
|
|
|
|
if itemlist[-1].action == "latest":
|
|
itemlist.pop()
|
|
|
|
# Continua la ricerca in caso di errore
|
|
except:
|
|
import sys
|
|
for line in sys.exc_info():
|
|
logger.error("{0}".format(line))
|
|
return []
|
|
|
|
return itemlist
|
|
|
|
|
|
def categorias(item):
|
|
itemlist = []
|
|
|
|
# Carica la pagina
|
|
data = httptools.downloadpage(item.url, headers=headers).data
|
|
bloque = scrapertools.find_single_match(data,
|
|
'<ul class="table-list">(.*?)</ul>')
|
|
|
|
# Estrae i contenuti
|
|
patron = '<li><a href=\'(.*?)\'><span></span>(.*?)</a></li>'
|
|
matches = re.compile(patron, re.DOTALL).findall(bloque)
|
|
|
|
for scrapedurl, scrapedtitle in matches:
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
action="peliculas",
|
|
title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
|
|
url=scrapedurl,
|
|
thumbnail="http://xbmc-repo-ackbarr.googlecode.com/svn/trunk/dev/skin.cirrus%20extended%20v2/extras/moviegenres/All%20Movies%20by%20Genre.png",
|
|
folder=True))
|
|
|
|
return itemlist
|
|
|
|
|
|
def search(item, texto):
|
|
logger.info("[tantifilm.py] " + item.url + " search " + texto)
|
|
item.url = "%s/?s=%s" % (host, texto)
|
|
|
|
try:
|
|
if item.extra == "movie":
|
|
return search_peliculas(item)
|
|
if item.extra == "tvshow":
|
|
return search_peliculas_tv(item)
|
|
|
|
# Continua la ricerca in caso di errore
|
|
except:
|
|
import sys
|
|
for line in sys.exc_info():
|
|
logger.error("%s" % line)
|
|
return []
|
|
|
|
|
|
def search_peliculas(item):
|
|
logger.info("kod.tantifilm search_peliculas")
|
|
itemlist = []
|
|
|
|
# Carica la pagina
|
|
data = httptools.downloadpage(item.url, headers=headers).data
|
|
|
|
# Estrae i contenuti
|
|
patron = '<a href="([^"]+)" title="([^"]+)" rel="[^"]+">\s*<img[^s]+src="(.*?)"'
|
|
matches = re.compile(patron, re.DOTALL).findall(data)
|
|
|
|
for scrapedurl, scrapedtitle, scrapedthumbnail in matches:
|
|
scrapedplot = ""
|
|
scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle)
|
|
scrapedtitle = scrapedtitle.replace("streaming", "").replace("Permalink to ", "")
|
|
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
action="findvideos",
|
|
contentType="movie",
|
|
fulltitle=scrapedtitle,
|
|
show=scrapedtitle,
|
|
title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
|
|
url=scrapedurl,
|
|
thumbnail=scrapedthumbnail,
|
|
plot=scrapedplot,
|
|
folder=True))
|
|
|
|
return itemlist
|
|
|
|
|
|
def search_peliculas_tv(item):
|
|
logger.info("kod.tantifilm search_peliculas")
|
|
itemlist = []
|
|
|
|
# Carica la pagina
|
|
data = httptools.downloadpage(item.url, headers=headers).data
|
|
|
|
# Estrae i contenuti
|
|
patron = '<a href="([^"]+)" title="([^"]+)" rel="[^"]+">\s*<img[^s]+src="(.*?)"'
|
|
matches = re.compile(patron, re.DOTALL).findall(data)
|
|
|
|
for scrapedurl, scrapedtitle, scrapedthumbnail in matches:
|
|
scrapedplot = ""
|
|
scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle)
|
|
scrapedtitle = scrapedtitle.replace("streaming", "").replace("Permalink to ", "")
|
|
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
action="episodios",
|
|
fulltitle=scrapedtitle,
|
|
show=scrapedtitle,
|
|
title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
|
|
url=scrapedurl,
|
|
thumbnail=scrapedthumbnail,
|
|
plot=scrapedplot,
|
|
folder=True))
|
|
|
|
return itemlist
|
|
|
|
|
|
def peliculas(item):
|
|
logger.info("kod.tantifilm peliculas")
|
|
itemlist = []
|
|
|
|
# Carica la pagina
|
|
data = httptools.downloadpage(item.url, headers=headers).data
|
|
|
|
# Estrae i contenuti
|
|
patron = '<div class="media3">[^>]+><a href="([^"]+)"><img[^s]+src="([^"]+)"[^>]+></a><[^>]+><a[^>]+><p>(.*?)</p></a></div>'
|
|
matches = re.compile(patron, re.DOTALL).findall(data)
|
|
|
|
for scrapedurl, scrapedthumbnail, scrapedtitle in matches:
|
|
html = httptools.downloadpage(scrapedurl, headers=headers).data
|
|
start = html.find("<div class=\"content-left-film\">")
|
|
end = html.find("</div>", start)
|
|
scrapedplot = html[start:end]
|
|
scrapedplot = re.sub(r'<[^>]*>', '', scrapedplot)
|
|
scrapedplot = scrapertools.decodeHtmlentities(scrapedplot)
|
|
scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle)
|
|
scrapedtitle = scrapedtitle.replace("streaming", "")
|
|
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
action="findvideos",
|
|
contentType="movie",
|
|
fulltitle=scrapedtitle,
|
|
show=scrapedtitle,
|
|
title=scrapedtitle,
|
|
url=scrapedurl,
|
|
thumbnail=scrapedthumbnail,
|
|
plot=scrapedplot,
|
|
folder=True))
|
|
|
|
# Paginazione
|
|
patronvideos = '<a class="nextpostslink".*?href="([^"]+)"' ### <- Fix Pagina successiva '<a class="nextpostslink" rel="next" href="([^"]+)">»</a>'
|
|
matches = re.compile(patronvideos, re.DOTALL).findall(data)
|
|
|
|
if len(matches) > 0:
|
|
scrapedurl = urlparse.urljoin(item.url, matches[0])
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
action="peliculas",
|
|
title="[COLOR lightgreen]" + config.get_localized_string(30992) + "[/COLOR]",
|
|
url=scrapedurl,
|
|
thumbnail="http://2.bp.blogspot.com/-fE9tzwmjaeQ/UcM2apxDtjI/AAAAAAAAeeg/WKSGM2TADLM/s1600/pager+old.png",
|
|
folder=True))
|
|
|
|
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
|
return itemlist
|
|
|
|
|
|
def peliculas_tv(item):
|
|
logger.info("kod.tantifilm peliculas")
|
|
itemlist = []
|
|
|
|
# Carica la pagina
|
|
data = httptools.downloadpage(item.url, headers=headers).data
|
|
|
|
# Estrae i contenuti
|
|
patron = '<div class="media3">[^>]+><a href="([^"]+)"><img[^s]+src="([^"]+)"[^>]+></a><[^>]+><a[^>]+><p>(.*?)</p></a></div>'
|
|
matches = re.compile(patron, re.DOTALL).findall(data)
|
|
|
|
for scrapedurl, scrapedthumbnail, scrapedtitle in matches:
|
|
html = httptools.downloadpage(scrapedurl, headers=headers).data
|
|
start = html.find("<div class=\"content-left-film\">")
|
|
end = html.find("</div>", start)
|
|
scrapedplot = html[start:end]
|
|
scrapedplot = re.sub(r'<[^>]*>', '', scrapedplot)
|
|
scrapedplot = scrapertools.decodeHtmlentities(scrapedplot)
|
|
scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle)
|
|
scrapedtitle = scrapedtitle.replace("streaming", "")
|
|
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
action="episodios",
|
|
fulltitle=scrapedtitle,
|
|
show=scrapedtitle,
|
|
title=scrapedtitle,
|
|
url=scrapedurl,
|
|
thumbnail=scrapedthumbnail,
|
|
plot=scrapedplot,
|
|
folder=True))
|
|
|
|
# Paginazione
|
|
patronvideos = '<a class="nextpostslink" rel="next" href="([^"]+)">»</a>'
|
|
matches = re.compile(patronvideos, re.DOTALL).findall(data)
|
|
|
|
if len(matches) > 0:
|
|
scrapedurl = urlparse.urljoin(item.url, matches[0])
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
action="peliculas_tv",
|
|
title="[COLOR lightgreen]" + config.get_localized_string(30992) + "[/COLOR]",
|
|
url=scrapedurl,
|
|
thumbnail="http://2.bp.blogspot.com/-fE9tzwmjaeQ/UcM2apxDtjI/AAAAAAAAeeg/WKSGM2TADLM/s1600/pager+old.png",
|
|
folder=True))
|
|
|
|
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
|
return itemlist
|
|
|
|
def latest(item):
|
|
logger.info("kod.tantifilm peliculas")
|
|
itemlist = []
|
|
|
|
# Carica la pagina
|
|
data = httptools.downloadpage(item.url, headers=headers).data
|
|
|
|
# Estrae i contenuti
|
|
patron = '<div class="mediaWrap mediaWrapAlt">\s*'
|
|
patron += '<a href="([^"]+)" title="([^"]+)" rel="bookmark">\s*'
|
|
patron += '<img[^s]+src="([^"]+)"[^>]+>'
|
|
matches = re.compile(patron, re.DOTALL).findall(data)
|
|
|
|
for scrapedurl, scrapedtitle, scrapedthumbnail in matches:
|
|
html = httptools.downloadpage(scrapedurl, headers=headers).data
|
|
start = html.find("<div class=\"content-left-film\">")
|
|
end = html.find("</div>", start)
|
|
scrapedplot = html[start:end]
|
|
scrapedplot = re.sub(r'<[^>]*>', '', scrapedplot)
|
|
scrapedplot = scrapertools.decodeHtmlentities(scrapedplot)
|
|
scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle)
|
|
scrapedtitle = scrapedtitle.replace("Permalink to ", "")
|
|
scrapedtitle = scrapedtitle.replace("streaming", "")
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
action="findvideos",
|
|
contentType="movie",
|
|
fulltitle=scrapedtitle,
|
|
show=scrapedtitle,
|
|
title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
|
|
url=scrapedurl,
|
|
thumbnail=scrapedthumbnail,
|
|
plot=scrapedplot,
|
|
folder=True))
|
|
|
|
# Paginazione
|
|
patronvideos = '<a class="nextpostslink" rel="next" href="([^"]+)">»</a>'
|
|
matches = re.compile(patronvideos, re.DOTALL).findall(data)
|
|
|
|
if len(matches) > 0:
|
|
scrapedurl = urlparse.urljoin(item.url, matches[0])
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
action="latest",
|
|
title="[COLOR lightgreen]" + config.get_localized_string(30992) + "[/COLOR]",
|
|
url=scrapedurl,
|
|
thumbnail="http://2.bp.blogspot.com/-fE9tzwmjaeQ/UcM2apxDtjI/AAAAAAAAeeg/WKSGM2TADLM/s1600/pager+old.png",
|
|
folder=True))
|
|
|
|
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
|
return itemlist
|
|
|
|
|
|
def episodios(item):
|
|
def load_episodios(html, item, itemlist):
|
|
for data in html.splitlines():
|
|
# Estrae i contenuti
|
|
end = data.find('<a ')
|
|
if end > 0:
|
|
scrapedtitle = re.sub(r'<[^>]*>', '', data[:end]).strip()
|
|
else:
|
|
scrapedtitle = ''
|
|
if scrapedtitle == '':
|
|
patron = '<a\s*href="[^"]+"(?:\s*target="_blank")?>([^<]+)</a>'
|
|
scrapedtitle = scrapertools.find_single_match(data, patron).strip()
|
|
title = scrapertools.find_single_match(scrapedtitle, '\d+[^\d]+\d+')
|
|
if title == '':
|
|
title = scrapedtitle
|
|
if title != '':
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
action="findvideos",
|
|
contentType="episode",
|
|
title=title,
|
|
url=data,
|
|
thumbnail=item.thumbnail,
|
|
extra=item.extra,
|
|
fulltitle=item.fulltitle,
|
|
show=item.show))
|
|
|
|
logger.info("kod.tantifilm episodios")
|
|
|
|
itemlist = []
|
|
|
|
data = httptools.downloadpage(item.url, headers=headers).data
|
|
data = scrapertools.decodeHtmlentities(data)
|
|
|
|
start = data.find('<div class="sp-wrap sp-wrap-blue">')
|
|
end = data.find('<div id="disqus_thread">', start)
|
|
|
|
data_sub = data[start:end]
|
|
|
|
starts = []
|
|
patron = r".*?STAGIONE|MINISERIE|WEBSERIE|SERIE"
|
|
matches = re.compile(patron, re.IGNORECASE).finditer(data_sub)
|
|
for match in matches:
|
|
season_title = match.group()
|
|
if season_title != '':
|
|
starts.append(match.end())
|
|
|
|
i = 1
|
|
len_starts = len(starts)
|
|
|
|
while i <= len_starts:
|
|
inizio = starts[i - 1]
|
|
fine = starts[i] if i < len_starts else -1
|
|
|
|
html = data_sub[inizio:fine]
|
|
|
|
load_episodios(html, item, itemlist)
|
|
|
|
i += 1
|
|
|
|
if len(itemlist) == 0:
|
|
patron = '<a href="(#wpwm-tabs-\d+)">([^<]+)</a></li>'
|
|
seasons_episodes = re.compile(patron, re.DOTALL).findall(data)
|
|
|
|
end = None
|
|
for scrapedtag, scrapedtitle in seasons_episodes:
|
|
start = data.find(scrapedtag, end)
|
|
end = data.find('<div class="clearfix"></div>', start)
|
|
html = data[start:end]
|
|
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
action="findvideos",
|
|
contentType="episode",
|
|
title=scrapedtitle,
|
|
url=html,
|
|
thumbnail=item.thumbnail,
|
|
extra=item.extra,
|
|
fulltitle=item.fulltitle,
|
|
show=item.show))
|
|
|
|
if config.get_videolibrary_support() and len(itemlist) != 0:
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
title="[COLOR lightblue]%s[/COLOR]" % config.get_localized_string(30161),
|
|
url=item.url,
|
|
action="add_serie_to_library",
|
|
extra="episodios",
|
|
show=item.show))
|
|
|
|
return itemlist
|
|
|
|
|
|
def findvideos(item):
|
|
logger.info("kod.tantifilm findvideos")
|
|
|
|
# Carica la pagina
|
|
data = item.url if item.contentType == "episode" else httptools.downloadpage(item.url, headers=headers).data
|
|
|
|
if 'protectlink' in data:
|
|
urls = scrapertools.find_multiple_matches(data, r'<iframe src="[^=]+=(.*?)"')
|
|
for url in urls:
|
|
url = url.decode('base64')
|
|
data += '\t' + url
|
|
url, c = unshorten_only(url)
|
|
data += '\t' + url
|
|
|
|
itemlist = servertools.find_video_items(data=data)
|
|
|
|
for videoitem in itemlist:
|
|
videoitem.title = item.title + videoitem.title
|
|
videoitem.fulltitle = item.fulltitle
|
|
videoitem.thumbnail = item.thumbnail
|
|
videoitem.show = item.show
|
|
videoitem.plot = item.plot
|
|
videoitem.channel = item.channel
|
|
videoitem.contentType = item.contentType
|
|
videoitem.language = IDIOMAS['Italiano']
|
|
|
|
# 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 item.contentType != 'episode':
|
|
if config.get_videolibrary_support() and len(itemlist) > 0 and item.extra != 'findvideos':
|
|
itemlist.append(
|
|
Item(channel=item.channel, title='[COLOR yellow][B]Aggiungi alla videoteca[/B][/COLOR]', url=item.url,
|
|
action="add_pelicula_to_library", extra="findvideos", contentTitle=item.contentTitle))
|
|
|
|
# Estrae i contenuti
|
|
patron = r'\{"file":"([^"]+)","type":"[^"]+","label":"([^"]+)"\}'
|
|
matches = re.compile(patron, re.DOTALL).findall(data)
|
|
for scrapedurl, scrapedtitle in matches:
|
|
title = item.title + " " + scrapedtitle + " quality"
|
|
itemlist.append(
|
|
Item(channel=item.channel,
|
|
action="play",
|
|
title=title,
|
|
url=scrapedurl.replace(r'\/', '/').replace('%3B', ';'),
|
|
thumbnail=item.thumbnail,
|
|
fulltitle=item.title,
|
|
show=item.title,
|
|
server='',
|
|
contentType=item.contentType,
|
|
folder=False))
|
|
|
|
return itemlist
|