This commit is contained in:
marco
2019-12-27 23:03:21 +01:00
parent e1c3900039
commit 0692132a3d
47 changed files with 218 additions and 3296 deletions

View File

@@ -48,7 +48,7 @@ from core import support
from platformcode import config
# in caso di necessità
#from core import scrapertoolsV2, httptools, servertools, tmdb
#from core import scrapertools, httptools, servertools, tmdb
from core.item import Item # per newest
#from lib import unshortenit
@@ -74,7 +74,7 @@ def findhost():
permUrl = httptools.downloadpage('INSERIRE-URL-QUI', follow_redirects=False).headers
host = 'https://www.'+permUrl['location'].replace('https://www.google.it/search?q=site:', '')
# cancellare host non utilizzato
host = scrapertoolsV2.find_single_match(permUrl, r'<div class="elementor-button-wrapper"> <a href="([^"]+)"')
host = scrapertools.find_single_match(permUrl, r'<div class="elementor-button-wrapper"> <a href="([^"]+)"')
headers = [['Referer', host]]
# così le imposta una volta per tutte
### fine findhost
@@ -220,7 +220,7 @@ def select(item):
# pulizia di data, in caso commentare le prossime 2 righe
data = re.sub('\n|\t', ' ', data)
data = re.sub(r'>\s+<', '> <', data)
block = scrapertoolsV2.find_single_match(data, r'')
block = scrapertools.find_single_match(data, r'')
if re.findall('', data, re.IGNORECASE):
support.log('select = ### è una serie ###')
return episodios(Item(channel=item.channel,

View File

@@ -13,7 +13,7 @@
Ulteriori info:
"""
from core import scrapertoolsV2, httptools, support
from core import scrapertools, httptools, support
from core.item import Item
from platformcode import config, logger
@@ -21,7 +21,7 @@ from platformcode import config, logger
def findhost():
data = httptools.downloadpage('https://altadefinizione01-nuovo.link/').data
host = scrapertoolsV2.find_single_match(data, '<div class="elementor-button-wrapper"> <a href="([^"]+)"')
host = scrapertools.find_single_match(data, '<div class="elementor-button-wrapper"> <a href="([^"]+)"')
return host

View File

@@ -81,8 +81,8 @@ def peliculas(item):
if item.args == 'newest':
url = support.match(item, '<a href="([^"]+)" title="[^"]+" target="[^"]+" class="btn', headers=headers)[0]
item.url = url[0] if url else ''
delete = support.scrapertoolsV2.find_single_match(item.fulltitle, r'( Episodi.*)')
episode = support.scrapertoolsV2.find_single_match(item.title, r'Episodi(?:o)? (?:\d+÷)?(\d+)')
delete = support.scrapertools.find_single_match(item.fulltitle, r'( Episodi.*)')
episode = support.scrapertools.find_single_match(item.title, r'Episodi(?:o)? (?:\d+÷)?(\d+)')
item.title = support.typo(episode + ' - ','bold') + item.title.replace(delete,'')
item.fulltitle = item.show = item.title.replace(delete,'')
item.episode = episode

View File

@@ -118,8 +118,8 @@ def findvideos(item):
headers['Referer'] = item.url
headers['Cookie'] = cookies[:-1]
url = support.scrapertoolsV2.find_single_match(data, """<source src="([^"]+)" type='video/mp4'>""")
if not url: url = support.scrapertoolsV2.find_single_match(data, 'file: "([^"]+)"')
url = support.scrapertools.find_single_match(data, """<source src="([^"]+)" type='video/mp4'>""")
if not url: url = support.scrapertools.find_single_match(data, 'file: "([^"]+)"')
if url:
url += '|' + urllib.urlencode(headers)
itemlist.append(

View File

@@ -145,9 +145,9 @@ def findvideos(item):
videoData = ''
for serverid in matches:
if not item.number: item.number = support.scrapertoolsV2.find_single_match(item.title,r'(\d+) -')
block = support.scrapertoolsV2.find_multiple_matches(data,'data-id="' + serverid + '">(.*?)<div class="server')
ID = support.scrapertoolsV2.find_single_match(str(block),r'<a data-id="([^"]+)" data-base="' + (item.number if item.number else '1') + '"')
if not item.number: item.number = support.scrapertools.find_single_match(item.title, r'(\d+) -')
block = support.scrapertools.find_multiple_matches(data, 'data-id="' + serverid + '">(.*?)<div class="server')
ID = support.scrapertools.find_single_match(str(block), r'<a data-id="([^"]+)" data-base="' + (item.number if item.number else '1') + '"')
support.log('ID= ',serverid)
if id:
if serverid == '26':

View File

@@ -24,7 +24,7 @@ from core import support
from platformcode import config
# in caso di necessità
from core import scrapertoolsV2, httptools
from core import scrapertools, httptools
from core.item import Item
@@ -124,7 +124,7 @@ def select(item):
data = re.sub('\n|\t', ' ', data)
data = re.sub(r'>\s+<', '> <', data)
if 'continua con il video' in data.lower():
## block = scrapertoolsV2.find_single_match(data, r'<div class="col-md-8 bg-white rounded-left p-5"><div>(.*?)<div style="margin-left: 0.5%; color: #FFF;">')
## block = scrapertools.find_single_match(data, r'<div class="col-md-8 bg-white rounded-left p-5"><div>(.*?)<div style="margin-left: 0.5%; color: #FFF;">')
## if re.findall('rel="category tag">serie', data, re.IGNORECASE):
support.log('select = ### è un film ###')
return findvideos(Item(channel=item.channel,

View File

@@ -19,13 +19,13 @@
"""
from core import support
from core import scrapertoolsV2, httptools
from core import scrapertools, httptools
from core.item import Item
def findhost():
data = httptools.downloadpage('https://casacinema.nuovo.link').data
host = scrapertoolsV2.find_single_match(data, r'<div class="elementor-widget-container"><div class="elementor-button-wrapper"> <a href="([^"]+)"')
host = scrapertools.find_single_match(data, r'<div class="elementor-widget-container"><div class="elementor-button-wrapper"> <a href="([^"]+)"')
if host.endswith('/'):
host = host[:-1]
return host

View File

@@ -5,7 +5,7 @@
import re
from core import scrapertoolsV2, httptools, servertools, tmdb, support
from core import scrapertools, httptools, servertools, tmdb, support
from core.item import Item
from lib import unshortenit
from platformcode import logger, config
@@ -173,7 +173,7 @@ def findvideos(item):
return findvid_serie(item)
def load_links(itemlist, re_txt, color, desc_txt, quality=""):
streaming = scrapertoolsV2.find_single_match(data, re_txt).replace('"', '')
streaming = scrapertools.find_single_match(data, re_txt).replace('"', '')
support.log('STREAMING',streaming)
support.log('STREAMING=', streaming)
# patron = '<td><a.*?href=(.*?) (?:target|rel)[^>]+>([^<]+)<'
@@ -207,7 +207,7 @@ def findvideos(item):
matches = re.compile(patronvideos, re.DOTALL).finditer(data)
QualityStr = ""
for match in matches:
QualityStr = scrapertoolsV2.decodeHtmlentities(match.group(1))[6:]
QualityStr = scrapertools.decodeHtmlentities(match.group(1))[6:]
# Estrae i contenuti - Streaming
load_links(itemlist, '<strong>Streamin?g:</strong>(.*?)cbtable', "orange", "Streaming", "SD")
@@ -307,12 +307,12 @@ def play(item):
data = httptools.downloadpage(item.url).data
if "window.location.href" in data:
try:
data = scrapertoolsV2.find_single_match(data, 'window.location.href = "([^"]+)";')
data = scrapertools.find_single_match(data, 'window.location.href = "([^"]+)";')
except IndexError:
data = httptools.downloadpage(item.url, only_headers=True, follow_redirects=False).headers.get("location", "")
data, c = unshortenit.unwrap_30x_only(data)
else:
data = scrapertoolsV2.find_single_match(data, r'<a href="([^"]+)".*?class="btn-wrapper">.*?licca.*?</a>')
data = scrapertools.find_single_match(data, r'<a href="([^"]+)".*?class="btn-wrapper">.*?licca.*?</a>')
logger.debug("##### play go.php data ##\n%s\n##" % data)
else:

View File

@@ -5,7 +5,7 @@
import re
from core import httptools, support, scrapertoolsV2
from core import httptools, support, scrapertools
from core.item import Item
from platformcode import config
@@ -89,7 +89,7 @@ def episodios(item):
patronBlock = r'<p><strong>(?:.+?[Ss]tagione\s)?(?:(?P<lang>iTA|ITA|Sub-ITA|Sub-iTA))?.*?</strong>(?P<block>.+?)(?:</span|</p)'
item.contentType = 'tvshow'
def itemHook(item):
if not scrapertoolsV2.find_single_match(item.title, r'(\d+x\d+)'):
if not scrapertools.find_single_match(item.title, r'(\d+x\d+)'):
item.title = re.sub(r'(\d+) -', '1x\\1', item.title)
return item
@@ -148,7 +148,7 @@ def check(item):
support.log()
data = httptools.downloadpage(item.url, headers=headers).data
if data:
blockAnime = scrapertoolsV2.find_single_match(data, r'<div id="container" class="container">(.+?<div style="margin-left)')
blockAnime = scrapertools.find_single_match(data, r'<div id="container" class="container">(.+?<div style="margin-left)')
if blockAnime and ('episodio' in blockAnime.lower() or 'saga' in blockAnime.lower()):
item.contentType = 'tvshow'
@@ -156,7 +156,7 @@ def check(item):
item.data = blockAnime
return episodios(item)
elif scrapertoolsV2.find_single_match(blockAnime,r'\d+(?:&#215;|×)?\d+\-\d+|\d+(?:&#215;|×)\d+'):
elif scrapertools.find_single_match(blockAnime, r'\d+(?:&#215;|×)?\d+\-\d+|\d+(?:&#215;|×)\d+'):
item.contentType = 'tvshow'
item.data = data
return episodios(item)

View File

@@ -47,7 +47,7 @@ import re
from core import support
from platformcode import config
from core import scrapertoolsV2, httptools, servertools, tmdb
from core import scrapertools, httptools, servertools, tmdb
from core.item import Item
##### fine import
@@ -228,8 +228,8 @@ def findvideos(item):
data = re.sub(r'>\s\s*<', '><', data)
patronBlock = r'LINK STREAMING(?P<block>.*?)LINK DOWNLOAD'
patron = r'href="(.+?)"'
block = scrapertoolsV2.find_single_match(data, patronBlock)
urls = scrapertoolsV2.find_multiple_matches(block, patron)
block = scrapertools.find_single_match(data, patronBlock)
urls = scrapertools.find_multiple_matches(block, patron)
#support.regexDbg(item, patron, headers, data=data)
for url in urls:
@@ -241,7 +241,7 @@ def findvideos(item):
lang = 'ITA'
if 'keepem.online' in data:
urls = scrapertoolsV2.find_multiple_matches(data, r'(https://keepem\.online/f/[^"]+)"')
urls = scrapertools.find_multiple_matches(data, r'(https://keepem\.online/f/[^"]+)"')
for url in urls:
url = httptools.downloadpage(url).url
itemlist += servertools.find_video_items(data=url)
@@ -254,14 +254,14 @@ def findvideos(item):
data = httptools.downloadpage(data).data
support.log("LINK-DATA2 :", data)
video_urls = scrapertoolsV2.find_single_match(data, r'<meta name="description" content="([^"]+)"')
video_urls = scrapertools.find_single_match(data, r'<meta name="description" content="([^"]+)"')
else:
data = httptools.downloadpage(url).data
#host_video = scrapertoolsV2.find_single_match(data, r'var thisPageUrl = "(http[s]\:\/\/[^\/]+).+?"')
host_video = scrapertoolsV2.find_single_match(data, r'(?:let|var) thisPageUrl = "(http[s]\:\/\/[^\/]+).+?"')
link = scrapertoolsV2.find_single_match(data, r'<video src="([^"]+)"')
#host_video = scrapertools.find_single_match(data, r'var thisPageUrl = "(http[s]\:\/\/[^\/]+).+?"')
host_video = scrapertools.find_single_match(data, r'(?:let|var) thisPageUrl = "(http[s]\:\/\/[^\/]+).+?"')
link = scrapertools.find_single_match(data, r'<video src="([^"]+)"')
video_urls = host_video+link
title_show = support.typo(titles,'_ bold') + support.typo(lang,'_ [] color kod')

View File

@@ -12,7 +12,7 @@
- serie, anime
"""
import re
from core import scrapertoolsV2, httptools, support
from core import scrapertools, httptools, support
from core.item import Item
from platformcode import config
@@ -96,13 +96,13 @@ def pagina(url):
data = httptools.downloadpage(url, headers=headers).data.replace("'", '"')
#support.log("DATA ----###----> ", data)
if 'clicca qui per aprire' in data.lower():
url = scrapertoolsV2.find_single_match(data, '"go_to":"([^"]+)"')
url = scrapertools.find_single_match(data, '"go_to":"([^"]+)"')
url = url.replace("\\","")
# Carica la pagina
data = httptools.downloadpage(url, headers=headers).data.replace("'", '"')
elif 'clicca qui</span>' in data.lower():
url = scrapertoolsV2.find_single_match(data, '<h2 style="text-align: center;"><a href="([^"]+)">')
url = scrapertools.find_single_match(data, '<h2 style="text-align: center;"><a href="([^"]+)">')
# Carica la pagina
data = httptools.downloadpage(url, headers=headers).data.replace("'", '"')

View File

@@ -16,7 +16,7 @@
- SOLO SUB-ITA
"""
from core import support, httptools, scrapertoolsV2
from core import support, httptools, scrapertools
from core.item import Item
from core.support import log
from platformcode import config
@@ -158,7 +158,7 @@ def findvideos(item):
data = httptools.downloadpage(item.url).data
patron = r'>Posted in <a href="https?://fastsubita.com/serietv/([^/]+)/(?:[^"]+)?"'
series = scrapertoolsV2.find_single_match(data, patron)
series = scrapertools.find_single_match(data, patron)
titles = support.typo(series.upper().replace('-', ' '), 'bold color kod')
goseries = support.typo("Vai alla Serie:", ' bold color kod')
itemlist.append(

View File

@@ -17,7 +17,7 @@
"""
import re
from core import scrapertoolsV2, httptools, support
from core import scrapertools, httptools, support
from core.item import Item
from platformcode import config
@@ -113,7 +113,7 @@ def select(item):
support.log()
data = httptools.downloadpage(item.url, headers=headers).data
patronBlock = scrapertoolsV2.find_single_match(data, r'class="taxonomy category" ><span property="name">(.*?)</span></a><meta property="position" content="2">')
patronBlock = scrapertools.find_single_match(data, r'class="taxonomy category" ><span property="name">(.*?)</span></a><meta property="position" content="2">')
if patronBlock.lower() != 'film':
support.log('select = ### è una serie ###')
item.contentType='tvshow'

View File

@@ -1,37 +0,0 @@
{
"id": "hdblog",
"name": "Hdblog",
"language": ["ita"],
"active": true,
"adult": false,
"thumbnail": "http://css.hd-cdn.it/new_files/templates/theme_darklight/img/logos_wt/logohdhardware.png",
"banner": "http://css.hd-cdn.it/new_files/templates/theme_darklight/img/logos_wt/logohdhardware.png",
"categories": ["documentary"],
"settings": [
{
"id": "include_in_global_search",
"type": "bool",
"label": "Includi in Ricerca Globale",
"default": false,
"enabled": false,
"visible": false
},
{
"id": "include_in_newest_documentales",
"type": "bool",
"label": "Includi in Novità - Documentari",
"default": true,
"enabled": true,
"visible": true
},
{
"id": "include_in_newest_italiano",
"type": "bool",
"label": "Includi in Novità - Italiano",
"default": true,
"enabled": true,
"visible": true
}
]
}

View File

@@ -1,94 +0,0 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------
# Ringraziamo Icarus crew
# Canale hdblog
# ------------------------------------------------------------
import re
import urlparse
from core import httptools, scrapertools
from core.item import Item
from platformcode import logger
from platformcode import config
host = "https://www.hdblog.it"
def mainlist(item):
logger.info("kod.hdblog mainlist")
itemlist = [Item(channel=item.channel,
title="[COLOR azure]Video recensioni tecnologiche[/COLOR]",
action="peliculas",
url=host + "/video/",
thumbnail="http://www.crat-arct.org/uploads/images/tic%201.jpg"),
Item(channel=item.channel,
title="[COLOR azure]Categorie[/COLOR]",
action="categorias",
url=host + "/video/",
thumbnail="http://www.crat-arct.org/uploads/images/tic%201.jpg")]
return itemlist
def categorias(item):
logger.info("kod.hdblog categorias")
itemlist = []
data = httptools.downloadpage(item.url).data
logger.info(data)
# Narrow search by selecting only the combo
start = data.find('<section class="left_toolbar" style="float: left;width: 125px;margin-right: 18px;">')
end = data.find('</section>', start)
bloque = data[start:end]
# The categories are the options for the combo
patron = '<a href="([^"]+)"[^>]+><span>(.*?)</span>'
matches = re.compile(patron, re.DOTALL).findall(bloque)
scrapertools.printMatches(matches)
for scrapedurl, scrapedtitle in matches:
scrapedthumbnail = ""
scrapedplot = ""
itemlist.append(
Item(channel=item.channel,
action="peliculas",
title="[COLOR azure]" + scrapedtitle + "[/COLOR]",
url=scrapedurl + "video/",
thumbnail=scrapedthumbnail,
plot=scrapedplot))
return itemlist
def peliculas(item):
logger.info("kod.hdblog peliculas")
itemlist = []
# Carica la pagina
data = httptools.downloadpage(item.url).data
# Estrae i contenuti
patron = '<a class="thumb_new_image" href="([^"]+)">\s*<img[^s]+src="([^"]+)"[^>]+>\s*</a>\s*[^>]+>\s*(.*?)\s*<'
matches = re.compile(patron, re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for scrapedurl, scrapedthumbnail, scrapedtitle in matches:
scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle)
scrapedplot = ""
itemlist.append(Item(channel=item.channel, action="findvideos", fulltitle=scrapedtitle, show=scrapedtitle,
title=scrapedtitle, url=scrapedurl, thumbnail=scrapedthumbnail, plot=scrapedplot,
folder=True))
# Paginazione
patronvideos = '<span class="attiva">[^>]+>[^=]+="next" href="(.*?)" class="inattiva">'
matches = re.compile(patronvideos, re.DOTALL).findall(data)
scrapertools.printMatches(matches)
if len(matches) > 0:
scrapedurl = urlparse.urljoin(item.url, matches[0])
itemlist.append(
Item(channel=item.channel, action="peliculas", title="[COLOR orange]Avanti >>[/COLOR]", url=scrapedurl,
folder=True))
return itemlist

View File

@@ -33,7 +33,7 @@
import re
from core import scrapertoolsV2, httptools, support
from core import scrapertools, httptools, support
from core.support import log
from core.item import Item
from platformcode import config
@@ -216,7 +216,7 @@ def findvideos(item):
matches, data = support.match(item, '<iframe class="metaframe rptss" src="([^"]+)"[^>]+>',headers=headers)
for url in matches:
html = httptools.downloadpage(url, headers=headers).data
data += str(scrapertoolsV2.find_multiple_matches(html, '<meta name="og:url" content="([^"]+)">'))
data += str(scrapertools.find_multiple_matches(html, '<meta name="og:url" content="([^"]+)">'))
itemlist = support.server(item, data)
@@ -224,7 +224,7 @@ def findvideos(item):
data = httptools.downloadpage(item.url).data
patron = r'<div class="item"><a href="'+host+'/serietv/([^"\/]+)\/"><i class="icon-bars">'
series = scrapertoolsV2.find_single_match(data, patron)
series = scrapertools.find_single_match(data, patron)
titles = support.typo(series.upper().replace('-', ' '), 'bold color kod')
goseries = support.typo("Vai alla Serie:", ' bold')
itemlist.append(

View File

@@ -1,37 +0,0 @@
{
"id": "ilgiramondo",
"name": "IlGiramondo",
"language": ["ita"],
"active": true,
"adult": false,
"thumbnail": "http://www.ilgiramondo.net/wp-content/uploads/2013/05/logo-fixed.jpg",
"banner": "http://www.ilgiramondo.net/wp-content/uploads/2013/05/logo-fixed.jpg",
"categories": ["documentary"],
"settings": [
{
"id": "include_in_global_search",
"type": "bool",
"label": "Incluir en busqueda global",
"default": false,
"enabled": false,
"visible": false
},
{
"id": "include_in_newest_documentales",
"type": "bool",
"label": "Includi in Novità - Documentari",
"default": true,
"enabled": true,
"visible": true
},
{
"id": "include_in_newest_italiano",
"type": "bool",
"label": "Includi in Novità - Italiano",
"default": true,
"enabled": true,
"visible": true
}
]
}

View File

@@ -1,67 +0,0 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------
# Ringraziamo Icarus crew
# Canale ilgiramondo
# ------------------------------------------------------------
import re
import urlparse
from core import httptools, scrapertools
from core.item import Item
from platformcode import logger
from platformcode import config
host = "http://www.ilgiramondo.net"
def mainlist(item):
logger.info("kod.ilgiramondo mainlist")
itemlist = [Item(channel=item.channel, title="[COLOR azure]Video di Viaggi[/COLOR]", action="peliculas",
url=host + "/video-vacanze-viaggi/",
thumbnail="http://hotelsjaisalmer.com/wp-content/uploads/2016/10/Travel1.jpg")]
return itemlist
def peliculas(item):
logger.info("kod.ilgiramondo peliculas")
itemlist = []
# Carica la pagina
data = httptools.downloadpage(item.url).data
# Estrae i contenuti
patron = '<article id=[^>]+><div class="space">\s*<a href="([^"]+)"><img[^s]+src="(.*?)"[^>]+><\/a>'
matches = re.compile(patron, re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for scrapedurl, scrapedthumbnail in matches:
html = httptools.downloadpage(scrapedurl).data
start = html.find("</script></div>")
end = html.find("</p>", start)
scrapedplot = html[start:end]
scrapedplot = re.sub(r'<[^>]*>', '', scrapedplot)
scrapedplot = scrapertools.decodeHtmlentities(scrapedplot)
html = httptools.downloadpage(scrapedurl).data
start = html.find("<title>")
end = html.find("</title>", start)
scrapedtitle = html[start:end]
scrapedtitle = re.sub(r'<[^>]*>', '', scrapedtitle)
scrapedtitle = scrapedtitle.replace(" | Video Di Viaggi E Vacanze", "")
# scrapedplot = ""
itemlist.append(Item(channel=item.channel, action="findvideos", fulltitle=scrapedtitle, show=scrapedtitle,
title=scrapedtitle, url=scrapedurl, thumbnail=scrapedthumbnail, plot=scrapedplot,
folder=True))
# Paginazione
patronvideos = '<a class="next page-numbers" href="(.*?)">Successivo'
matches = re.compile(patronvideos, re.DOTALL).findall(data)
scrapertools.printMatches(matches)
if len(matches) > 0:
scrapedurl = urlparse.urljoin(item.url, matches[0])
itemlist.append(
Item(channel=item.channel, action="peliculas", title="[COLOR orange]Avanti >>[/COLOR]", url=scrapedurl,
folder=True))
return itemlist

View File

@@ -1,37 +0,0 @@
{
"id": "istitutoluce",
"name": "Istituto Luce",
"language": ["ita"],
"active": true,
"adult": false,
"thumbnail": "http://www.archivioluce.com/wp-content/themes/wpbootstrap/bootstrap/img/luce-logo.png",
"banner": "http://www.archivioluce.com/wp-content/themes/wpbootstrap/bootstrap/img/luce-logo.png",
"categories": ["documentary"],
"settings": [
{
"id": "include_in_global_search",
"type": "bool",
"label": "Includi in Ricerca Globale",
"default": false,
"enabled": false,
"visible": false
},
{
"id": "include_in_newest_documentales",
"type": "bool",
"label": "Includi in Novità - Documentari",
"default": true,
"enabled": true,
"visible": true
},
{
"id": "include_in_newest_italiano",
"type": "bool",
"label": "Includi in Novità - Italiano",
"default": true,
"enabled": true,
"visible": true
}
]
}

View File

@@ -1,288 +0,0 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------
# Ringraziamo Icarus crew
# Canale istitutoluce
# ------------------------------------------------------------
import re
import urlparse
from core import httptools, scrapertools, servertools
from core.item import Item
from platformcode import logger, config
host = "https://patrimonio.archivioluce.com"
host2 = "https://www.archivioluce.com"
headers = [['Referer', host]]
PERPAGE = 7
def mainlist(item):
logger.info("kod.istitutoluce mainlist")
itemlist = [
Item(
channel=item.channel,
title="[COLOR azure]Archivio - Tutti i Filmati[/COLOR]",
action="peliculas",
url="%s/luce-web/search/result.html?query=&perPage=7" % host,
thumbnail="http://www.archivioluce.com/wp-content/themes/wpbootstrap/bootstrap/img/luce-logo.png"
),
Item(
channel=item.channel,
title="[COLOR azure]Categorie Tematiche[/COLOR]",
action="categorie",
url="%s/navigazione-tematica/" % host2,
thumbnail="http://www.archivioluce.com/wp-content/themes/wpbootstrap/bootstrap/img/luce-logo.png"
),
Item(
channel=item.channel,
title="[COLOR yellow]Cerca...[/COLOR]",
action="search",
thumbnail="http://dc467.4shared.com/img/fEbJqOum/s7/13feaf0c8c0/Search"
)
]
return itemlist
def categorie(item):
itemlist = []
data = httptools.downloadpage(item.url, headers=headers).data
bloque = scrapertools.find_single_match(data, '<section class="container directory">(.*?)<footer class="main">')
patron = '<a class="label label-white" href="(.*?)">\s*(.*?)</a>'
matches = re.compile(patron, re.DOTALL).findall(bloque)
for scrapedurl, scrapedtitle in matches:
scrapedtitle = scrapedtitle.title()
itemlist.append(
Item(channel=item.channel,
action="cat_results",
fulltitle=scrapedtitle,
title=scrapedtitle,
url=scrapedurl,
viewmode="movie_with_plot",
Folder=True))
return itemlist
def cat_results(item):
logger.info("kod.istitutoluce cat_results")
itemlist = []
# Carica la pagina
data = httptools.downloadpage(item.url, headers=headers).data
# Estrae i contenuti
patron = '<a href="([^"]+)" class="thumbnail">\s*<h1>'
matches = re.compile(patron, re.DOTALL).findall(data)
for scrapedurl in matches:
scrapedtitle = scrapedurl
scrapedtitle = scrapedtitle.rsplit('/', 1)[-1].rsplit(".", 1)[0].replace("-", " ").title()
scrapedurl = host + scrapedurl
scrapedplot = ""
# html = scrapertools.cache_page(scrapedurl)
# start = html.find('<p class="abstract">')
# end = html.find('</p>', start)
# scrapedplot = html[start:end]
# scrapedplot = re.sub(r'<[^>]*>', '', scrapedplot)
# scrapedplot = scrapertools.decodeHtmlentities(scrapedplot)
scrapedthumbnail = ""
# cache = httptools.downloadpage(scrapedurl, headers=headers).data
# patron = 'image: "(.*?)"'
# matches = re.compile(patron, re.DOTALL).findall(cache)
# for scrapedthumbnail in matches:
itemlist.append(
Item(channel=item.channel,
action="findvideos",
fulltitle=scrapedtitle,
show=scrapedtitle,
title=scrapedtitle,
url=scrapedurl,
thumbnail=scrapedthumbnail,
plot=scrapedplot,
folder=True))
# Paginazione
patron = r'</span></td>\s*<td>\s*<a href="([^"]+)" class="btn-pag-luce">'
next_page = scrapertools.find_single_match(data, patron)
if next_page > 0:
scrapedurl = urlparse.urljoin(item.url, next_page)
itemlist.append(
Item(channel=item.channel,
action="cat_results",
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))
return itemlist
def peliculas(item):
logger.info("kod.istitutoluce peliculas")
itemlist = []
# Carica la pagina
data = httptools.downloadpage(item.url, headers=headers).data
# Estrae i contenuti
patron = '<a href="([^"]+)" class="thumbnail">\s*<h1>'
matches = re.compile(patron, re.DOTALL).findall(data)
for scrapedurl in matches:
scrapedtitle = scrapedurl
scrapedtitle = scrapedtitle.rsplit('/', 1)[-1].rsplit(".", 1)[0].replace("-", " ").title()
scrapedurl = host + scrapedurl
## html = scrapertools.cache_page(scrapedurl)
html = httptools.downloadpage(scrapedurl, headers=headers).data
start = html.find('<p class="abstract">')
end = html.find('</p>', start)
scrapedplot = html[start:end]
scrapedplot = re.sub(r'<[^>]*>', '', scrapedplot)
scrapedplot = scrapertools.decodeHtmlentities(scrapedplot)
html = httptools.downloadpage(scrapedurl, headers=headers).data
patron = 'image: "(.*?)"'
scrapedthumbnail = scrapertools.find_single_match(html, patron)
itemlist.append(
Item(channel=item.channel,
action="findvideos",
fulltitle=scrapedtitle,
show=scrapedtitle,
title=scrapedtitle,
url=scrapedurl,
thumbnail=scrapedthumbnail,
plot=scrapedplot,
folder=True))
# Paginazione
patron = r'</span></td>\s*<td>\s*<a href="([^"]+)" class="btn-pag-luce">'
next_page = scrapertools.find_single_match(data, patron)
if next_page:
scrapedurl = urlparse.urljoin(item.url, next_page)
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))
return itemlist
def peliculas_src(item):
logger.info("kod.istitutoluce peliculas")
itemlist = []
p = 1
if '{}' in item.url:
item.url, p = item.url.split('{}')
p = int(p)
# Carica la pagina
data = httptools.downloadpage(item.url, headers=headers).data
# Estrae i contenuti
patron = '<a href="([^"]+)" class="thumbnail">\s*<h1>'
matches = re.compile(patron, re.DOTALL).findall(data)
for i, (scrapedurl) in enumerate(matches):
if (p - 1) * PERPAGE > i: continue
if i >= p * PERPAGE: break
scrapedtitle = scrapedurl
scrapedtitle = scrapedtitle.rsplit('/', 1)[-1].rsplit(".", 1)[0].replace("-", " ").title()
scrapedurl = urlparse.urljoin(host, scrapedurl)
html = httptools.downloadpage(scrapedurl, headers=headers).data
start = html.find('<p class="abstract">')
end = html.find('</p>', start)
scrapedplot = html[start:end]
scrapedplot = re.sub(r'<[^>]*>', '', scrapedplot)
scrapedplot = scrapertools.decodeHtmlentities(scrapedplot)
html = httptools.downloadpage(scrapedurl, headers=headers).data
patron = 'image: "(.*?)"'
scrapedthumbnail = scrapertools.find_single_match(html, patron)
itemlist.append(
Item(channel=item.channel,
action="findvideos",
fulltitle=scrapedtitle,
show=scrapedtitle,
title=scrapedtitle,
url=scrapedurl,
thumbnail=scrapedthumbnail,
plot=scrapedplot,
folder=True))
# Paginazione
if len(matches) >= p * PERPAGE:
scrapedurl = item.url + '{}' + str(p + 1)
itemlist.append(
Item(channel=item.channel,
extra=item.extra,
action="peliculas_src",
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))
return itemlist
def search(item, texto):
logger.info("[istitutoluce.py] search")
item.url = host + '/luce-web/search/result.html?archiveType_string="xDamsCineLuce"&archiveName_string="luceFondoCinegiornali"&archiveName_string="luceFondoDocumentari"&archiveName_string="luceFondoRepertori"&titoloADV=&descrizioneADV="' + texto + '"'
try:
return peliculas_src(item)
# Continua la ricerca in caso di errore .
except:
import sys
for line in sys.exc_info():
logger.error("%s" % line)
return []
def findvideos(item):
logger.info("kod.istitutoluce findvideos")
data = httptools.downloadpage(item.url, headers=headers).data
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
# Estrae i contenuti
patron = 'file: "rtsp:([^"]+)"\s*}'
matches = re.compile(patron, re.DOTALL).findall(data)
for video in matches:
video = "rtsp:" + video
itemlist.append(
Item(
channel=item.channel,
action="play",
title=item.title + " [[COLOR orange]Diretto[/COLOR]]",
url=video,
folder=False))
return itemlist

View File

@@ -15,7 +15,7 @@
"""
import re
from core import support, httptools, scrapertoolsV2
from core import support, httptools, scrapertools
from core.item import Item
from platformcode import config
@@ -130,8 +130,8 @@ def findvideos(item):
data = httptools.downloadpage(item.url, headers=headers).data
data = re.sub('\n|\t', ' ', data)
data = re.sub(r'>\s+<', '> <', data)
url_video = scrapertoolsV2.find_single_match(data, r'<a rel="[^"]+" target="[^"]+" act="[^"]+"\s+href="([^"]+)" class="[^"]+-link".+?\d+.+?</strong> </a>', -1)
url_serie = scrapertoolsV2.find_single_match(data, r'<link rel="canonical" href="([^"]+)" />')
url_video = scrapertools.find_single_match(data, r'<a rel="[^"]+" target="[^"]+" act="[^"]+"\s+href="([^"]+)" class="[^"]+-link".+?\d+.+?</strong> </a>', -1)
url_serie = scrapertools.find_single_match(data, r'<link rel="canonical" href="([^"]+)" />')
goseries = support.typo("Vai alla Serie:", ' bold')
series = support.typo(item.contentSerieName, ' bold color kod')
itemlist = support.server(item, data=url_video)

View File

@@ -1,21 +0,0 @@
{
"id": "programmazione",
"name": "Programmazione",
"language": ["ita"],
"active": true,
"adult": false,
"thumbnail": "http://www.smartworld.it/wp-content/uploads/2015/02/codice-code-programmazione-fhd-720x480.png",
"banner": "http://www.smartworld.it/wp-content/uploads/2015/02/codice-code-programmazione-fhd-720x480.png",
"categories": ["documentary"],
"settings": [
{
"id": "include_in_global_search",
"type": "bool",
"label": "Incluir en busqueda global",
"default": false,
"enabled": false,
"visible": false
}
]
}

View File

@@ -1,71 +0,0 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------
# Ringraziamo Icarus crew
# Canale Video Corsi Programmazione
# Creato da iSOD
# https://alfa-addon.com/categories/kod-addon.50/.
# ------------------------------------------------------------
import re
from core import httptools, scrapertools
from core.item import Item
from platformcode import logger
from platformcode import config
site = "https://www.youtube.com"
def mainlist(item):
logger.info("kod.programmazione mainlist")
itemlist = []
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso Html 5[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PL7A4A3449C649048F", thumbnail="http://i.ytimg.com/vi/TyCvfNt20nM/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso Css[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PLD74C5E763D39793D", thumbnail="http://i.ytimg.com/vi/hd8k82aG_O4/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso Javascript[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PL1A447BA7F7F9EB9E", thumbnail="http:////i.ytimg.com/vi/eXlzdxyThLM/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso PHP[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PL0qAPtx8YtJc664i2Cv0X0ibM9b1YqRyd", thumbnail="http://i.ytimg.com/vi/0nA1gPWdBWw/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso PHP Mysql[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PL101314D973955661", thumbnail="http://i.ytimg.com/vi/QIxmITjITY8/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso Jquery[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PLC959BB22285B353F", thumbnail="http://i.ytimg.com/vi/mxl2IcNdbrk/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso Java da Zero[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PL0qAPtx8YtJe2dpE7di4aPJwrQuRD6IDD", thumbnail="http://i.ytimg.com/vi/7PGPLqFpDMc/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso Java 2 OOP[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PL0qAPtx8YtJee1dk24wX-68yHTnMfzdX5", thumbnail="http://i.ytimg.com/vi/h6VoxIAUZoo/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso Java Interfaccia Grafica[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PL0qAPtx8YtJfRML8EDs7v9nwjdOt6dvaf", thumbnail="http://i.ytimg.com/vi/fS7OxhbIlw4/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso Java Android[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PL0qAPtx8YtJeqmBWbE1Rbac2QWHoPCjR2", thumbnail="http://i.ytimg.com/vi/GINLfdq-elE/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso Progettazione DB[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PL0qAPtx8YtJcJPSV4sOfhLtPbtQ-yycFH", thumbnail="http://i.ytimg.com/vi/FnkL4YdWAwE/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso SQL[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PLE555DB6188C967AC", thumbnail="http://i.ytimg.com/vi/jM55Fb9YTfE/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso Python[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PLC64779F4E2E7EB10", thumbnail="http://i.ytimg.com/vi/_iX9CSX09Z8/mqdefault.jpg"))
itemlist.append( Item(channel=item.channel, title="[COLOR azure]Corso Unit 3D[/COLOR]", action="corsi", url="https://www.youtube.com/playlist?list=PL0qAPtx8YtJcbl6ZHwtFIkFxWY-adCeS7", thumbnail="http://i.ytimg.com/vi/QiFBrHp3IGk/mqdefault.jpg"))
return itemlist
def corsi(item):
logger.info("kod.programmazione peliculas")
itemlist = []
# scarrico il canale
html = httptools.downloadpage(item.url).data
# Estraggo l'elenco dei video e titoli
patron = '<a class="pl-video-title-link.*?href="(.*?)"[^>]+>(.*?)</a>'
trovati = re.compile(patron, re.DOTALL).findall(html)
scrapertools.printMatches(trovati)
max = len(trovati)
min = 0
# ciclo sull'elenco trovato
for VideoUrl, VideoTitolo in trovati:
# Decodifico Html
titolo = scrapertools.decodeHtmlentities(VideoTitolo)
# contatore
min += 1
# aggiungo alla lista
itemlist.append(
Item(channel=item.channel,
action="findvideos",
fulltitle=titolo,
show=titolo,
title="[COLOR azure]" + item.title + " - " + str(min) + "x" + str(max) + "[/COLOR]",
url=site + VideoUrl,
thumbnail=item.thumbnail,
plot=titolo,
folder=True))
return itemlist

File diff suppressed because it is too large Load Diff

View File

@@ -1,37 +0,0 @@
{
"id": "ricettevideo",
"name": "Ricette Video",
"language": ["ita"],
"active": true,
"adult": false,
"thumbnail": "http://ricettevideo.net/wp-content/uploads/2013/08/Ricette-Video-Logo.png",
"banner": "http://ricettevideo.net/wp-content/uploads/2013/08/Ricette-Video-Logo.png",
"categories": ["documentary"],
"settings": [
{
"id": "include_in_global_search",
"type": "bool",
"label": "Incluir en busqueda global",
"default": false,
"enabled": false,
"visible": false
},
{
"id": "include_in_newest_documentales",
"type": "bool",
"label": "Includi in Novità - Documentari",
"default": true,
"enabled": true,
"visible": true
},
{
"id": "include_in_newest_italiano",
"type": "bool",
"label": "Includi in Novità - Italiano",
"default": true,
"enabled": true,
"visible": true
}
]
}

View File

@@ -1,58 +0,0 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------
# Ringraziamo Icarus crew
# Canale ricettevideo
# ------------------------------------------------------------
import re
import urlparse
from core import httptools, scrapertools
from core.item import Item
from platformcode import logger
from platformcode import config
host = "http://ricettevideo.net"
def mainlist(item):
logger.info("kod.ricettevideo mainlist")
itemlist = [Item(channel=item.channel, title="[COLOR azure]Videoricette[/COLOR]", action="peliculas",
url=host,
thumbnail="http://www.brinkmanscountrycorner.com/images/Recipies.png")]
return itemlist
def peliculas(item):
logger.info("kod.ricettevideo peliculas")
itemlist = []
# Carica la pagina
data = httptools.downloadpage(item.url).data
# Estrae i contenuti
patron = '<div class="post-item-small">\s*<a href="([^"]+)"[^t]+title="Permanent Link: ([^"]+)"><img[^s]+src="([^"]+)"[^>]+>'
matches = re.compile(patron, re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for scrapedurl, scrapedtitle, scrapedthumbnail in matches:
scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle)
scrapedplot = ""
itemlist.append(Item(channel=item.channel, action="findvideos", fulltitle=scrapedtitle, show=scrapedtitle,
title=scrapedtitle, url=scrapedurl, thumbnail=scrapedthumbnail, plot=scrapedplot,
folder=True))
# Paginazione
patronvideos = '<link rel=\'next\' href=\'([^\']+)\' />'
matches = re.compile(patronvideos, re.DOTALL).findall(data)
scrapertools.printMatches(matches)
if len(matches) > 0:
scrapedurl = urlparse.urljoin(item.url, matches[0])
itemlist.append(
Item(channel=item.channel, action="peliculas", title="[COLOR orange]Avanti >>[/COLOR]", url=scrapedurl,
folder=True))
return itemlist
# test update

View File

@@ -4,7 +4,7 @@
# ------------------------------------------------------------
from core import scrapertoolsV2, httptools, support
from core import scrapertools, httptools, support
from core.item import Item
host = support.config.get_channel_url()
@@ -17,7 +17,7 @@ headers = [['Referer', host]]
# global host, headers
# data= httptools.downloadpage('https://seriehd.nuovo.link/').data
# global host, headers
# host = scrapertoolsV2.find_single_match(data, r'<div class="elementor-button-wrapper"> <a href="([^"]+)"')
# host = scrapertools.find_single_match(data, r'<div class="elementor-button-wrapper"> <a href="([^"]+)"')
# headers = [['Referer', host]]
list_servers = ['verystream', 'openload', 'streamango', 'thevideome']

View File

@@ -16,14 +16,14 @@
- Prima fare la 'Rinumerazione' dal menu contestuale dal titolo della serie
"""
import re
from core import support, httptools, scrapertoolsV2
from core import support, httptools, scrapertools
from platformcode import config
from core.item import Item
def findhost():
data = httptools.downloadpage('https://serietvonline.me/').data
host = scrapertoolsV2.find_single_match(data, r'<a class="pure-button pure-button-primary" title=\'serie tv online\' href="([^"]+)">')
host = scrapertools.find_single_match(data, r'<a class="pure-button pure-button-primary" title=\'serie tv online\' href="([^"]+)">')
return host
host = config.get_channel_url(findhost)
@@ -180,8 +180,8 @@ def findvideos(item):
data = re.sub('\n|\t', ' ', data)
data = re.sub(r'>\s+<', '> <', data)
#support.log("DATA - HTML:\n", data)
url_video = scrapertoolsV2.find_single_match(data, r'<tr><td>(.+?)</td><tr>', -1)
url_serie = scrapertoolsV2.find_single_match(data, r'<link rel="canonical" href="([^"]+)"\s?/>')
url_video = scrapertools.find_single_match(data, r'<tr><td>(.+?)</td><tr>', -1)
url_serie = scrapertools.find_single_match(data, r'<link rel="canonical" href="([^"]+)"\s?/>')
goseries = support.typo("Vai alla Serie:", ' bold')
series = support.typo(item.contentSerieName, ' bold color kod')
itemlist = support.server(item, data=url_video)

View File

@@ -8,7 +8,7 @@
"""
import re
from core import support, httptools, scrapertoolsV2
from core import support, httptools, scrapertools
from core.item import Item
from core.support import log
from platformcode import config
@@ -118,8 +118,8 @@ def findvideos(item):
data = httptools.downloadpage(item.url, headers=headers).data
data = re.sub('\n|\t', ' ', data)
data = re.sub(r'>\s+<', '> <', data)
url_video = scrapertoolsV2.find_single_match(data, r'<div class="item"> <a data-id="[^"]+" data-href="([^"]+)" data-original="[^"]+"[^>]+> <div> <div class="title">Episodio \d+', -1)
url_serie = scrapertoolsV2.find_single_match(data, r'<link rel="canonical" href="([^"]+)"\s?/>')
url_video = scrapertools.find_single_match(data, r'<div class="item"> <a data-id="[^"]+" data-href="([^"]+)" data-original="[^"]+"[^>]+> <div> <div class="title">Episodio \d+', -1)
url_serie = scrapertools.find_single_match(data, r'<link rel="canonical" href="([^"]+)"\s?/>')
goseries = support.typo(">> Vai alla Serie:", ' bold')
series = support.typo(item.contentSerieName, ' bold color kod')

View File

@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
from core import support, httptools, scrapertoolsV2
from core import support, httptools, scrapertools
from core.item import Item
from platformcode import config, logger
@@ -113,7 +113,7 @@ def episodios(item):
stagioni[st] = nEp
itemlist = []
domain, id = scrapertoolsV2.find_single_match(url, r'(https?://[a-z0-9.-]+)/[^/]+/([^-/]+)')
domain, id = scrapertools.find_single_match(url, r'(https?://[a-z0-9.-]+)/[^/]+/([^-/]+)')
for st in sorted(stagioni.keys()):
season = st[1:]
episode = stagioni[st]
@@ -140,7 +140,7 @@ def episodios(item):
def findvideos(item):
# support.dbg()
domain = scrapertoolsV2.find_single_match(item.url, 'https?://[a-z0-9.-]+')
domain = scrapertools.find_single_match(item.url, 'https?://[a-z0-9.-]+')
if item.contentType == 'movie':
id = item.url.split('/')[-1]
url = domain + '/play_f.php?f=' + id

View File

@@ -7,7 +7,7 @@ import re
import urlparse
from core import scrapertoolsV2, httptools, tmdb, support,servertools
from core import scrapertools, httptools, tmdb, support,servertools
from core.item import Item
from core.support import menu, log
from platformcode import logger
@@ -22,7 +22,7 @@ def findhost():
pass
# global host, headers
# permUrl = httptools.downloadpage('https://www.tantifilm.info/', follow_redirects=False).data
# host = scrapertoolsV2.find_single_match(permUrl, r'<h2 style="text-align: center;"><a href="([^"]+)">Il nuovo indirizzo di Tantifilm è:</a></h2>')
# host = scrapertools.find_single_match(permUrl, r'<h2 style="text-align: center;"><a href="([^"]+)">Il nuovo indirizzo di Tantifilm è:</a></h2>')
# if host.endswith('/'):
# host = host[:-1]
# headers = [['Referer', host]]
@@ -90,7 +90,7 @@ def episodios(item):
else:
data_check = item.data
patron_check = r'<iframe src="([^"]+)" scrolling="no" frameborder="0" width="626" height="550" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true">'
item.url = scrapertoolsV2.find_single_match(data_check, patron_check)
item.url = scrapertools.find_single_match(data_check, patron_check)
patronBlock = r'Stagioni<\/a>.*?<ul class="nav navbar-nav">(?P<block>.*?)<\/ul>'
patron = r'<a href="(?P<url>[^"]+)"\s*>\s*<i[^>]+><\/i>\s*(?P<episode>\d+)<\/a>'
@@ -105,8 +105,8 @@ def episodios(item):
season_data = httptools.downloadpage(item.url).data
season_data = re.sub('\n|\t', ' ', season_data)
season_data = re.sub(r'>\s+<', '> <', season_data)
block = scrapertoolsV2.find_single_match(season_data, 'Episodi.*?<ul class="nav navbar-nav">(.*?)</ul>')
episodes = scrapertoolsV2.find_multiple_matches(block, '<a href="([^"]+)"\s*>\s*<i[^>]+><\/i>\s*(\d+)<\/a>')
block = scrapertools.find_single_match(season_data, 'Episodi.*?<ul class="nav navbar-nav">(.*?)</ul>')
episodes = scrapertools.find_multiple_matches(block, '<a href="([^"]+)"\s*>\s*<i[^>]+><\/i>\s*(\d+)<\/a>')
for url, episode in episodes:
i = item.clone()
i.action = 'findvideos'
@@ -136,9 +136,9 @@ def anime(item):
seasons = support.match(item, r'<div class="sp-body[^"]+">(.*?)<\/div>')[0]
for season in seasons:
episodes = scrapertoolsV2.find_multiple_matches(season, r'<a.*?href="([^"]+)"[^>]+>([^<]+)<\/a>(.*?)<(:?br|\/p)')
episodes = scrapertools.find_multiple_matches(season, r'<a.*?href="([^"]+)"[^>]+>([^<]+)<\/a>(.*?)<(:?br|\/p)')
for url, title, urls, none in episodes:
urls = scrapertoolsV2.find_multiple_matches(urls, '<a.*?href="([^"]+)"[^>]+>')
urls = scrapertools.find_multiple_matches(urls, '<a.*?href="([^"]+)"[^>]+>')
for url2 in urls:
url += url2 + '\n'
@@ -192,8 +192,8 @@ def search(item, texto):
## for url, title, year, thumb, quality in matches:
## infoLabels = {}
## infoLabels['year'] = year
## title = scrapertoolsV2.decodeHtmlentities(title)
## quality = scrapertoolsV2.decodeHtmlentities(quality)
## title = scrapertools.decodeHtmlentities(title)
## quality = scrapertools.decodeHtmlentities(quality)
## longtitle = title + support.typo(quality,'_ [] color kod')
## itemlist.append(
## Item(channel=item.channel,
@@ -221,7 +221,7 @@ def newest(categoria):
matches = support.match(item, r'mediaWrapAlt recomended_videos"[^>]+>\s*<a href="([^"]+)" title="([^"]+)" rel="bookmark">\s*<img[^s]+src="([^"]+)"[^>]+>')[0]
for url, title, thumb in matches:
title = scrapertoolsV2.decodeHtmlentities(title).replace("Permalink to ", "").replace("streaming", "")
title = scrapertools.decodeHtmlentities(title).replace("Permalink to ", "").replace("streaming", "")
title = re.sub(r'\s\(\d+\)','',title)
itemlist.append(
Item(channel=item.channel,
@@ -250,7 +250,7 @@ def findvideos(item):
data = re.sub('\n|\t', ' ', data)
data = re.sub(r'>\s+<', '> <', data)
check = scrapertoolsV2.find_single_match(data, r'<div class="category-film">\s+<h3>\s+(.*?)\s+</h3>\s+</div>')
check = scrapertools.find_single_match(data, r'<div class="category-film">\s+<h3>\s+(.*?)\s+</h3>\s+</div>')
if 'sub' in check.lower():
item.contentLanguage = 'Sub-ITA'
support.log("CHECK : ", check)
@@ -265,7 +265,7 @@ def findvideos(item):
return episodios(item)
if 'protectlink' in data:
urls = scrapertoolsV2.find_multiple_matches(data, r'<iframe src="[^=]+=(.*?)"')
urls = scrapertools.find_multiple_matches(data, r'<iframe src="[^=]+=(.*?)"')
support.log("SONO QUI: ", urls)
for url in urls:
url = url.decode('base64')
@@ -273,7 +273,7 @@ def findvideos(item):
url, c = unshorten_only(url)
if 'nodmca' in url:
page = httptools.downloadpage(url, headers=headers).data
url = '\t' + scrapertoolsV2.find_single_match(page,'<meta name="og:url" content="([^=]+)">')
url = '\t' + scrapertools.find_single_match(page, '<meta name="og:url" content="([^=]+)">')
if url:
listurl.add(url)
return support.server(item, data=listurl if listurl else data)#, headers=headers)
@@ -286,7 +286,7 @@ def findvideos(item):
## data = item.url if item.contentType == "episode" else httptools.downloadpage(item.url, headers=headers).data
##
## if 'protectlink' in data:
## urls = scrapertoolsV2.find_multiple_matches(data, r'<iframe src="[^=]+=(.*?)"')
## urls = scrapertools.find_multiple_matches(data, r'<iframe src="[^=]+=(.*?)"')
## for url in urls:
## url = url.decode('base64')
## data += '\t' + url

View File

@@ -3,7 +3,7 @@
# Canale per vedohd
# ------------------------------------------------------------
from core import scrapertoolsV2, httptools, support
from core import scrapertools, httptools, support
from core.item import Item
from platformcode import logger, config
from specials import autoplay
@@ -47,7 +47,7 @@ def findvideos(item):
for link in support.dooplay_get_links(item, host):
if link['title'] != 'Trailer':
logger.info(link['title'])
server, quality = scrapertoolsV2.find_single_match(link['title'], '([^ ]+) ?(HD|3D)?')
server, quality = scrapertools.find_single_match(link['title'], '([^ ]+) ?(HD|3D)?')
if quality:
title = server + " [COLOR blue][" + quality + "][/COLOR]"
else:

View File

@@ -1,112 +0,0 @@
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------------
# Cloudflare decoder
# --------------------------------------------------------------------------------
import re
import time
import urllib
import urlparse
from platformcode import logger
class Cloudflare:
def __init__(self, response):
self.timeout = 5
self.domain = urlparse.urlparse(response["url"])[1]
self.protocol = urlparse.urlparse(response["url"])[0]
self.js_data = {}
self.header_data = {}
if not "var s,t,o,p,b,r,e,a,k,i,n,g,f" in response["data"] or "chk_jschl" in response["url"]:
return
try:
self.js_data["data"] = response["data"]
self.js_data["auth_url"] = \
re.compile('<form id="challenge-form" action="([^"]+)" method="get">').findall(response["data"])[0]
self.js_data["params"] = {}
self.js_data["params"]["jschl_vc"] = \
re.compile('<input type="hidden" name="jschl_vc" value="([^"]+)"/>').findall(response["data"])[0]
self.js_data["params"]["pass"] = \
re.compile('<input type="hidden" name="pass" value="([^"]+)"/>').findall(response["data"])[0]
self.js_data["wait"] = int(re.compile("\}, ([\d]+)\);", re.MULTILINE).findall(response["data"])[0]) / 1000
self.js_data["params"]["s"] = \
re.compile('<input type="hidden" name="s" value="([^"]+)"').findall(response["data"])[0]
except:
logger.debug("Metodo #1 (javascript): NO disponible")
self.js_data = {}
if "refresh" in response["headers"]:
try:
self.header_data["wait"] = int(response["headers"]["refresh"].split(";")[0])
self.header_data["auth_url"] = response["headers"]["refresh"].split("=")[1].split("?")[0]
self.header_data["params"] = {}
self.header_data["params"]["pass"] = response["headers"]["refresh"].split("=")[2]
except:
logger.debug("Metodo #2 (headers): NO disponible")
self.header_data = {}
def solve_cf(self, body, domain):
js = re.search(
r"setTimeout\(function\(\){\s+(var s,t,o,p,b,r,e,a,k,i,n,g,f.+?\r?\n[\s\S]+?a\.value =.+?)\r?\n",
body
).group(1)
js = re.sub(r"a\.value = ((.+).toFixed\(10\))?", r"\1", js)
js = re.sub(r'(e\s=\sfunction\(s\)\s{.*?};)', '', js, flags=re.DOTALL|re.MULTILINE)
js = re.sub(r"\s{3,}[a-z](?: = |\.).+", "", js).replace("t.length", str(len(domain)))
js = js.replace('; 121', '')
js = re.sub(r"[\n\\']", "", js)
jsEnv = """
var t = "{domain}";
var g = String.fromCharCode;
o = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
e = function(s) {{
s += "==".slice(2 - (s.length & 3));
var bm, r = "", r1, r2, i = 0;
for (; i < s.length;) {{
bm = o.indexOf(s.charAt(i++)) << 18 | o.indexOf(s.charAt(i++)) << 12 | (r1 = o.indexOf(s.charAt(i++))) << 6 | (r2 = o.indexOf(s.charAt(i++)));
r += r1 === 64 ? g(bm >> 16 & 255) : r2 === 64 ? g(bm >> 16 & 255, bm >> 8 & 255) : g(bm >> 16 & 255, bm >> 8 & 255, bm & 255);
}}
return r;
}};
function italics (str) {{ return '<i>' + this + '</i>'; }};
var document = {{
getElementById: function () {{
return {{'innerHTML': '{innerHTML}'}};
}}
}};
{js}
"""
innerHTML = re.search('<div(?: [^<>]*)? id="([^<>]*?)">([^<>]*?)<\/div>', body , re.MULTILINE | re.DOTALL)
innerHTML = innerHTML.group(2).replace("'", r"\'") if innerHTML else ""
import js2py
from jsc import jsunc
js = jsunc(jsEnv.format(domain=domain, innerHTML=innerHTML, js=js))
def atob(s):
return base64.b64decode('{}'.format(s)).decode('utf-8')
js2py.disable_pyimport()
context = js2py.EvalJs({'atob': atob})
result = context.eval(js)
return float(result)
@property
def wait_time(self):
if self.js_data.get("wait", 0):
return self.js_data["wait"]
else:
return self.header_data.get("wait", 0)
@property
def is_cloudflare(self):
return self.header_data.get("wait", 0) > 0 or self.js_data.get("wait", 0) > 0
def get_url(self):
# Metodo #1 (javascript)
if self.js_data.get("wait", 0):
self.js_data["params"]["jschl_answer"] = self.solve_cf(self.js_data["data"], self.domain)
response = "%s://%s%s?%s" % (
self.protocol, self.domain, self.js_data["auth_url"], urllib.urlencode(self.js_data["params"]))
time.sleep(self.js_data["wait"])
return response

View File

@@ -17,7 +17,7 @@ from threading import Lock
from core.jsontools import to_utf8
from platformcode import config, logger
from platformcode.logger import WebErrorException
from core import scrapertoolsV2
from core import scrapertools
# Get the addon version
__version = config.get_addon_version()
@@ -48,7 +48,7 @@ def get_user_agent():
def get_url_headers(url, forced=False):
domain = urlparse.urlparse(url)[1]
sub_dom = scrapertoolsV2.find_single_match(domain, r'\.(.*?\.\w+)')
sub_dom = scrapertools.find_single_match(domain, r'\.(.*?\.\w+)')
if sub_dom and not 'google' in url:
domain = sub_dom
domain_cookies = cj._cookies.get("." + domain, {}).get("/", {})
@@ -159,16 +159,16 @@ def channel_proxy_list(url, forced_proxy=None):
if not url.endswith('/'):
url += '/'
if scrapertoolsV2.find_single_match(url, r'(?:http.*\:)?\/\/(?:www\.)?([^\?|\/]+)(?:\?|\/)') \
if scrapertools.find_single_match(url, r'(?:http.*\:)?\/\/(?:www\.)?([^\?|\/]+)(?:\?|\/)') \
in proxy_channel_bloqued:
if forced_proxy and forced_proxy not in ['Total', 'ProxyDirect', 'ProxyCF', 'ProxyWeb']:
if forced_proxy in proxy_channel_bloqued[scrapertoolsV2.find_single_match(url, r'(?:http.*\:)?\/\/(?:www\.)?([^\?|\/]+)(?:\?|\/)')]:
if forced_proxy in proxy_channel_bloqued[scrapertools.find_single_match(url, r'(?:http.*\:)?\/\/(?:www\.)?([^\?|\/]+)(?:\?|\/)')]:
return True
else:
return False
if forced_proxy:
return True
if not 'OFF' in proxy_channel_bloqued[scrapertoolsV2.find_single_match(url, r'(?:http.*\:)?\/\/(?:www\.)?([^\?|\/]+)(?:\?|\/)')]:
if not 'OFF' in proxy_channel_bloqued[scrapertools.find_single_match(url, r'(?:http.*\:)?\/\/(?:www\.)?([^\?|\/]+)(?:\?|\/)')]:
return True
return False
@@ -248,7 +248,7 @@ def check_proxy(url, **opt):
proxy_data['log'] = proxytools.get_proxy_addr(url, post=opt.get('post', None), forced_proxy=forced_proxy)
if proxy_addr_forced and proxy_data['log']:
proxy_data['log'] = scrapertoolsV2.find_single_match(str(proxy_addr_forced), r"{'http.*':\s*'(.*?)'}")
proxy_data['log'] = scrapertools.find_single_match(str(proxy_addr_forced), r"{'http.*':\s*'(.*?)'}")
if proxy and proxy_data['addr']:
if proxy_addr_forced: proxy_data['addr'] = proxy_addr_forced
@@ -564,7 +564,7 @@ def downloadpage(url, **opt):
save_cookies(alfa_s=opt.get('alfa_s', False))
# is_channel = inspect.getmodule(inspect.currentframe().f_back)
# is_channel = scrapertoolsV2.find_single_match(str(is_channel), "<module '(channels).*?'")
# is_channel = scrapertools.find_single_match(str(is_channel), "<module '(channels).*?'")
# if is_channel and isinstance(response_code, int):
# if not opt.get('ignore_response_code', False) and not proxy_data.get('stat', ''):
# if response_code > 399:

View File

@@ -1,27 +1,17 @@
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------------
# Scraper tools for reading and processing web elements
# Scraper tools v2 for reading and processing web elements
# --------------------------------------------------------------------------------
import re
import time
from core import httptools
import urlparse
from core.entities import html5
from platformcode import logger
def get_header_from_response(url, header_to_get="", post=None, headers=None):
header_to_get = header_to_get.lower()
response = httptools.downloadpage(url, post=post, headers=headers, only_headers=True)
return response.headers.get(header_to_get)
def read_body_and_headers(url, post=None, headers=None, follow_redirects=False, timeout=None):
response = httptools.downloadpage(url, post=post, headers=headers, follow_redirects=follow_redirects,
timeout=timeout)
return response.data, response.headers
def printMatches(matches):
i = 0
for match in matches:
@@ -42,8 +32,37 @@ def find_multiple_matches(text, pattern):
return re.findall(pattern, text, re.DOTALL)
def entityunescape(cadena):
return unescape(cadena)
def find_multiple_matches_groups(text, pattern):
r = re.compile(pattern)
return [m.groupdict() for m in r.finditer(text)]
# Convierte los codigos html "&ntilde;" y lo reemplaza por "ñ" caracter unicode utf-8
def decodeHtmlentities(data):
entity_re = re.compile("&(#?)(\d{1,5}|\w{1,8})(;?)")
def substitute_entity(match):
ent = match.group(2) + match.group(3)
res = ""
while not ent in html5 and not ent.endswith(";") and match.group(1) != "#":
# Excepción para cuando '&' se usa como argumento en la urls contenidas en los datos
try:
res = ent[-1] + res
ent = ent[:-1]
except:
break
if match.group(1) == "#":
ent = unichr(int(ent.replace(";", "")))
return ent.encode('utf-8')
else:
cp = html5.get(ent)
if cp:
return cp.decode("unicode-escape").encode('utf-8') + res
else:
return match.group()
return entity_re.subn(substitute_entity, data)[0]
def unescape(text):
@@ -84,47 +103,6 @@ def unescape(text):
# Convierte los codigos html "&ntilde;" y lo reemplaza por "ñ" caracter unicode utf-8
def decodeHtmlentities(string):
string = entitiesfix(string)
entity_re = re.compile("&(#?)(\d{1,5}|\w{1,8});")
def substitute_entity(match):
from htmlentitydefs import name2codepoint as n2cp
ent = match.group(2)
if match.group(1) == "#":
return unichr(int(ent)).encode('utf-8')
else:
cp = n2cp.get(ent)
if cp:
return unichr(cp).encode('utf-8')
else:
return match.group()
return entity_re.subn(substitute_entity, string)[0]
def entitiesfix(string):
# Las entidades comienzan siempre con el símbolo & , y terminan con un punto y coma ( ; ).
string = string.replace("&aacute", "&aacute;")
string = string.replace("&eacute", "&eacute;")
string = string.replace("&iacute", "&iacute;")
string = string.replace("&oacute", "&oacute;")
string = string.replace("&uacute", "&uacute;")
string = string.replace("&Aacute", "&Aacute;")
string = string.replace("&Eacute", "&Eacute;")
string = string.replace("&Iacute", "&Iacute;")
string = string.replace("&Oacute", "&Oacute;")
string = string.replace("&Uacute", "&Uacute;")
string = string.replace("&uuml", "&uuml;")
string = string.replace("&Uuml", "&Uuml;")
string = string.replace("&ntilde", "&ntilde;")
string = string.replace("&#191", "&#191;")
string = string.replace("&#161", "&#161;")
string = string.replace(";;", ";")
return string
def htmlclean(cadena):
cadena = re.compile("<!--.*?-->", re.DOTALL).sub("", cadena)
@@ -226,7 +204,7 @@ def htmlclean(cadena):
cadena = re.compile("<link[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("\t", "")
cadena = entityunescape(cadena)
# cadena = entityunescape(cadena)
return cadena
@@ -314,8 +292,8 @@ def remove_show_from_title(title, show):
return title
# scrapertools.get_filename_from_url(media_url)[-4:]
def get_filename_from_url(url):
import urlparse
parsed_url = urlparse.urlparse(url)
try:
filename = parsed_url.path
@@ -332,19 +310,18 @@ def get_filename_from_url(url):
return filename
# def get_domain_from_url(url):
# import urlparse
# parsed_url = urlparse.urlparse(url)
# try:
# filename = parsed_url.netloc
# except:
# # Si falla es porque la implementación de parsed_url no reconoce los atributos como "path"
# if len(parsed_url) >= 4:
# filename = parsed_url[1]
# else:
# filename = ""
#
# return filename
def get_domain_from_url(url):
parsed_url = urlparse.urlparse(url)
try:
filename = parsed_url.netloc
except:
# Si falla es porque la implementación de parsed_url no reconoce los atributos como "path"
if len(parsed_url) >= 4:
filename = parsed_url[1]
else:
filename = ""
return filename
def get_season_and_episode(title):
@@ -365,22 +342,15 @@ def get_season_and_episode(title):
@return: Numero de temporada y episodio en formato "1x01" o cadena vacia si no se han encontrado
"""
filename = ""
# 4l3x87 - fix for series example 9-1-1
# original_title = title
# title = title.replace('9-1-1','')
patrons = ["(\d+)\s*[x-]\s*(\d+)", "(\d+)\s*×\s*(\d+)", "(?:s|t)(\d+)e(\d+)",
"(?:season|temp|stagione\w*)\s*(\d+)\s*(?:capitulo|epi|episode|episodio\w*)\s*(\d+)"]
patrons = ["(\d+)x(\d+)", "(?:s|t)(\d+)e(\d+)",
"(?:season|temp\w*)\s*(\d+)\s*(?:capitulo|epi\w*)\s*(\d+)"]
for patron in patrons:
try:
matches = re.compile(patron, re.I).search(title)
if matches:
if len(matches.group(1)) == 1:
filename = matches.group(1) + "x" + matches.group(2).zfill(2)
else:
filename = matches.group(1).lstrip('0') + "x" + matches.group(2).zfill(2)
filename = matches.group(1) + "x" + matches.group(2).zfill(2)
break
except:
pass
@@ -388,3 +358,27 @@ def get_season_and_episode(title):
logger.info("'" + title + "' -> '" + filename + "'")
return filename
def get_sha1(cadena):
try:
import hashlib
devuelve = hashlib.sha1(cadena).hexdigest()
except:
import sha
import binascii
devuelve = binascii.hexlify(sha.new(cadena).digest())
return devuelve
def get_md5(cadena):
try:
import hashlib
devuelve = hashlib.md5(cadena).hexdigest()
except:
import md5
import binascii
devuelve = binascii.hexlify(md5.new(cadena).digest())
return devuelve

View File

@@ -1,346 +0,0 @@
# -*- coding: utf-8 -*-
# --------------------------------------------------------------------------------
# Scraper tools v2 for reading and processing web elements
# --------------------------------------------------------------------------------
import re
import time
import urlparse
from core.entities import html5
from platformcode import logger
def printMatches(matches):
i = 0
for match in matches:
logger.info("%d %s" % (i, match))
i = i + 1
def find_single_match(data, patron, index=0):
try:
matches = re.findall(patron, data, flags=re.DOTALL)
return matches[index]
except:
return ""
# Parse string and extracts multiple matches using regular expressions
def find_multiple_matches(text, pattern):
return re.findall(pattern, text, re.DOTALL)
def find_multiple_matches_groups(text, pattern):
r = re.compile(pattern)
return [m.groupdict() for m in r.finditer(text)]
# Convierte los codigos html "&ntilde;" y lo reemplaza por "ñ" caracter unicode utf-8
def decodeHtmlentities(data):
entity_re = re.compile("&(#?)(\d{1,5}|\w{1,8})(;?)")
def substitute_entity(match):
ent = match.group(2) + match.group(3)
res = ""
while not ent in html5 and not ent.endswith(";") and match.group(1) != "#":
# Excepción para cuando '&' se usa como argumento en la urls contenidas en los datos
try:
res = ent[-1] + res
ent = ent[:-1]
except:
break
if match.group(1) == "#":
ent = unichr(int(ent.replace(";", "")))
return ent.encode('utf-8')
else:
cp = html5.get(ent)
if cp:
return cp.decode("unicode-escape").encode('utf-8') + res
else:
return match.group()
return entity_re.subn(substitute_entity, data)[0]
def htmlclean(cadena):
cadena = re.compile("<!--.*?-->", re.DOTALL).sub("", cadena)
cadena = cadena.replace("<center>", "")
cadena = cadena.replace("</center>", "")
cadena = cadena.replace("<cite>", "")
cadena = cadena.replace("</cite>", "")
cadena = cadena.replace("<em>", "")
cadena = cadena.replace("</em>", "")
cadena = cadena.replace("<u>", "")
cadena = cadena.replace("</u>", "")
cadena = cadena.replace("<li>", "")
cadena = cadena.replace("</li>", "")
cadena = cadena.replace("<turl>", "")
cadena = cadena.replace("</tbody>", "")
cadena = cadena.replace("<tr>", "")
cadena = cadena.replace("</tr>", "")
cadena = cadena.replace("<![CDATA[", "")
cadena = cadena.replace("<wbr>", "")
cadena = cadena.replace("<Br />", " ")
cadena = cadena.replace("<BR />", " ")
cadena = cadena.replace("<Br>", " ")
cadena = re.compile("<br[^>]*>", re.DOTALL).sub(" ", cadena)
cadena = re.compile("<script.*?</script>", re.DOTALL).sub("", cadena)
cadena = re.compile("<option[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</option>", "")
cadena = re.compile("<button[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</button>", "")
cadena = re.compile("<i[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</iframe>", "")
cadena = cadena.replace("</i>", "")
cadena = re.compile("<table[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</table>", "")
cadena = re.compile("<td[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</td>", "")
cadena = re.compile("<div[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</div>", "")
cadena = re.compile("<dd[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</dd>", "")
cadena = re.compile("<b[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</b>", "")
cadena = re.compile("<font[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</font>", "")
cadena = re.compile("<strong[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</strong>", "")
cadena = re.compile("<small[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</small>", "")
cadena = re.compile("<span[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</span>", "")
cadena = re.compile("<a[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</a>", "")
cadena = re.compile("<p[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</p>", "")
cadena = re.compile("<ul[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</ul>", "")
cadena = re.compile("<h1[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</h1>", "")
cadena = re.compile("<h2[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</h2>", "")
cadena = re.compile("<h3[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</h3>", "")
cadena = re.compile("<h4[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</h4>", "")
cadena = re.compile("<!--[^-]+-->", re.DOTALL).sub("", cadena)
cadena = re.compile("<img[^>]*>", re.DOTALL).sub("", cadena)
cadena = re.compile("<object[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</object>", "")
cadena = re.compile("<param[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</param>", "")
cadena = re.compile("<embed[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</embed>", "")
cadena = re.compile("<title[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("</title>", "")
cadena = re.compile("<link[^>]*>", re.DOTALL).sub("", cadena)
cadena = cadena.replace("\t", "")
# cadena = entityunescape(cadena)
return cadena
def slugify(title):
# print title
# Sustituye acentos y eñes
title = title.replace("Á", "a")
title = title.replace("É", "e")
title = title.replace("Í", "i")
title = title.replace("Ó", "o")
title = title.replace("Ú", "u")
title = title.replace("á", "a")
title = title.replace("é", "e")
title = title.replace("í", "i")
title = title.replace("ó", "o")
title = title.replace("ú", "u")
title = title.replace("À", "a")
title = title.replace("È", "e")
title = title.replace("Ì", "i")
title = title.replace("Ò", "o")
title = title.replace("Ù", "u")
title = title.replace("à", "a")
title = title.replace("è", "e")
title = title.replace("ì", "i")
title = title.replace("ò", "o")
title = title.replace("ù", "u")
title = title.replace("ç", "c")
title = title.replace("Ç", "C")
title = title.replace("Ñ", "n")
title = title.replace("ñ", "n")
title = title.replace("/", "-")
title = title.replace("&amp;", "&")
# Pasa a minúsculas
title = title.lower().strip()
# Elimina caracteres no válidos
validchars = "abcdefghijklmnopqrstuvwxyz1234567890- "
title = ''.join(c for c in title if c in validchars)
# Sustituye espacios en blanco duplicados y saltos de línea
title = re.compile("\s+", re.DOTALL).sub(" ", title)
# Sustituye espacios en blanco por guiones
title = re.compile("\s", re.DOTALL).sub("-", title.strip())
# Sustituye espacios en blanco duplicados y saltos de línea
title = re.compile("\-+", re.DOTALL).sub("-", title)
# Arregla casos especiales
if title.startswith("-"):
title = title[1:]
if title == "":
title = "-" + str(time.time())
return title
def remove_htmltags(string):
return re.sub('<[^<]+?>', '', string)
def remove_show_from_title(title, show):
# print slugify(title)+" == "+slugify(show)
# Quita el nombre del programa del título
if slugify(title).startswith(slugify(show)):
# Convierte a unicode primero, o el encoding se pierde
title = unicode(title, "utf-8", "replace")
show = unicode(show, "utf-8", "replace")
title = title[len(show):].strip()
if title.startswith("-"):
title = title[1:].strip()
if title == "":
title = str(time.time())
# Vuelve a utf-8
title = title.encode("utf-8", "ignore")
show = show.encode("utf-8", "ignore")
return title
# scrapertools.get_filename_from_url(media_url)[-4:]
def get_filename_from_url(url):
parsed_url = urlparse.urlparse(url)
try:
filename = parsed_url.path
except:
# Si falla es porque la implementación de parsed_url no reconoce los atributos como "path"
if len(parsed_url) >= 4:
filename = parsed_url[2]
else:
filename = ""
if "/" in filename:
filename = filename.split("/")[-1]
return filename
def get_domain_from_url(url):
parsed_url = urlparse.urlparse(url)
try:
filename = parsed_url.netloc
except:
# Si falla es porque la implementación de parsed_url no reconoce los atributos como "path"
if len(parsed_url) >= 4:
filename = parsed_url[1]
else:
filename = ""
return filename
def get_season_and_episode(title):
"""
Retorna el numero de temporada y de episodio en formato "1x01" obtenido del titulo de un episodio
Ejemplos de diferentes valores para title y su valor devuelto:
"serie 101x1.strm", "s101e1.avi", "t101e1.avi" -> '101x01'
"Name TvShow 1x6.avi" -> '1x06'
"Temp 3 episodio 2.avi" -> '3x02'
"Alcantara season 13 episodie 12.avi" -> '13x12'
"Temp1 capitulo 14" -> '1x14'
"Temporada 1: El origen Episodio 9" -> '' (entre el numero de temporada y los episodios no puede haber otro texto)
"Episodio 25: titulo episodio" -> '' (no existe el numero de temporada)
"Serie X Temporada 1" -> '' (no existe el numero del episodio)
@type title: str
@param title: titulo del episodio de una serie
@rtype: str
@return: Numero de temporada y episodio en formato "1x01" o cadena vacia si no se han encontrado
"""
filename = ""
patrons = ["(\d+)x(\d+)", "(?:s|t)(\d+)e(\d+)",
"(?:season|temp\w*)\s*(\d+)\s*(?:capitulo|epi\w*)\s*(\d+)"]
for patron in patrons:
try:
matches = re.compile(patron, re.I).search(title)
if matches:
filename = matches.group(1) + "x" + matches.group(2).zfill(2)
break
except:
pass
logger.info("'" + title + "' -> '" + filename + "'")
return filename
def get_sha1(cadena):
try:
import hashlib
devuelve = hashlib.sha1(cadena).hexdigest()
except:
import sha
import binascii
devuelve = binascii.hexlify(sha.new(cadena).digest())
return devuelve
def get_md5(cadena):
try:
import hashlib
devuelve = hashlib.md5(cadena).hexdigest()
except:
import md5
import binascii
devuelve = binascii.hexlify(md5.new(cadena).digest())
return devuelve

View File

@@ -506,8 +506,8 @@ def get_server_json(server_name):
def get_server_host(server_name):
from core import scrapertoolsV2
return [scrapertoolsV2.get_domain_from_url(pattern['url']) for pattern in get_server_json(server_name)['find_videos']['patterns']]
from core import scrapertools
return [scrapertools.get_domain_from_url(pattern['url']) for pattern in get_server_json(server_name)['find_videos']['patterns']]
def get_server_controls_settings(server_name):

View File

@@ -10,7 +10,7 @@ import urlparse
import xbmcaddon
from channelselector import thumb
from core import httptools, scrapertoolsV2, servertools, tmdb, channeltools
from core import httptools, scrapertools, servertools, tmdb, channeltools
from core.item import Item
from lib import unshortenit
from platformcode import logger, config
@@ -21,7 +21,7 @@ def hdpass_get_servers(item):
itemlist = []
data = httptools.downloadpage(item.url).data.replace('\n', '')
patron = r'<iframe(?: id="[^"]+")? width="[^"]+" height="[^"]+" src="([^"]+)"[^>]+><\/iframe>'
url = scrapertoolsV2.find_single_match(data, patron).replace("?alta", "")
url = scrapertools.find_single_match(data, patron).replace("?alta", "")
url = url.replace("&download=1", "")
if 'https' not in url:
url = 'https:' + url
@@ -37,20 +37,20 @@ def hdpass_get_servers(item):
patron_mir = '<div class="row mobileMirrs">(.*?)</div>'
patron_media = r'<input type="hidden" name="urlEmbed" data-mirror="([^"]+)" id="urlEmbed"\s*value="([^"]+)"\s*/>'
res = scrapertoolsV2.find_single_match(data, patron_res)
res = scrapertools.find_single_match(data, patron_res)
itemlist = []
for res_url, res_video in scrapertoolsV2.find_multiple_matches(res, '<option.*?value="([^"]+?)">([^<]+?)</option>'):
for res_url, res_video in scrapertools.find_multiple_matches(res, '<option.*?value="([^"]+?)">([^<]+?)</option>'):
data = httptools.downloadpage(urlparse.urljoin(url, res_url)).data.replace('\n', '')
mir = scrapertoolsV2.find_single_match(data, patron_mir)
mir = scrapertools.find_single_match(data, patron_mir)
for mir_url, srv in scrapertoolsV2.find_multiple_matches(mir, '<option.*?value="([^"]+?)">([^<]+?)</value>'):
for mir_url, srv in scrapertools.find_multiple_matches(mir, '<option.*?value="([^"]+?)">([^<]+?)</value>'):
data = httptools.downloadpage(urlparse.urljoin(url, mir_url)).data.replace('\n', '')
for media_label, media_url in scrapertoolsV2.find_multiple_matches(data, patron_media):
for media_label, media_url in scrapertools.find_multiple_matches(data, patron_media):
itemlist.append(Item(channel=item.channel,
action="play",
fulltitle=item.fulltitle,
@@ -168,13 +168,13 @@ def scrapeLang(scraped, lang, longtitle):
return language, longtitle
def cleantitle(title):
cleantitle = scrapertoolsV2.htmlclean(scrapertoolsV2.decodeHtmlentities(title).replace('"', "'").replace('×', 'x').replace('', '-')).strip()
cleantitle = scrapertools.htmlclean(scrapertools.decodeHtmlentities(title).replace('"', "'").replace('×', 'x').replace('', '-')).strip()
return cleantitle
def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, typeContentDict, typeActionDict, blacklist, search, pag, function, lang):
itemlist = []
log("scrapeBlock qui", block, patron)
matches = scrapertoolsV2.find_multiple_matches_groups(block, patron)
matches = scrapertools.find_multiple_matches_groups(block, patron)
log('MATCHES =', matches)
if debug:
@@ -214,7 +214,7 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
for kk in known_keys:
val = match[listGroups.index(kk)] if kk in listGroups else ''
if val and (kk == "url" or kk == 'thumb') and 'http' not in val:
val = scrapertoolsV2.find_single_match(item.url, 'https?://[a-z0-9.-]+') + val
val = scrapertools.find_single_match(item.url, 'https?://[a-z0-9.-]+') + val
scraped[kk] = val
if scraped['season']:
@@ -227,7 +227,7 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
episode = ''
else:
episode = re.sub(r'\s-\s|-|x|&#8211|&#215;|×', 'x', scraped['episode']) if scraped['episode'] else ''
second_episode = scrapertoolsV2.find_single_match(episode,'x\d+x(\d+)')
second_episode = scrapertools.find_single_match(episode, 'x\d+x(\d+)')
if second_episode: episode = re.sub(r'(\d+x\d+)x\d+',r'\1-', episode) + second_episode.zfill(2)
#episode = re.sub(r'\s-\s|-|x|&#8211|&#215;', 'x', scraped['episode']) if scraped['episode'] else ''
@@ -257,18 +257,18 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
if scraped["plot"]:
infolabels['plot'] = plot
if scraped['duration']:
matches = scrapertoolsV2.find_multiple_matches(scraped['duration'],
matches = scrapertools.find_multiple_matches(scraped['duration'],
r'([0-9])\s*?(?:[hH]|:|\.|,|\\|\/|\||\s)\s*?([0-9]+)')
for h, m in matches:
scraped['duration'] = int(h) * 60 + int(m)
if not matches:
scraped['duration'] = scrapertoolsV2.find_single_match(scraped['duration'], r'(\d+)')
scraped['duration'] = scrapertools.find_single_match(scraped['duration'], r'(\d+)')
infolabels['duration'] = int(scraped['duration']) * 60
if scraped['genere']:
genres = scrapertoolsV2.find_multiple_matches(scraped['genere'], '[A-Za-z]+')
genres = scrapertools.find_multiple_matches(scraped['genere'], '[A-Za-z]+')
infolabels['genere'] = ", ".join(genres)
if scraped["rating"]:
infolabels['rating'] = scrapertoolsV2.decodeHtmlentities(scraped["rating"])
infolabels['rating'] = scrapertools.decodeHtmlentities(scraped["rating"])
AC = CT = ''
if typeContentDict:
@@ -379,11 +379,11 @@ def scrape(func):
if not data:
page = httptools.downloadpage(item.url, headers=headers, ignore_response_code=True, session=item.session)
# if url may be changed and channel has findhost to update
if (not page.data or scrapertoolsV2.get_domain_from_url(page.url) != scrapertoolsV2.get_domain_from_url(item.url)) and 'findhost' in func.__globals__:
if (not page.data or scrapertools.get_domain_from_url(page.url) != scrapertools.get_domain_from_url(item.url)) and 'findhost' in func.__globals__:
host = func.__globals__['findhost']()
from core import jsontools
jsontools.update_node(host, func.__module__.split('.')[-1], 'url')
item.url = item.url.replace(scrapertoolsV2.get_domain_from_url(item.url), scrapertoolsV2.get_domain_from_url(host))
item.url = item.url.replace(scrapertools.get_domain_from_url(item.url), scrapertools.get_domain_from_url(host))
page = httptools.downloadpage(item.url, headers=headers, ignore_response_code=True,
session=item.session)
data = page.data.replace("'", '"')
@@ -394,7 +394,7 @@ def scrape(func):
if patronBlock:
if debugBlock:
regexDbg(item, patronBlock, headers, data)
blocks = scrapertoolsV2.find_multiple_matches_groups(data, patronBlock)
blocks = scrapertools.find_multiple_matches_groups(data, patronBlock)
block = ""
for bl in blocks:
# log(len(blocks),bl)
@@ -443,7 +443,7 @@ def scrape(func):
if anime:
if function == 'episodios' or item.action == 'episodios': autorenumber.renumber(itemlist, item, 'bold')
else: autorenumber.renumber(itemlist)
if anime and autorenumber.check(item) == False and not scrapertoolsV2.find_single_match(itemlist[0].title, r'(\d+.\d+)'):
if anime and autorenumber.check(item) == False and not scrapertools.find_single_match(itemlist[0].title, r'(\d+.\d+)'):
pass
else:
if addVideolibrary and (item.infoLabels["title"] or item.fulltitle):
@@ -471,7 +471,7 @@ def dooplay_get_links(item, host):
data = httptools.downloadpage(item.url).data.replace("'", '"')
patron = r'<li id="player-option-[0-9]".*?data-type="([^"]+)" data-post="([^"]+)" data-nume="([^"]+)".*?<span class="title".*?>([^<>]+)</span>(?:<span class="server">([^<>]+))?'
matches = scrapertoolsV2.find_multiple_matches(data, patron)
matches = scrapertools.find_multiple_matches(data, patron)
ret = []
@@ -483,7 +483,7 @@ def dooplay_get_links(item, host):
"type": type
})
dataAdmin = httptools.downloadpage(host + '/wp-admin/admin-ajax.php', post=postData,headers={'Referer': item.url}).data
link = scrapertoolsV2.find_single_match(dataAdmin, "<iframe.*src='([^']+)'")
link = scrapertools.find_single_match(dataAdmin, "<iframe.*src='([^']+)'")
ret.append({
'url': link,
'title': title,
@@ -560,25 +560,25 @@ def swzz_get_url(item):
if "/link/" in item.url:
data = httptools.downloadpage(item.url, headers=headers).data
if "link =" in data:
data = scrapertoolsV2.find_single_match(data, 'link = "([^"]+)"')
data = scrapertools.find_single_match(data, 'link = "([^"]+)"')
if 'http' not in data:
data = 'https:' + data
else:
match = scrapertoolsV2.find_single_match(data, r'<meta name="og:url" content="([^"]+)"')
match = scrapertoolsV2.find_single_match(data, r'URL=([^"]+)">') if not match else match
match = scrapertools.find_single_match(data, r'<meta name="og:url" content="([^"]+)"')
match = scrapertools.find_single_match(data, r'URL=([^"]+)">') if not match else match
if not match:
from lib import jsunpack
try:
data = scrapertoolsV2.find_single_match(data.replace('\n', ''), r"(eval\s?\(function\(p,a,c,k,e,d.*?)</script>")
data = scrapertools.find_single_match(data.replace('\n', ''), r"(eval\s?\(function\(p,a,c,k,e,d.*?)</script>")
data = jsunpack.unpack(data)
logger.debug("##### play /link/ unpack ##\n%s\n##" % data)
except:
logger.debug("##### The content is yet unpacked ##\n%s\n##" % data)
data = scrapertoolsV2.find_single_match(data, r'var link(?:\s)?=(?:\s)?"([^"]+)";')
data = scrapertools.find_single_match(data, r'var link(?:\s)?=(?:\s)?"([^"]+)";')
data, c = unshortenit.unwrap_30x_only(data)
else:
data = match
@@ -753,7 +753,7 @@ def typo(string, typography=''):
if 'submenu' in string:
string = u"\u2022\u2022 ".encode('utf-8') + re.sub(r'\ssubmenu','',string)
if 'color' in string:
color = scrapertoolsV2.find_single_match(string,'color ([a-z]+)')
color = scrapertools.find_single_match(string, 'color ([a-z]+)')
if color == 'kod' or '': color = kod_color
string = '[COLOR '+ color +']' + re.sub(r'\scolor\s([a-z]+)','',string) + '[/COLOR]'
if 'bold' in string:
@@ -785,13 +785,13 @@ def match(item, patron='', patronBlock='', headers='', url='', post=''):
log('DATA= ', data)
if patronBlock:
block = scrapertoolsV2.find_single_match(data, patronBlock)
block = scrapertools.find_single_match(data, patronBlock)
log('BLOCK= ',block)
else:
block = data
if patron:
matches = scrapertoolsV2.find_multiple_matches(block, patron)
matches = scrapertools.find_multiple_matches(block, patron)
log('MATCHES= ',matches)
return matches, block
@@ -899,12 +899,12 @@ def nextPage(itemlist, item, data='', patron='', function_or_level=1, next_page=
# If the call is direct, leave it blank
action = inspect.stack()[function_or_level][3] if type(function_or_level) == int else function_or_level
if next_page == '':
next_page = scrapertoolsV2.find_single_match(data, patron)
next_page = scrapertools.find_single_match(data, patron)
if next_page != "":
if resub: next_page = re.sub(resub[0], resub[1], next_page)
if 'http' not in next_page:
next_page = scrapertoolsV2.find_single_match(item.url, 'https?://[a-z0-9.-]+') + next_page
next_page = scrapertools.find_single_match(item.url, 'https?://[a-z0-9.-]+') + next_page
next_page = re.sub('&amp;', '&',next_page)
log('NEXT= ', next_page)
itemlist.append(

View File

@@ -20,7 +20,7 @@ import xbmcplugin
from channelselector import get_thumb
from core import channeltools
from core import trakt_tools, scrapertoolsV2
from core import trakt_tools, scrapertools
from core.item import Item
from platformcode import logger, keymaptools
from platformcode import unify
@@ -799,7 +799,7 @@ def get_seleccion(default_action, opciones, seleccion, video_urls):
def calcResolution(option):
match = scrapertoolsV2.find_single_match(option, '([0-9]{2,4})x([0-9]{2,4})')
match = scrapertools.find_single_match(option, '([0-9]{2,4})x([0-9]{2,4})')
resolution = False
if match:
resolution = int(match[0])*int(match[1])

View File

@@ -2,7 +2,7 @@
# Ringraziamo errmax e dr-z3r0
import re
from core import httptools, scrapertoolsV2
from core import httptools, scrapertools
from platformcode import logger
from servers.decrypters import expurl
@@ -62,10 +62,10 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
if '/olink/' in url: continue
else:
idata = httptools.downloadpage(url).data
data = scrapertoolsV2.find_single_match(idata, "<iframe[^<>]*src=\\'([^'>]*)\\'[^<>]*>")
data = scrapertools.find_single_match(idata, "<iframe[^<>]*src=\\'([^'>]*)\\'[^<>]*>")
#fix by greko inizio
if not data:
data = scrapertoolsV2.find_single_match(idata, 'action="(?:[^/]+.*?/[^/]+/([a-zA-Z0-9_]+))">')
data = scrapertools.find_single_match(idata, 'action="(?:[^/]+.*?/[^/]+/([a-zA-Z0-9_]+))">')
from lib import unshortenit
data, status = unshortenit.unshorten(url)
# logger.info("Data - Status zcrypt linkup : [%s] [%s] " %(data, status))

View File

@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from core import httptools, scrapertoolsV2
from core import httptools, scrapertools
from platformcode import config, logger
import base64

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import re
from core import httptools
from core import scrapertoolsV2
from core import scrapertools
from platformcode import config, logger
from lib import jsunpack
@@ -24,9 +24,9 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
data = httptools.downloadpage(page_url).data
data = re.sub(r'\n|\t|\r', ' ', data)
data = re.sub(r'>\s\s*<', '><', data)
jsCode = scrapertoolsV2.find_single_match(data, r'<script>\s*MDCore\.ref = "[a-z0-9]+"; (.*?) </script>')
jsCode = scrapertools.find_single_match(data, r'<script>\s*MDCore\.ref = "[a-z0-9]+"; (.*?) </script>')
jsUnpacked = jsunpack.unpack(jsCode)
url = "https://" + scrapertoolsV2.find_single_match(jsUnpacked, r'vsr[^=]*="(?:/)?(/[^"]+)')
url = "https://" + scrapertools.find_single_match(jsUnpacked, r'vsr[^=]*="(?:/)?(/[^"]+)')
itemlist.append([".mp4 [MixDrop]", url])
@@ -38,7 +38,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
# import simplejson as json
# page_url = page_url.replace('/e/', '/f/') + '?download'
# data = httptools.downloadpage(page_url).data
# csrf = scrapertoolsV2.find_single_match(data, '<meta name="csrf" content="([^"]+)">')
# csrf = scrapertools.find_single_match(data, '<meta name="csrf" content="([^"]+)">')
# postData = {'csrf': csrf, 'a': 'genticket'}
# resp = httptools.downloadpage(page_url, post=urllib.urlencode(postData)).data
# resp = json.loads(resp)

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from core import httptools
from core import scrapertoolsV2
from core import scrapertools
from lib import jsunpack
from platformcode import config, logger
import ast
@@ -22,10 +22,10 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
video_urls = []
data = httptools.downloadpage(page_url).data
# logger.info(data)
block = scrapertoolsV2.find_single_match(data, r'sources: \[([^\]]+)\]')
sources = scrapertoolsV2.find_multiple_matches(block, r'file:\s*"([^"]+)"(?:,label:\s*"([^"]+)")?')
block = scrapertools.find_single_match(data, r'sources: \[([^\]]+)\]')
sources = scrapertools.find_multiple_matches(block, r'file:\s*"([^"]+)"(?:,label:\s*"([^"]+)")?')
if not sources:
sources = scrapertoolsV2.find_multiple_matches(data, r'src:\s*"([^"]+)",\s*type:\s*"[^"]+",[^,]+,\s*label:\s*"([^"]+)"')
sources = scrapertools.find_multiple_matches(data, r'src:\s*"([^"]+)",\s*type:\s*"[^"]+",[^,]+,\s*label:\s*"([^"]+)"')
for url, quality in sources:
quality = 'auto' if not quality else quality
video_urls.append(['.' + url.split('.')[-1] + ' [' + quality + '] [Onlystream]', url])

View File

@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from core import httptools
from core import scrapertoolsV2
from core import scrapertools
from lib import jsunpack
from platformcode import config, logger
import ast
@@ -22,10 +22,10 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
video_urls = []
data = httptools.downloadpage(page_url).data
logger.info('SUPER DATA= '+data)
code_data = scrapertoolsV2.find_single_match(data, "<script type='text/javascript'>(eval.*)")
code_data = scrapertools.find_single_match(data, "<script type='text/javascript'>(eval.*)")
if code_data:
code = jsunpack.unpack(code_data)
match = scrapertoolsV2.find_single_match(code, r'sources:(\[[^]]+\])')
match = scrapertools.find_single_match(code, r'sources:(\[[^]]+\])')
lSrc = ast.literal_eval(match)
lQuality = ['360p', '720p', '1080p', '4k'][:len(lSrc)-1]
@@ -36,7 +36,7 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
video_urls.append(['.' + source.split('.')[-1] + '(' + quality + ') [SuperVideo]', source])
else:
logger.info('ELSE!')
matches = scrapertoolsV2.find_multiple_matches(data, r'src:\s*"([^"]+)",\s*type:\s*"[^"]+"(?:\s*, res:\s(\d+))?')
matches = scrapertools.find_multiple_matches(data, r'src:\s*"([^"]+)",\s*type:\s*"[^"]+"(?:\s*, res:\s(\d+))?')
for url, quality in matches:
if url.split('.')[-1] != 'm3u8':
video_urls.append([url.split('.')[-1] + ' [' + quality + ']', url])

View File

@@ -33,7 +33,7 @@ except:
xbmcgui = None
import xbmc
import re, base64, json, os, inspect
from core import jsontools, tvdb, scrapertoolsV2
from core import jsontools, tvdb, scrapertools
from core.support import typo, log, dbg
from platformcode import config, platformtools, logger
from platformcode.config import get_setting
@@ -118,7 +118,7 @@ def manual_renumeration(item, modify=False):
for item in itemlist:
Title = re.sub(r'\d+x\d+ - ', '', item.title)
if modify == True:
ep = int(scrapertoolsV2.find_single_match(Title, r'(\d+)'))
ep = int(scrapertools.find_single_match(Title, r'(\d+)'))
if item.action == 'findvideos' and not EpisodeDict.has_key(str(ep)):
_list.append(Title)
else:
@@ -138,7 +138,7 @@ def manual_renumeration(item, modify=False):
while not season:
season = platformtools.dialog_numeric(0, config.get_localized_string(70733))
for select in selected:
ep = int(scrapertoolsV2.find_single_match(_list[select], r'(\d+)'))
ep = int(scrapertools.find_single_match(_list[select], r'(\d+)'))
if season == '0':
episode = ''
while not episode:
@@ -219,7 +219,7 @@ def semiautomatic_config_item(item):
selected = platformtools.dialog_multiselect(config.get_localized_string(70734), _list)
# if len(selected) > 0:
for select in selected:
specials.append(int(scrapertoolsV2.find_single_match(_list[select],r'(\d+)')))
specials.append(int(scrapertools.find_single_match(_list[select], r'(\d+)')))
dict_renumerate[TAG_SPECIAL] = specials
# stop = False
@@ -359,7 +359,7 @@ def renumeration (itemlist, item, typography, dict_series, ID, SEASON, EPISODE,
EpisodeDict = {}
for item in itemlist:
if config.get_localized_string(30992) not in item.title:
number = scrapertoolsV2.find_single_match(item.title, r'\d+')
number = scrapertools.find_single_match(item.title, r'\d+')
item.title = typo('0x' + number + ' - ', typography) + item.title
@@ -373,10 +373,10 @@ def renumeration (itemlist, item, typography, dict_series, ID, SEASON, EPISODE,
return error(itemlist)
if TYPE == 'manual' and len(EpisodeDict) < len(itemlist):
EpisodeDict = manual_renumeration(item, True)
if len(EpisodeDict) >= len(itemlist) and EpisodeDict.has_key(scrapertoolsV2.find_single_match(itemlist[0].title, r'\d+')):
if len(EpisodeDict) >= len(itemlist) and EpisodeDict.has_key(scrapertools.find_single_match(itemlist[0].title, r'\d+')):
for item in itemlist:
if config.get_localized_string(30992) not in item.title:
number = scrapertoolsV2.find_single_match(item.title, r'\d+')
number = scrapertools.find_single_match(item.title, r'\d+')
number = int(number) # if number !='0': number.lstrip('0')
item.title = typo(EpisodeDict[str(number)] + ' - ', typography) + item.title
else:
@@ -467,7 +467,7 @@ def make_list(itemlist, item, typography, dict_series, ID, SEASON, EPISODE, MODE
for item in itemlist:
# Otiene Numerazione Episodi
if config.get_localized_string(30992) not in item.title:
episode = int(scrapertoolsV2.find_single_match(item.title, r'\d+'))
episode = int(scrapertools.find_single_match(item.title, r'\d+'))
number = episode + FirstOfSeason - addiction
count = number + addiction
# Crea Dizionario Episodi

View File

@@ -3,7 +3,7 @@
import re, os, inspect, requests, xbmc, xbmcaddon
from core import httptools, scrapertoolsV2, servertools, jsontools, tmdb, support
from core import httptools, scrapertools, servertools, jsontools, tmdb, support
from core.item import Item
from core.support import typo
from channelselector import get_thumb
@@ -751,7 +751,7 @@ def set_title(title, language, quality):
def format_title(title):
t = scrapertoolsV2.find_single_match(title, r'\{([^\}]+)\}')
t = scrapertools.find_single_match(title, r'\{([^\}]+)\}')
if 'bold' not in t: t += ' bold'
title = re.sub(r'(\{[^\}]+\})','',title)
return typo(title,t)

View File

@@ -1,866 +0,0 @@
# -*- coding: utf-8 -*-
import datetime
import glob
import os
import re
import threading
import time
import urllib
from threading import Thread
from unicodedata import normalize
import Queue
import xbmc
from lib.fuzzywuzzy import fuzz
from core import channeltools, httptools, tmdb, servertools
from platformcode import platformtools
try:
import json
except:
import simplejson as json
from platformcode import config
from platformcode import logger
from core.item import Item
TMDB_KEY = tmdb.tmdb_auth_key ######TMDB_KEY = '92db8778ccb39d825150332b0a46061d'
# TMDB_KEY = '92db8778ccb39d825150332b0a46061d'
TMDB_URL_BASE = 'http://api.themoviedb.org/3/'
TMDB_IMAGES_BASEURL = 'http://image.tmdb.org/t/p/'
INCLUDE_ADULT = True if config.get_setting("enableadultmode") else False
LANGUAGE_ID = 'it'
DTTIME = (datetime.datetime.utcnow() - datetime.timedelta(hours=5))
SYSTIME = DTTIME.strftime('%Y%m%d%H%M%S%f')
TODAY_TIME = DTTIME.strftime('%Y-%m-%d')
MONTH_TIME = (DTTIME - datetime.timedelta(days=30)).strftime('%Y-%m-%d')
MONTH2_TIME = (DTTIME - datetime.timedelta(days=60)).strftime('%Y-%m-%d')
YEAR_DATE = (DTTIME - datetime.timedelta(days=365)).strftime('%Y-%m-%d')
TIMEOUT_TOTAL = config.get_setting("timeout")
MAX_THREADS = config.get_setting("maxthreads")
# TIMEOUT_TOTAL = config.get_setting("timeout", default=90)
# MAX_THREADS = config.get_setting("maxthreads", default=24)
NLS_Search_by_Channel = config.get_localized_string(30974)
NLS_Alternative_Search = config.get_localized_string(70021)
NLS_Search_by_Title = config.get_localized_string(30980)
NLS_Search_by_Person = config.get_localized_string(30981)
NLS_Search_by_Company = config.get_localized_string(30982)
NLS_Now_Playing = config.get_localized_string(30983)
NLS_Popular = config.get_localized_string(30984)
NLS_Top_Rated = config.get_localized_string(30985)
NLS_Search_by_Collection = config.get_localized_string(30986)
NLS_List_by_Genre = config.get_localized_string(30987)
NLS_Search_by_Year = config.get_localized_string(30988)
NLS_Search_Similar_by_Title = config.get_localized_string(30989)
NLS_Search_Tvshow_by_Title = config.get_localized_string(30990)
NLS_Most_Voted = config.get_localized_string(30996)
NLS_Oscar = config.get_localized_string(30997)
NLS_Last_2_months = config.get_localized_string(60534)
NLS_Library = config.get_localized_string(30991)
NLS_Next_Page = config.get_localized_string(30992)
NLS_Looking_For = config.get_localized_string(30993)
NLS_Searching_In = config.get_localized_string(30994)
NLS_Found_So_Far = config.get_localized_string(30995)
NLS_Info_Title = config.get_localized_string(30975)
NLS_Info_Person = config.get_localized_string(30979)
NLS_New_TVShow = config.get_localized_string(30978)
NLS_TVShow_onair = config.get_localized_string(30977)
NLS_TVShow_airing_today = config.get_localized_string(30976)
TMDb_genres = {}
def mainlist(item):
logger.info(" mainlist")
itemlist = [Item(channel="search",
title="[COLOR lightgreen]%s[/COLOR]" % NLS_Search_by_Channel,
action="mainlist",
thumbnail="http://i.imgur.com/pE5WSZp.png"),
Item(channel="tvmoviedb",
title="[COLOR yellow]%s[/COLOR]" % NLS_Alternative_Search,
action="mainlist",
url="search_movie_by_title",
thumbnail="https://s6.postimg.cc/6lll9b8c1/searching.png"),
Item(channel=item.channel,
title="[COLOR yellow]%s[/COLOR]" % NLS_Search_by_Title,
action="search",
url="search_movie_by_title",
thumbnail="http://i.imgur.com/B1H1G8U.png"),
Item(channel=item.channel,
title="[COLOR yellow]%s[/COLOR]" % NLS_Search_by_Person,
action="search",
url="search_person_by_name",
thumbnail="http://i.imgur.com/efuEeNu.png"),
Item(channel=item.channel,
title="[COLOR yellow]%s[/COLOR]" % NLS_Search_by_Year,
action="search_movie_by_year",
url="search_movie_by_year",
thumbnail="https://d1kz0yd1invg7i.cloudfront.net/uploads/app/icon/1/calendar-icon-big.png"),
Item(channel=item.channel,
title="[COLOR yellow]%s[/COLOR]" % NLS_Search_by_Collection,
action="search",
url="search_collection_by_name",
thumbnail="http://i.imgur.com/JmcvZDL.png"),
Item(channel=item.channel,
title="[COLOR yellow]%s[/COLOR]" % NLS_Search_Similar_by_Title,
action="search",
url="search_similar_movie_by_title",
thumbnail="http://i.imgur.com/JmcvZDL.png"),
Item(channel=item.channel,
title="[COLOR lime]%s[/COLOR]" % NLS_Search_Tvshow_by_Title,
action="search",
url="search_tvshow_by_title",
thumbnail="https://i.imgur.com/2ZWjLn5.jpg?1"),
Item(channel=item.channel,
title="(TV Shows) [COLOR lime]%s[/COLOR]" % NLS_New_TVShow,
action="list_tvshow",
url='discover/tv?sort_by=popularity.desc&first_air_date.gte=%s&first_air_date.lte=%s&' % (
MONTH2_TIME, TODAY_TIME),
plot="1",
type="tvshow",
thumbnail="https://i.imgur.com/2ZWjLn5.jpg?1"),
Item(channel=item.channel,
title="(TV Shows) [COLOR lime]%s[/COLOR]" % NLS_TVShow_onair,
action="list_tvshow",
url="tv/on_the_air?",
plot="1",
type="tvshow",
thumbnail="https://i.imgur.com/2ZWjLn5.jpg?1"),
Item(channel=item.channel,
title="(TV Shows) [COLOR lime]%s[/COLOR]" % NLS_Popular,
action="list_tvshow",
url="tv/popular?",
plot="1",
type="tvshow",
thumbnail="https://i.imgur.com/2ZWjLn5.jpg?1"),
Item(channel=item.channel,
title="(TV Shows) [COLOR lime]%s[/COLOR]" % NLS_Top_Rated,
action="list_tvshow",
url="tv/top_rated?",
plot="1",
type="tvshow",
thumbnail="https://i.imgur.com/2ZWjLn5.jpg?1"),
Item(channel=item.channel,
title="(TV Shows) [COLOR lime]%s[/COLOR]" % NLS_TVShow_airing_today,
action="list_tvshow",
url="tv/airing_today?",
plot="1",
type="tvshow",
thumbnail="https://i.imgur.com/2ZWjLn5.jpg?1"),
Item(channel=item.channel,
title="(Movies) [COLOR yellow]%s[/COLOR]" % NLS_Now_Playing,
action="list_movie",
url="movie/now_playing?",
plot="1",
type="movie",
thumbnail="http://i.imgur.com/B16HnVh.png"),
Item(channel=item.channel,
title="(Movies) [COLOR yellow]%s[/COLOR]" % NLS_Popular,
action="list_movie",
url="movie/popular?",
plot="1",
type="movie",
thumbnail="http://i.imgur.com/8IBjyzw.png"),
Item(channel=item.channel,
title="(Movies) [COLOR yellow]%s[/COLOR]" % NLS_Top_Rated,
action="list_movie",
url="movie/top_rated?",
plot="1",
type="movie",
thumbnail="http://www.clipartbest.com/cliparts/RiG/6qn/RiG6qn79T.png"),
Item(channel=item.channel,
title="(Movies) [COLOR yellow]%s[/COLOR]" % NLS_Most_Voted,
action="list_movie",
url='discover/movie?certification_country=US&sort_by=vote_count.desc&',
plot="1",
type="movie",
thumbnail="http://i.imgur.com/5ShnO8w.png"),
Item(channel=item.channel,
title="(Movies) [COLOR yellow]%s[/COLOR]" % NLS_Oscar,
action="list_movie",
url='list/509ec17b19c2950a0600050d?',
plot="1",
type="movie",
thumbnail="http://i.imgur.com/5ShnO8w.png"),
Item(channel=item.channel,
title="(Movies) [COLOR yellow]%s[/COLOR]" % NLS_Last_2_months,
action="list_movie",
url='discover/movie?primary_release_date.gte=%s&primary_release_date.lte=%s&' % (
YEAR_DATE, MONTH2_TIME),
plot="1",
type="movie",
thumbnail="http://i.imgur.com/CsizqUI.png"),
Item(channel=item.channel,
title="(Movies) [COLOR yellow]%s[/COLOR]" % NLS_List_by_Genre,
action="list_genres",
type="movie",
thumbnail="http://i.imgur.com/uotyBbU.png")]
return itemlist
def list_movie(item):
logger.info(" list_movie '%s/%s'" % (item.url, item.plot))
results = [0, 0]
page = int(item.plot)
itemlist = build_movie_list(item, tmdb_get_data('%s&page=%d&' % (item.url, page), results=results))
if page < results[0]:
itemlist.append(Item(
channel=item.channel,
title="[COLOR orange]%s (%d/%d)[/COLOR]" % (NLS_Next_Page, page * len(itemlist), results[1]),
action="list_movie",
url=item.url,
plot="%d" % (page + 1),
type=item.type,
viewmode="" if page <= 1 else "paged_list"))
return itemlist
def list_tvshow(item):
logger.info(" list_tvshow '%s/%s'" % (item.url, item.plot))
results = [0, 0]
page = int(item.plot)
itemlist = build_movie_list(item, tmdb_get_data('%spage=%d&' % (item.url, page), results=results))
if page < results[0]:
itemlist.append(Item(
channel=item.channel,
title="[COLOR orange]%s (%d/%d)[/COLOR]" % (NLS_Next_Page, page * len(itemlist), results[1]),
action="list_tvshow",
url=item.url,
plot="%d" % (page + 1),
type=item.type,
viewmode="" if page <= 1 else "paged_list"))
return itemlist
def list_genres(item):
logger.info(" list_genres")
tmdb_genre(1)
itemlist = []
for genre_id, genre_name in TMDb_genres.iteritems():
itemlist.append(
Item(channel=item.channel,
title=genre_name,
action="list_movie",
url='genre/%d/movies?primary_release_date.gte=%s&primary_release_date.lte=%s&language=it' % (
genre_id, YEAR_DATE, TODAY_TIME),
plot="1"))
return itemlist
def discover_list(item):
from platformcode import unify
from core import scrapertools
itemlist = []
result = tmdb.discovery(item)
tvshow = False
logger.debug(item)
for elem in result:
elem['tmdb_id'] = elem['id']
if 'title' in elem:
title = unify.normalize(elem['title']).capitalize()
elem['year'] = scrapertools.find_single_match(elem['release_date'], '(\d{4})-\d+-\d+')
else:
title = unify.normalize(elem['name']).capitalize()
tvshow = True
new_item = Item(channel='searchall', title=title, infoLabels=elem, action='search_tmdb', extra=title,
category=config.get_localized_string(70695), context='')
if tvshow:
new_item.contentSerieName = title
else:
new_item.contentTitle = title
itemlist.append(new_item)
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
if item.page != '' and len(itemlist) > 0:
next_page = str(int(item.page) + 1)
# if not 'similar' in item.list_type:
# itemlist.append(item.clone(title='Pagina Siguente', page=next_page))
# else:
itemlist.append(Item(channel=item.channel, action='discover_list', title=config.get_localized_string(30992),
text_color="orange", search_type=item.search_type, list_type=item.list_type,
type=item.type, page=next_page))
return itemlist
# Do not change the name of this function otherwise launcher.py won't create the keyboard dialog required to enter the search terms
def search(item, search_terms):
if item.url == '': return []
return globals()[item.url](item, search_terms) if item.url in globals() else []
def search_tvshow_by_title(item, search_terms):
logger.info(" search_tvshow_by_title '%s'" % (search_terms))
return list_movie(
Item(channel=item.channel,
url='search/tv?query=%s&' % search_terms,
plot="1",
type="tvshow"))
def search_movie_by_title(item, search_terms):
logger.info(" search_movie_by_title '%s'" % (search_terms))
return list_movie(
Item(channel=item.channel,
url='search/movie?query=%s&' % search_terms,
plot="1",
type="movie"))
def search_similar_movie_by_title(item, search_terms):
logger.info(" search_similar_movie_by_title '%s'" % (search_terms))
return list_movie(
Item(channel=item.channel,
url='search/movie?append_to_response=similar_movies,alternative_title&query=%s&' % search_terms,
plot="1",
type='movie'))
def search_movie_by_year(item):
logger.info(" search_movie_by_year")
now = datetime.datetime.now()
year = int(now.year)
result = []
for i in range(150):
year_to_search = year - i
result.append(Item(channel=item.channel,
url='discover/movie?primary_release_year=%s&' % year_to_search,
plot="1",
type="movie",
title="%s" % year_to_search,
action="list_movie"))
return result
def search_person_by_name(item, search_terms):
logger.info(" search_person_by_name '%s'" % (search_terms))
persons = tmdb_get_data("search/person?query=%s&" % search_terms)
itemlist = []
for person in persons:
name = normalize_unicode(tmdb_tag(person, 'name'))
poster = tmdb_image(person, 'profile_path')
fanart = ''
for movie in tmdb_tag(person, 'known_for', []):
if tmdb_tag_exists(movie, 'backdrop_path'):
fanart = tmdb_image(movie, 'backdrop_path', 'w1280')
break
# extracmds = [
# (NLS_Info_Person, "RunScript(script.extendedinfo,info=extendedactorinfo,id=%s)" % str(tmdb_tag(person, 'id')))] \
# if xbmc.getCondVisibility('System.HasAddon(script.extendedinfo)') else []
itemlist.append(Item(
channel=item.channel,
action='search_movie_by_person',
extra=str(tmdb_tag(person, 'id')),
title=name,
thumbnail=poster,
viewmode='list',
fanart=fanart,
type='movie'
# extracmds=extracmds
))
return itemlist
def search_movie_by_person(item):
logger.info(" search_movie_by_person '%s'" % (item.extra))
# return list_movie(
# Item(channel=item.channel,
# url="discover/movie?with_people=%s&primary_release_date.lte=%s&sort_by=primary_release_date.desc&" % (
# item.extra, TODAY_TIME),
# plot="1"))
person_movie_credits = tmdb_get_data(
"person/%s/movie_credits?primary_release_date.lte=%s&sort_by=primary_release_date.desc&" % (
item.extra, TODAY_TIME))
movies = []
if person_movie_credits:
movies.extend(tmdb_tag(person_movie_credits, 'cast', []))
movies.extend(tmdb_tag(person_movie_credits, 'crew', []))
# Movie person list is not paged
return build_movie_list(item, movies)
def search_collection_by_name(item, search_terms):
logger.info(" search_collection_by_name '%s'" % (search_terms))
collections = tmdb_get_data("search/collection?query=%s&" % search_terms)
itemlist = []
for collection in collections:
name = normalize_unicode(tmdb_tag(collection, 'name'))
poster = tmdb_image(collection, 'poster_path')
fanart = tmdb_image(collection, 'backdrop_path', 'w1280')
itemlist.append(Item(
channel=item.channel,
action='search_movie_by_collection',
extra=str(tmdb_tag(collection, 'id')),
title=name,
thumbnail=poster,
viewmode='list',
fanart=fanart,
type='movie'
))
return itemlist
def search_movie_by_collection(item):
logger.info(" search_movie_by_collection '%s'" % (item.extra))
collection = tmdb_get_data("collection/%s?" % item.extra)
# Movie collection list is not paged
return build_movie_list(item, collection['parts']) if 'parts' in collection else []
def build_movie_list(item, movies):
if movies is None: return []
itemlist = []
for movie in movies:
t = tmdb_tag(movie, 'title')
if t == '':
t = re.sub('\s(|[(])(UK|US|AU|\d{4})(|[)])$', '', tmdb_tag(movie, 'name'))
title = normalize_unicode(t)
title_search = normalize_unicode(t, encoding='ascii')
if not all(ord(char) < 128 for char in title): continue
poster = tmdb_image(movie, 'poster_path')
fanart = tmdb_image(movie, 'backdrop_path', 'w1280')
jobrole = normalize_unicode(
' [COLOR yellow][' + tmdb_tag(movie, 'job') + '][/COLOR]' if tmdb_tag_exists(movie, 'job') else '')
genres = normalize_unicode(
' / '.join([tmdb_genre(genre).upper() for genre in tmdb_tag(movie, 'genre_ids', [])]))
year = tmdb_tag(movie, 'release_date')[0:4] if tmdb_tag_exists(movie, 'release_date') else ''
plot = normalize_unicode(tmdb_tag(movie, 'overview'))
rating = tmdb_tag(movie, 'vote_average')
votes = tmdb_tag(movie, 'vote_count')
extrameta = {'plot': plot}
if year != "": extrameta["Year"] = year
if genres != "": extrameta["Genre"] = genres
if votes:
extrameta["Rating"] = rating
extrameta["Votes"] = "%d" % votes
# extracmds = [(NLS_Info_Title, "RunScript(script.extendedinfo,info=extendedinfo,id=%s)" % str(tmdb_tag(movie, 'id')))] \
# if xbmc.getCondVisibility('System.HasAddon(script.extendedinfo)') else [('Movie/Show Info', 'XBMC.Action(Info)')]
found = False
kodi_db_movies = kodi_database_movies(title)
for kodi_db_movie in kodi_db_movies:
logger.info('Kod.database set for local playing(%s):\n%s' % (title, str(kodi_db_movie)))
if year == str(kodi_db_movie["year"]):
found = True
# If some, less relevant, keys are missing locally
# try to get them through TMDB anyway.
try:
poster = kodi_db_movie["art"]["poster"]
fanart = kodi_db_movie["art"]["fanart"]
except KeyError:
poster = poster
fanart = fanart
itemlist.append(Item(
channel=item.channel,
action='play',
url=kodi_db_movie["file"],
title='[COLOR orange][%s][/COLOR] ' % NLS_Library + kodi_db_movie["title"] + jobrole,
thumbnail=poster,
category=genres,
plot=plot,
viewmode='movie_with_plot',
fanart=fanart,
infoLabels=extrameta,
folder=False,
))
if not found:
logger.info('Kod.database set for channels search(%s)' % title)
itemlist.append(Item(
channel=item.channel,
action='do_channels_search',
extra=url_quote_plus(title_search) + '{}' + item.type + '{}' + year,
title=title + jobrole,
thumbnail=poster,
category=genres,
plot=plot,
viewmode='movie_with_plot',
fanart=fanart,
infoLabels=extrameta,
))
return itemlist
def normalize_unicode(string, encoding='utf-8'):
if string is None: string = ''
return normalize('NFKD', string if isinstance(string, unicode) else unicode(string, encoding, 'ignore')).encode(
encoding, 'ignore')
def tmdb_get_data(url="", results=[0, 0], language=True):
url = TMDB_URL_BASE + "%sinclude_adult=%s&api_key=%s" % (url, INCLUDE_ADULT, TMDB_KEY)
# Temporary fix until tmdb fixes the issue with getting the genres by language!
if language: url += "&language=%s" % LANGUAGE_ID
response = get_json_response(url)
results[0] = response['total_pages'] if 'total_pages' in response else 0
results[1] = response['total_results'] if 'total_results' in response else 0
if response:
if "results" in response:
return response["results"]
elif "items" in response:
return response["items"]
elif "tv_credits" in response:
return response["tv_credits"]["cast"]
else:
return response
def tmdb_tag_exists(entry, tag):
return isinstance(entry, dict) and tag in entry and entry[tag] is not None
def tmdb_tag(entry, tag, default=""):
return entry[tag] if isinstance(entry, dict) and tag in entry else default
def tmdb_image(entry, tag, width='original'):
return TMDB_IMAGES_BASEURL + width + '/' + tmdb_tag(entry, tag) if tmdb_tag_exists(entry, tag) else ''
def tmdb_genre(id):
if id not in TMDb_genres:
genres = tmdb_get_data("genre/list?", language="it")
for genre in tmdb_tag(genres, 'genres', []):
TMDb_genres[tmdb_tag(genre, 'id')] = tmdb_tag(genre, 'name')
return TMDb_genres[id] if id in TMDb_genres and TMDb_genres[id] != None else str(id)
def kodi_database_movies(title):
json_query = \
'{"jsonrpc": "2.0",\
"params": {\
"sort": {"order": "ascending", "method": "title"},\
"filter": {"operator": "is", "field": "title", "value": "%s"},\
"properties": ["title", "art", "file", "year"]\
},\
"method": "VideoLibrary.GetMovies",\
"id": "libMovies"\
}' % title
response = get_xbmc_jsonrpc_response(json_query)
return response["result"]["movies"] if response and "result" in response and "movies" in response["result"] else []
def get_xbmc_jsonrpc_response(json_query=""):
try:
response = xbmc.executeJSONRPC(json_query)
response = unicode(response, 'utf-8', errors='ignore')
response = json.loads(response)
logger.info(" jsonrpc %s" % response)
except Exception, e:
logger.info(" jsonrpc error: %s" % str(e))
response = None
return response
def url_quote_plus(input_string):
try:
return urllib.quote_plus(input_string.encode('utf8', 'ignore'))
except:
return urllib.quote_plus(unicode(input_string, "utf-8").encode("utf-8"))
def get_json_response(url=""):
response = httptools.downloadpage(url).data
try:
results = json.loads(response)
except:
logger.info(" Exception: Could not get new JSON data from %s" % url)
results = []
return results
def channel_search(queue, channel_parameters, category, title_year, tecleado):
try:
search_results = []
title_search = urllib.unquote_plus(tecleado)
exec "from specials import " + channel_parameters["channel"] + " as module"
mainlist = module.mainlist(Item(channel=channel_parameters["channel"]))
for item in mainlist:
if item.action != "search" or category and item.extra != category:
continue
for res_item in module.search(item.clone(), tecleado):
title = res_item.fulltitle
# If the release year is known, check if it matches the year found in the title
if title_year > 0:
year_match = re.search('\(.*(\d{4}).*\)', title)
if year_match and abs(int(year_match.group(1)) - title_year) > 1:
continue
# Clean up a bit the returned title to improve the fuzzy matching
title = re.sub(r'\(.*\)', '', title) # Anything within ()
title = re.sub(r'\[.*\]', '', title) # Anything within []
# Check if the found title fuzzy matches the searched one
if fuzz.token_sort_ratio(title_search, title) > 85:
res_item.title = "[COLOR azure]" + res_item.title + "[/COLOR][COLOR orange] su [/COLOR][COLOR green]" + \
channel_parameters["title"] + "[/COLOR]"
search_results.append(res_item)
queue.put(search_results)
except:
logger.error("No se puede buscar en: " + channel_parameters["title"])
import traceback
logger.error(traceback.format_exc())
def do_channels_search(item):
logger.info(" do_channels_search")
tecleado, category, title_year = item.extra.split('{}')
try:
title_year = int(title_year)
except:
title_year = 0
itemlist = []
channels_path = os.path.join(config.get_runtime_path(), "channels", '*.json')
logger.info(" channels_path=" + channels_path)
# channel_language = config.get_setting("channel_language")
channel_language = auto_filter()
logger.info(" channel_language=" + channel_language)
if channel_language == "":
channel_language = "all"
logger.info(" channel_language=" + channel_language)
progreso = platformtools.dialog_progress_bg(NLS_Looking_For % urllib.unquote_plus(tecleado))
channel_files = sorted(glob.glob(channels_path))
search_results = Queue.Queue()
completed_channels = 0
number_of_channels = 0
start_time = int(time.time())
for infile in channel_files:
basename_without_extension = os.path.basename(infile)[:-5]
channel_parameters = channeltools.get_channel_parameters(basename_without_extension)
# No busca si es un canal inactivo
if channel_parameters["active"] != True:
continue
# En caso de busqueda por categorias
if category and category not in channel_parameters["categories"]:
continue
# No busca si el canal es en un idioma filtrado
if channel_language != "all" and channel_language not in str(channel_parameters["language"]):
continue
# No busca si es un canal excluido de la busqueda global
include_in_global_search = channel_parameters["include_in_global_search"]
if include_in_global_search == True:
# Buscar en la configuracion del canal
include_in_global_search = config.get_setting("include_in_global_search", basename_without_extension)
if include_in_global_search == False:
continue
t = Thread(target=channel_search, args=[search_results, channel_parameters, category, title_year, tecleado])
t.setDaemon(True)
t.start()
number_of_channels += 1
while threading.active_count() >= MAX_THREADS:
delta_time = int(time.time()) - start_time
if len(itemlist) <= 0:
timeout = None # No result so far,lets the thread to continue working until a result is returned
elif delta_time >= TIMEOUT_TOTAL:
progreso.close()
itemlist = sorted(itemlist, key=lambda item: item.fulltitle)
return itemlist
else:
timeout = TIMEOUT_TOTAL - delta_time # Still time to gather other results
progreso.update(completed_channels * 100 / number_of_channels)
try:
itemlist.extend(search_results.get(timeout=timeout))
completed_channels += 1
except:
progreso.close()
itemlist = sorted(itemlist, key=lambda item: item.fulltitle)
return itemlist
while completed_channels < number_of_channels:
delta_time = int(time.time()) - start_time
if len(itemlist) <= 0:
timeout = None # No result so far,lets the thread to continue working until a result is returned
elif delta_time >= TIMEOUT_TOTAL:
break # At least a result matching the searched title has been found, lets stop the search
else:
timeout = TIMEOUT_TOTAL - delta_time # Still time to gather other results
progreso.update(completed_channels * 100 / number_of_channels)
try:
itemlist.extend(search_results.get(timeout=timeout))
completed_channels += 1
except:
# Expired timeout raise an exception
break
progreso.close()
# todo 1 : impostare una visualizzazione % di avanzamento (serve?)
# todo 2 : verificare la formattazione dei titoli estratti
# todo 3 : gestione numero threads e timeout
if config.get_setting("findlinks") == True and "{}movie{}" in item.extra:
itemlist = links_list(itemlist)
itemlist = sorted(itemlist, key=lambda item: item.title.lower())
else:
itemlist = sorted(itemlist, key=lambda item: item.fulltitle)
return itemlist
def links_list(itemlist):
logger.info(" links_list")
itemlistresults = []
itemlistlist = []
allthreads = []
global_search_results = Queue.Queue()
# create and collect threads
for item in itemlist:
t = Thread(target=list_single_site, args=[global_search_results, item])
t.setDaemon(True)
allthreads.append(t)
# start threads
for thread in allthreads:
try:
thread.start()
except:
logger.error("thread error !")
# join threads, to wait all threads end before going on
for thread in allthreads:
thread.join()
# collect results
while not global_search_results.empty():
for item in global_search_results.get():
if not item_url_in_itemlist(item, itemlistresults):
channelformatteditem = rewrite_item_title(item)
if channelformatteditem is not None:
itemlistresults.append(channelformatteditem)
return itemlistresults
def list_single_site(queue, item):
logger.info(" list_single_site")
channelitemlist = []
try:
# logger.info(item.channel + " start channel search " + time.strftime("%Y-%m-%d %H:%M:%S"))
module_to_call = getattr(__import__("channels"), item.channel)
channelitemlist = module_to_call.findvideos(item)
queue.put(channelitemlist)
# logger.info(item.channel + " end channel search " + time.strftime("%Y-%m-%d %H:%M:%S"))
except:
try:
# logger.info(item.channel + " start servertools search " + time.strftime("%Y-%m-%d %H:%M:%S"))
# logger.info("no findvideos defined in channel functions, calling servertools.findvideos to find links")
servertools_itemlist = []
headers = [['Referer', item.channel]]
data = httptools.downloadpage(item.url, headers=headers).data
list_servertools = servertools.findvideos(data)
for item_servertools in list_servertools:
servertools_itemlist.append(Item(channel=item.channel,
action="play",
fulltitle=item.title,
server=item_servertools[0],
thumbnail=item_servertools[3],
title=item.title,
url=item_servertools[1]))
queue.put(servertools_itemlist)
# logger.info(item.channel + " end servertools search " + time.strftime("%Y-%m-%d %H:%M:%S"))
except Exception, e:
logger.error('exception in list_single_site: ' + str(e))
return channelitemlist
# utility function
def item_url_in_itemlist(item, itemlist):
logger.info(" item_url_in_itemlist")
i = 0
while i < len(itemlist):
if itemlist[i].url == item.url:
# logger.info("elemento eliminato : " + item.url)
return True
i = i + 1
return False
# utility function, optional
def rewrite_item_title(item):
logger.info(" rewrite_item_title")
if "download" not in item.title.lower():
item.title = "[COLOR yellow][%s][/COLOR][COLOR orange][%s][/COLOR] %s" % (
item.server, item.channel, item.fulltitle)
else:
return None
return item