@@ -311,46 +311,45 @@ def _MFACheck(br, email, soup):
311311 Log ('MFA, DCQ or Captcha form' )
312312 uni_soup = soup .__unicode__ ()
313313 try :
314- br .select_form ('form[name="signIn"]' )
314+ form = br .select_form ('form[name="signIn"]' )
315315 except mechanicalsoup .LinkNotFoundError :
316- br .select_form ()
316+ form = br .select_form ()
317317
318318 if 'auth-mfa-form' in uni_soup :
319319 msg = soup .find ('form' , attrs = {'id' : 'auth-mfa-form' })
320- msgtxt = msg .p .renderContents (). strip ( )
320+ msgtxt = msg .p .get_text ( strip = True )
321321 kb = xbmc .Keyboard ('' , msgtxt )
322322 kb .doModal ()
323323 if kb .isConfirmed () and kb .getText ():
324324 # xbmc.executebuiltin('ActivateWindow(busydialog)')
325325 br ['otpCode' ] = kb .getText ()
326- # br.find_control('rememberDevice').items[0].selected = True
327326 else :
328- return False
327+ return None
329328 elif 'ap_dcq_form' in uni_soup :
330329 msg = soup .find ('div' , attrs = {'id' : 'message_warning' })
331- g .dialog .ok (g .__plugin__ , msg .p .contents [ 0 ]. strip ( ))
330+ g .dialog .ok (g .__plugin__ , msg .p .get_text ( strip = True ))
332331 dcq = soup .find ('div' , attrs = {'id' : 'ap_dcq1a_pagelet' })
333- dcq_title = dcq .find ('div' , attrs = {'id' : 'ap_dcq1a_pagelet_title' }).h1 . contents [ 0 ]. strip ( )
332+ dcq_title = dcq .find ('div' , attrs = {'id' : 'ap_dcq1a_pagelet_title' }).get_text ( strip = True )
334333 q_title = []
335334 q_id = []
336335 for q in dcq .findAll ('div' , attrs = {'class' : 'dcq_question' }):
337336 if q .span .label :
338- label = q .span .label .renderContents (). strip ( ).replace (' ' , '' ).replace ('\n ' , '' )
337+ label = q .span .label .get_text ( strip = True ).replace (' ' , '' ).replace ('\n ' , '' )
339338 if q .span .label .span :
340339 label = label .replace (str (q .span .label .span ), q .span .label .span .text )
341340 q_title .append (_insertLF (label ))
342341 q_id .append (q .input ['id' ])
343342
344343 sel = g .dialog .select (_insertLF (dcq_title , 60 ), q_title ) if len (q_title ) > 1 else 0
345344 if sel < 0 :
346- return False
345+ return None
347346
348347 ret = g .dialog .input (q_title [sel ])
349348 if ret :
350349 # xbmc.executebuiltin('ActivateWindow(busydialog)')
351350 br [q_id [sel ]] = ret
352351 else :
353- return False
352+ return None
354353 elif ('ap_captcha_img_label' in uni_soup ) or ('auth-captcha-image-container' in uni_soup ):
355354 wnd = _Captcha ((getString (30008 ).split ('…' )[0 ]), soup , email )
356355 wnd .doModal ()
@@ -360,35 +359,34 @@ def _MFACheck(br, email, soup):
360359 br ['password' ] = wnd .pwd
361360 br ['guess' ] = wnd .cap
362361 else :
363- return False
362+ return None
364363 del wnd
365364 elif 'claimspicker' in uni_soup :
366365 msg = soup .find ('form' , attrs = {'name' : 'claimspicker' })
367- cs_title = msg .find ('div' , attrs = {'class' : 'a-row a-spacing-small' })
368- cs_title = cs_title .h1 .contents [0 ].strip ()
366+ cs_title = msg .find ('div' , attrs = {'class' : 'a-row a-spacing-small' }).get_text (strip = True )
369367 cs_quest = msg .find ('label' , attrs = {'class' : 'a-form-label' })
370- cs_hint = msg .find ('div' , attrs = { 'class' : 'a-row' }). contents [ 0 ]. strip ( )
368+ cs_hint = msg .find (lambda tag : tag . name == 'div' and tag . get ( 'class' ) == [ 'a-row' ]). get_text ( strip = True )
371369 choices = []
372370 if cs_quest :
373371 for c in soup .findAll ('div' , attrs = {'data-a-input-name' : 'option' }):
374- choices .append ((c .span .contents [ 0 ]. strip ( ), c .input ['name' ], c .input ['value' ]))
375- sel = g .dialog .select ('%s - %s' % (cs_title , cs_quest .contents [ 0 ]. strip ( )), [k [0 ] for k in choices ])
372+ choices .append ((c .span .get_text ( strip = True ), c .input ['name' ], c .input ['value' ]))
373+ sel = g .dialog .select ('%s - %s' % (cs_title , cs_quest .get_text ( strip = True )), [k [0 ] for k in choices ])
376374 else :
377375 sel = 100 if g .dialog .ok (cs_title , cs_hint ) else - 1
378376
379377 if sel > - 1 :
380378 # xbmc.executebuiltin('ActivateWindow(busydialog)')
381379 if sel < 100 :
382- br [ choices [sel ][1 ]] = [ choices [sel ][2 ]]
380+ form . set_radio ({ choices [sel ][1 ]: choices [sel ][2 ]})
383381 else :
384- return False
382+ return None
385383 elif 'fwcim-form' in uni_soup :
386- msg = soup .find ('div' , attrs = {'class' : 'a-row a-spacing-micro cvf-widget-input-code-label' }).contents [ 0 ]. strip ( )
384+ msg = soup .find ('div' , attrs = {'class' : 'a-row a-spacing-micro cvf-widget-input-code-label' }).get_text ( strip = True )
387385 ret = g .dialog .input (msg )
388386 if ret :
389387 br ['code' ] = ret
390388 else :
391- return False
389+ return None
392390 return br
393391
394392 def _setLoginPW ():
@@ -508,20 +506,28 @@ def LoginLock():
508506 ('User-Agent' , getConfig ('UserAgent' )),
509507 ('Upgrade-Insecure-Requests' , '1' )]
510508 br .submit_selected ()
509+ # br.open_fake_page(open('/storage/emulated/0/Download/Kodi/avod-login-mfa.log').read())
511510 response , soup = _parseHTML (br )
512511 # xbmc.executebuiltin('Dialog.Close(busydialog)')
513512 WriteLog (response , 'login' )
514513
515514 while any (sp in response for sp in ['auth-mfa-form' , 'ap_dcq_form' , 'ap_captcha_img_label' , 'claimspicker' , 'fwcim-form' , 'auth-captcha-image-container' ]):
516515 br = _MFACheck (br , email , soup )
517- if not br :
516+ if br is None :
518517 return False
519518 useMFA = True if br .get_current_form ().form .find ('input' , {'name' : 'otpCode' }) else False
520519 br .submit_selected ()
521520 response , soup = _parseHTML (br )
522521 WriteLog (response , 'login-mfa' )
523522 # xbmc.executebuiltin('Dialog.Close(busydialog)')
524523
524+ if 'accountFixup' in response :
525+ Log ('Login AccountFixup' )
526+ skip_link = br .find_link (id = 'ap-account-fixup-phone-skip-link' )
527+ br .follow_link (skip_link )
528+ response , soup = _parseHTML (br )
529+ WriteLog (response , 'login-fixup' )
530+
525531 if 'action=sign-out' in response :
526532 try :
527533 usr = re .search (r'action=sign-out[^"]*"[^>]*>[^?]+\s+([^?]+?)\s*\?' , response ).group (1 )
0 commit comments