Skip to content

Commit 3509185

Browse files
author
kilingzhang
committed
添加 获取音乐 url 接口
1 parent ac8b738 commit 3509185

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed

run-docker.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,9 @@ docker run -itd --name=php_container \
99
-p 80:80 \
1010
kilingzhang/netease-cloud-music-api:dev
1111

12+
#docker run -itd --name=php_container \
13+
#-p 80:80 \
14+
#-v /Users/kilingzhang/Code/NeteaseCloudMusicApi-php:/var/www/html/NeteaseCloudMusicApi \
15+
#kilingzhang/netease-cloud-music-api:dev
16+
1217
docker exec -it php_container sh
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<?php
2+
/**
3+
* Created by PhpStorm.
4+
* User: kilingzhang
5+
* Date: 2020-04-19
6+
* Time: 22:20
7+
*/
8+
9+
namespace NeteaseCloudMusicApi\V1\Song;
10+
11+
12+
use NeteaseCloudMusicApi\Controller;
13+
14+
/**
15+
* Class Detail
16+
* @package NeteaseCloudMusicApi\V1\Song
17+
*
18+
* 获取音乐 url
19+
* 说明 : 使用歌单详情接口后 , 能得到的音乐的 id, 但不能得到的音乐 url, 调用此接口 , 传入的音乐 id( 可多个 , 用逗号隔开 ), 可以获取对应的音乐的 url( 不需要登录 )
20+
*
21+
* 注 : 部分用户反馈获取的 url 会 403,hwaphon 找到的 解决方案是当获取到音乐的 id 后,将 https://music.163.com/song/media/outer/url?id=id.mp3 以 src 赋予 Audio 即可播放
22+
*
23+
* 必选参数 : id : 音乐 id
24+
*
25+
* 可选参数 : br: 码率,默认设置了 999000 即最大码率,如果要 320k 则可设置为 320000,其他类推
26+
* 接口地址 : /song/url
27+
*
28+
* 调用例子 :
29+
* http://i.music.163.com/song/url?ids=33894312
30+
* http://i.music.163.com/song/url?ids=405998841,33894312
31+
*
32+
*/
33+
class Url extends Controller
34+
{
35+
protected $uri = 'https://music.163.com/api/song/enhance/player/url';
36+
37+
protected $params = [
38+
'ids' => null,
39+
'br' => 999000
40+
];
41+
42+
protected $options = [
43+
'crypto' => 'linuxapi',
44+
'ua' => 'pc',
45+
'url' => 'https://music.163.com/api/song/enhance/player/url'
46+
];
47+
48+
protected function parseParams($params): array
49+
{
50+
$params['ids'] = "[{$params['ids']}]";
51+
$params['br'] = intval($params['br']);
52+
return $params;
53+
}
54+
}

0 commit comments

Comments
 (0)