mirror of
https://github.com/hanxi/xiaomusic.git
synced 2025-12-06 14:52:50 +08:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ee6b9778ac | ||
|
|
881c34bcb5 | ||
|
|
c22fc99235 | ||
|
|
0874efe58b | ||
|
|
f01665c998 | ||
|
|
ac23080f6a | ||
|
|
15ee6c4dd1 | ||
|
|
aeaa8f8925 |
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "xiaomusic"
|
||||
version = "0.1.43"
|
||||
version = "0.1.47"
|
||||
description = "Play Music with xiaomi AI speaker"
|
||||
authors = [
|
||||
{name = "涵曦", email = "im.hanxi@gmail.com"},
|
||||
|
||||
@@ -374,24 +374,6 @@ requests==2.31.0 \
|
||||
rich==13.7.1 \
|
||||
--hash=sha256:4edbae314f59eb482f54e9e30bf00d33350aaa94f4bfcd4e9e3110e64d0d7222 \
|
||||
--hash=sha256:9be308cb1fe2f1f57d67ce99e95af38a1e2bc71ad9813b0e247cf7ffbcc3a432
|
||||
ruff==0.4.8 \
|
||||
--hash=sha256:14019a06dbe29b608f6b7cbcec300e3170a8d86efaddb7b23405cb7f7dcaf780 \
|
||||
--hash=sha256:16d717b1d57b2e2fd68bd0bf80fb43931b79d05a7131aa477d66fc40fbd86268 \
|
||||
--hash=sha256:284c2e3f3396fb05f5f803c9fffb53ebbe09a3ebe7dda2929ed8d73ded736deb \
|
||||
--hash=sha256:384154a1c3f4bf537bac69f33720957ee49ac8d484bfc91720cc94172026ceed \
|
||||
--hash=sha256:6d795d7639212c2dfd01991259460101c22aabf420d9b943f153ab9d9706e6a9 \
|
||||
--hash=sha256:6ea874950daca5697309d976c9afba830d3bf0ed66887481d6bca1673fc5b66a \
|
||||
--hash=sha256:704977a658131651a22b5ebeb28b717ef42ac6ee3b11e91dc87b633b5d83142b \
|
||||
--hash=sha256:72584676164e15a68a15778fd1b17c28a519e7a0622161eb2debdcdabdc71883 \
|
||||
--hash=sha256:7663a6d78f6adb0eab270fa9cf1ff2d28618ca3a652b60f2a234d92b9ec89066 \
|
||||
--hash=sha256:9678d5c9b43315f323af2233a04d747409d1e3aa6789620083a82d1066a35199 \
|
||||
--hash=sha256:a7354f921e3fbe04d2a62d46707e569f9315e1a613307f7311a935743c51a764 \
|
||||
--hash=sha256:aad360893e92486662ef3be0a339c5ca3c1b109e0134fcd37d534d4be9fb8de3 \
|
||||
--hash=sha256:d05f8d6f0c3cce5026cecd83b7a143dcad503045857bc49662f736437380ad45 \
|
||||
--hash=sha256:e14a3a095d07560a9d6769a72f781d73259655919d9b396c650fc98a8157555d \
|
||||
--hash=sha256:e9d5ce97cacc99878aa0d084c626a15cd21e6b3d53fd6f9112b7fc485918e1fa \
|
||||
--hash=sha256:eeceb78da8afb6de0ddada93112869852d04f1cd0f6b80fe464fd4e35c330913 \
|
||||
--hash=sha256:fc95aac2943ddf360376be9aa3107c8cf9640083940a8c5bd824be692d2216dc
|
||||
typing-extensions==4.9.0; python_version < "3.11" \
|
||||
--hash=sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783 \
|
||||
--hash=sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd
|
||||
|
||||
@@ -1 +1 @@
|
||||
pdm export -o requirements.txt
|
||||
pdm export --prod -o requirements.txt
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "0.1.43"
|
||||
__version__ = "0.1.47"
|
||||
|
||||
@@ -85,7 +85,7 @@ class Config:
|
||||
mute_xiaoai: bool = True
|
||||
cookie: str = ""
|
||||
use_command: bool = False
|
||||
verbose: bool = (os.getenv("XIAOMUSIC_VERBOSE", "").lower() == "true")
|
||||
verbose: bool = os.getenv("XIAOMUSIC_VERBOSE", "").lower() == "true"
|
||||
music_path: str = os.getenv("XIAOMUSIC_MUSIC_PATH", "music")
|
||||
hostname: str = os.getenv("XIAOMUSIC_HOSTNAME", "192.168.2.5")
|
||||
port: int = int(os.getenv("XIAOMUSIC_PORT", "8090"))
|
||||
@@ -95,6 +95,7 @@ class Config:
|
||||
) # "bilisearch:" or "ytsearch:"
|
||||
ffmpeg_location: str = os.getenv("XIAOMUSIC_FFMPEG_LOCATION", "./ffmpeg/bin")
|
||||
active_cmd: str = os.getenv("XIAOMUSIC_ACTIVE_CMD", "play,random_play")
|
||||
exclude_dirs: str = os.getenv("XIAOMUSIC_EXCLUDE_DIRS", "@eadir")
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
if self.proxy:
|
||||
|
||||
@@ -108,12 +108,14 @@ async def musiclist():
|
||||
async def curplaylist():
|
||||
return xiaomusic.get_cur_play_list()
|
||||
|
||||
|
||||
@app.route("/delmusic", methods=["POST"])
|
||||
def delmusic():
|
||||
data = request.get_json()
|
||||
log.info(data)
|
||||
xiaomusic.del_music(data["name"])
|
||||
return 'success'
|
||||
return "success"
|
||||
|
||||
|
||||
def static_path_handler(filename):
|
||||
log.debug(filename)
|
||||
|
||||
@@ -62,6 +62,7 @@ class XiaoMusic:
|
||||
self.search_prefix = config.search_prefix
|
||||
self.ffmpeg_location = config.ffmpeg_location
|
||||
self.active_cmd = config.active_cmd.split(",")
|
||||
self.exclude_dirs = set(config.exclude_dirs.split(","))
|
||||
|
||||
# 下载对象
|
||||
self.download_proc = None
|
||||
@@ -347,6 +348,7 @@ class XiaoMusic:
|
||||
self._all_music = {}
|
||||
all_music_by_dir = {}
|
||||
for root, dirs, filenames in os.walk(self.music_path):
|
||||
dirs[:] = [d for d in dirs if d not in self.exclude_dirs]
|
||||
self.log.debug("root:%s dirs:%s music_path:%s", root, dirs, self.music_path)
|
||||
dir_name = os.path.basename(root)
|
||||
if self.music_path == root:
|
||||
@@ -523,17 +525,35 @@ class XiaoMusic:
|
||||
return ("stop", {})
|
||||
return (None, None)
|
||||
|
||||
# 判断是否播放一下私募歌曲
|
||||
def check_play_next(self):
|
||||
# 当前没我在播放的歌曲
|
||||
if self.cur_music == "":
|
||||
return True
|
||||
else:
|
||||
filename = self.get_filename(self.cur_music)
|
||||
# 当前播放的歌曲不存在了
|
||||
if len(filename) <= 0:
|
||||
return True
|
||||
pass
|
||||
return False
|
||||
|
||||
# 播放歌曲
|
||||
async def play(self, **kwargs):
|
||||
self._playing = True
|
||||
parts = kwargs["arg1"].split("|")
|
||||
search_key = parts[0]
|
||||
name = parts[1] if len(parts) > 1 else search_key
|
||||
if search_key == "" and name == "":
|
||||
await self.play_next()
|
||||
return
|
||||
if name == "":
|
||||
name = search_key
|
||||
|
||||
if search_key == "" and name == "":
|
||||
if self.check_play_next():
|
||||
await self.play_next()
|
||||
return
|
||||
else:
|
||||
name = self.cur_music
|
||||
|
||||
self.log.debug("play. search_key:%s name:%s", search_key, name)
|
||||
filename = self.get_filename(name)
|
||||
|
||||
@@ -610,6 +630,7 @@ class XiaoMusic:
|
||||
return
|
||||
self._play_list = self._music_list[list_name]
|
||||
self._cur_play_list = list_name
|
||||
random.shuffle(self._play_list)
|
||||
self.log.info(f"开始播放列表{list_name}")
|
||||
|
||||
music_name = ""
|
||||
@@ -624,7 +645,6 @@ class XiaoMusic:
|
||||
if self._next_timer:
|
||||
self._next_timer.cancel()
|
||||
self.log.info("定时器已取消")
|
||||
self.cur_music = ""
|
||||
await self.force_stop_xiaoai()
|
||||
|
||||
async def stop_after_minute(self, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user