check api key

This commit is contained in:
Yaronzz
2022-06-27 11:16:00 +08:00
parent a7aa38e563
commit 0172301769
3 changed files with 18 additions and 9 deletions
+4 -1
View File
@@ -78,7 +78,10 @@ def main():
Printf.logo()
Printf.settings()
if not loginByConfig():
if not apiKey.isItemValid(SETTINGS.apiKeyIndex):
changeApiKey()
loginByWeb()
elif not loginByConfig():
loginByWeb()
Printf.checkVersion()
+12 -8
View File
@@ -60,12 +60,12 @@ __KEYS_JSON__ = '''
'''
__API_KEYS__ = json.loads(__KEYS_JSON__)
__ERROR_KEY__ = {
'platform': 'None',
'formats': '',
'clientId': '',
'clientSecret': '',
'platform': 'None',
'formats': '',
'clientId': '',
'clientSecret': '',
'valid': 'False',
},
},
def getNum():
@@ -78,6 +78,11 @@ def getItem(index: int):
return __API_KEYS__['keys'][index]
def isItemValid(index: int):
item = getItem(index)
return item['valid'] == 'True'
def getItems():
return __API_KEYS__['keys']
@@ -92,7 +97,8 @@ def getLimitIndexs():
def getVersion():
return __API_KEYS__['version']
#Load from gist
# Load from gist
try:
respond = requests.get('https://api.github.com/gists/48d01f5a24b4b7b37f19443977c22cd6')
if respond.status_code == 200:
@@ -100,5 +106,3 @@ try:
__API_KEYS__ = json.loads(content)
except:
pass
+2
View File
@@ -290,6 +290,8 @@ class TidalAPI(object):
ret.encryptionKey = manifest['keyId'] if 'keyId' in manifest else ""
ret.url = manifest['urls'][0]
return ret
# else:
# manifest = json.loads(base64.b64decode(resp.manifest).decode('utf-8'))
raise Exception("Can't get the streamUrl, type is " + resp.manifestMimeType)
def getVideoStreamUrl(self, id, quality: VideoQuality):