hanxi / xiaomusic

使用小爱音箱播放音乐,音乐使用 yt-dlp 下载。
https://github.com/hanxi/xiaomusic
MIT License
868 stars 83 forks source link

采用config.json配置方式 #94

Open hanxi opened 5 days ago

hanxi commented 5 days ago

docker 方式部署默认推荐使用环境变量的方式来配置参数,如果是自己用命令行启动,目前支持的参数配置比较少,但是是支持 --config 参数。

使用 pip 安装 xiaomusic 【0.1.83版本才支持 pip 安装】

pip install xiaomusic

依赖的 ffmpeg 需要自己安装。

image

仓库中有个 config-example.json 文件,可以把这个文件拷贝为 config.json 然后修改 config.json 里的配置,再用下面的命令启动。

xiaomusic --config ./config.json

默认的 config.json 模板如下:

{
    "hardware": "L07A",
    "account": "",
    "password": "",
    "mi_did": "",
    "cookie": "",
    "verbose": false,
    "music_path": "music",
    "conf_path": null,
    "hostname": "192.168.2.5",
    "port": 8090,
    "proxy": null,
    "search_prefix": "ytsearch:",
    "ffmpeg_location": "./ffmpeg/bin",
    "active_cmd": "play,random_play,playlocal,play_music_list,stop",
    "exclude_dirs": "@eaDir",
    "music_path_depth": 10,
    "disable_httpauth": true,
    "httpauth_username": "admin",
    "httpauth_password": "admin",
    "music_list_url": "",
    "music_list_json": "",
    "disable_download": false,
    "use_music_api": false,
    "log_file": "/tmp/xiaomusic.txt",
    "fuzzy_match_cutoff": 0.6,
    "enable_fuzzy_match": true
}

如果采用 docker compose 启动想用 config.json 的配置方式,可以这样配:

services:
  xiaomusic:
    image: hanxi/xiaomusic
    container_name: xiaomusic
    restart: unless-stopped
    ports:
      - 8090:8090
    volumes:
      - ./music:/app/music
      - ./config.json:/app/config.json
    command: ['--config', '/app/config.json']

主要就是把 config.json 文件映射进容器和传 --config 参数。

alitime commented 5 days ago

正需要,有配置文件方便多了

hanxi commented 5 days ago

ffmpeg 如果是用 apt install 这类系统工具安装的,默认会在 /usr/bin 目录下,ffmpeg_location 这个参数就需要设置为 /usr/bin .

目前 armv7 cpu 的 docker 镜像里的 ffmpeg 有问题,最好是用 pip 方式安装运行。

hanxi commented 2 days ago

ffmpeg 如果是用 apt install 这类系统工具安装的,默认会在 /usr/bin 目录下,ffmpeg_location 这个参数就需要设置为 /usr/bin .

目前 armv7 cpu 的 docker 镜像里的 ffmpeg 有问题,最好是用 pip 方式安装运行。

armv7 问题已经解决。