Skip to content

Commit

Permalink
v1.4.1 优化 QQ 音乐品质
Browse files Browse the repository at this point in the history
  • Loading branch information
maicong committed Dec 4, 2017
1 parent ccfed40 commit 678967e
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@

## Changelog / 更新日志

- 2017.12.04 `v1.4.1` 优化 QQ 音乐品质
- 2017.11.28 `v1.4.0` 优化接口和代码、优化 Curl 模块加载方式
- 2017.09.12 `v1.3.0` 更新 QQ 音乐 API 接口
- 2017.09.08 `v1.2.9` 优化模版代码,更新说明
Expand Down
37 changes: 32 additions & 5 deletions core/music.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @author MaiCong <[email protected]>
* @link https://github.com/maicong/music
* @since 1.4.0
* @since 1.4.1
*
*/

Expand Down Expand Up @@ -662,6 +662,18 @@ function mc_get_song_by_id($songid, $site = 'netease', $multi = false)
}
break;
case 'qq':
$radio_vkey = json_decode(mc_curl(array(
'method' => 'GET',
'url' => 'http://base.music.qq.com/fcgi-bin/fcg_musicexpress.fcg',
'referer' => 'https://y.qq.com',
'proxy' => false,
'body' => array(
'json' => 3,
'guid' => 5150825362,
'format' => 'json'
),
'user-agent' => 'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B143 Safari/601.1'
)), true);
foreach ($radio_result as $val) {
$radio_json = json_decode($val, true);
$radio_data = $radio_json['data'];
Expand All @@ -670,20 +682,23 @@ function mc_get_song_by_id($songid, $site = 'netease', $multi = false)
foreach ($radio_data as $value) {
$radio_song_id = $value['mid'];
$radio_authors = array();
foreach ($radio_data[0]['singer'] as $singer) {
foreach ($value['singer'] as $singer) {
$radio_authors[] = $singer['title'];
}
$radio_author = implode('/', $radio_authors);
$radio_music1 = 'http://' . $radio_url[$value['id']];
$radio_music2 = 'http://isure.stream.qqmusic.qq.com/C100' . $radio_song_id . '.m4a?fromtag=32';
if (!empty($radio_vkey['key'])) {
$radio_music = generate_qqmusic_url($radio_song_id, $radio_vkey['key']);
} else {
$radio_music = 'https://' . str_replace('ws', 'dl', $radio_url[$value['id']]);
}
$radio_album_id = $value['album']['mid'];
$radio_songs[] = array(
'type' => 'qq',
'link' => 'https://y.qq.com/n/yqq/song/' . $radio_song_id . '.html',
'songid' => $radio_song_id,
'name' => urldecode($value['title']),
'author' => urldecode($radio_author),
'music' => $radio_music1 ? $radio_music1 : $radio_music2,
'music' => $radio_music,
'pic' => 'http://y.gtimg.cn/music/photo_new/T002R300x300M000' . $radio_album_id . '.jpg'
);
}
Expand Down Expand Up @@ -1045,6 +1060,18 @@ function split_songid ($songid, $index = 0, $delimiter = '|') {
return;
}

// 生成 QQ 音乐各品质链接
function generate_qqmusic_url ($songmid, $key) {
$quality = array('M800', 'M500', 'C600', 'C400', 'C100');
foreach ($quality as $value) {
$url = 'https://dl.stream.qqmusic.qq.com/' . $value . $songmid . '.mp3?vkey=' . $key . '&guid=5150825362&fromtag=1';
$header = get_headers($url, 1);
if (empty($header['error'])) {
return $url;
}
}
}

// Server
function server($key)
{
Expand Down
4 changes: 2 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
*
* @author MaiCong <[email protected]>
* @link https://github.com/maicong/music
* @since 1.4.0
* @since 1.4.1
*
*/

// 定义核心
define('MC_CORE', true);

// 定义版本
define('MC_VERSION', '1.4.0');
define('MC_VERSION', '1.4.1');

// 核心文件目录
define('MC_CORE_DIR', __DIR__ . '/core');
Expand Down

0 comments on commit 678967e

Please sign in to comment.