# -*- coding: utf-8 -*- # ------------------------------------------------------------ # Canale per CinemaLibero - First Version # ------------------------------------------------------------ """ Trasformate le sole def per support.menu e support.scrape da non inviare nel test. Test solo a trasformazione completa """ import re from core import scrapertools, servertools, httptools, support from core import tmdb from core.item import Item from lib import unshortenit from platformcode import config from platformcode import logger from specials import autoplay import channelselector # Necessario per Autoplay IDIOMAS = {'Italiano': 'IT'} list_language = IDIOMAS.values() list_servers = ['akstream', 'wstream', 'openload', 'streamango'] list_quality = ['default'] # Necessario per Verifica Link checklinks = config.get_setting('checklinks', 'cinemalibero') checklinks_number = config.get_setting('checklinks_number', 'cinemalibero') __channel__ = "cinemalibero" host = config.get_channel_url(__channel__) headers = [['Referer', host]] @support.menu def mainlist(item): support.log() film = '/category/film/' filmSub = [ ('Generi', ['', 'genres']), ('Sport', ['/category/sport/', 'peliculas']), ] tvshow = '/category/serie-tv/' tvshowSub = [ ('Anime ', ['/category/anime-giapponesi/', 'video']) ] return locals() @support.scrape def genres(item): support.log() action='video' patron=r'.*?class="col-md-12[^"]*?">(.*?)
') # Estrae i contenuti matches = re.compile(r'
(.*?)<\/a><\/div>', re.DOTALL).findall(block) for match in matches: url = scrapertools.find_single_match(match, r'href="([^"]+)"') long_title = scrapertools.find_single_match(match, r'
([^<]+)<\/div>') thumb = scrapertools.find_single_match(match, r'url=\((.*?)\)') quality = scrapertools.find_single_match(match, r'
([^<]+)<\/div>') genere = scrapertools.find_single_match(match, r'
([^<]+)<\/div>') year = scrapertools.find_single_match(long_title, r'\(([0-9)]+)') or scrapertools.find_single_match(long_title, r'\) ([0-9)]+)') lang = scrapertools.find_single_match(long_title, r'\(([a-zA-Z)]+)') title = re.sub(r'\(.*','',long_title) title = re.sub(r'(?:\(|\))','',title) if genere: genere = ' - [' + genere + ']' if year: long_title = title + ' - ('+ year + ')' + genere if lang: long_title = '[B]' + title + '[/B]' + ' - ('+ lang + ')' + genere else: long_title = '[B]' + title + '[/B]' # Seleziona fra Serie TV e Film if item.contentType == 'movie': tipologia = 'movie' action = 'findvideos' elif item.contentType == 'episode': tipologia = 'tv' action = 'episodios' else: tipologia = 'movie' action = 'select' itemlist.append( Item(channel=item.channel, action=action, contentType=item.contentType, title=long_title, fulltitle=title, quality=quality, url=url, thumbnail=thumb, infoLabels={'year': year}, show=title)) # Next page next_page = scrapertools.find_single_match(data, '
0 and item.extra != 'findservers': itemlist.append( Item(channel=item.channel, title='[COLOR lightblue][B]Aggiungi alla videoteca[/B][/COLOR]', url=item.url, action='add_pelicula_to_library', extra='findservers', contentTitle=item.contentTitle)) # Necessario per filtrare i Link if checklinks: itemlist = servertools.check_list_links(itemlist, checklinks_number) # Necessario per FilterTools # itemlist = filtertools.get_links(itemlist, item, list_language) # Necessario per AutoPlay autoplay.start(itemlist, item) return itemlist def episodios(item): # Questa def. deve sempre essere nominata episodios logger.info('[cinemalibero.py] episodios') itemlist = [] extra = '' # Carica la pagina data = httptools.downloadpage(item.url, headers=headers).data block = scrapertools.find_single_match(data, r'
(.*?)at-below-post') if re.findall('rel="category tag">serie', data, re.IGNORECASE): # logger.info('select = ### è una serie ###') extra='serie' elif re.findall('rel="category tag">anime', data, re.IGNORECASE): if re.findall('episodi', block, re.IGNORECASE): # logger.info('select = ### è un anime ###') extra='anime' block = re.sub(r'

.*?<\/h2>','',block) block = block.replace('

','').replace('

','').replace('–<','<').replace('-<','<').replace('–<','<').replace('– <','<').replace('','')+'' block = re.sub(r'stagione completa.*?<\/p>','',block,flags=re.IGNORECASE) if extra == 'serie': block = block.replace('
.*?(?:stagione|Stagione)(.*?)<\/(?:strong|span)><\/p>(.*?)', re.DOTALL).findall(block) if not matches: matches = scrapertools.find_multiple_matches(block, r'
]+>(Episodio [0-9]+)') for scrapedurl, scrapedtitle in matches: scrapedtitle = re.sub(r'Episodio ([0-9]+)', r'Episodio 1x\1', scrapedtitle) itemlist.append( Item(channel=item.channel, action="findvideos", contentType='episode', title=scrapedtitle, fulltitle=scrapedtitle, show=item.fulltitle, url=scrapedurl, args='direct')) else: for lang, html in matches: lang = re.sub('<.*?>','',lang) html = html.replace('
','\n').replace('

', '\n') matches = re.compile(r'([^<]+)([^\n]+)\n', re.DOTALL).findall(html) for scrapedtitle, html in matches: itemlist.append( Item(channel=item.channel, action="findvideos", contentType='episode', title=scrapedtitle + ' - (' + lang + ')', fulltitle=scrapedtitle, show=item.fulltitle, url=html)) elif extra == 'anime': block = re.sub(r'','',block) block = re.sub(r'(?:mirror|Mirror)[^<]+<','',block) block = block.replace('
','\n').replace('/a>

','\n') block = re.sub(r'(.*?)<\/a>') itemlist.append( Item(channel=item.channel, action="findvideos", contentType='episode', title=scrapedtitle, fulltitle=scrapedtitle, show=item.fulltitle, url=html)) else: logger.info('select = ### è un film ###') return findvideos(Item(channel=item.channel, title=item.title, fulltitle=item.fulltitle, url=item.url, show=item.fulltitle, contentType='movie')) if config.get_videolibrary_support() and len(itemlist) != 0: itemlist.append( Item(channel=item.channel, title="[COLOR lightblue]%s[/COLOR]" % config.get_localized_string(30161), url=item.url, action="add_serie_to_library", extra="episodios", show=item.show)) return itemlist