MCPcopy Create free account
hub / github.com/smallfawn/QLScriptPublic / load_token_from_cache

Method load_token_from_cache

daily/chinaUnicom.py:530–549  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

528 return None
529
530 def load_token_from_cache(self):
531 if not self.account_mobile:
532 return False
533 if not os.path.exists(UNICOM_TOKEN_CACHE_PATH):
534 return False
535 try:
536 with open(UNICOM_TOKEN_CACHE_PATH, 'r', encoding='utf-8') as f:
537 cache = json.load(f)
538 user_cache = cache.get(self.account_mobile)
539 if user_cache and user_cache.get('token_online'):
540 if (datetime.now().timestamp() * 1000) - user_cache.get('timestamp', 0) < 12 * 60 * 60 * 1000:
541 self.token_online = user_cache['token_online']
542 self.appId = user_cache.get('appId', self.appId)
543 self.city_info = user_cache.get('city_info', [])
544 self.update_session_cookies()
545 self.log(f"♻️ [缓存复用] 成功加载本地 Token ({user_cache.get('time')})")
546 return True
547 except Exception as e:
548 pass
549 return False
550
551 def save_token_to_cache(self):
552 if not self.account_mobile:

Callers 2

mainFunction · 0.95
run_grab_taskFunction · 0.80

Calls 3

logMethod · 0.95
getMethod · 0.45

Tested by

no test coverage detected