Code Monkey home page Code Monkey logo

music-api-server's Introduction

music api server

音乐服务的api通用接口,目前已支持的音乐服务:

  • 虾米
    • 专辑
    • 歌曲列表
    • 精选集
  • 网易云音乐
    • 专辑
    • 歌曲列表
    • 歌单

安装(debian/ubuntu)

首先检查GOPATH变量是否正确设置,如果未设置,参考这里进行设置。

# install redis-server
sudo apt-get install redis-server

# install redis driver for golang
go get github.com/garyburd/redigo/redis

# install music api server
go get github.com/mawenbao/music-api-server

# install init script
sudo cp $GOPATH/src/github.com/mawenbao/music-api-server/tools/init-script /etc/init.d/music-api-server

# set your GOPATH in init script
sudo sed -i "s|/SET/YOUR/GOPATH/HERE|`echo $GOPATH`|" /etc/init.d/music-api-server

sudo chmod +x /etc/init.d/music-api-server

# start music api server
sudo service music-api-server start

# (optional) let music api server start on boot
sudo update-rc.d music-api-server defaults

# (optional) install logrotate config
sudo cp $GOPATH/src/github.com/mawenbao/music-api-server/tools/logrotate-config /etc/logrotate.d/music-api-server

更新(debian/ubuntu)

# update and restart music-api-server
go get -u github.com/mawenbao/music-api-server
sudo service music-api-server restart

# flush redis cache
redis-cli FLUSHDB

API

Demo

https://app.mawenbao.com/music-api-server/?p=xiami&t=songlist&i=20526,1772292423&c=abc123

请求

GET http://localhost:9099/?p=xiami&t=songlist&i=20526,1772292423&c=abc123&q=high
  • localhost:9099: 默认监听地址
  • p=xiami: 音乐API提供商,目前支持:
    • 虾米(xiami)
    • 网易云音乐(netease)
  • t=songlist: 音乐类型
    • songlist(xiami + netease): 歌曲列表,对应的id是半角逗号分隔的多个歌曲id
    • album(xiami + netease): 音乐专辑,对应的id为专辑id
    • collect(xiami): 虾米的精选集,对应的id为精选集id
    • playlist(netease): 网易云音乐的歌单,对应的id为歌单(playlist)id
  • i=20526,1772292423: 歌曲/专辑/精选集/歌单的id,歌曲列表类型可用半角逗号分割多个歌曲id
  • c=abc123: 使用jsonp方式返回数据,实际返回为abc123({songs: ...});
  • q=high: 音乐品质,high表示优先返回高比特率的音乐链接,该参数目前仅对网易云音乐有效
    • high: 高品音质
    • medium: 普通音质
    • low: 低品音质

返回

{
    "status": "返回状态,ok为正常,failed表示出错并设置msg",
    "msg":    "如果status为failed,这里会保存错误信息",
    "songs": [
        {
            "name":     "歌曲名称",
            "url":      "歌曲播放地址",
            "artists":  "演唱者",
            "provider": "音乐提供商"
            "lrc_url":  "歌词文件地址(可能没有)",
        }
    ]
} 

如果有c=abc123请求参数,则实际以jsonp方式返回数据。

Thanks

music-api-server's People

Contributors

mawenbao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.