mirror of
https://github.com/hanxi/xiaomusic.git
synced 2025-12-07 15:02:55 +08:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
95f756fb28 | ||
|
|
25ed90efa3 | ||
|
|
147bbcdd4c | ||
|
|
8dd9cfe0ac | ||
|
|
089bafd693 | ||
|
|
13b72bff97 | ||
|
|
3e959a08f0 | ||
|
|
3d1517854c | ||
|
|
e65c2ca3c9 | ||
|
|
6d7ff48913 | ||
|
|
7291826b56 | ||
|
|
fa06a7ad17 | ||
|
|
614cff3f05 | ||
|
|
a8d924e31f | ||
|
|
a9a6ead73f | ||
|
|
bd41735df2 | ||
|
|
655f0f9ab7 | ||
|
|
a003b6d0bf | ||
|
|
16f224b8e5 | ||
|
|
d4ca2c886f | ||
|
|
48b9e0a837 | ||
|
|
38df7aa6b9 | ||
|
|
29756c29a7 | ||
|
|
89287164ad | ||
|
|
81fb330db9 | ||
|
|
365954ecb0 | ||
|
|
d7fd7c43dc | ||
|
|
e48c6456fc | ||
|
|
193e1885e0 | ||
|
|
9acd5820ef | ||
|
|
119283693a | ||
|
|
dc9eb96a27 | ||
|
|
c022b5a0b1 | ||
|
|
bcbbfc5f52 | ||
|
|
3da07ce816 | ||
|
|
8629c16fe4 | ||
|
|
ac6fbd1b82 | ||
|
|
6995afed16 | ||
|
|
b49e250488 | ||
|
|
5032747f1e | ||
|
|
f749edcf16 | ||
|
|
14598aedee | ||
|
|
8845148cce | ||
|
|
1513a59726 | ||
|
|
497c1f34ef | ||
|
|
77920dffac | ||
|
|
c452136537 |
45
.github/workflows/build-base-image.yml
vendored
Normal file
45
.github/workflows/build-base-image.yml
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
name: Build Docker Base Image
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'Dockerfile.builder'
|
||||
- 'Dockerfile.runtime'
|
||||
- 'install_dependencies.sh'
|
||||
- '.github/workflows/build-base-image.yml'
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-image:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name != 'pull_request'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v2
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v2
|
||||
- name: Login to Docker Hub
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Build and push runtime
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile.runtime
|
||||
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
||||
push: true
|
||||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:runtime
|
||||
|
||||
- name: Build and push builder
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
file: ./Dockerfile.builder
|
||||
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
||||
push: true
|
||||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:builder
|
||||
|
||||
17
.github/workflows/ci.yml
vendored
17
.github/workflows/ci.yml
vendored
@@ -1,21 +1,18 @@
|
||||
name: ci
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "*"
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
TEST_TAG: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}
|
||||
|
||||
jobs:
|
||||
build-image:
|
||||
build-test-publish:
|
||||
runs-on: ubuntu-latest
|
||||
# run unless event type is pull_request
|
||||
if: github.event_name != 'pull_request'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
@@ -28,9 +25,6 @@ jobs:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
# We have to build each platform separately because when using multi-arch
|
||||
# builds, only one platform is being loaded into the cache. This would
|
||||
# prevent us from testing the other platforms.
|
||||
- name: Build Docker image (linux/amd64)
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
@@ -87,3 +81,8 @@ jobs:
|
||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
repository: hanxi/xiaomusic
|
||||
|
||||
- name: Move cache to limit growth
|
||||
run: |
|
||||
rm -rf /tmp/.buildx-cache
|
||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||
|
||||
3
.github/workflows/release.yml
vendored
3
.github/workflows/release.yml
vendored
@@ -38,7 +38,6 @@ jobs:
|
||||
|
||||
build-image:
|
||||
runs-on: ubuntu-latest
|
||||
#needs: release-pypi
|
||||
# run unless event type is pull_request
|
||||
if: github.event_name != 'pull_request'
|
||||
steps:
|
||||
@@ -56,6 +55,6 @@ jobs:
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
platforms: linux/amd64,linux/arm64,linux/arm/v7
|
||||
platforms: linux/amd64, linux/arm64, linux/arm/v7
|
||||
push: true
|
||||
tags: ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:${{ github.ref_name }}, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:latest, ${{ secrets.DOCKERHUB_USERNAME }}/xiaomusic:stable
|
||||
|
||||
22
CHANGELOG.md
22
CHANGELOG.md
@@ -1,3 +1,25 @@
|
||||
## v0.3.44 (2024-11-01)
|
||||
|
||||
### Feat
|
||||
|
||||
- 日志时间里加上日期
|
||||
|
||||
### Fix
|
||||
|
||||
- 修复搜索失败的问题
|
||||
|
||||
## v0.3.43 (2024-10-30)
|
||||
|
||||
### Feat
|
||||
|
||||
- 播放列表可以删除当前歌曲(!危险操作,请在设置中心开启相关功能) (#250)
|
||||
- 插件自定义口令支持获取语音输入内容 #105
|
||||
|
||||
### Fix
|
||||
|
||||
- 修复谷歌统计导致的卡顿问题
|
||||
- 解决挂载网盘卡死的问题
|
||||
|
||||
## v0.3.42 (2024-10-24)
|
||||
|
||||
### Fix
|
||||
|
||||
20
Dockerfile
20
Dockerfile
@@ -1,4 +1,4 @@
|
||||
FROM python:3.10 AS builder
|
||||
FROM hanxi/xiaomusic:builder AS builder
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN pip install -U pdm
|
||||
ENV PDM_CHECK_UPDATE=false
|
||||
@@ -8,23 +8,13 @@ COPY xiaomusic/ ./xiaomusic/
|
||||
COPY plugins/ ./plugins/
|
||||
COPY xiaomusic.py .
|
||||
RUN pdm install --prod --no-editable
|
||||
COPY install_dependencies.sh .
|
||||
RUN bash install_dependencies.sh
|
||||
|
||||
FROM python:3.10-slim
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
libtiff6 \
|
||||
libopenjp2-7 \
|
||||
libxcb1 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
FROM hanxi/xiaomusic:runtime
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/.venv /app/.venv
|
||||
COPY --from=builder /app/ffmpeg /app/ffmpeg
|
||||
COPY xiaomusic/ ./xiaomusic/
|
||||
COPY plugins/ ./plugins/
|
||||
COPY xiaomusic.py .
|
||||
COPY --from=builder /app/xiaomusic/ ./xiaomusic/
|
||||
COPY --from=builder /app/plugins/ ./plugins/
|
||||
COPY --from=builder /app/xiaomusic.py .
|
||||
ENV XIAOMUSIC_HOSTNAME=192.168.2.5
|
||||
ENV XIAOMUSIC_PORT=8090
|
||||
VOLUME /app/conf
|
||||
|
||||
11
Dockerfile.builder
Normal file
11
Dockerfile.builder
Normal file
@@ -0,0 +1,11 @@
|
||||
FROM python:3.10
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
RUN pip install -U pdm
|
||||
ENV PDM_CHECK_UPDATE=false
|
||||
WORKDIR /app
|
||||
COPY pyproject.toml README.md .
|
||||
COPY xiaomusic/ ./xiaomusic/
|
||||
COPY plugins/ ./plugins/
|
||||
COPY xiaomusic.py .
|
||||
RUN pdm install --prod --no-editable
|
||||
|
||||
14
Dockerfile.runtime
Normal file
14
Dockerfile.runtime
Normal file
@@ -0,0 +1,14 @@
|
||||
FROM python:3.10-slim
|
||||
ENV DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update && apt-get install -y \
|
||||
wget \
|
||||
xz-utils \
|
||||
libtiff6 \
|
||||
libopenjp2-7 \
|
||||
libxcb1 \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /app
|
||||
COPY install_dependencies.sh .
|
||||
RUN bash install_dependencies.sh
|
||||
@@ -16,6 +16,7 @@ install_from_github() {
|
||||
mkdir -p ffmpeg/bin
|
||||
mv $pkg/bin/ffmpeg ffmpeg/bin/
|
||||
mv $pkg/bin/ffprobe ffmpeg/bin/
|
||||
rm -rf $pkg $pkg.tar.xz
|
||||
}
|
||||
|
||||
install_from_ffmpeg() {
|
||||
@@ -26,6 +27,7 @@ install_from_ffmpeg() {
|
||||
mkdir -p ffmpeg/bin
|
||||
mv $pkg/*/ffmpeg ffmpeg/bin/
|
||||
mv $pkg/*/ffprobe ffmpeg/bin/
|
||||
rm -rf $pkg $pkg.tar.xz
|
||||
}
|
||||
|
||||
# 基于架构执行不同的操作
|
||||
|
||||
@@ -3,3 +3,7 @@ async def code1(arg1):
|
||||
log.info(f"code1:{arg1}")
|
||||
did = xiaomusic._cur_did
|
||||
await xiaomusic.do_tts(did, "你好,我是自定义的测试口令")
|
||||
|
||||
last_record = xiaomusic.last_record
|
||||
query = last_record.get("query", "").strip()
|
||||
await xiaomusic.do_tts(did, f"你说的是: {query}")
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[project]
|
||||
name = "xiaomusic"
|
||||
version = "0.3.42"
|
||||
version = "0.3.44"
|
||||
description = "Play Music with xiaomi AI speaker"
|
||||
authors = [
|
||||
{name = "涵曦", email = "im.hanxi@gmail.com"},
|
||||
|
||||
@@ -36,8 +36,7 @@ async def main(directory):
|
||||
# await test_one_music(file)
|
||||
pass
|
||||
|
||||
await test_one_music("./music/4.mp3")
|
||||
# await test_one_music("./music/4 In Love - 一千零一个愿.mp3")
|
||||
await test_one_music("music/4 In Love - 一千零一个愿望.mp3")
|
||||
# await test_one_music("./music/程响-人间烟火.flac")
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
__version__ = "0.3.42"
|
||||
__version__ = "0.3.44"
|
||||
|
||||
@@ -11,7 +11,6 @@ class Analytics:
|
||||
self.gtag = None
|
||||
self.current_date = None
|
||||
self.log = log
|
||||
self.task = None
|
||||
self.init()
|
||||
|
||||
def init(self):
|
||||
@@ -30,10 +29,7 @@ class Analytics:
|
||||
|
||||
async def run_with_cancel(self, func, *args, **kwargs):
|
||||
try:
|
||||
if self.task:
|
||||
self.log.warning(f"analytics run_with_cancel old : {self.task}")
|
||||
self.task.cancel()
|
||||
self.task = asyncio.create_task(func(*args, **kwargs))
|
||||
asyncio.ensure_future(asyncio.to_thread(func, *args, **kwargs))
|
||||
except Exception as e:
|
||||
self.log.warning(f"analytics run_with_cancel failed {e}")
|
||||
return None
|
||||
@@ -45,7 +41,7 @@ class Analytics:
|
||||
self.log.warning(f"analytics send_startup_event failed {e}")
|
||||
self.init()
|
||||
|
||||
async def _send_startup_event(self):
|
||||
def _send_startup_event(self):
|
||||
event = self.gtag.create_new_event(name="startup")
|
||||
event.set_event_param(name="version", value=__version__)
|
||||
event_list = [event]
|
||||
@@ -58,7 +54,7 @@ class Analytics:
|
||||
self.log.warning(f"analytics send_daily_event failed {e}")
|
||||
self.init()
|
||||
|
||||
async def _send_daily_event(self):
|
||||
def _send_daily_event(self):
|
||||
current_date = datetime.now().strftime("%Y-%m-%d")
|
||||
if self.current_date == current_date:
|
||||
return
|
||||
@@ -77,7 +73,7 @@ class Analytics:
|
||||
self.log.warning(f"analytics send_play_event failed {e}")
|
||||
self.init()
|
||||
|
||||
async def _send_play_event(self, name, sec):
|
||||
def _send_play_event(self, name, sec):
|
||||
event = self.gtag.create_new_event(name="play")
|
||||
event.set_event_param(name="version", value=__version__)
|
||||
event.set_event_param(name="music", value=name)
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>Debug For XiaoMusic</title>
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="./style.css?version=1729738799">
|
||||
<link rel="stylesheet" type="text/css" href="./style.css?version=1730427269">
|
||||
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
|
||||
<script src="./jquery-3.7.1.min.js?version=1729738799"></script>
|
||||
<script src="./jquery-3.7.1.min.js?version=1730427269"></script>
|
||||
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Z09NC1K7ZW"></script>
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>歌曲下载工具</title>
|
||||
<link rel="stylesheet" type="text/css" href="./style.css?version=1729738799">
|
||||
<script src="./jquery-3.7.1.min.js?version=1729738799"></script>
|
||||
<link rel="stylesheet" type="text/css" href="./style.css?version=1730427269">
|
||||
<script src="./jquery-3.7.1.min.js?version=1730427269"></script>
|
||||
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Z09NC1K7ZW"></script>
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>小爱音箱操控面板</title>
|
||||
<script src="./jquery-3.7.1.min.js?version=1729738799"></script>
|
||||
<script src="./app.js?version=1729738799"></script>
|
||||
<link rel="stylesheet" type="text/css" href="./style.css?version=1729738799">
|
||||
<script src="./jquery-3.7.1.min.js?version=1730427269"></script>
|
||||
<script src="./app.js?version=1730427269"></script>
|
||||
<link rel="stylesheet" type="text/css" href="./style.css?version=1730427269">
|
||||
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Z09NC1K7ZW"></script>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>M3U to JSON Converter</title>
|
||||
<link rel="stylesheet" type="text/css" href="./style.css?version=1729738799">
|
||||
<link rel="stylesheet" type="text/css" href="./style.css?version=1730427269">
|
||||
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Z09NC1K7ZW"></script>
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
<link rel="icon" href="/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width">
|
||||
<title>小爱音箱操控面板</title>
|
||||
<script src="./jquery-3.7.1.min.js?version=1729738799"></script>
|
||||
<script src="./setting.js?version=1729738799"></script>
|
||||
<link rel="stylesheet" type="text/css" href="./style.css?version=1729738799">
|
||||
<script src="./jquery-3.7.1.min.js?version=1730427269"></script>
|
||||
<script src="./setting.js?version=1730427269"></script>
|
||||
<link rel="stylesheet" type="text/css" href="./style.css?version=1730427269">
|
||||
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-Z09NC1K7ZW"></script>
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 224 KiB |
BIN
xiaomusic/static/pure/assets/guidance-NW-kY-w0.png
Normal file
BIN
xiaomusic/static/pure/assets/guidance-NW-kY-w0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 279 KiB |
File diff suppressed because one or more lines are too long
1
xiaomusic/static/pure/assets/index-Btj9QAkL.css
Normal file
1
xiaomusic/static/pure/assets/index-Btj9QAkL.css
Normal file
File diff suppressed because one or more lines are too long
41
xiaomusic/static/pure/assets/index-CaDINhtr.js
Normal file
41
xiaomusic/static/pure/assets/index-CaDINhtr.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -6,8 +6,8 @@
|
||||
<link rel="icon" href="/static/pure/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>小爱音箱操控面板</title>
|
||||
<script type="module" crossorigin src="/static/pure/assets/index-B19OeAC1.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/static/pure/assets/index-co2Wfzfa.css">
|
||||
<script type="module" crossorigin src="/static/pure/assets/index-CaDINhtr.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/static/pure/assets/index-Btj9QAkL.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -5,8 +5,8 @@
|
||||
<link rel="icon" href="/static/xplayer/favicon.ico">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>XMusicPlayer</title>
|
||||
<script type="module" crossorigin src="/static/xplayer/assets/index-BhKRZfzz.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/static/xplayer/assets/index-DZp3LGgk.css">
|
||||
<script type="module" crossorigin src="/static/xplayer/assets/index-C1eAAj9j.js"></script>
|
||||
<link rel="stylesheet" crossorigin href="/static/xplayer/assets/index-BBmHnUeL.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
@@ -145,7 +145,7 @@ class XiaoMusic:
|
||||
|
||||
def setup_logger(self):
|
||||
log_format = f"%(asctime)s [{__version__}] [%(levelname)s] %(filename)s:%(lineno)d: %(message)s"
|
||||
date_format = "[%X]"
|
||||
date_format = "[%Y-%m-%d %H:%M:%S]"
|
||||
formatter = logging.Formatter(fmt=log_format, datefmt=date_format)
|
||||
logging.basicConfig(
|
||||
format=log_format,
|
||||
@@ -550,7 +550,7 @@ class XiaoMusic:
|
||||
all_music_tags = self.try_load_from_tag_cache()
|
||||
all_music_tags.update(self.all_music_tags) # 保证最新
|
||||
for name, file_or_url in only_items.items():
|
||||
await asyncio.sleep(0.001)
|
||||
start = time.perf_counter()
|
||||
if name not in all_music_tags:
|
||||
try:
|
||||
if self.is_web_music(name):
|
||||
@@ -564,6 +564,11 @@ class XiaoMusic:
|
||||
self.log.info(f"{name}/{file_or_url} 无法更新 tag")
|
||||
except BaseException as e:
|
||||
self.log.exception(f"{e} {file_or_url} error {type(file_or_url)}!")
|
||||
if (time.perf_counter() - start) < 1:
|
||||
await asyncio.sleep(0.001)
|
||||
else:
|
||||
# 处理一首歌超过1秒,则等1秒,解决挂载网盘卡死的问题
|
||||
await asyncio.sleep(1)
|
||||
# 全部更新结束后,一次性赋值
|
||||
self.all_music_tags = all_music_tags
|
||||
# 刷新 tag cache
|
||||
@@ -829,6 +834,10 @@ class XiaoMusic:
|
||||
continue
|
||||
|
||||
self.log.info(f"匹配到指令. opkey:{opkey} opvalue:{opvalue} oparg:{oparg}")
|
||||
# 自定义口令
|
||||
if opvalue.startswith("exec#"):
|
||||
code = opvalue.split("#", 1)[1]
|
||||
return ("exec", code)
|
||||
return (opvalue, oparg)
|
||||
self.log.info(f"未匹配到指令 {query} {ctrl_panel}")
|
||||
return (None, None)
|
||||
|
||||
Reference in New Issue
Block a user