refactor(tiktok): 优化提示信息

This commit is contained in:
imgyh 2023-03-07 21:10:38 +08:00
parent e608e5431b
commit 3fcacbd14c
2 changed files with 9 additions and 6 deletions

View File

@ -513,9 +513,12 @@ class TikTok(object):
# 保存获取到的字典信息
print("[ 提示 ]:正在保存获取到的信息到 result.json\r\n")
with open(os.path.join(aweme_path, "result.json"), "w", encoding='utf-8') as f:
f.write(json.dumps(awemeDict, ensure_ascii=False, indent=2))
f.close()
try:
with open(os.path.join(aweme_path, "result.json"), "w", encoding='utf-8') as f:
f.write(json.dumps(awemeDict, ensure_ascii=False, indent=2))
f.close()
except Exception as e:
print("[ 错误 ]:保存 result.json 出错\r\n")
# 下载 视频
if awemeDict["awemeType"] == 0:

View File

@ -67,15 +67,15 @@ class Utils(object):
xbogus = execjs.compile(open(self.resource_path(os.path.join("X-Bogus.js"))).read()).call('sign', url, user_agent)
params = url + "&X-Bogus=" + xbogus
except Exception as e:
print('[ 错误 ]:X-Bogus算法异常或者本地没有JS环境')
# print('[ 错误 ]:X-Bogus算法异常或者本地没有JS环境')
try:
print('[ 提示 ]:尝试远程调用X-Bogus接口')
# print('[ 提示 ]:尝试远程调用X-Bogus接口')
response = json.loads(requests.post(
url=Urls().GET_XB_PATH, data={"param": url}, headers=headers).text)
params = response["param"]
xbogus = response["X-Bogus"]
except Exception as e:
print('[ 错误 ]:X-Bogus接口异常, 可能是访问流量高, 接口限流请稍等几分钟再次尝试')
# print('[ 错误 ]:X-Bogus接口异常, 可能是访问流量高, 接口限流请稍等几分钟再次尝试')
return
return params