Fix Login Altadefinizione Community
This commit is contained in:
@@ -6,6 +6,8 @@ from lib.fakeMail import Gmailnator
|
|||||||
from platformcode import config, platformtools, logger
|
from platformcode import config, platformtools, logger
|
||||||
from core import scrapertools, httptools
|
from core import scrapertools, httptools
|
||||||
|
|
||||||
|
from lib import cloudscraper
|
||||||
|
|
||||||
|
|
||||||
def findhost(url):
|
def findhost(url):
|
||||||
return support.match(url, patron=r'<a href="([^"]+)/\w+">Accedi').match
|
return support.match(url, patron=r'<a href="([^"]+)/\w+">Accedi').match
|
||||||
@@ -15,6 +17,7 @@ host = config.get_channel_url(findhost)
|
|||||||
register_url = 'https://altaregistrazione.com'
|
register_url = 'https://altaregistrazione.com'
|
||||||
headers = [['Referer', host], ['x-requested-with', 'XMLHttpRequest']]
|
headers = [['Referer', host], ['x-requested-with', 'XMLHttpRequest']]
|
||||||
|
|
||||||
|
cf = cloudscraper.create_scraper()
|
||||||
|
|
||||||
@support.menu
|
@support.menu
|
||||||
def mainlist(item):
|
def mainlist(item):
|
||||||
@@ -41,19 +44,23 @@ def mainlist(item):
|
|||||||
|
|
||||||
|
|
||||||
def login():
|
def login():
|
||||||
r = httptools.downloadpage(host)
|
r = cf.get(host)
|
||||||
Token = support.match(r.data, patron=r'name=\s*"_token"\s*value=\s*"([^"]+)').match
|
Token = support.match(r.text, patron=r'name=\s*"_token"\s*value=\s*"([^"]+)').match
|
||||||
if 'id="logged"' in r.data:
|
if 'id="logged"' in r.text:
|
||||||
logger.info('Già loggato')
|
logger.info('Già loggato')
|
||||||
else:
|
else:
|
||||||
logger.info('Login in corso')
|
logger.info('Login in corso')
|
||||||
post = '_token={}&form_action=login&email={}&password={}'.format(Token, config.get_setting('username', channel='altadefinizionecommunity'),config.get_setting('password', channel='altadefinizionecommunity'))
|
post = {'_token': '',
|
||||||
r = httptools.downloadpage(host + '/login', post=post)
|
'form_action':'login',
|
||||||
if not r.success or 'Email o Password non validi' in r.data:
|
'email': config.get_setting('username', channel='altadefinizionecommunity'),
|
||||||
|
'password':config.get_setting('password', channel='altadefinizionecommunity')}
|
||||||
|
|
||||||
|
r = cf.post(host + '/login', json=post, headers={'referer': host})
|
||||||
|
if not r.status_code in [200, 302] or 'Email o Password non validi' in r.text:
|
||||||
platformtools.dialog_ok('AltadefinizioneCommunity', 'Username/password non validi')
|
platformtools.dialog_ok('AltadefinizioneCommunity', 'Username/password non validi')
|
||||||
return False
|
return False
|
||||||
logger.debug(r.data)
|
|
||||||
return 'id="logged"' in r.data
|
return 'id="logged"' in r.text
|
||||||
|
|
||||||
|
|
||||||
def registerOrLogin():
|
def registerOrLogin():
|
||||||
@@ -195,7 +202,7 @@ def findvideos(item):
|
|||||||
itemlist = []
|
itemlist = []
|
||||||
video_url = item.url
|
video_url = item.url
|
||||||
if '/watch-unsubscribed' not in video_url:
|
if '/watch-unsubscribed' not in video_url:
|
||||||
playWindow = support.match(item.url, patron='playWindow" href="([^"]+)')
|
playWindow = support.match(cf.get(item.url).text, patron='playWindow" href="([^"]+)')
|
||||||
video_url = playWindow.match
|
video_url = playWindow.match
|
||||||
if '/tvshow' in video_url:
|
if '/tvshow' in video_url:
|
||||||
item.data = playWindow.data
|
item.data = playWindow.data
|
||||||
@@ -212,7 +219,7 @@ def findvideos(item):
|
|||||||
def play(item):
|
def play(item):
|
||||||
if host in item.url: # intercetto il server proprietario
|
if host in item.url: # intercetto il server proprietario
|
||||||
if registerOrLogin():
|
if registerOrLogin():
|
||||||
return support.get_jwplayer_mediaurl(httptools.downloadpage(item.url).data, 'Diretto')
|
return support.get_jwplayer_mediaurl(cf.get(item.url).text, 'Diretto')
|
||||||
else:
|
else:
|
||||||
platformtools.play_canceled = True
|
platformtools.play_canceled = True
|
||||||
return []
|
return []
|
||||||
|
|||||||
Reference in New Issue
Block a user