Fix altacommunity
This commit is contained in:
@@ -9,13 +9,13 @@ from core import scrapertools, httptools
|
|||||||
|
|
||||||
|
|
||||||
def findhost(url):
|
def findhost(url):
|
||||||
global register_url
|
|
||||||
register_url = url
|
|
||||||
return support.match(url, patron=r'<a href="([^"]+)/\w+">Accedi').match
|
return support.match(url, patron=r'<a href="([^"]+)/\w+">Accedi').match
|
||||||
|
|
||||||
host = config.get_channel_url(findhost)
|
|
||||||
|
|
||||||
if not 'altadeifnizionecommunity' in host:
|
host = config.get_channel_url(findhost)
|
||||||
|
register_url = 'https://altaregistrazione.net'
|
||||||
|
|
||||||
|
if 'altadefinizionecommunity' not in host:
|
||||||
config.get_channel_url(findhost, forceFindhost=True)
|
config.get_channel_url(findhost, forceFindhost=True)
|
||||||
|
|
||||||
if host.endswith('/'):
|
if host.endswith('/'):
|
||||||
@@ -42,6 +42,9 @@ def mainlist(item):
|
|||||||
|
|
||||||
def search(item, text):
|
def search(item, text):
|
||||||
logger.debug("search ", text)
|
logger.debug("search ", text)
|
||||||
|
# per evitare fastidi da ricerca globale
|
||||||
|
if not item.globalsearch:
|
||||||
|
registerOrLogin()
|
||||||
|
|
||||||
item.args = 'search'
|
item.args = 'search'
|
||||||
item.url = host + "/search?s={}&f={}".format(text.replace(' ', '+'), item.contentType)
|
item.url = host + "/search?s={}&f={}".format(text.replace(' ', '+'), item.contentType)
|
||||||
@@ -58,6 +61,7 @@ def search(item, text):
|
|||||||
|
|
||||||
@support.scrape
|
@support.scrape
|
||||||
def genres(item):
|
def genres(item):
|
||||||
|
registerOrLogin()
|
||||||
logger.debug(item)
|
logger.debug(item)
|
||||||
data = support.httptools.downloadpage(item.url).data
|
data = support.httptools.downloadpage(item.url).data
|
||||||
blacklist= ['Film', 'Serie TV']
|
blacklist= ['Film', 'Serie TV']
|
||||||
@@ -173,7 +177,7 @@ def play(item):
|
|||||||
|
|
||||||
|
|
||||||
def resolve_url(item):
|
def resolve_url(item):
|
||||||
# registerOrLogin()
|
registerOrLogin()
|
||||||
if '/watch-unsubscribed' not in item.url and '/watch-external' not in item.url:
|
if '/watch-unsubscribed' not in item.url and '/watch-external' not in item.url:
|
||||||
playWindow = support.match(support.httptools.downloadpage(item.url, cloudscraper=True).data, patron='playWindow" href="([^"]+)')
|
playWindow = support.match(support.httptools.downloadpage(item.url, cloudscraper=True).data, patron='playWindow" href="([^"]+)')
|
||||||
video_url = playWindow.match
|
video_url = playWindow.match
|
||||||
@@ -182,87 +186,87 @@ def resolve_url(item):
|
|||||||
return item
|
return item
|
||||||
|
|
||||||
|
|
||||||
# def login():
|
def login():
|
||||||
# r = support.httptools.downloadpage(host, cloudscraper=True)
|
r = support.httptools.downloadpage(host, cloudscraper=True)
|
||||||
# Token = support.match(r.data, patron=r'name=\s*"_token"\s*value=\s*"([^"]+)', cloudscraper=True).match
|
Token = support.match(r.data, patron=r'name=\s*"_token"\s*value=\s*"([^"]+)', cloudscraper=True).match
|
||||||
# if 'id="logged"' in r.data:
|
if 'id="logged"' in r.data:
|
||||||
# logger.info('Già loggato')
|
logger.info('Già loggato')
|
||||||
# else:
|
else:
|
||||||
# logger.info('Login in corso')
|
logger.info('Login in corso')
|
||||||
# post = {'_token': '',
|
post = {'_token': '',
|
||||||
# 'form_action':'login',
|
'form_action':'login',
|
||||||
# 'email': config.get_setting('username', channel='altadefinizionecommunity'),
|
'email': config.get_setting('username', channel='altadefinizionecommunity'),
|
||||||
# 'password':config.get_setting('password', channel='altadefinizionecommunity')}
|
'password':config.get_setting('password', channel='altadefinizionecommunity')}
|
||||||
|
|
||||||
# r = support.httptools.downloadpage(host + '/login', post=post, headers={'referer': host}, cloudscraper=True)
|
r = support.httptools.downloadpage(host + '/login', post=post, headers={'referer': host}, cloudscraper=True)
|
||||||
# if not r.status_code in [200, 302] or 'Email o Password non validi' in r.data:
|
if r.code not in [200, 302] or 'Email o Password non validi' in r.data:
|
||||||
# platformtools.dialog_ok('AltadefinizioneCommunity', 'Username/password non validi')
|
platformtools.dialog_ok('AltadefinizioneCommunity', 'Username/password non validi')
|
||||||
# return False
|
return False
|
||||||
|
|
||||||
# return 'id="logged"' in r.data
|
return 'id="logged"' in r.data
|
||||||
|
|
||||||
|
|
||||||
# def registerOrLogin():
|
def registerOrLogin():
|
||||||
# if config.get_setting('username', channel='altadefinizionecommunity') and config.get_setting('password', channel='altadefinizionecommunity'):
|
if config.get_setting('username', channel='altadefinizionecommunity') and config.get_setting('password', channel='altadefinizionecommunity'):
|
||||||
# if login():
|
if login():
|
||||||
# return True
|
return True
|
||||||
|
|
||||||
# action = platformtools.dialog_yesno('AltadefinizioneCommunity',
|
action = platformtools.dialog_yesno('AltadefinizioneCommunity',
|
||||||
# 'Questo server necessita di un account, ne hai già uno oppure vuoi tentare una registrazione automatica?',
|
'Questo server necessita di un account, ne hai già uno oppure vuoi tentare una registrazione automatica?',
|
||||||
# yeslabel='Accedi', nolabel='Tenta registrazione', customlabel='Annulla')
|
yeslabel='Accedi', nolabel='Tenta registrazione', customlabel='Annulla')
|
||||||
# if action == 1: # accedi
|
if action == 1: # accedi
|
||||||
# from specials import setting
|
from specials import setting
|
||||||
# from core.item import Item
|
from core.item import Item
|
||||||
# user_pre = config.get_setting('username', channel='altadefinizionecommunity')
|
user_pre = config.get_setting('username', channel='altadefinizionecommunity')
|
||||||
# password_pre = config.get_setting('password', channel='altadefinizionecommunity')
|
password_pre = config.get_setting('password', channel='altadefinizionecommunity')
|
||||||
# setting.channel_config(Item(config='altadefinizionecommunity'))
|
setting.channel_config(Item(config='altadefinizionecommunity'))
|
||||||
# user_post = config.get_setting('username', channel='altadefinizionecommunity')
|
user_post = config.get_setting('username', channel='altadefinizionecommunity')
|
||||||
# password_post = config.get_setting('password', channel='altadefinizionecommunity')
|
password_post = config.get_setting('password', channel='altadefinizionecommunity')
|
||||||
|
|
||||||
# if user_pre != user_post or password_pre != password_post:
|
if user_pre != user_post or password_pre != password_post:
|
||||||
# return registerOrLogin()
|
return registerOrLogin()
|
||||||
# else:
|
else:
|
||||||
# return []
|
return []
|
||||||
# elif action == 0: # tenta registrazione
|
elif action == 0: # tenta registrazione
|
||||||
# import random
|
import random
|
||||||
# import string
|
import string
|
||||||
# logger.debug('Registrazione automatica in corso')
|
logger.debug('Registrazione automatica in corso')
|
||||||
# mailbox = Gmailnator()
|
mailbox = Gmailnator()
|
||||||
# randPsw = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(10))
|
randPsw = ''.join(random.choice(string.ascii_letters + string.digits) for i in range(10))
|
||||||
# logger.debug('email: ' + mailbox.address)
|
logger.debug('email: ' + mailbox.address)
|
||||||
# logger.debug('pass: ' + randPsw)
|
logger.debug('pass: ' + randPsw)
|
||||||
# reg = platformtools.dialog_register(register_url, email=True, password=True, email_default=mailbox.address, password_default=randPsw)
|
reg = platformtools.dialog_register(register_url, email=True, password=True, email_default=mailbox.address, password_default=randPsw)
|
||||||
# if not reg:
|
if not reg:
|
||||||
# return False
|
return False
|
||||||
# regPost = httptools.downloadpage(register_url, post={'email': reg['email'], 'password': reg['password']}, cloudscraper=True)
|
regPost = httptools.downloadpage(register_url, post={'email': reg['email'], 'password': reg['password']}, cloudscraper=True)
|
||||||
|
|
||||||
# if regPost.url == register_url:
|
if regPost.url == register_url:
|
||||||
# error = scrapertools.htmlclean(scrapertools.find_single_match(regPost.data, 'Impossibile proseguire.*?</div>'))
|
error = scrapertools.htmlclean(scrapertools.find_single_match(regPost.data, 'Impossibile proseguire.*?</div>'))
|
||||||
# error = scrapertools.unescape(scrapertools.re.sub('\n\s+', ' ', error))
|
error = scrapertools.unescape(scrapertools.re.sub('\n\s+', ' ', error))
|
||||||
# platformtools.dialog_ok('AltadefinizioneCommunity', error)
|
platformtools.dialog_ok('AltadefinizioneCommunity', error)
|
||||||
# return False
|
return False
|
||||||
# if reg['email'] == mailbox.address:
|
if reg['email'] == mailbox.address:
|
||||||
# if "L'indirizzo email risulta già registrato" in regPost.data:
|
if "L'indirizzo email risulta già registrato" in regPost.data:
|
||||||
# # httptools.downloadpage(baseUrl + '/forgotPassword', post={'email': reg['email']})
|
# httptools.downloadpage(baseUrl + '/forgotPassword', post={'email': reg['email']})
|
||||||
# platformtools.dialog_ok('AltadefinizioneCommunity', 'Indirizzo mail già utilizzato')
|
platformtools.dialog_ok('AltadefinizioneCommunity', 'Indirizzo mail già utilizzato')
|
||||||
# return False
|
return False
|
||||||
# mail = mailbox.waitForMail()
|
mail = mailbox.waitForMail()
|
||||||
# if mail:
|
if mail:
|
||||||
# checkUrl = scrapertools.find_single_match(mail.body, '<a href="([^"]+)[^>]+>Verifica').replace(r'\/', '/')
|
checkUrl = scrapertools.find_single_match(mail.body, '<a href="([^"]+)[^>]+>Verifica').replace(r'\/', '/')
|
||||||
# logger.debug('CheckURL: ' + checkUrl)
|
logger.debug('CheckURL: ' + checkUrl)
|
||||||
# httptools.downloadpage(checkUrl, cloudscraper=True)
|
httptools.downloadpage(checkUrl, cloudscraper=True)
|
||||||
# config.set_setting('username', mailbox.address, channel='altadefinizionecommunity')
|
config.set_setting('username', mailbox.address, channel='altadefinizionecommunity')
|
||||||
# config.set_setting('password', randPsw, channel='altadefinizionecommunity')
|
config.set_setting('password', randPsw, channel='altadefinizionecommunity')
|
||||||
# platformtools.dialog_ok('AltadefinizioneCommunity',
|
platformtools.dialog_ok('AltadefinizioneCommunity',
|
||||||
# 'Registrato automaticamente con queste credenziali:\nemail:' + mailbox.address + '\npass: ' + randPsw)
|
'Registrato automaticamente con queste credenziali:\nemail:' + mailbox.address + '\npass: ' + randPsw)
|
||||||
# else:
|
else:
|
||||||
# platformtools.dialog_ok('AltadefinizioneCommunity', 'Impossibile registrarsi automaticamente')
|
platformtools.dialog_ok('AltadefinizioneCommunity', 'Impossibile registrarsi automaticamente')
|
||||||
# return False
|
return False
|
||||||
# else:
|
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']
|
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')
|
+ ' e clicca sul link. Premi ok quando fatto')
|
||||||
# logger.debug('Registrazione completata')
|
logger.debug('Registrazione completata')
|
||||||
# else:
|
else:
|
||||||
# return False
|
return False
|
||||||
|
|
||||||
# return True
|
return True
|
||||||
|
|||||||
@@ -766,6 +766,7 @@ def menuItem(itemlist, filename, title='', action='', url='', contentType='undef
|
|||||||
extra = extra,
|
extra = extra,
|
||||||
args = args,
|
args = args,
|
||||||
contentType = contentType,
|
contentType = contentType,
|
||||||
|
globalsearch = not style
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user