diff --git a/channels.json b/channels.json index d5999baf..6b0f2416 100644 --- a/channels.json +++ b/channels.json @@ -46,6 +46,7 @@ "vvvvid": "https://www.vvvvid.it" }, "findhost": { + "altadefinizionecommunity": "https://altaregistrazione.com", "altadefinizioneclick": "https://altadefinizione-nuovo.click", "animealtadefinizione": "https://www.animealtadefinizione.it", "filmpertutti": "https://filmpertuttiii.nuovo.live" diff --git a/channels/altadefinizionecommunity.json b/channels/altadefinizionecommunity.json new file mode 100644 index 00000000..cc0ccff9 --- /dev/null +++ b/channels/altadefinizionecommunity.json @@ -0,0 +1,27 @@ +{ + "id": "altadefinizionecommunity", + "name": "Altadefinizione Community", + "language": ["ita", "sub-ita"], + "active": true, + "thumbnail": "", + "banner": "", + "categories": ["movie", "tvshow", "vos"], + "not_active": ["include_in_newest"], + "settings": [ + { + "default": "", + "enabled": true, + "id": "username", + "label": "username", + "type": "text", + "visible": true + }, + { + "default": "", + "enabled": true, + "id": "password", + "label": "password", + "type": "text", + "visible": true + }] +} diff --git a/channels/altadefinizionecommunity.py b/channels/altadefinizionecommunity.py new file mode 100644 index 00000000..79247c9b --- /dev/null +++ b/channels/altadefinizionecommunity.py @@ -0,0 +1,217 @@ +# -*- coding: utf-8 -*- +# ------------------------------------------------------------ +# Canale per Altadefinizione Community +from core import support +from lib.fakeMail import Gmailnator +from platformcode import config, platformtools, logger +from core import scrapertools, httptools + + +def findhost(url): + return support.match(url, patron=r'Accedi').match + + +host = config.get_channel_url(findhost) +register_url = 'https://altaregistrazione.com' +headers = [['Referer', host], ['x-requested-with', 'XMLHttpRequest']] + + +@support.menu +def mainlist(item): + support.info(item) + + film = ['/load-more-film?anno=&order=&support_webp=1&type=movie&page=1', + #Voce Menu,['url','action','args',contentType] + ('Generi', ['', 'genres', 'genres']), + ] + + tvshow = ['/load-more-film?type=tvshow&anno=&order=&support_webp=1&page=1', + #Voce Menu,['url','action','args',contentType] + ('Generi', ['', 'genres', 'genres']), + ] + + altri = [ + # ('Per Lettera', ['/lista-film', 'genres', 'letters']), + ('Qualità', ['', 'genres', 'quality']), + # ('Anni', ['/anno', 'genres', 'years']) + ] + search = '' + + return locals() + + +def login(): + r = httptools.downloadpage(host) + if 'id="logged"' in r.data: + logger.info('Già loggato') + else: + logger.info('Login in corso') + r = httptools.downloadpage(host + '/login', post={'email': config.get_setting('username', channel='altadefinizionecommunity'), + 'password': config.get_setting('password', channel='altadefinizionecommunity')}) + if not r.success or 'Email o Password non validi' in r.data: + platformtools.dialog_ok('AltadefinizioneCommunity', 'Username/password non validi') + return False + + return 'id="logged"' in r.data + + +def registerOrLogin(): + if config.get_setting('username', channel='altadefinizionecommunity') and config.get_setting('password', channel='altadefinizionecommunity'): + if login(): + return True + + action = platformtools.dialog_yesno('AltadefinizioneCommunity', + 'Questo server necessita di un account, ne hai già uno oppure vuoi tentare una registrazione automatica?', + yeslabel='Accedi', nolabel='Tenta registrazione', customlabel='Annulla') + if action == 1: # accedi + from specials import setting + from core.item import Item + user_pre = config.get_setting('username', channel='altadefinizionecommunity') + password_pre = config.get_setting('password', channel='altadefinizionecommunity') + setting.channel_config(Item(config='altadefinizionecommunity')) + user_post = config.get_setting('username', channel='altadefinizionecommunity') + password_post = config.get_setting('password', channel='altadefinizionecommunity') + + if user_pre != user_post or password_pre != password_post: + return registerOrLogin() + else: + return [] + elif action == 0: # tenta registrazione + import random + import string + logger.debug('Registrazione automatica in corso') + mailbox = Gmailnator() + randPsw = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(10)) + logger.debug('email: ' + mailbox.address) + logger.debug('pass: ' + randPsw) + reg = platformtools.dialog_register(register_url, email=True, password=True, email_default=mailbox.address, password_default=randPsw) + if not reg: + return False + regPost = httptools.downloadpage(register_url, post={'email': reg['email'], 'password': reg['password']}) + + if regPost.url == register_url: + error = scrapertools.htmlclean(scrapertools.find_single_match(regPost.data, 'Impossibile proseguire.*?')) + error = scrapertools.unescape(scrapertools.re.sub('\n\s+', ' ', error)) + platformtools.dialog_ok('AltadefinizioneCommunity', error) + return False + if reg['email'] == mailbox.address: + if "L'indirizzo email risulta già registrato" in regPost.data: + # httptools.downloadpage(baseUrl + '/forgotPassword', post={'email': reg['email']}) + platformtools.dialog_ok('AltadefinizioneCommunity', 'Indirizzo mail già utilizzato') + return False + mail = mailbox.waitForMail() + if mail: + checkUrl = scrapertools.find_single_match(mail.body, ']+>Verifica').replace(r'\/', '/') + logger.debug('CheckURL: ' + checkUrl) + httptools.downloadpage(checkUrl) + config.set_setting('username', mailbox.address, channel='altadefinizionecommunity') + config.set_setting('password', randPsw, channel='altadefinizionecommunity') + platformtools.dialog_ok('AltadefinizioneCommunity', + 'Registrato automaticamente con queste credenziali:\nemail:' + mailbox.address + '\npass: ' + randPsw) + else: + platformtools.dialog_ok('AltadefinizioneCommunity', 'Impossibile registrarsi automaticamente') + return False + else: + platformtools.dialog_ok('AltadefinizioneCommunity', 'Hai modificato la mail quindi KoD non sarà in grado di effettuare la verifica in autonomia, apri la casella ' + reg['email'] + + ' e clicca sul link. Premi ok quando fatto') + logger.debug('Registrazione completata') + else: + return False + + return True + + +@support.scrape +def peliculas(item): + # debug = True + support.info(item) + if '/load-more-film' not in item.url and '/search' not in item.url: # generi o altri menu, converto + import ast + ajax = support.match(item.url, patron="ajax_data\s*=\s*([^;]+)").match + item.url = host + '/load-more-film?' + support.urlencode(ast.literal_eval(ajax)) + '&page=1' + json = support.httptools.downloadpage(item.url, headers=headers).json + data = "\n".join(json['data']) + patron = r'wrapFilm">\s*\s*(?P[0-9]{4})\s*]+>[^<]+\s*(?P[^<]+).*?]+>\s*

(?P[^<[]+)(?:\[(?P<lang>[sSuUbBiItTaA-]+))?' + + # paginazione + if json.get('have_next'): + def fullItemlistHook(itemlist): + spl = item.url.split('=') + url = '='.join(spl[:-1]) + page = str(int(spl[-1])+1) + support.nextPage(itemlist, item, next_page='='.join((url, page)), function_or_level='peliculas') + return itemlist + return locals() + + +def search(item, texto): + support.info("search ", texto) + + item.args = 'search' + item.url = host + "/search?s={0}&page=1".format(texto) + try: + return peliculas(item) + # Continua la ricerca in caso di errore + except: + import sys + for line in sys.exc_info(): + support.logger.error("%s" % line) + return [] + + +@support.scrape +def genres(item): + support.info(item) + + patronMenu = r'<a href="(?P<url>[^"]+)">(?P<title>[^<]+)' + if item.args == 'quality': + patronBlock = 'Risoluzione(?P<block>.*?)</ul>' + else: + patronBlock = ('Film' if item.contentType == 'movie' else 'Serie TV') + r'<span></span></a>\s+<ul class="dropdown-menu(?P<block>.*?)active-parent-menu' + action = 'peliculas' + + # debug = True + return locals() + + +@support.scrape +def episodios(item): + support.info(item) + data = item.data + patron = r'class="playtvshow " data-href="(?P<url>[^"]+)' + + # debug = True + def itemHook(it): + spl = it.url.split('/')[-2:] + it.contentSeason = int(spl[0])+1 + it.contentEpisodeNumber = int(spl[1])+1 + it.title = str(it.contentSeason) + 'x' + str(it.contentEpisodeNumber) + return it + return locals() + + +def findvideos(item): + itemlist = [] + video_url = item.url + if '/watch-unsubscribed' not in video_url: + playWindow = support.match(item.url, patron='playWindow" href="([^"]+)') + video_url = playWindow.match + if '/tvshow' in video_url: + item.data = playWindow.data + return episodios(item) + itemlist.append(item.clone(action='play', url=support.match(video_url.replace('/watch-unsubscribed', '/watch-external'), + patron='src="([^"]+)').match, quality='')) + itemlist.append(item.clone(action='play', server='directo', title=support.config.get_localized_string(30137), + url=video_url.replace('/watch-unsubscribed', '/watch'))) + return support.server(item, itemlist=itemlist) + + +def play(item): + if host in item.url: # intercetto il server proprietario + if registerOrLogin(): + return support.get_jwplayer_mediaurl(httptools.downloadpage(item.url).data, 'Diretto') + else: + platformtools.play_canceled = True + return [] + else: + return [item] diff --git a/core/support.py b/core/support.py index d1ef244d..893f0aab 100755 --- a/core/support.py +++ b/core/support.py @@ -1166,6 +1166,7 @@ def nextPage(itemlist, item, data='', patron='', function_or_level=1, next_page= thumbnail=thumb())) return itemlist[-1] + def pagination(itemlist, item, page, perpage, function_level=1): if len(itemlist) >= page * perpage: itemlist.append( @@ -1381,9 +1382,8 @@ def addQualityTag(item, itemlist, data, patron): def get_jwplayer_mediaurl(data, srvName, onlyHttp=False, dataIsBlock=False): from core import jsontools - video_urls = [] - block = scrapertools.find_single_match(data, r'sources:\s*([^\]]+\])') if not dataIsBlock else data + block = scrapertools.find_single_match(data, r'sources"?\s*:\s*(.*?}])') if not dataIsBlock else data if block: json = jsontools.load(block) if json: @@ -1404,7 +1404,7 @@ def get_jwplayer_mediaurl(data, srvName, onlyHttp=False, dataIsBlock=False): for url, quality in sources: quality = 'auto' if not quality else quality if url.split('.')[-1] != 'mpd': - video_urls.append(['.' + url.split('.')[-1] + ' [' + quality + '] [' + srvName + ']', url if not onlyHttp else url.replace('https://', 'http://')]) + video_urls.append(['.' + url.split('.')[-1].split('?')[0] + ' [' + quality + '] [' + srvName + ']', url.replace(' ', '%20') if not onlyHttp else url.replace('https://', 'http://')]) video_urls.sort(key=lambda x: x[0].split()[1]) return video_urls diff --git a/core/tmdb.py b/core/tmdb.py index 6f3222c9..cd9c6209 100644 --- a/core/tmdb.py +++ b/core/tmdb.py @@ -1053,7 +1053,10 @@ class Tmdb(object): # We sort result based on fuzzy match to detect most similar if len(results) > 1: from lib.fuzzy_match import algorithims - results.sort(key=lambda r: algorithims.trigram(text_simple, r.get('name', '') if self.search_type == 'tv' else r.get('title', '')), reverse=True) + if self.search_type == 'multi': + results.sort(key=lambda r: algorithims.trigram(text_simple, r.get('name', '') if r.get('media_type') == 'tv' else r.get('title', '')), reverse=True) + else: + results.sort(key=lambda r: algorithims.trigram(text_simple, r.get('name', '') if self.search_type == 'tv' else r.get('title', '')), reverse=True) # We return the number of results of this page self.results = results @@ -1652,7 +1655,10 @@ class Tmdb(object): if v == "None": continue - if k == 'overview': + if k == 'media_type': + ret_infoLabels['mediatype'] = 'tvshow' if v == 'tv' else 'movie' + + elif k == 'overview': if origen: ret_infoLabels['plot'] = v else: diff --git a/servers/youdbox.py b/servers/youdbox.py index c60e6794..e8bd9a74 100644 --- a/servers/youdbox.py +++ b/servers/youdbox.py @@ -14,7 +14,7 @@ def test_video_exists(page_url): return True, "" -def get_video_url(page_url, video_password): +def get_video_url(page_url, premium=False, user="", password="", video_password=""): logger.info("(page_url='%s')" % page_url) global data video_urls = [] @@ -26,4 +26,4 @@ def get_video_url(page_url, video_password): url += decoded.decode("utf8") url = scrapertools.find_single_match(url, '<source src="([^"]+)"') video_urls.append(["[youdbox]", url]) - return video_urls \ No newline at end of file + return video_urls diff --git a/tests/test_generic.py b/tests/test_generic.py index 111b4329..e89b677e 100644 --- a/tests/test_generic.py +++ b/tests/test_generic.py @@ -315,7 +315,7 @@ class GenericServerTest(unittest.TestCase): def test_get_video_url(self): module = __import__('servers.%s' % self.name, fromlist=["servers.%s" % self.name]) page_url = self.server.url - httptools.default_headers['Referer'] = self.server.referer + # httptools.default_headers['Referer'] = self.server.referer print('testing ' + page_url) print('Found on ' + self.server.foundOn) print()