hdmario:supporto conferma con mail
This commit is contained in:
51
lib/onesecmail.py
Normal file
51
lib/onesecmail.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import random
|
||||
import string
|
||||
import time
|
||||
|
||||
from core import httptools
|
||||
|
||||
baseUrl = 'https://www.1secmail.com/api/v1/'
|
||||
defDomain = '1secmail.com'
|
||||
|
||||
def splitMail(mail):
|
||||
if '@' in mail:
|
||||
user, domain = mail.split('@')
|
||||
else:
|
||||
user = mail
|
||||
domain = defDomain
|
||||
return user, domain
|
||||
|
||||
def getMessages(mail):
|
||||
"""
|
||||
:param user: user@1secmail.com
|
||||
:return: json containing inbox id and subjects
|
||||
"""
|
||||
user, domain = splitMail(mail)
|
||||
apiUrl = baseUrl + '?action=getMessages&login=' + user + '&domain=' + domain
|
||||
return httptools.downloadpage(apiUrl).json
|
||||
|
||||
|
||||
def readLastMessage(mail):
|
||||
user, domain = splitMail(mail)
|
||||
try:
|
||||
id = getMessages(mail)[0]['id']
|
||||
except:
|
||||
return None
|
||||
apiUrl = baseUrl + '?action=readMessage&login=' + user + '&domain=' + domain + '&id=' + str(id)
|
||||
return httptools.downloadpage(apiUrl).json
|
||||
|
||||
|
||||
def waitForMail(mail, timeout=10):
|
||||
secs = 0
|
||||
while secs < 10:
|
||||
msg = readLastMessage(mail)
|
||||
if msg:
|
||||
return msg
|
||||
else:
|
||||
time.sleep(1)
|
||||
secs += 1
|
||||
return None
|
||||
|
||||
def getRandom(len=10):
|
||||
letters = string.ascii_lowercase
|
||||
return ''.join(random.choice(letters) for i in range(len)) + '@' + defDomain
|
||||
@@ -5,7 +5,7 @@
|
||||
"patterns": [
|
||||
{
|
||||
"pattern": "https?://hdmario.live/embed/([0-9]+)",
|
||||
"url": "https://hdmario.live/embed/\\1?"
|
||||
"url": "https://hdmario.live/embed/\\1"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
@@ -8,8 +8,22 @@ baseUrl = 'https://hdmario.live'
|
||||
def test_video_exists(page_url):
|
||||
logger.info("(page_url='%s')" % page_url)
|
||||
global data
|
||||
|
||||
page = httptools.downloadpage(page_url)
|
||||
logger.info(page.url)
|
||||
if 'unconfirmed' in page.url:
|
||||
from lib import onesecmail
|
||||
id = page_url.split('/')[-1]
|
||||
mail = onesecmail.getRandom()
|
||||
postData = {
|
||||
'email': mail,
|
||||
'hls_video_id': id
|
||||
}
|
||||
httptools.downloadpage(page.url, post=postData)
|
||||
jsonMail = onesecmail.waitForMail(mail)
|
||||
logger.info(jsonMail)
|
||||
code = jsonMail['subject'].split(' - ')[0]
|
||||
page = httptools.downloadpage(page_url + '?code=' + code)
|
||||
data = page.data
|
||||
if "the page you are looking for could not be found" in data:
|
||||
return False, config.get_localized_string(70449) % "HDmario"
|
||||
|
||||
Reference in New Issue
Block a user