@@ -780,26 +780,50 @@ def advancedsettings(device):
780780
781781def accountinfo ():
782782 response = tools .OPEN_URL (panel_api )
783- parse = json .loads (response )
784- expiry = parse ['user_info' ]['exp_date' ]
785- if not expiry == "" :
786- expiry = datetime .datetime .fromtimestamp (int (expiry )).strftime ('%d/%m/%Y - %H:%M' )
787- expreg = re .compile ('^(.*?)/(.*?)/(.*?)$' ,re .DOTALL ).findall (expiry )
788- for day ,month ,year in expreg :
789- month = tools .MonthNumToName (month )
790- year = re .sub (' -.*?$' ,'' ,year )
791- expiry = month + ' ' + day + ' - ' + year
792- else :
793- expiry = 'Unlimited'
794- tools .addDir ('[B][COLOR white]Username :[/COLOR][/B] ' + parse ['user_info' ]['username' ],'' ,'' ,icon ,background ,'' )
795- tools .addDir ('[B][COLOR white]Password :[/COLOR][/B] ' + parse ['user_info' ]['password' ],'' ,'' ,icon ,background ,'' )
796- tools .addDir ('[B][COLOR white]Expiry Date:[/COLOR][/B] ' + expiry ,'' ,'' ,icon ,background ,'' )
797- tools .addDir ('[B][COLOR white]Account Status :[/COLOR][/B] %s' % parse ['user_info' ]['status' ],'' ,'' ,icon ,background ,'' )
798- tools .addDir ('[B][COLOR white]Current Connections:[/COLOR][/B] ' + parse ['user_info' ]['active_cons' ],'' ,'' ,icon ,background ,'' )
799- tools .addDir ('[B][COLOR white]Allowed Connections:[/COLOR][/B] ' + parse ['user_info' ]['max_connections' ],'' ,'' ,icon ,background ,'' )
800- tools .addDir ('[B][COLOR white]Local IP Address:[/COLOR][/B] ' + tools .getlocalip (),'' ,'' ,icon ,background ,'' )
801- tools .addDir ('[B][COLOR white]External IP Address:[/COLOR][/B] ' + tools .getexternalip (),'' ,'' ,icon ,background ,'' )
802- tools .addDir ('[B][COLOR white]Kodi Version:[/COLOR][/B] ' + str (KODIV ),'' ,'' ,icon ,background ,'' )
783+ if not response :
784+ tools .addDir ('[B][COLOR white]Account Information:[/COLOR][/B] Unable to fetch account details (no response)' , '' , '' , icon , background , '' )
785+ return
786+ try :
787+ parse = json .loads (response )
788+ except Exception as e :
789+ try :
790+ xbmc .log (f'{ ADDON_ID } : accountinfo() JSON parse error: { e } ' , LOG_NOTICE )
791+ except Exception :
792+ pass
793+ tools .addDir ('[B][COLOR white]Account Information:[/COLOR][/B] Unable to parse server response' , '' , '' , icon , background , '' )
794+ return
795+ user_info = parse .get ('user_info' , {}) or {}
796+ expiry_raw = user_info .get ('exp_date' , '' )
797+ expiry = 'Unlimited'
798+ if expiry_raw not in (None , '' , '0' ):
799+ try :
800+ expiry_ts = int (expiry_raw )
801+ expiry = datetime .datetime .fromtimestamp (expiry_ts ).strftime ('%d/%m/%Y - %H:%M' )
802+ expreg = re .compile ('^(.*?)/(.*?)/(.*?)$' , re .DOTALL ).findall (expiry )
803+ if expreg :
804+ day , month , year = expreg [0 ]
805+ month = tools .MonthNumToName (month )
806+ year = re .sub (' -.*?$' , '' , year )
807+ expiry = month + ' ' + day + ' - ' + year
808+ except Exception :
809+ expiry = 'Unlimited'
810+ username = str (user_info .get ('username' , '' ))
811+ password = str (user_info .get ('password' , '' ))
812+ status = str (user_info .get ('status' , '' ))
813+ active_cons = str (user_info .get ('active_cons' , '' ))
814+ max_connections = str (user_info .get ('max_connections' , '' ))
815+ local_ip = str (tools .getlocalip () or '' )
816+ external_ip = str (tools .getexternalip () or '' )
817+
818+ tools .addDir ('[B][COLOR white]Username :[/COLOR][/B] ' + username , '' , '' , icon , background , '' )
819+ tools .addDir ('[B][COLOR white]Password :[/COLOR][/B] ' + password , '' , '' , icon , background , '' )
820+ tools .addDir ('[B][COLOR white]Expiry Date:[/COLOR][/B] ' + expiry , '' , '' , icon , background , '' )
821+ tools .addDir ('[B][COLOR white]Account Status :[/COLOR][/B] %s' % status , '' , '' , icon , background , '' )
822+ tools .addDir ('[B][COLOR white]Current Connections:[/COLOR][/B] ' + active_cons , '' , '' , icon , background , '' )
823+ tools .addDir ('[B][COLOR white]Allowed Connections:[/COLOR][/B] ' + max_connections , '' , '' , icon , background , '' )
824+ tools .addDir ('[B][COLOR white]Local IP Address:[/COLOR][/B] ' + local_ip , '' , '' , icon , background , '' )
825+ tools .addDir ('[B][COLOR white]External IP Address:[/COLOR][/B] ' + external_ip , '' , '' , icon , background , '' )
826+ tools .addDir ('[B][COLOR white]Kodi Version:[/COLOR][/B] ' + str (KODIV ), '' , '' , icon , background , '' )
803827
804828def waitasec (time_to_wait ,title ,text ):
805829 FTGcd = xbmcgui .DialogProgress ()
0 commit comments