Skip to content

Commit

Permalink
Merge pull request #98 from HisAtri/patch-b1
Browse files Browse the repository at this point in the history
Fix #92 修复客户端请求缺少content-type导致的歌词确认异常的问题
  • Loading branch information
HisAtri authored Nov 18, 2024
2 parents 17d1200 + 7911023 commit 7aa86f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions api/tag.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import json

from . import *

Expand All @@ -13,8 +14,14 @@
@app.route('/confirm', methods=['POST', 'PUT'], endpoint='set_tag_endpoint')
@require_auth_decorator(permission='rw')
def set_tag():
music_data = request.json
audio_path = music_data.get("path")
try:
music_data_json: str = request.data.decode('utf-8')
music_data: dict = json.loads(music_data_json)
except json.JSONDecodeError:
return "Invalid JSON.", 422
except UnicodeError:
return "Invalid encoding.", 422
audio_path: str = music_data.get("path")
if not audio_path:
return "Missing 'path' key in JSON.", 422
debugger.log("info", f"Editing file {audio_path}")
Expand Down
2 changes: 1 addition & 1 deletion mod/auth/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ def wrapper(*args, **kwargs):
return render_template_string(webui.error()), 401
return func(*args, **kwargs)
return wrapper
return decorator
return decorator

0 comments on commit 7aa86f6

Please sign in to comment.