记录学习与后端知识并分享学习代码过程(会飞的鱼Blog)

闲置吃灰小鸡来搭建在线音乐播放器啦

会飞的鱼 0 817 2020年12月31日

前言

先上链接 -> YesPlayMusic

源码来自 -> https://github.com/Binaryify/NeteaseCloudMusicApi (感谢Binaryify)
              -> https://github.com/qier222/YesPlayMusic (感谢qier222)

简单上手 -> 环境 LinodeVPS + debian 10,一只小鸡即可胜任。

操作

下面是核心操作

#安装node.js LTS (v14.x)
apt update && apt install -y git curl
curl -sL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs

#安装网易云音乐API
git clone https://github.com/Binaryify/NeteaseCloudMusicApi.git
cd NeteaseCloudMusicApi
npm install

#运行网易云音乐API(可以通过nohup screen supervisor等后台运行)
cd NeteaseCloudMusicApi
PORT=3000 HOST=0.0.0.0 node app.js

#安装yarn
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
apt-get update && apt-get install -y yarn

#安装YesPlayMusic
git clone https://github.com/qier222/YesPlayMusic.git
cd YesPlayMusic
yarn install
cp .env.example .env
#假设上述网易云音乐API解析到了musicapi.example.com
sed -i 's/127.0.0.1/musicapi.example.com/g' ./.env
yarn run build
#将 /dist 目录下的文件上传到你的 Web 服务器(不限制本机),最后启动web服务

对了还有个坑,如果顺利搭建完成加载不出来页面,服务器端ping一下music.163.com。

如果不通,找个能ping通的ip,然后修改/etc/hosts即可。
---------------------------------------------------------------------------------
如果觉得麻烦,可以换这个项目 https://github.com/sl1673495/vue-netease-music

内置了接口,还挺快的

git clone https://github.com/sl1673495/vue-netease-music.git
cd vue*
npm install
npm run build

然后把music目录下的文件上传到web服务器,可以是虚拟空间可以是装有nginx/apache/caddy/lighttpd的vps。

记得装上ssl证书,不然加载不出来。效果看个签第三个 "听音乐"。

截图


文章末尾有解锁灰色歌曲方法

 

 

下面是解锁灰色歌曲方法
https://music.malahu.org/#/album/3184340

#开始更新方法
首先要有一个解锁的host 运行的时候加上 -p 80:443 最好是另外一台鸡鸡 因为会占用 80 443端口
https://github.com/nondanee/UnblockNeteaseMusic

在api服务器增加hosts
hostip music.163.com
hostip interface.music.163.com
hostip music.126.net
hostip interface3.music.163.com

然后正常安装到yarn run build之前
修改 src/store/actions.js
注释第4行
//import { updateHttps } from "@/utils/common";
116行下面增加如下内容
unblockSongUrl = getMP3(track.id);

忘了忘了昨天烧烤吃多了
第71行const url = updateHttps(data.data[0].url);改为
const url =data.data[0].url;
如果不取消掉updatehttps 有些歌链接是http强制https会不播放

保存
运行yarn run build
然后将 /dist 目录下的文件上传到你的 Web 服务器(不限制本机),最后启动web服务

如果api服务报错SSL
修改netease_api/util/request.js 忽略ssl错误
方法:https://www.google.com.hk/search?q=nodejs%E5%BF%BD%E7%95%A5ssl%E9%94%99%E8%AF%AF

本文由 @会飞的鱼 于 2020-12-31 发布在 会飞的鱼Blog,如无特别说明,本博文章均为原创,转载请保留出处。

网友评论

    暂无评论

会飞的鱼 V

一条会飞的鱼!

745 文章
7275 评论
1071 万 阅读
8年 博龄
最新文章
最新评论
嘻嘻嘻
2个月前 (2024-03-19)

ThinkPHP实现用户注册、登录模块

标签

会飞的鱼 在线咨询

在线时间:9:00-22:00
周六、周日:14:00-22:00