28 lines
1.2 KiB
Python
28 lines
1.2 KiB
Python
import email, imaplib, re, sys, time
|
|
from email.header import decode_header
|
|
addr, pwd, wait = sys.argv[1], sys.argv[2], int(sys.argv[3]) if len(sys.argv) > 3 else 120
|
|
dl = time.time() + wait
|
|
while time.time() < dl:
|
|
try:
|
|
M = imaplib.IMAP4_SSL('secureimap.t-online.de', 993)
|
|
M.login(addr, pwd)
|
|
M.select('INBOX', readonly=True)
|
|
typ, ids = M.search(None, 'FROM', 'framer')
|
|
idl = ids[0].split()
|
|
if idl:
|
|
typ, msg = M.fetch(idl[-1], '(RFC822)')
|
|
m = email.message_from_bytes(msg[0][1])
|
|
body = ''
|
|
for part in (m.walk() if m.is_multipart() else [m]):
|
|
if part.get_content_type() in ('text/plain','text/html'):
|
|
try: body += part.get_payload(decode=True).decode(part.get_content_charset() or 'utf-8','replace')
|
|
except Exception: pass
|
|
mm = re.search(r'https://framer\.com/login#token=([0-9a-f-]{36})', body)
|
|
if mm:
|
|
print(mm.group(1)); M.logout(); sys.exit(0)
|
|
M.logout()
|
|
except Exception as e:
|
|
print('ERR', str(e)[:80], file=sys.stderr)
|
|
time.sleep(6)
|
|
print('NONE'); sys.exit(1)
|