mirror of
https://github.com/Evil0ctal/Douyin_TikTok_Download_API.git
synced 2025-04-23 05:24:26 +08:00
🏷修改了错误日志格式
This commit is contained in:
parent
eeb3475f34
commit
667a358e0f
29
TikTok_ZH.py
29
TikTok_ZH.py
@ -2,7 +2,7 @@
|
|||||||
# -*- encoding: utf-8 -*-
|
# -*- encoding: utf-8 -*-
|
||||||
# @Author: https://github.com/Evil0ctal/
|
# @Author: https://github.com/Evil0ctal/
|
||||||
# @Time: 2021/11/06
|
# @Time: 2021/11/06
|
||||||
# @Update: 2021/11/19
|
# @Update: 2021/12/04
|
||||||
# @Function:
|
# @Function:
|
||||||
# 基于 PyWebIO、Requests、Flask,可实现在线批量解析抖音的无水印视频/图集。
|
# 基于 PyWebIO、Requests、Flask,可实现在线批量解析抖音的无水印视频/图集。
|
||||||
# 可用于下载作者禁止下载的视频,同时可搭配iOS的快捷指令APP配合本项目API实现应用内下载。
|
# 可用于下载作者禁止下载的视频,同时可搭配iOS的快捷指令APP配合本项目API实现应用内下载。
|
||||||
@ -42,18 +42,21 @@ def valid_check(kou_ling):
|
|||||||
return '抖音分享口令有误!'
|
return '抖音分享口令有误!'
|
||||||
|
|
||||||
|
|
||||||
def error_msg():
|
def error_do(e, func_name):
|
||||||
# 输出一个毫无用处的信息
|
# 输出一个毫无用处的信息
|
||||||
put_html("<hr>")
|
put_html("<hr>")
|
||||||
put_text("无法解析输入内容,请检查输入内容或稍后再试。如多次尝试仍失败,请点击反馈。")
|
put_error("There was an error happened.")
|
||||||
|
put_html('<h3>⚠️Detail</h3>')
|
||||||
|
put_table([
|
||||||
|
['Function', 'Reason'],
|
||||||
|
[func_name, str(e)]])
|
||||||
put_html("<hr>")
|
put_html("<hr>")
|
||||||
|
put_markdown('Please try again!\nIf multiple attempts still fail, please click [Feedback](https://github.com/Evil0ctal/Calibear_User/issues).')
|
||||||
|
put_link('返回主页', '/')
|
||||||
def error_log(e):
|
|
||||||
# 将错误记录在logs.txt中
|
# 将错误记录在logs.txt中
|
||||||
date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
date = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
|
||||||
with open('logs.txt', 'a') as f:
|
with open('logs.txt', 'a') as f:
|
||||||
f.write(date + ": " + str(e) + '\n')
|
f.write(date + " " + func_name + ': ' + str(e) + '\n')
|
||||||
|
|
||||||
|
|
||||||
def loading():
|
def loading():
|
||||||
@ -116,7 +119,7 @@ def get_video_info(original_url):
|
|||||||
return video_info, 'video'
|
return video_info, 'video'
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# 异常捕获
|
# 异常捕获
|
||||||
error_log(e)
|
error_do(e, 'get_video_info')
|
||||||
|
|
||||||
|
|
||||||
@app.route("/api")
|
@app.route("/api")
|
||||||
@ -138,7 +141,7 @@ def webapi():
|
|||||||
video_author_id=response_data[4], original_url=response_data[5])
|
video_author_id=response_data[4], original_url=response_data[5])
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# 异常捕获
|
# 异常捕获
|
||||||
error_log(e)
|
error_do(e, 'webapi')
|
||||||
return jsonify(Message="解析失败", Reason=str(e), Result=False)
|
return jsonify(Message="解析失败", Reason=str(e), Result=False)
|
||||||
|
|
||||||
|
|
||||||
@ -265,14 +268,14 @@ def main():
|
|||||||
# 解析结束时间
|
# 解析结束时间
|
||||||
end = time.time()
|
end = time.time()
|
||||||
put_html("<br><hr>")
|
put_html("<br><hr>")
|
||||||
put_text('解析完成: 耗时: %.4f秒' % (end - start))
|
put_link('返回主页', '/')
|
||||||
|
put_text('解析完成! 耗时: %.4f秒' % (end - start))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# 异常捕获
|
# 异常捕获
|
||||||
clear('bar')
|
clear('bar')
|
||||||
error_msg()
|
error_do(e, 'main')
|
||||||
end = time.time()
|
end = time.time()
|
||||||
put_text('解析完成: 耗时: %.4f秒' % (end - start))
|
put_text('解析完成! 耗时: %.4f秒' % (end - start))
|
||||||
error_log(e)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Loading…
x
Reference in New Issue
Block a user