mirror of
https://github.com/Evil0ctal/Douyin_TikTok_Download_API.git
synced 2025-04-20 22:40:08 +08:00
🗳当提交值为空时返回JSON提示
This commit is contained in:
parent
4906f07429
commit
9479d1390b
@ -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: 2022/04/05
|
# @Update: 2022/04/06
|
||||||
# @Function:
|
# @Function:
|
||||||
# 创建一个接受提交参数的Flask应用程序。
|
# 创建一个接受提交参数的Flask应用程序。
|
||||||
# 将scraper.py返回的内容以JSON格式返回。
|
# 将scraper.py返回的内容以JSON格式返回。
|
||||||
@ -85,7 +85,7 @@ def webapi():
|
|||||||
return jsonify(status='failed', reason=str(e), time=analyze_time, function='webapi()', value=content)
|
return jsonify(status='failed', reason=str(e), time=analyze_time, function='webapi()', value=content)
|
||||||
else:
|
else:
|
||||||
# 返回错误信息
|
# 返回错误信息
|
||||||
return jsonify(status='failed', reason='url value cannot be empty')
|
return jsonify(status='failed', reason='url value cannot be empty', function='api()', value=content)
|
||||||
|
|
||||||
|
|
||||||
@app.route("/video", methods=["POST", "GET"])
|
@app.route("/video", methods=["POST", "GET"])
|
||||||
@ -93,6 +93,9 @@ def download_video():
|
|||||||
# 用于返回视频下载请求(返回MP4文件下载请求,面对大量请求时非常吃服务器内存,容易崩,慎用。)
|
# 用于返回视频下载请求(返回MP4文件下载请求,面对大量请求时非常吃服务器内存,容易崩,慎用。)
|
||||||
api = Scraper()
|
api = Scraper()
|
||||||
content = request.args.get("url")
|
content = request.args.get("url")
|
||||||
|
if content == '':
|
||||||
|
return jsonify(status='failed', reason='url value cannot be empty', function='download_music()', value=content)
|
||||||
|
else:
|
||||||
post_content = find_url(content)[0]
|
post_content = find_url(content)[0]
|
||||||
try:
|
try:
|
||||||
if 'douyin.com' in post_content:
|
if 'douyin.com' in post_content:
|
||||||
@ -147,8 +150,8 @@ def download_music():
|
|||||||
# 用于返回视频下载请求(返回MP3文件下载请求,面对大量请求时非常吃服务器内存,容易崩,慎用。)
|
# 用于返回视频下载请求(返回MP3文件下载请求,面对大量请求时非常吃服务器内存,容易崩,慎用。)
|
||||||
api = Scraper()
|
api = Scraper()
|
||||||
content = request.args.get("url")
|
content = request.args.get("url")
|
||||||
if content == 'No BGM found':
|
if content == '':
|
||||||
return jsonify(status='failed', reason='No BGM found', function='download_music()', value=content)
|
return jsonify(status='failed', reason='url value cannot be empty', function='download_music()', value=content)
|
||||||
else:
|
else:
|
||||||
post_content = find_url(content)[0]
|
post_content = find_url(content)[0]
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user