1
0
mirror of https://github.com/hanxi/xiaomusic.git synced 2026-05-10 00:44:18 +08:00
Files
xiaomusic/xiaomusic/api/models.py
mwjdot888 9229392ee6 feat(api): 优化音乐信息获取接口,解除TailWind主题下仅支持mp3文件播放的限制 (#852)
* feat: 支持自定义temp_path路径,临时文件不再依赖music_path挂载

以前临时文件需挂载在music_path下才能访问,现在temp/前缀的文件直接从
config.temp_path提供访问,支持自定义任意临时目录路径。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* feat: 增强OGG封面解析,支持FLAC二进制结构的metadata_block_picture

解析metadata_block_picture标签时,先尝试JSON格式再尝试FLAC二进制结构格式,
兼容更多工具生成的OGG文件封面数据。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>

* feat(api): 优化音乐信息获取接口

- 将 musicinfos 接口从 GET 请求改为 POST 请求以支持批量查询
- 添加 MusicInfosQuery 模型用于接收音乐信息查询参数
- 在前端 API 调用中使用 JSON 格式传输歌曲名称数组
- 扩展音频文件格式验证,支持 mp3、flac、wav、ogg、aac、m4a、wma、ape 等格式
- 保留 musictag 参数功能以控制是否返回音乐标签信息

---------

Co-authored-by: mwjdot888 <mwjdot888@users.noreply.github.com>
Co-authored-by: Claude Opus 4.7 <noreply@anthropic.com>
Co-authored-by: maowenjun <dot888@qq.com>
2026-05-04 16:25:15 +08:00

80 lines
1.2 KiB
Python

"""Pydantic 数据模型定义"""
from pydantic import BaseModel
class Did(BaseModel):
did: str
class DidVolume(BaseModel):
did: str
volume: int = 0
class DidCmd(BaseModel):
did: str
cmd: str
class MusicInfoObj(BaseModel):
musicname: str
title: str = ""
artist: str = ""
album: str = ""
year: str = ""
genre: str = ""
lyrics: str = ""
picture: str = "" # base64
class MusicItem(BaseModel):
name: str
class UrlInfo(BaseModel):
url: str
class DidPlayMusic(BaseModel):
did: str
musicname: str = ""
searchkey: str = ""
class DidPlayMusicList(BaseModel):
did: str
listname: str = ""
musicname: str = ""
class DownloadPlayList(BaseModel):
dirname: str
url: str
class DownloadOneMusic(BaseModel):
name: str = ""
url: str
dirname: str = ""
playlist_name: str = ""
class PlayListObj(BaseModel):
name: str = "" # 歌单名
class PlayListUpdateObj(BaseModel):
oldname: str # 旧歌单名字
newname: str # 新歌单名字
class PlayListMusicObj(BaseModel):
name: str = "" # 歌单名
music_list: list[str] # 歌曲名列表
class MusicInfosQuery(BaseModel):
name: list[str]
musictag: bool = False