<s> '''<STR_LIT>''' <EOL> import urllib , json , time <EOL> import urlparse <EOL> from resources . lib . libraries import cache <EOL> from resources . lib . libraries import control <EOL> from resources . lib . libraries import client <EOL> def rdAuthorize ( ) : <EOL> try : <EOL> CLIENT_ID = '<STR_LIT>' <EOL> USER_AGENT = '<STR_LIT>' <EOL> if not '<STR_LIT>' in credentials ( ) [ '<STR_LIT>' ] . values ( ) : <EOL> if control . yesnoDialog ( control . lang ( <NUM_LIT> ) . encode ( '<STR_LIT:utf-8>' ) , control . lang ( <NUM_LIT> ) . encode ( '<STR_LIT:utf-8>' ) , '<STR_LIT>' , '<STR_LIT>' , control . lang ( <NUM_LIT> ) . encode ( '<STR_LIT:utf-8>' ) , control . lang ( <NUM_LIT> ) . encode ( '<STR_LIT:utf-8>' ) ) : <EOL> control . set_setting ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> control . set_setting ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> control . set_setting ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> control . set_setting ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> control . set_setting ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> raise Exception ( ) <EOL> headers = { '<STR_LIT>' : USER_AGENT } <EOL> url = '<STR_LIT>' % ( CLIENT_ID ) <EOL> result = client . request ( url , headers = headers ) <EOL> result = json . loads ( result ) <EOL> verification_url = control . lang ( <NUM_LIT> ) . encode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' % ( result [ '<STR_LIT>' ] ) <EOL> user_code = control . lang ( <NUM_LIT> ) . encode ( '<STR_LIT:utf-8>' ) + '<STR_LIT>' % ( result [ '<STR_LIT>' ] ) <EOL> device_code = result [ '<STR_LIT>' ] <EOL> interval = result [ '<STR_LIT>' ] <EOL> progressDialog = control . progressDialog <EOL> progressDialog . create ( '<STR_LIT>' , verification_url , user_code ) <EOL> for i in range ( <NUM_LIT:0> , <NUM_LIT> ) : <EOL> try : <EOL> if progressDialog . iscanceled ( ) : break <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> if not float ( i ) % interval == <NUM_LIT:0> : raise Exception ( ) <EOL> url = '<STR_LIT>' % ( CLIENT_ID , device_code ) <EOL> result = client . request ( url , headers = headers , error = True ) <EOL> result = json . loads ( result ) <EOL> if '<STR_LIT>' in result : break <EOL> except : <EOL> pass <EOL> try : progressDialog . close ( ) <EOL> except : pass <EOL> id , secret = result [ '<STR_LIT>' ] , result [ '<STR_LIT>' ] <EOL> url = '<STR_LIT>' <EOL> post = { '<STR_LIT>' : id , '<STR_LIT>' : secret , '<STR_LIT:code>' : device_code , '<STR_LIT>' : '<STR_LIT>' } <EOL> result = client . request ( url , post = post , headers = headers ) <EOL> result = json . loads ( result ) <EOL> token , refresh = result [ '<STR_LIT>' ] , result [ '<STR_LIT>' ] <EOL> control . set_setting ( '<STR_LIT>' , id ) <EOL> control . set_setting ( '<STR_LIT>' , secret ) <EOL> control . set_setting ( '<STR_LIT>' , token ) <EOL> control . set_setting ( '<STR_LIT>' , refresh ) <EOL> control . set_setting ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> raise Exception ( ) <EOL> except : <EOL> control . openSettings ( '<STR_LIT>' ) <EOL> def rdDict ( ) : <EOL> try : <EOL> if '<STR_LIT>' in credentials ( ) [ '<STR_LIT>' ] . values ( ) : raise Exception ( ) <EOL> url = '<STR_LIT>' <EOL> result = cache . get ( client . request , <NUM_LIT> , url ) <EOL> hosts = json . loads ( result ) <EOL> hosts = [ i . lower ( ) for i in hosts ] <EOL> return hosts <EOL> except : <EOL> return [ ] <EOL> def pzDict ( ) : <EOL> try : <EOL> if '<STR_LIT>' in credentials ( ) [ '<STR_LIT>' ] . values ( ) : raise Exception ( ) <EOL> user , password = credentials ( ) [ '<STR_LIT>' ] [ '<STR_LIT:user>' ] , credentials ( ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> url = '<STR_LIT>' % ( user , password ) <EOL> result = cache . get ( client . request , <NUM_LIT> , url ) <EOL> hosts = json . loads ( result ) [ '<STR_LIT:result>' ] [ '<STR_LIT>' ] <EOL> hosts = [ i . lower ( ) for i in hosts ] <EOL> return hosts <EOL> except : <EOL> return [ ] <EOL> def adDict ( ) : <EOL> try : <EOL> if '<STR_LIT>' in credentials ( ) [ '<STR_LIT>' ] . values ( ) : raise Exception ( ) <EOL> url = '<STR_LIT>' <EOL> result = cache . get ( client . request , <NUM_LIT> , url ) <EOL> hosts = json . loads ( '<STR_LIT>' % result ) <EOL> hosts = [ i . lower ( ) for i in hosts ] <EOL> return hosts <EOL> except : <EOL> return [ ] <EOL> def rpDict ( ) : <EOL> try : <EOL> if '<STR_LIT>' in credentials ( ) [ '<STR_LIT>' ] . values ( ) : raise Exception ( ) <EOL> url = '<STR_LIT>' <EOL> result = cache . get ( client . request , <NUM_LIT> , url ) <EOL> result = json . loads ( result ) <EOL> hosts = result [ '<STR_LIT>' ] <EOL> hosts = [ i . lower ( ) for i in hosts ] <EOL> return hosts <EOL> except : <EOL> return [ ] <EOL> def debridDict ( ) : <EOL> return { <EOL> '<STR_LIT>' : rdDict ( ) , <EOL> '<STR_LIT>' : pzDict ( ) , <EOL> '<STR_LIT>' : adDict ( ) , <EOL> '<STR_LIT>' : rpDict ( ) <EOL> } <EOL> def credentials ( ) : <EOL> return { <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:id>' : control . setting ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : control . setting ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : control . setting ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : control . setting ( '<STR_LIT>' ) <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:user>' : control . setting ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : control . setting ( '<STR_LIT>' ) <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:user>' : control . setting ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : control . setting ( '<STR_LIT>' ) <EOL> } , <EOL> '<STR_LIT>' : { <EOL> '<STR_LIT:user>' : control . setting ( '<STR_LIT>' ) , <EOL> '<STR_LIT>' : control . setting ( '<STR_LIT>' ) <EOL> } } <EOL> def status ( ) : <EOL> try : <EOL> c = [ i for i in credentials ( ) . values ( ) if not '<STR_LIT>' in i . values ( ) ] <EOL> if len ( c ) == <NUM_LIT:0> : return False <EOL> else : return True <EOL> except : <EOL> return False <EOL> def getHosts ( ) : <EOL> myhosts = rdDict ( ) <EOL> for i in range ( len ( myhosts ) ) : <EOL> myhosts [ i ] = myhosts [ i ] . split ( '<STR_LIT:.>' ) [ - <NUM_LIT:2> ] . encode ( '<STR_LIT:utf-8>' ) <EOL> return myhosts <EOL> def resolve ( url , debrid = '<STR_LIT>' ) : <EOL> u = url <EOL> u = u . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> try : <EOL> u1 = urlparse . urlparse ( url ) [ <NUM_LIT:1> ] . split ( '<STR_LIT:.>' ) <EOL> u1 = u [ - <NUM_LIT:2> ] + '<STR_LIT:.>' + u [ - <NUM_LIT:1> ] <EOL> if status ( ) is False : raise Exception ( ) <EOL> if not debrid == '<STR_LIT>' and not debrid == True : raise Exception ( ) <EOL> if '<STR_LIT>' in credentials ( ) [ '<STR_LIT>' ] . values ( ) : raise Exception ( ) <EOL> id , secret , token , refresh = credentials ( ) [ '<STR_LIT>' ] [ '<STR_LIT:id>' ] , credentials ( ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] , credentials ( ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] , credentials ( ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> USER_AGENT = '<STR_LIT>' <EOL> post = { '<STR_LIT>' : u } <EOL> headers = { '<STR_LIT>' : '<STR_LIT>' % token , '<STR_LIT>' : USER_AGENT } <EOL> url = '<STR_LIT>' <EOL> result = client . request ( url , post = post , headers = headers , error = True ) <EOL> control . log ( '<STR_LIT>' % result ) <EOL> result = json . loads ( result ) <EOL> if '<STR_LIT:error>' in result and result [ '<STR_LIT:error>' ] == '<STR_LIT>' : <EOL> result = client . request ( '<STR_LIT>' , post = { '<STR_LIT>' : id , '<STR_LIT>' : secret , '<STR_LIT:code>' : refresh , '<STR_LIT>' : '<STR_LIT>' } , headers = { '<STR_LIT>' : USER_AGENT } , error = True ) <EOL> result = json . loads ( result ) <EOL> control . log ( '<STR_LIT>' % ( id , refresh ) ) <EOL> control . log ( '<STR_LIT>' % ( result ) ) <EOL> if '<STR_LIT:error>' in result : return <EOL> token , refresh = result [ '<STR_LIT>' ] , result [ '<STR_LIT>' ] <EOL> control . set_setting ( '<STR_LIT>' , token ) <EOL> control . set_setting ( '<STR_LIT>' , refresh ) <EOL> headers [ '<STR_LIT>' ] = '<STR_LIT>' % result [ '<STR_LIT>' ] <EOL> result = client . request ( url , post = post , headers = headers ) <EOL> result = json . loads ( result ) <EOL> if '<STR_LIT:error>' in result and result [ '<STR_LIT:error>' ] == '<STR_LIT>' : <EOL> control . log ( "<STR_LIT>" % ( url ) ) <EOL> return <EOL> url = result [ '<STR_LIT>' ] <EOL> control . log ( '<STR_LIT>' % url ) <EOL> return url <EOL> except : <EOL> pass <EOL> try : <EOL> if not debrid == '<STR_LIT>' and not debrid == True : raise Exception ( ) <EOL> if '<STR_LIT>' in credentials ( ) [ '<STR_LIT>' ] . values ( ) : raise Exception ( ) <EOL> user , password = credentials ( ) [ '<STR_LIT>' ] [ '<STR_LIT:user>' ] , credentials ( ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> url = '<STR_LIT>' % ( user , password , urllib . quote_plus ( u ) ) <EOL> result = client . request ( url , close = False ) <EOL> url = json . loads ( result ) [ '<STR_LIT:result>' ] [ '<STR_LIT:location>' ] <EOL> return url <EOL> except : <EOL> pass <EOL> try : <EOL> if not debrid == '<STR_LIT>' and not debrid == True : raise Exception ( ) <EOL> if '<STR_LIT>' in credentials ( ) [ '<STR_LIT>' ] . values ( ) : raise Exception ( ) <EOL> user , password = credentials ( ) [ '<STR_LIT>' ] [ '<STR_LIT:user>' ] , credentials ( ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> login_data = { '<STR_LIT:action>' : '<STR_LIT>' , '<STR_LIT>' : user , '<STR_LIT>' : password } <EOL> login_link = '<STR_LIT>' % login_data <EOL> cookie = client . request ( login_link , output = '<STR_LIT>' , close = False ) <EOL> url = '<STR_LIT>' % urllib . quote_plus ( u ) <EOL> result = client . request ( url , cookie = cookie , close = False ) <EOL> url = client . parseDOM ( result , '<STR_LIT:a>' , ret = '<STR_LIT>' , attrs = { '<STR_LIT:class>' : '<STR_LIT>' } ) [ <NUM_LIT:0> ] <EOL> url = client . replaceHTMLCodes ( url ) <EOL> url = '<STR_LIT>' % ( url , urllib . quote_plus ( cookie ) ) <EOL> return url <EOL> except : <EOL> pass <EOL> try : <EOL> if not debrid == '<STR_LIT>' and not debrid == True : raise Exception ( ) <EOL> if '<STR_LIT>' in credentials ( ) [ '<STR_LIT>' ] . values ( ) : raise Exception ( ) <EOL> user , password = credentials ( ) [ '<STR_LIT>' ] [ '<STR_LIT:user>' ] , credentials ( ) [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> login_data = { '<STR_LIT:username>' : user , '<STR_LIT:password>' : password , '<STR_LIT:action>' : '<STR_LIT>' , '<STR_LIT>' : u } <EOL> login_link = '<STR_LIT>' % login_data <EOL> result = client . request ( login_link , close = False ) <EOL> result = json . loads ( result ) <EOL> url = result [ '<STR_LIT>' ] [ <NUM_LIT:0> ] [ '<STR_LIT>' ] <EOL> return url <EOL> except : <EOL> return </s>
