黄三岁大爱人生 / 网页 / 小谈网易云音乐

分享

   

小谈网易云音乐

2018-03-28  黄三岁大...
  1. 网易云音乐API分析  
  2.   
  3.   
  4. 1. 总览  
  5.   
  6.   
  7. 本文档是通过对网易云音乐Android客户端(1.5.2)的部分功能进行分析得出的  
  8.   
  9.   
  10. 在所有的交互中,均需要在cookie中添加这对键值appver=1.5.2;  
  11.   
  12.   
  13. (Update 2014-07-13) cookie中添加appver=2.0.2 referer设置为http://music.163.com  
  14. 2. 搜索  
  15.   
  16.   
  17. POST http://music.163.com/api/search/get/  
  18.   
  19.   
  20. 参数  
  21.   
  22.   
  23. s: 搜索词  
  24.   
  25.   
  26. limit: 返回数量  
  27.   
  28.   
  29. sub: 意义不明(非必须参数);取值:false  
  30.   
  31.   
  32. type: 搜索类型;取值意义  
  33.   
  34.   
  35. 1 单曲  
  36. 10 专辑  
  37. 100 歌手  
  38. 1000 歌单  
  39. 1002 用户  
  40. offset: 偏移数量,用于分页  
  41.   
  42.   
  43. MUSIC_U: 意义不明(非必须参数)  
  44.   
  45.   
  46. 示例  
  47.   
  48.   
  49. curl -d "s=玫瑰色的你&limit=20&type=1&offset=0" -b "appver=1.5.2;" http://music.163.com/api/search/get/  
  50.   
  51.   
  52. 结果:  
  53.   
  54.   
  55. {  
  56.     "code": 200,   
  57.     "result": {  
  58.         "songCount": 1,   
  59.         "songs": [  
  60.             {  
  61.                 "album": {  
  62.                     "status": 1,   
  63.                     "copyrightId": 0,   
  64.                     "name": "\u795e\u7684\u6e38\u620f",   
  65.                     "artist": {  
  66.                         "alias": [],   
  67.                         "picUrl": null,   
  68.                         "id": 0,   
  69.                         "name": ""  
  70.                     },   
  71.                     "publishTime": 1344528000000,   
  72.                     "id": 32311,   
  73.                     "size": 10  
  74.                 },   
  75.                 "status": 1,   
  76.                 "copyrightId": 0,   
  77.                 "name": "\u73ab\u7470\u8272\u7684\u4f60",   
  78.                 "mvid": 5102,   
  79.                 "alias": [],   
  80.                 "artists": [  
  81.                     {  
  82.                         "alias": [],   
  83.                         "picUrl": null,   
  84.                         "id": 10557,   
  85.                         "name": "\u5f20\u60ac"  
  86.                     }  
  87.                 ],   
  88.                 "duration": 297927,   
  89.                 "id": 326695  
  90.             }  
  91.         ]  
  92.     }  
  93. }  
  94. 3. 获取歌手专辑列表  
  95.   
  96.   
  97. GET http://music.163.com/api/artist/albums/[artist_id]/  
  98.   
  99.   
  100. 其中artist_id用歌手id替换  
  101.   
  102.   
  103. 参数  
  104.   
  105.   
  106. offset: 偏移数量,用于分页  
  107.   
  108.   
  109. limit: 返回数量  
  110.   
  111.   
  112. 示例  
  113.   
  114.   
  115. curl -b "appver=1.5.2;" "http://music.163.com/api/artist/albums/10557?offset=0&limit=3"  
  116.   
  117.   
  118. 结果:  
  119.   
  120.   
  121. {  
  122.     "hotAlbums": [  
  123.         {  
  124.             "status": 1,   
  125.             "blurPicUrl": "http://p2.music.126.net/mic-HzsY8tNY6DD1eHzdlg==/612427976714915.jpg",   
  126.             "commentThreadId": "R_AL_3_2263047",   
  127.             "description": "",   
  128.             "tags": "",   
  129.             "briefDesc": "",   
  130.             "artist": {  
  131.                 "img1v1Url": "http://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",   
  132.                 "name": "\u5f20\u60ac",   
  133.                 "briefDesc": "",   
  134.                 "albumSize": 8,   
  135.                 "img1v1Id": 0,   
  136.                 "alias": [  
  137.                     "\u7126\u5b89\u6ea5"  
  138.                 ],   
  139.                 "picId": 168225279065170,   
  140.                 "picUrl": "http://p1.music.126.net/F7i_-eBbuhpBXodY5U2oTw==/168225279065170.jpg",   
  141.                 "id": 10557  
  142.             },   
  143.             "companyId": 0,   
  144.             "publishTime": 1349366400007,   
  145.             "name": "\u795e\u7684\u6e38\u620f \u5de1\u6f14\u7cbe\u534e\u5b9e\u5f55",   
  146.             "alias": [],   
  147.             "picId": 612427976714915,   
  148.             "copyrightId": 0,   
  149.             "picUrl": "http://p1.music.126.net/mic-HzsY8tNY6DD1eHzdlg==/612427976714915.jpg",   
  150.             "company": "\u7d22\u5c3c\u97f3\u4e50",   
  151.             "songs": null,   
  152.             "type": null,   
  153.             "id": 2263047,   
  154.             "size": 7  
  155.         },   
  156.         ...  
  157.     ],   
  158.     "more": true,   
  159.     "code": 200,   
  160.     "artist": {  
  161.         "img1v1Url": "http://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",   
  162.         "name": "\u5f20\u60ac",   
  163.         "briefDesc": "",   
  164.         "albumSize": 8,   
  165.         "img1v1Id": 0,   
  166.         "alias": [  
  167.             "\u7126\u5b89\u6ea5"  
  168.         ],   
  169.         "picId": 168225279065170,   
  170.         "picUrl": "http://p1.music.126.net/F7i_-eBbuhpBXodY5U2oTw==/168225279065170.jpg",   
  171.         "id": 10557  
  172.     }  
  173. }  
  174. 4. 获取专辑音乐列表  
  175.   
  176.   
  177. GET http://music.163.com/api/album/[album_id]/  
  178.   
  179.   
  180. 其中album_id用专辑id替换  
  181.   
  182.   
  183. 示例  
  184.   
  185.   
  186. curl -b "appver=1.5.2;" "http://music.163.com/api/album/32311/"  
  187.   
  188.   
  189. 结果:  
  190.   
  191.   
  192. {  
  193.     "album": {  
  194.         "alias": [  
  195.             "Games We Play"  
  196.         ],  
  197.         "artist": {  
  198.             "albumSize": 8,  
  199.             "alias": [  
  200.                 "\u7126\u5b89\u6ea5"  
  201.             ],  
  202.             "briefDesc": "",  
  203.             "id": 10557,  
  204.             "img1v1Id": 0,  
  205.             "img1v1Url": "http://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",  
  206.             "name": "\u5f20\u60ac",  
  207.             "picId": 168225279065170,  
  208.             "picUrl": "http://p1.music.126.net/F7i_-eBbuhpBXodY5U2oTw==/168225279065170.jpg"  
  209.         },  
  210.         "blurPicUrl": "http://p1.music.126.net/cdoUJ2yO5LRuJhGeIsRdjQ==/46179488380332.jpg",  
  211.         "briefDesc": "",  
  212.         "commentThreadId": "R_AL_3_32311",  
  213.         "company": "\u7d22\u5c3c\u97f3\u4e50\u5a31\u4e50",  
  214.         "companyId": 0,  
  215.         "copyrightId": 0,  
  216.         "description": "2012...\n\n",  
  217.         "id": 32311,  
  218.         "info": {  
  219.             "commentCount": 1,  
  220.             "comments": null,  
  221.             "latestLikedUsers": null,  
  222.             "liked": false,  
  223.             "likedCount": 0,  
  224.             "shareCount": 2,  
  225.             "threadId": "R_AL_3_32311"  
  226.         },  
  227.         "name": "\u795e\u7684\u6e38\u620f",  
  228.         "picId": 46179488380332,  
  229.         "picUrl": "http://p1.music.126.net/cdoUJ2yO5LRuJhGeIsRdjQ==/46179488380332.jpg",  
  230.         "publishTime": 1344528000000,  
  231.         "size": 10,  
  232.         "songs": [  
  233.             {  
  234.                 "album": {  
  235.                     "alias": [  
  236.                         "Games We Play"  
  237.                     ],  
  238.                     "artist": {  
  239.                         "albumSize": 0,  
  240.                         "alias": [],  
  241.                         "briefDesc": "",  
  242.                         "id": 0,  
  243.                         "img1v1Id": 0,  
  244.                         "img1v1Url": "http://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",  
  245.                         "name": "",  
  246.                         "picId": 0,  
  247.                         "picUrl": ""  
  248.                     },  
  249.                     "blurPicUrl": "http://p1.music.126.net/cdoUJ2yO5LRuJhGeIsRdjQ==/46179488380332.jpg",  
  250.                     "briefDesc": "",  
  251.                     "commentThreadId": "R_AL_3_32311",  
  252.                     "company": "\u7d22\u5c3c\u97f3\u4e50\u5a31\u4e50",  
  253.                     "companyId": 0,  
  254.                     "copyrightId": 0,  
  255.                     "description": "",  
  256.                     "id": 32311,  
  257.                     "name": "\u795e\u7684\u6e38\u620f",  
  258.                     "picId": 46179488380332,  
  259.                     "picUrl": "http://p1.music.126.net/cdoUJ2yO5LRuJhGeIsRdjQ==/46179488380332.jpg",  
  260.                     "publishTime": 1344528000000,  
  261.                     "size": 10,  
  262.                     "songs": null,  
  263.                     "status": 1,  
  264.                     "tags": "",  
  265.                     "type": ""  
  266.                 },  
  267.                 "alias": [],  
  268.                 "artists": [  
  269.                     {  
  270.                         "albumSize": 0,  
  271.                         "alias": [],  
  272.                         "briefDesc": "",  
  273.                         "id": 10557,  
  274.                         "img1v1Id": 0,  
  275.                         "img1v1Url": "http://p1.music.126.net/6y-UleORITEDbvrOLV0Q8A==/5639395138885805.jpg",  
  276.                         "name": "\u5f20\u60ac",  
  277.                         "picId": 0,  
  278.                         "picUrl": ""  
  279.                     }  
  280.                 ],  
  281.                 "bMusic": {  
  282.                     "bitrate": 320000,  
  283.                     "dfsId": 1012650209189891,  
  284.                     "id": 10334056,  
  285.                     "name": "\u73ab\u7470\u8272\u7684\u4f60",  
  286.                     "playTime": 297927,  
  287.                     "size": 11930240  
  288.                 },  
  289.                 "commentThreadId": "R_SO_4_326695",  
  290.                 "copyrightId": 0,  
  291.                 "dayPlays": 0,  
  292.                 "duration": 297927,  
  293.                 "hMusic": {  
  294.                     "bitrate": 320000,  
  295.                     "dfsId": 1012650209189888,  
  296.                     "id": 10334053,  
  297.                     "name": "\u73ab\u7470\u8272\u7684\u4f60",  
  298.                     "playTime": 297927,  
  299.                     "size": 11930240  
  300.                 },  
  301.                 "hearTime": 0,  
  302.                 "id": 326695,  
  303.                 "lMusic": {  
  304.                     "bitrate": 96000,  
  305.                     "dfsId": 1012650209189890,  
  306.                     "id": 10334055,  
  307.                     "name": "\u73ab\u7470\u8272\u7684\u4f60",  
  308.                     "playTime": 297927,  
  309.                     "size": 3595194  
  310.                 },  
  311.                 "mMusic": {  
  312.                     "bitrate": 160000,  
  313.                     "dfsId": 1012650209189889,  
  314.                     "id": 10334054,  
  315.                     "name": "\u73ab\u7470\u8272\u7684\u4f60",  
  316.                     "playTime": 297927,  
  317.                     "size": 5976935  
  318.                 },  
  319.                 "mp3Url": "http://m1.music.126.net/uCNvR9xHLoQIj1kIRyzadQ==/1012650209189889.mp3",  
  320.                 "mvid": 5102,  
  321.                 "name": "\u73ab\u7470\u8272\u7684\u4f60",  
  322.                 "playedNum": 0,  
  323.                 "popularity": 95.0,  
  324.                 "position": 1,  
  325.                 "score": 95,  
  326.                 "starred": false,  
  327.                 "starredNum": 0,  
  328.                 "status": 1  
  329.             },  
  330.             ...  
  331.         ],  
  332.         "status": 1,  
  333.         "tags": "",  
  334.         "type": ""  
  335.     },  
  336.     "code": 200  
  337. }  
  338. 5. 下载音乐文件  
  339.   
  340.   
  341. GET http://m1.music.126.net/[encrypted_song_id]/[song_dfsId].mp3  
  342.   
  343.   
  344. 其中song_dfsId为歌曲id,同一歌曲不同比特率有不同的id,见上结果。encrypted_song_id为song_dfsId加密后的字符串。  
  345.   
  346.   
  347. 歌曲id加密代码  
  348.   
  349.   
  350. import md5  
  351.   
  352.   
  353. def encrypted_id(id):  
  354.     byte1 = bytearray('3go8&$8*3*3h0k(2)2')  
  355.     byte2 = bytearray(id)  
  356.     byte1_len = len(byte1)  
  357.     for i in xrange(len(byte2)):  
  358.         byte2[i] = byte2[i]^byte1[i%byte1_len]  
  359.     m = md5.new()  
  360.     m.update(byte2)  
  361.     result = m.digest().encode('base64')[:-1]  
  362.     result = result.replace('/', '_')  
  363.     result = result.replace('+', '-')  
  364.     return result  

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多
    喜欢该文的人也喜欢 更多

    ×
    ×

    ¥.00

    微信或支付宝扫码支付:

    开通即同意《个图VIP服务协议》

    全部>>