Fix Altadefinizione Click
This commit is contained in:
@@ -1,107 +1,42 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# ------------------------------------------------------------
|
||||
# Canale per altadefinizioneclick
|
||||
# Canale per Altadefinizione Click
|
||||
# ----------------------------------------------------------
|
||||
"""
|
||||
|
||||
Eccezioni che non superano il test del canale:
|
||||
- indicare le eccezioni
|
||||
|
||||
Novità. Indicare in quale/i sezione/i è presente il canale:
|
||||
- film
|
||||
|
||||
Avvisi:
|
||||
- Eventuali avvisi per i tester
|
||||
|
||||
Ulteriori info:
|
||||
|
||||
|
||||
"""
|
||||
from platformcode.logger import debug
|
||||
from core import support
|
||||
from core.item import Item
|
||||
from platformcode import config
|
||||
from platformcode import config, logger
|
||||
|
||||
def findhost(url):
|
||||
data = support.httptools.downloadpage(url).data
|
||||
host = support.scrapertools.find_single_match(data, '<div class="elementor-button-wrapper">\s*<a href="([^"]+)"')
|
||||
return host
|
||||
return support.match(url, patron=r'<div class="elementor-button-wrapper">\s*<a href="([^"]+)"').match
|
||||
|
||||
host = config.get_channel_url(findhost)
|
||||
headers = [['Referer', host]]
|
||||
if host.endswith('/'):
|
||||
host = host[:-1]
|
||||
headers = {'Referer': host, 'x-requested-with': 'XMLHttpRequest'}
|
||||
order = ['', 'i_piu_visti', 'i_piu_votati', 'i_piu_votati_dellultimo_mese', 'titolo_az', 'voto_imdb_piu_alto'][config.get_setting('order', 'altadefinizionecommunity')]
|
||||
|
||||
|
||||
@support.menu
|
||||
def mainlist(item):
|
||||
film = ['',
|
||||
('Novità', ['/nuove-uscite/', 'peliculas', 'news']),
|
||||
('Al Cinema', ['/al-cinema/', 'peliculas', 'cinema']),
|
||||
('A-Z',['/lista-film/', 'genres', 'az']),
|
||||
('Generi', ['', 'genres', 'genres']),
|
||||
('Anni', ['', 'genres', 'years']),
|
||||
('Qualità', ['', 'genres', 'quality']),
|
||||
('Mi sento Fortunato',[ '', 'genres', 'lucky']),
|
||||
('Sub-ITA', ['/sub-ita/', 'peliculas', 'sub'])
|
||||
]
|
||||
logger.debug(item)
|
||||
|
||||
tvshow = ['/serie-tv/']
|
||||
film = ['/type/movie',
|
||||
('Generi', ['/type/movie', 'genres', 'genres']),
|
||||
('Anni', ['/type/movie', 'genres', 'year']),]
|
||||
|
||||
search = ''
|
||||
tvshow = ['/serie-tv/tvshow',
|
||||
('Generi', ['/serie-tv/tvshow', 'genres', 'genres']),
|
||||
('Anni', ['/serie-tv/tvshow', 'genres', 'year'])]
|
||||
|
||||
advanced = [('Ricerca Avanzata', ['', 'advanced_search'])]
|
||||
return locals()
|
||||
|
||||
@support.scrape
|
||||
def peliculas(item):
|
||||
action = 'check'
|
||||
|
||||
patron = r'<div class="wrapperImage">\s*(?:<span class="year">(?P<year>[^<]+)[^>]+>)?(?:<span class="hd">(?P<quality>[^<>]+))?.+?href="(?P<url>[^"]+)".+?src="(?P<thumb>[^"]+)".+?<h2 class="titleFilm">[^>]+>(?P<title>.+?)[ ]?(?:|\[(?P<lang>[^\]]+)\])?</a>.*?(?:IMDB\:</strong>[ ](?P<rating>.+?)<|</div>)'
|
||||
|
||||
if item.args == 'az':
|
||||
patron = r'<img style="[^"]+" src="(?P<thumb>[^"]+)"[^>]+>[^>]+>[^>]+>[^>]+>[^>]+><a href="(?P<url>[^"]+)" [^>]+>(?P<title>[^<\[]+)(?:\[(?P<lang>[^\]]+)\]\s*)?<'\
|
||||
r'[^>]+>[^>]+>[^>]+>[^>]+>\s*(?P<year>\d{4})[^>]+>[^>]+>\s*(?P<quality>[^<]+).*?<span class="label">(?P<ratting>[^<]+)<'
|
||||
patronBlock =''
|
||||
|
||||
elif item.args == 'search':
|
||||
patronBlock = r'<section id="lastUpdate">(?P<block>.*?)(?:<div class="row ismobile">|<section)'
|
||||
patron = r'<a href="(?P<url>[^"]+)">\s*<div class="wrapperImage">(?:\s*<span class="year">(?P<year>[^<]+)<\/span>)?(?:\s*<span class="hd">(?P<quality>[^<]+)<\/span>)?[^>]+>\s*<img[^s]+src="(?P<thumb>[^"]+)"(?:(?:[^>]+>){5}\s*(?P<rating>[^<]+))?(?:[^>]+>){4}(?P<title>[^<]+)'
|
||||
|
||||
if not item.args:
|
||||
# patronBlock = r'(?:ULTIMI INSERITI|Serie TV)(?P<block>.*?)</section'
|
||||
patronBlock = r'({})(?P<block>.*?)</section'.format('ULTIMI INSERITI' if item.contentType == 'movie' else 'Serie TV')
|
||||
|
||||
# nella pagina "CERCA", la voce "SUCCESSIVO" apre la maschera di inserimento dati
|
||||
patronNext = r'<a class="next page-numbers" href="([^"]+)">'
|
||||
|
||||
return locals()
|
||||
|
||||
@support.scrape
|
||||
def genres(item):
|
||||
action = 'peliculas'
|
||||
patronMenu = r'<li><a href="(?P<url>[^"]+)">(?P<title>[^<]+)<'
|
||||
|
||||
if item.args == 'genres':
|
||||
patronBlock = r'<ul class="listSubCat" id="Film">(?P<block>.*)<ul class="listSubCat" id="Anno">'
|
||||
elif item.args == 'years':
|
||||
patronBlock = r'<ul class="listSubCat" id="Anno">(?P<block>.*)<ul class="listSubCat" id="Qualita">'
|
||||
elif item.args == 'quality':
|
||||
patronBlock = r'<ul class="listSubCat" id="Qualita">(?P<block>.*)</li>\s*?</ul>\s*?</div>\s*?</div>\s*?</div>\s*?<a'
|
||||
elif item.args == 'lucky': # sono i titoli random nella pagina
|
||||
patronBlock = r'<h3 class="titleSidebox dado">FILM RANDOM</h3>(?P<block>.*)</section>'
|
||||
patron = r'<li><a href="(?P<url>[^"]+)">(?P<title>[^<[]+)(?:\[(?P<lang>.+?)\])?<'
|
||||
action = 'findvideos'
|
||||
elif item.args == 'az':
|
||||
blacklist = ['FILM 4K IN STREAMING']
|
||||
patron = r'<a title="(?P<title>[^"]+)" href="(?P<url>[^"]+)"'
|
||||
item.args = 'az'
|
||||
if not item.args == 'az':
|
||||
item.args = 'genres'
|
||||
|
||||
return locals()
|
||||
|
||||
def search(item, texto):
|
||||
support.info("search ", texto)
|
||||
logger.debug("search ", texto)
|
||||
|
||||
item.args = 'search'
|
||||
item.url = host + "?s=" + texto
|
||||
item.url = host + "/search?s={}&f={}&page=1".format(texto, item.contentType)
|
||||
try:
|
||||
return peliculas(item)
|
||||
# Continua la ricerca in caso di errore
|
||||
@@ -111,87 +46,107 @@ def search(item, texto):
|
||||
support.logger.error("%s" % line)
|
||||
return []
|
||||
|
||||
def newest(categoria):
|
||||
support.info(categoria)
|
||||
itemlist = []
|
||||
item = Item()
|
||||
try:
|
||||
if categoria == "peliculas":
|
||||
item.args = 'news'
|
||||
item.contentType = 'movie'
|
||||
item.url = host + "/nuove-uscite/"
|
||||
item.action = "peliculas"
|
||||
itemlist = peliculas(item)
|
||||
|
||||
if itemlist[-1].action == "peliculas":
|
||||
itemlist.pop()
|
||||
|
||||
# Continua la ricerca in caso di errore
|
||||
except:
|
||||
import sys
|
||||
for line in sys.exc_info():
|
||||
from platformcode import logger
|
||||
logger.error("{0}".format(line))
|
||||
return []
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def check(item):
|
||||
item.contentType = 'tvshow'
|
||||
def get_season(pageData, seas_url, season):
|
||||
data = ''
|
||||
episodes = support.match(pageData if pageData else seas_url, patronBlock=patron_episode, patron=patron_option).matches
|
||||
for episode_url, episode in episodes:
|
||||
# episode_url = support.urlparse.urljoin(item.url, episode_url)
|
||||
# if '-' in episode: episode = episode.split('-')[0].zfill(2) + 'x' + episode.split('-')[1].zfill(2)
|
||||
title = season + "x" + episode.zfill(2) + ' - ' + item.fulltitle
|
||||
data += title + '|' + episode_url + '\n'
|
||||
return data
|
||||
|
||||
patron_season = '<div class="[^"]+" id="seasonsModal"[^>]+>(.*?)</ul>'
|
||||
patron_episode = '<div class="[^"]+" id="episodesModal"[^>]+>(.*?)</ul>'
|
||||
patron_option = r'<a href="([^"]+?)".*?>(?:Stagione |Episodio )([^<]+?)</a>'
|
||||
|
||||
url = support.match(item, patron=r'<iframe id="iframeVid" width="[^"]+" height="[^"]+" src="([^"]+)" allowfullscreen').match
|
||||
seasons = support.match(url, patronBlock=patron_season, patron=patron_option)
|
||||
if not seasons.match:
|
||||
item.contentType = 'movie'
|
||||
return findvideos(item)
|
||||
|
||||
data = ''
|
||||
|
||||
import sys
|
||||
if sys.version_info[0] >= 3: from concurrent import futures
|
||||
else: from concurrent_py2 import futures
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
thL = []
|
||||
for i, season in enumerate(seasons.matches):
|
||||
thL.append(executor.submit(get_season, seasons.data if i == 0 else '', season[0], season[1]))
|
||||
for res in futures.as_completed(thL):
|
||||
if res.result():
|
||||
data += res.result()
|
||||
item.data = data
|
||||
return episodios(item)
|
||||
|
||||
@support.scrape
|
||||
def episodios(item):
|
||||
data = item.data
|
||||
def genres(item):
|
||||
logger.debug(item)
|
||||
data = support.httptools.downloadpage(item.url, cloudscraper=True).data
|
||||
blacklist= ['Film', 'Serie TV']
|
||||
|
||||
patron = r'(?P<season>\d+)x(?P<episode>\d+)\s*-\s*(?P<title>[^\|]+)\|(?P<url>[^ ]+)'
|
||||
action = 'findvideos'
|
||||
if item.args == 'genres':
|
||||
categories ={}
|
||||
res = support.match(host + '/cerca', patron=r'for="cat-(\d+)[^>]+>([^<]+)').matches
|
||||
for _id, name in res:
|
||||
categories[name] = _id
|
||||
|
||||
def itemlistHook(itemlist):
|
||||
itemlist.sort(key=lambda item: (item.infoLabels['season'], item.infoLabels['episode']))
|
||||
return itemlist
|
||||
patronBlock = r'{}<span></span>(?P<block>.*?)</ul>\s*</li'.format('Film' if item.contentType == 'movie' else 'Serie TV')
|
||||
patronMenu = r'<a href="[^"]+">(?P<title>[^<]+)'
|
||||
|
||||
def itemHook(it):
|
||||
it.cat_id = categories[it.fulltitle]
|
||||
return it
|
||||
|
||||
if item.args == 'year':
|
||||
patron = r'value="(?P<year_id>[^"]+)"[^>]*>(?P<title>\d+)'
|
||||
patronBlock = r'Anno</option>(?P<block>.*?</select>)'
|
||||
|
||||
elif item.args == 'quality':
|
||||
patronMenu = r'quality/(?P<quality_id>[^"]+)">(?P<title>[^<]+)'
|
||||
patronBlock = r'Risoluzione(?P<block>.*?)</ul>'
|
||||
action = 'peliculas'
|
||||
return locals()
|
||||
|
||||
|
||||
@support.scrape
|
||||
def peliculas(item):
|
||||
item.quality = 'HD'
|
||||
json = {}
|
||||
params ={'type':item.contentType, 'anno':item.year_id, 'quality':item.quality_id, 'cat':item.cat_id, 'order':order}
|
||||
|
||||
|
||||
if item.contentType == 'movie':
|
||||
action = 'findvideos'
|
||||
else:
|
||||
action = 'episodios'
|
||||
if not item.page: item.page = 1
|
||||
try:
|
||||
# support.dbg()
|
||||
if item.args in ['search']:
|
||||
page = support.httptools.downloadpage(item.url, headers=headers)
|
||||
if page.json:
|
||||
data = "\n".join(page.json['data'])
|
||||
else:
|
||||
data = page.data
|
||||
else:
|
||||
params['page'] = item.page
|
||||
|
||||
url = '{}/load-more-film?{}'.format(host, support.urlencode(params))
|
||||
json = support.httptools.downloadpage(url, headers=headers).json
|
||||
data = "\n".join(json['data'])
|
||||
except:
|
||||
data = ' '
|
||||
|
||||
patron = r'wrapFilm">\s*<a href="(?P<url>[^"]+)">[^>]+>(?P<year>\d+)(?:[^>]+>){2}(?P<rating>[^<]+)(?:[^>]+>){4}\s*<img src="(?P<thumb>[^"]+)(?:[^>]+>){3}(?P<title>[^<[]+)(?:\[(?P<lang>[sSuUbBiItTaA-]+))?'
|
||||
# patron = r'wrapFilm">\s*<a href="(?P<url>[^"]+)">[^>]+>(?P<year>\d+)(?:[^>]+>){2}(?P<rating>[^<]+)(?:[^>]+>){2}(?P<quality>[^<]+)(?:[^>]+>){2}\s*<img src="(?P<thumb>[^"]+)(?:[^>]+>){3}(?P<title>[^<[]+)(?:\[(?P<lang>[sSuUbBiItTaA-]+))?'
|
||||
|
||||
# paginazione
|
||||
if json.get('have_next') or 'have_next_film=true' in data:
|
||||
def fullItemlistHook(itemlist):
|
||||
cat_id = support.match(data, patron=r''''cat':"(\d+)"''').match
|
||||
if cat_id: item.cat_id = cat_id
|
||||
item.page += 1
|
||||
support.nextPage(itemlist, item, function_or_level='peliculas')
|
||||
return itemlist
|
||||
|
||||
return locals()
|
||||
|
||||
def findvideos(item):
|
||||
support.info('findvideos', item)
|
||||
return support.hdpass_get_servers(item)
|
||||
|
||||
# def play(item):
|
||||
# if 'hdpass' in item.url:
|
||||
# return support.hdpass_get_url(item)
|
||||
# return [item]
|
||||
@support.scrape
|
||||
def episodios(item):
|
||||
logger.debug(item)
|
||||
# debug = True
|
||||
data = item.data
|
||||
patron = r'class="playtvshow "\s+data-href="(?P<url>[^"]+)'
|
||||
|
||||
def itemHook(it):
|
||||
spl = it.url.split('/')[-2:]
|
||||
it.infoLabels['season'] = int(spl[0])+1
|
||||
it.infoLabels['episode'] = int(spl[1])+1
|
||||
it.url = it.url.replace('/watch-unsubscribed', '/watch-external')
|
||||
it.title = '{}x{:02d} - {}'.format(it.contentSeason, it.contentEpisodeNumber, it.fulltitle)
|
||||
return it
|
||||
|
||||
return locals()
|
||||
|
||||
|
||||
def findvideos(item):
|
||||
itemlist = []
|
||||
playWindow = support.match(item, patron='(?:playWindow|iframe)" (?:href|src)="([^"]+)').match
|
||||
if host in playWindow:
|
||||
url = support.match(playWindow, patron='allowfullscreen[^<]+src="([^"]+)"').match
|
||||
else:
|
||||
url = playWindow
|
||||
itemlist.append(item.clone(action='play', url=url, quality=''))
|
||||
|
||||
|
||||
return support.server(item, itemlist=itemlist)
|
||||
|
||||
Reference in New Issue
Block a user