Skip to content
chengxianghe edited this page Jan 10, 2017 · 6 revisions
  • api是豆瓣升级过的v2版的接口(本文更新时间:2017-01-10)

  • 这里所列的api都是基于豆瓣FM客户端抓包而来, 这里只是拿出来作为学习研究, 不得用于商业行为...

  • 豆瓣FM改版前的api整理, 我之前也是用的这里的,传送门

登录接口

  • URL: https://www.douban.com/service/auth2/token

  • Method: POST

  • Arguments:

    • apikey: 02646d3fb69a52ff072d47bf23cef8fd

    • client_id: 02646d3fb69a52ff072d47bf23cef8fd

    • client_secret: cde5d61429abcd7c

    • udid: b88146214e19b8a8244c9bc0e2789da68955234d

    • douban_udid: b635779c65b816b13b330b68921c0f8edc049590

    • device_id: b88146214e19b8a8244c9bc0e2789da68955234d

    • grant_type: password

    • redirect_uri: http://www.douban.com/mobile/fm

    • username: 用户帐号

    • password: 明文密码

  • Header: Content-Type: application/x-www-form-urlencoded

  • Response ( application/json )

登录成功

{
    "access_token": "21a0867e86f16fb464e1937b94d44f1w",
    "douban_user_id": 145636941,
    "douban_user_name": "xxxx",
    "expires_in": 7775999,
    "refresh_token": "77bc1538a652d3b867343fa9f2f87b18"
}

在获得access_tokenexpire后,保存起来,expire 应该是默认的90天的过期时间, 在使用获取歌曲列表、红心等API时,需要在相应的请求header里面添加Authorization字段,对应的值是Bearer + access_token, 注意Bearer后面是有空格的,例如 Bearer 21a0867e86f16fb464e1937b94d44f1w

获取频道列表

这个接口获取的频道列表是对应客户端上的第一个Tab。 测试

  • URL: https://api.douban.com/v2/fm/app_channels

  • Method: GET

  • Arguments:

    • alt: json

    • app_name: radio_iphone

    • apikey: 02646d3fb69a52ff072d47bf23cef8fd

    • client: s:mobile|y:iOS 10.2|f:115|d:b88146214e19b8a8244c9bc0e2789da68955234d|e:iPhone7,1|m:appstore

    • client_id: 02646d3fb69a52ff072d47bf23cef8fd

    • icon_cate: xlarge

    • udid: b88146214e19b8a8244c9bc0e2789da68955234d

    • douban_udid: b635779c65b816b13b330b68921c0f8edc049590

    • version: 115

  • Response ( application/json ):

{
    "groups": [
        {
            "chls": [
                {
                    "style": {
                        "display_text": "",
                        "bg_color": "0x499884",
                        "layout_type": 1,
                        "bg_image": ""
                    },
                    "intro": "我的个性化音乐频道",
                    "name": "我的私人",
                    "song_num": 0,
                    "collected": "disabled",
                    "cover": "https://img3.doubanio.com/f/fm/11bed977076d721fb66ef6c2f2cfb66ae79ed07a/pics/fm/default_personal_channel_cover.png",
                    "id": 0
                }, {
                    "style": {
                        "bg_color": "0xe06b59",
                        "layout_type": 2,
                        "bg_image": ""
                    },
                    "intro": "豆瓣好评音乐精选",
                    "name": "豆瓣精选",
                    "collected": "disabled",
                    "cover": "https://img3.doubanio.com/f/fm/c1f6362114965225752341e9291a4b2f39f78cfb/pics/fm/channel_selected_cover.png",
                    "id": -10
                }
            ],
            "group_id": 0,
            "group_name": ""
        },
...
 ]
}

基本上是几个大分组,比如单曲, 风格流派, 语言年代...

歌曲列表

歌曲列表参数比较多, 登录与否主要看header的Authorization字段,在我测试的时候发现和userid基本没有关系... 测试

  • URL: https://api.douban.com/v2/fm/playlist

  • Method: GET

  • Header:

    //未登录的不填

    • Authorization: Bearer 21a0867e86f16fb464e1937b94d44f1w
  • Arguments:

    • channel: 填写对应的channel id

    • from: mainsite

    • pt: 0.0

    • kbps: 128

    • formats: aac

    • alt: json

    • app_name: radio_iphone

    • apikey: 02646d3fb69a52ff072d47bf23cef8fd

    • client: s:mobile|y:iOS 10.2|f:115|d:b88146214e19b8a8244c9bc0e2789da68955234d|e:iPhone7,1|m:appstore

    • client_id: 02646d3fb69a52ff072d47bf23cef8fd

    • icon_cate: xlarge

    • udid: b88146214e19b8a8244c9bc0e2789da68955234d

    • douban_udid: b635779c65b816b13b330b68921c0f8edc049590

    • version: 115

  • Response ( application/json ):

{
    "warning": "user_is_ananymous",
    "r": 0,
    "version_max": 116,
    "is_show_quick_start": 0,
    "song": [
        {
            "albumtitle": "The Princess Diaries 2: Royal Engagement",
            "url": "http://mr3.doubanio.com/764cb746b8dfa264b39aa5513c8bc4fb/0/fm/song/p1439388_128k.mp4",
            "file_ext": "mp4",
            "album": "/subject/1765409/",
            "ssid": "98c4",
            "title": "Because You Live",
            "sid": "1439388",
            "sha256": "fd651e012a7c45bc5c9e582d06c88d44fdb845d6d2ae9b2515343e3eafb0e4a7",
            "status": 0,
            "picture": "http://img3.doubanio.com/lpic/s2837777.jpg",
            "update_time": 1470126128,
            "alert_msg": "",
            "public_time": "2004",
            "singers": [
                {
                    "style": [],
                    "name": "Jesse McCartney",
                    "region": [
                        "美国"
                    ],
                    "name_usual": "Jesse McCartney",
                    "genre": [
                        "Pop"
                    ],
                    "avatar": "http://img7.doubanio.com/img/fmadmin/large/32852.jpg",
                    "related_site_id": 0,
                    "is_site_artist": false,
                    "id": "2558"
                },
                {
                    "style": [],
                    "name": "Various Artists",
                    "region": [
                        "欧美"
                    ],
                    "name_usual": "Various Artists",
                    "genre": [
                        "Pop",
                        "Rock",
                        "Electronic"
                    ],
                    "avatar": "http://img7.doubanio.com/img/fmadmin/large/2118995.jpg",
                    "related_site_id": 0,
                    "is_site_artist": false,
                    "id": "0"
                }
            ],
            "like": 0,
            "artist": "Various Artists / Jesse McCartney",
            "is_royal": false,
            "subtype": "",
            "length": 199,
            "release": {
                "link": "https://douban.fm/album/1765409gb789",
                "id": "1765409",
                "ssid": "b789"
            },
            "aid": "1765409",
            "kbps": "128"
        },
...
  ]
}

列出来的返回字段可能不全,建议点击测试直接看结果。

歌词获取

歌词获取比较简单,就是一个普通的GET请求。 测试

  • URL: https://api.douban.com/v2/fm/lyric

  • Method: GET

  • Arguments:

    • sid: 歌曲的sid

    • ssid: 歌曲的ssid

  • Response ( application/json ):

{
    "lyric": "[00:00.00]\r\n[00:11.50]\r\n[00:14.70]没人打开的记忆\r\n[00:21.46]又自动播放在夜空里\r\n[00:28.05]离开的人 \r\n[00:31.20]陨落的流星\r\n[00:33.67]又回来咬我的心\r\n[00:38.77]\r\n[00:40.79]没人打开的泪滴\r\n[00:47.66]又敲着窗户自言自语\r\n[00:54.37]泥泞的路\r\n[00:57.51]坎坷的感情\r\n[00:59.86]都剩下云淡风轻\r\n[01:04.96]\r\n[01:06.39]不要伤心 \r\n[01:10.67]不要灰心\r\n[01:13.12]是命运教我的事情\r\n[01:19.43]苦难到虚脱的绝境\r\n[01:23.49]会被时间酿成 \r\n[01:26.45]微甜的回忆\r\n[01:32.46]\r\n[01:46.70]没人打开的泪滴\r\n[01:53.38]又敲着窗户自言自语\r\n[02:00.23]泥泞的路\r\n[02:03.26]坎坷的感情\r\n[02:05.81]都剩下云淡风轻\r\n[02:11.54]\r\n[02:12.24]不要伤心 \r\n[02:16.40]不要灰心\r\n[02:18.82]是命运教我的事情\r\n[02:25.10]苦难到虚脱的绝境\r\n[02:29.25]会被时间酿成 \r\n[02:32.08]微甜的回忆\r\n[02:38.14]\r\n[02:38.40]不要伤心 \r\n[02:42.74]不要担心\r\n[02:45.23]哪有雨会永远不停\r\n[02:51.55]曾酸到窒息的别离\r\n[02:55.45]会被怀念酿成 \r\n[02:59.26]微甜的回忆\r\n[03:04.17]\r\n[03:04.64]曾酸到窒息的别离\r\n[03:08.66]会被怀念酿成 \r\n[03:11.76]微甜的回忆\r\n[03:17.41]\r\n[03:17.87]最永恒的幸福 \r\n[03:21.10]不是拥有你\r\n[03:24.28]而是拥有\r\n[03:26.29]和你有关的回忆\r\n[03:31.97]",
    "name": "微甜的回忆",
    "sid": "2197343"
}

没啥好说的,不过豆瓣的一些歌曲的歌词竟然是没有对应时间的。。。

##有什么需要的接口后续再补充吧

Clone this wiki locally