honmaple / meting-api

MetingJS服务端的Golang实现

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Meting-API

使用 Go 实现的 meting-js 接口,主要用于替换 MetingJS 的默认API, 当前 支持网易云音乐、网易云音乐API、QQ音乐

使用

└──╼ ./meting-api --help
NAME:
   meting-api - meting api

USAGE:
   meting-api [global options] command [command options] [arguments...]

VERSION:
   0.1.0

COMMANDS:
   cache-delete  delete cache from key
   config        show all config
   help, h       Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --debug, -D                                debug mode (default: false)
   --addr ADDR, -a ADDR                       listen ADDR
   --list, -l                                 list music servers (default: false)
   --config FILE, -c FILE                     load config from FILE (default: "config.yaml")
   --set-config value [ --set-config value ]  set config from string
   --help, -h                                 show help
   --version, -v                              print the version

服务端

└──╼ ./meting-api -D
[DEBUG] GET    /meting                              --> meting-api/internal/app.(*App).aplayer-fm (4 handlers)
Listening and serving HTTP on :8000

默认将会使用缓存:

  • 禁用缓存
    └──╼ ./meting-api -D --set-config cache.enabled=false
    └──╼ METING_CACHE_ENABLED=false ./meting-api -D
        
  • 修改缓存目录(默认为 ./cache)
    └──╼ ./meting-api -D --set-config cache.path="/tmp/meting-cache"
    └──╼ METING_CACHE_PATH="/tmp/meting-cache" ./meting-api -D
        
  • 修改缓存过期时间(默认为 3600 秒)
    └──╼ ./meting-api -D --set-config cache.ttl=60
    └──╼ METING_CACHE_TTL=60 ./meting-api -D
        

如果使用网易云音乐API,需要自行部署 NeteaseCloudMusicApi,并设置

└──╼ ./meting-api -D --set-config netease_api.host=https://netease_api.xxx.com
└──╼ METING_NETEASE_API_HOST=https://netease_api.xxx.com ./meting-api -D

网页端

<meting-js
  server="netease"
  type="artist"
  id="6452">
</meting-js>
<script type="text/javascript">
  var meting_api='http://localhost:8000/?server=:server&type=:type&id=:id&auth=:auth&r=:r';
</script>
<script src="https://cdn.jsdelivr.net/npm/aplayer/dist/APlayer.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/meting@2/dist/Meting.min.js"></script>

部署

docker run --name meting-api --restart=always -d -p 8000:8000 -v /tmp/meting-cache:/opt/meting-api/cache honmaple/meting-api

About

MetingJS服务端的Golang实现

License:MIT License


Languages

Language:Go 96.5%Language:HTML 2.4%Language:Dockerfile 1.1%