自建音乐服务器Navidrome之二

2023-11-10 21:42

本文主要是介绍自建音乐服务器Navidrome之二,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

开源音乐服务器

自建音乐服务器Navidrome之一


自建音乐服务器Navidrome之二

  • 开源音乐服务器
  • 6 准备音乐资源 可选
    • Last.fm
    • Spotify
  • 7 安装 Docker
    • 启动 docker
  • 8 安装音乐服务器
  • 9 音乐上传
  • 使用miserver上传
  • 启动音乐服务器
  • 浏览器访问:账号
  • 10 Navidrome 第三方客户端
    • Substreamer
    • Subtracks
    • Subsonic


6 准备音乐资源 可选

Last.fm

Last·fm是 Audioscrobbler 音乐引擎设计团队的旗舰产品,以英国为总部的网络电台和音乐社区。有遍布232个国家超过1500万的活跃听众。据说有6亿音乐资源。
docker-compose.yml 配置 Navidrome 可以从 Last.fm 和 Spotify 获取专辑信息和图像。
Last.fm。首先需要一个Last.fm 免费帐户,其次你要能访问Last.fm。转到 https://www.last.fm/api/account/create 并创建一个 API 帐户。只有 应用程序名称 字段是强制性的。
账号信息

XXX: XXX

[图片]

提交表单后,可以从 API account Created 页面获取 API Key 和 Shared Secret,将上面的值复制到 Docker 的环境变量。

ND_LASTFM_ENABLED    设置 false 为完全禁用 Last.fm 集成
ND_LASTFM_APIKEY     Last.fm 获取的 API Key
ND_LASTFM_SECRET     Last.fm 获取的 Shared Secret
ND_LASTFM_LANGUAGE   用于从 Last.fm 检索的语言的两个字母代码,简体中文为 zh
Application name音狗
API key80b1d5a74507f809b98e5c0223e297d9
Shared secret98f492aae5f595f2880b674977e0efd9
Registered toxiaolaifeng

Spotify

Spotify,中文名称声田或声破天,是一个全球范围的正版音乐服务平台,于2008年10月在瑞典首都斯德哥尔摩正式上线。Spotify是目前是全球最大的流音乐服务商之一,与环球音乐集团、索尼音乐娱乐、华纳音乐集团三大唱片公司及其它唱片公司合作授权、由数字版权管理保护的音乐。
截止2020年第一季度的报告,Spotify 在全球拥有2.86亿月活跃用户,其中1.3亿为Spotify Premium付费用户。Spotify支持PC/Android安卓/苹果iOS系统,你可以在线查找最新歌曲,也可以搜索关键词,还可以建立属于自己的试听曲库。此外,Spotify还支持在线社区功能,可以参与歌曲评分互动。Spotify的全部客户端资源通用,只要一个账号就能在不同设备上共享音乐资源,让音乐试听播放变得更加轻松便利。Spotify为免费用户在Spotify听音乐时插播广告,而付费用户没有,且能享受更出色的音质。
Spotify。在 Spotify 中创建一个免费帐户,单击 Spotify 的开发者仪表板中的CREATE AN APP 按钮:https://developer.spotify.com/dashboard/applications。
填写所有字段并单击 CREATE 按钮,将值复制到 Docker 的环境变量。

ND_SPOTIFY_ID        Spotify 客户端 ID
ND_SPOTIFY_SECRET    Spotify 客户端 Secret

7 安装 Docker

安装 Docker 过程网上教程很多,下面只简单记录。
Ubuntu 系统为了安装软件速度更快,可以先更换软件源为国内软件源。
编辑文件:

sudo vim /etc/apt/sources.list

使用下面的阿里云软件源配置进行内容替换。

deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib

安装 Dokcer,直接使用一句话脚本安装。

curl -sSL https://get.daocloud.io/docker | sh

安装过程:

linux@darcy:~ $ curl -sSL https://get.daocloud.io/docker | sh
# Executing docker install script, commit: 4f282167c425347a931ccfd95cc91fab041d414f
+ sudo -E sh -c apt-get update -qq >/dev/null
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq apt-transport-https ca-certificates curl >/dev/null
+ sudo -E sh -c mkdir -p /etc/apt/keyrings && chmod -R 0755 /etc/apt/keyrings
+ sudo -E sh -c curl -fsSL "https://download.docker.com/linux/debian/gpg" | gpg --dearmor --yes -o /etc/apt/keyrings/docker.gpg
+ sudo -E sh -c chmod a+r /etc/apt/keyrings/docker.gpg
+ sudo -E sh -c echo "deb [arch=arm64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/debian bullseye stable" > /etc/apt/sources.list.d/docker.list
+ sudo -E sh -c apt-get update -qq >/dev/null
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq --no-install-recommends docker-ce docker-ce-cli containerd.io docker-compose-plugin >/dev/null
+ version_gte 20.10
+ [ -z  ]
+ return 0
+ sudo -E sh -c DEBIAN_FRONTEND=noninteractive apt-get install -y -qq docker-ce-rootless-extras >/dev/null
+ sudo -E sh -c docker version
Client: Docker Engine - CommunityVersion:           20.10.21API version:       1.41Go version:        go1.18.7Git commit:        baeda1fBuilt:             Tue Oct 25 18:01:19 2022OS/Arch:           linux/arm64Context:           defaultExperimental:      trueServer: Docker Engine - CommunityEngine:Version:          20.10.21API version:      1.41 (minimum version 1.12)Go version:       go1.18.7Git commit:       3056208Built:            Tue Oct 25 17:59:41 2022OS/Arch:          linux/arm64Experimental:     falsecontainerd:Version:          1.6.10GitCommit:        770bd0108c32f3fb5c73ae1264f7e503fe7b2661runc:Version:          1.1.4GitCommit:        v1.1.4-0-g5fd4c4ddocker-init:Version:          0.19.0GitCommit:        de40ad0================================================================================To run Docker as a non-privileged user, consider setting up the
Docker daemon in rootless mode for your user:dockerd-rootless-setuptool.sh installVisit https://docs.docker.com/go/rootless/ to learn about rootless mode.To run the Docker daemon as a fully privileged service, but granting non-root
users access, refer to https://docs.docker.com/go/daemon-access/WARNING: Access to the remote API on a privileged Docker daemon is equivalentto root access on the host. Refer to the 'Docker daemon attack surface'documentation for details: https://docs.docker.com/go/attack-surface/================================================================================darcy@darcy:~ $

安装 docker-compose.

linux@darcy:~/music $ sudo apt install docker-compose
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:libslirp0 slirp4netns
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:apparmor cgroupfs-mount containerd docker.io git git-man liberror-perl libintl-perl libintl-xs-perl libmodule-find-perl libmodule-scandeps-perl libproc-processtable-perl libsort-naturally-perl libterm-readkey-perlneedrestart Python3-attr python3-cached-property python3-distutils python3-docker python3-dockerpty python3-docopt python3-importlib-metadata python3-jsonschema python3-lib2to3 python3-more-itertools python3-pyrsistentpython3-setuptools python3-texttable python3-websocket python3-yaml python3-zipp runc tini
Suggested packages:apparmor-profiles-extra apparmor-utils containernetworking-plugins docker-doc aufs-tools btrfs-progs debootstrap rinse rootlesskit xfsprogs zfs-fuse | zfsutils-linux git-daemon-run | git-daemon-sysvinit git-doc git-elgit-email git-gui gitk gitweb git-cvs git-mediawiki git-svn needrestart-session | libnotify-bin iucode-tool python-attr-doc python-jsonschema-doc python-setuptools-doc
Recommended packages:criu
The following packages will be REMOVED:containerd.io docker-ce docker-ce-cli docker-ce-rootless-extras
The following NEW packages will be installed:apparmor cgroupfs-mount containerd docker-compose docker.io git git-man liberror-perl libintl-perl libintl-xs-perl libmodule-find-perl libmodule-scandeps-perl libproc-processtable-perl libsort-naturally-perllibterm-readkey-perl needrestart python3-attr python3-cached-property python3-distutils python3-docker python3-dockerpty python3-docopt python3-importlib-metadata python3-jsonschema python3-lib2to3python3-more-itertools python3-pyrsistent python3-setuptools python3-texttable python3-websocket python3-yaml python3-zipp runc tini
0 upgraded, 34 newly installed, 4 to remove and 39 not upgraded.
Need to get 55.9 MB of archives.
After this operation, 45.4 MB disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 https://mirrors.aliyun.com/debian bullseye/main arm64 runc arm64 1.0.0~rc93+ds1-5+deb11u2 [2,078 kB]
Get:2 https://mirrors.aliyun.com/debian bullseye/main arm64 containerd arm64 1.4.13~ds1-1~deb11u2 [14.7 MB]
Get:3 https://mirrors.aliyun.com/debian bullseye/main arm64 tini arm64 0.19.0-1 [209 kB]
Get:4 https://mirrors.aliyun.com/debian bullseye/main arm64 docker.io arm64 20.10.5+dfsg1-1+deb11u2 [28.8 MB]
Get:5 https://mirrors.aliyun.com/debian bullseye/main arm64 apparmor arm64 2.13.6-10 [601 kB]
Get:6 https://mirrors.aliyun.com/debian bullseye/main arm64 cgroupfs-mount all 1.4 [6,276 B]
Get:7 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-cached-property all 1.5.2-1 [12.5 kB]
Get:8 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-lib2to3 all 3.9.2-1 [77.8 kB]
Get:9 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-distutils all 3.9.2-1 [143 kB]
Get:10 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-websocket all 0.57.0-1 [34.3 kB]
Get:11 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-docker all 4.1.0-1.2 [85.2 kB]
Get:12 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-dockerpty all 0.4.1-2 [11.1 kB]
Get:13 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-docopt all 0.6.2-3 [26.6 kB]
Get:14 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-attr all 20.3.0-1 [52.9 kB]
Get:15 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-more-itertools all 4.2.0-3 [42.7 kB]
Get:16 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-zipp all 1.0.0-3 [6,060 B]
Get:17 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-importlib-metadata all 1.6.0-2 [10.3 kB]
Get:18 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-setuptools all 52.0.0-4 [366 kB]
Get:19 https://mirrors.aliyun.com/debian bullseye/main arm64 python3-pyrsistent arm64 0.15.5-1+b3 [58

启动 docker

# 查看docker服务是否启动
sudo systemctl status docker
# 如果没有启动
sudo systemctl start docker

8 安装音乐服务器

Navidrome是一款完全开源免费的音乐服务器,且有很多开源客户端可以直接使用,十分方便。
在这里插入图片描述

Navidrome 音乐服务器
官方也给出了如何使用 Docker 安装 Navidrome 的教程,可以点击查看。
链接:Docker 安装 Navidrome 音乐服务器

cd /home/index/server/music

编写 docker-compose.yml 文件,配置中使用 volumes 指定了配置文件夹 data,歌曲存放文件夹 folder.

version: "3"
services:navidrome:container_name: navidromeimage: deluan/navidrome:latestuser: 0:0 #0:0代表用root用户运行ports:- "4533:4533"restart: unless-stoppedenvironment:# Optional: put your config options customization here. Examples:ND_SCANSCHEDULE: 1hND_LASTFM_ENABLED:ND_LASTFM_APIKEY: key80b1d5a74507f809b98e5c0223e297d9# 修改成自己的APIKEYND_LASTFM_SECRET: secret98f492aae5f595f2880b674977e0efd9# 修改成自己的SECRETND_SPOTIFY_ID: 4cd036bsqd1594bd0b41bc8f94c46846d  # 修改成自己的IDND_SPOTIFY_SECRET: 249ca01a48be46fcb084523a6b267661bb1  # 修改成自己的SECRETND_LASTFM_LANGUAGE: zhND_LOGLEVEL: info  ND_SESSIONTIMEOUT: 24hND_BASEURL: ""ND_ENABLETRANSCODINGCONFIG: "true"ND_TRANSCODINGCACHESIZE: "4000M"ND_IMAGECACHESIZE: "1000M"volumes:- "/home/index/music/data:/data"- "/home/index/music/song:/music:ro"miniserve:image: svenstaro/miniserve:latestdepends_on:- navidromeports:- "4534:4534"volumes:- "/home/index/music/song:/downloads"  command: "-r -z -u -q -p 4534 -a dujin:www.dujin.org /downloads" restart: unless-stopped

下载 docker 镜像,等待 navidrome 镜像下载完成。

linux@darcy:~/music $ sudo docker-compose up -d
Creating network "music_default" with the default driver
Pulling navidrome (deluan/navidrome:latest)...
latest: Pulling from deluan/navidrome
9b18e9b68314: Extracting [==================================================>]  2.708MB/2.708MB
6faacaf0d83b: Downloading [=================>                                 ]  11.49MB/32.64MB
4f4fb700ef54: Download complete
e67430195958: Downloading [========>                                          ]  2.203MB/13.64MB

9 音乐上传

歌曲的来源这里不细说,本人百度云盘收藏n多音乐资源。部分整理已分享,请自取。 更多请加qq407737980,获取
链接: https://pan.baidu.com/s/124fGXC44QjTnJfubXf8CmA 提取码: jppg 复制这段内容后打开百度网盘手机App,操作更方便哦

这里直接使用 scp 命令进行上传,需要在歌曲所在文件夹下运行。

  • • ./* 表示上传当前目录所有文件。
  • • root@192.168.0.7 为服务器用户名和 IP.
  • • :/home/index/music/folder 为上传到的路径。
➜  folder scp ./* XX@1XX:/home/index/music/folder
XX@X's password:
GALA - 追梦赤子心.mp3                        100%   13MB   7.0MB/s   00:01
伍佰 - 晚风.mp3                              100% 4102KB   9.4MB/s   00:00
暗杠 - 狂草.mp3                              100% 9693KB   9.1MB/s   00:01
被动(Live).mp3                               100% 4463KB  10.4MB/s   00:00
刘德华 - 17岁 (Live).mp3                      100%   12MB  10.0MB/s   00:01
张雨生 - 我期待.mp3                            100%   14MB   6.8MB/s   00:02
赵英俊 - 方的言.ncm

使用miserver上传

打开浏览器,输入ip:4534,输入docker-compose.yaml文件末尾预先设置的用户名和密码(如果你没有改动的话,用户名dujin,密码www.dujin.org),就可以进入音乐上传页面了。
[图片]

当我们上传音乐文件之后,点击头像左边的图标(刷新&运行情况)可以快速扫描音乐文件。
[图片]

个人感觉宝塔的可视化上传更加方便,这也意味着还可以配置宝塔 FTP,甚至挂载网盘来进行扩容、保存、备份你的音乐文件。
注意: 上传完毕,在浏览器navidrome刷新
[图片]

启动音乐服务器

先使用 sudo docker ps -a 查看 Navidrome 是否已经启动了,如果没有启动可以使用 docker start id 进行启动。服务的默认端口是 4533。

linux@darcy:~ $ sudo docker ps -a
CONTAINER ID   IMAGE                     COMMAND            CREATED       STATUS                 PORTS                    NAMES
97a8a2681179   deluan/navidrome:latest   "/app/navidrome"   2 weeks ago   Up 6 hours (healthy)   0.0.0.0:4533->4533/tcp   music_navidrome_1
docker run 容器id
docker restart容器id

常见问题
docker 容器启动成功 外部访问不到原因 本机访问成功
Centos8 安装 Docker 后容器端口无法访问

centos8防火墙启动 systemctl start firewalld
防火墙启动 systemctl stop firewalld
查看状态 systemctl status firewalld
查看开放的端口  firewall-cmd --list-ports
查看需要开放的端口 netstat -lnpt
打开我们所需的端口 firewall-cmd --permanent --add-port=4533/tcp等
然后其他服务器telnet  ip  port  不通
永久开启 IP 地址转发 firewall-cmd --add-masquerade --permanent
刷新配置  firewall-cmd --reload
重新telnet,完成

浏览器访问:账号

IP:PORT 访问音乐服务,Navidrome 为 PC 端和手机端已经适配了不同的 UI 界面。
[图片]

配置 账号:密码
PC 浏览器:http://192.168.0.7:4533/
[图片]

navidrome pc 端
移动浏览器:
[图片]

navidrome 手机端
Navidrome 的管理功能尚可,点击右上角的头像,可以新增用户,可以为其他人创建一个登录账户。
使用 APP 访问

10 Navidrome 第三方客户端

Navidrome 除了网页界面,还支持各种第三方客户端:

  • iOS: play:Sub, substreamer, Amperfy and iSub
  • Android: DSub, Subtracks, substreamer, Ultrasonic and Audinaut,Subsonic
  • Web: Subplayer, Airsonic Refix, Aurial, Jamstash and Subfire
  • Desktop: Sublime Music (Linux) and Sonixd (Windows/Linux/macOS)
  • CLI: Jellycli (Windows/Linux) and STMP (Linux/macOS)
  • Connected Speakers:
    • Sonos: bonob
    • Alexa: AskSonic
  • Other:
    • Subsonic Kodi Plugin
    • Navidrome Kodi Plugin
    • HTTPDirFS
      感兴趣的同学可以先从在线 DEM

Substreamer

兼容 Navidrome 的 APP 有很多,这里我使用 Substreamer 这款 APP,界面算得上简洁,使用体验尚可。
[图片]

substreamer app
初次启动需要进行登录,可以使用刚刚新增的用户进行登录。
[图片]

歌曲界面:
[图片]

Subtracks

http://m.289.com/azrj/469481.html

Subsonic

https://subsonic-music-streamer.en.softonic.com/android/download?ex=DINS-635.0
外网访问
如果已经是使用云服务器进行部署,那么因为有相应的公网 IP,其实已经可以直接使用公网 IP 访问了。
但是如果使用的树莓派或者家里的其他机器进行部署的,因为没有公网 IP ,只能局限在家庭局域网内,就会让公网访问十分困难。这时有下面的几个方案。

  1. 如果你的宽带运营商每次会分配公网 IP,刚好你又有一个域名,那么可以使用 DNS 服务商提供的 API 进行动态 DNS 配置,让域名总能解析到运营商分配给你的公网 IP。
  2. 如果你有公网服务器,可以使用类似于 FRP 这样的内网穿透工具,借助公网服务器暴露局域网服务。
    FRP GitHub:https://github.com/fatedier/frp/releases
    FRP 通过自定义域名访问内网的 Web 服务:https://gofrp.org/docs/examples/vhost-http/

这篇关于自建音乐服务器Navidrome之二的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/385446

相关文章

springboot上传zip包并解压至服务器nginx目录方式

《springboot上传zip包并解压至服务器nginx目录方式》:本文主要介绍springboot上传zip包并解压至服务器nginx目录方式,具有很好的参考价值,希望对大家有所帮助,如有错误... 目录springboot上传zip包并解压至服务器nginx目录1.首先需要引入zip相关jar包2.然

将Java项目提交到云服务器的流程步骤

《将Java项目提交到云服务器的流程步骤》所谓将项目提交到云服务器即将你的项目打成一个jar包然后提交到云服务器即可,因此我们需要准备服务器环境为:Linux+JDK+MariDB(MySQL)+Gi... 目录1. 安装 jdk1.1 查看 jdk 版本1.2 下载 jdk2. 安装 mariadb(my

基于Python打造一个可视化FTP服务器

《基于Python打造一个可视化FTP服务器》在日常办公和团队协作中,文件共享是一个不可或缺的需求,所以本文将使用Python+Tkinter+pyftpdlib开发一款可视化FTP服务器,有需要的小... 目录1. 概述2. 功能介绍3. 如何使用4. 代码解析5. 运行效果6.相关源码7. 总结与展望1

使用Python开发一个简单的本地图片服务器

《使用Python开发一个简单的本地图片服务器》本文介绍了如何结合wxPython构建的图形用户界面GUI和Python内建的Web服务器功能,在本地网络中搭建一个私人的,即开即用的网页相册,文中的示... 目录项目目标核心技术栈代码深度解析完整代码工作流程主要功能与优势潜在改进与思考运行结果总结你是否曾经

使用Python实现快速搭建本地HTTP服务器

《使用Python实现快速搭建本地HTTP服务器》:本文主要介绍如何使用Python快速搭建本地HTTP服务器,轻松实现一键HTTP文件共享,同时结合二维码技术,让访问更简单,感兴趣的小伙伴可以了... 目录1. 概述2. 快速搭建 HTTP 文件共享服务2.1 核心思路2.2 代码实现2.3 代码解读3.

CentOS 7部署主域名服务器 DNS的方法

《CentOS7部署主域名服务器DNS的方法》文章详细介绍了在CentOS7上部署主域名服务器DNS的步骤,包括安装BIND服务、配置DNS服务、添加域名区域、创建区域文件、配置反向解析、检查配置... 目录1. 安装 BIND 服务和工具2.  配置 BIND 服务3 . 添加你的域名区域配置4.创建区域

Windows Server服务器上配置FileZilla后,FTP连接不上?

《WindowsServer服务器上配置FileZilla后,FTP连接不上?》WindowsServer服务器上配置FileZilla后,FTP连接错误和操作超时的问题,应该如何解决?首先,通过... 目录在Windohttp://www.chinasem.cnws防火墙开启的情况下,遇到的错误如下:无法与

Windows server服务器使用blat命令行发送邮件

《Windowsserver服务器使用blat命令行发送邮件》在linux平台的命令行下可以使用mail命令来发送邮件,windows平台没有内置的命令,但可以使用开源的blat,其官方主页为ht... 目录下载blatBAT命令行示例备注总结在linux平台的命令行下可以使用mail命令来发送邮件,Win

Ubuntu 22.04 服务器安装部署(nginx+postgresql)

《Ubuntu22.04服务器安装部署(nginx+postgresql)》Ubuntu22.04LTS是迄今为止最好的Ubuntu版本之一,很多linux的应用服务器都是选择的这个版本... 目录是什么让 Ubuntu 22.04 LTS 变得安全?更新了安全包linux 内核改进一、部署环境二、安装系统

nginx配置多域名共用服务器80端口

《nginx配置多域名共用服务器80端口》本文主要介绍了配置Nginx.conf文件,使得同一台服务器上的服务程序能够根据域名分发到相应的端口进行处理,从而实现用户通过abc.com或xyz.com直... 多个域名,比如两个域名,这两个域名其实共用一台服务器(意味着域名解析到同一个IP),一个域名为abc