<?php
header('Content-type: text/json;charset=utf-8');
$mv_id = '14316913';//这里写mv的id
$array = parse_url('https://music.163.com/mv?id='.$mv_id);
$id = str_replace("id=", "",$array['query']);
$html = music163_mv('http://music.163.com/api/mv/detail/?id='.$id.'&type=mp4');
$mv = json_decode($html, true);
if($mv['code'] == '200'){
$json = ['code'=> 1, 'msg'=>"解析成功"];
$json['desc'] = empty($mv['data']['desc']) ? '暂无简介' : $mv['data']['desc'];
$json['title'] = $mv['data']['name'];
$json['list'] = array_map(function($url){
return str_replace("http://", "https://", $url);
}, $mv['data']['brs']);
foreach($mv['data']['artists'] as $pron){
$json['artists'][] = ['name' => $pron['name']];
}
if (!empty($_GET['brs']) && $json['list'][$_GET['brs']] != '') {
header('location:'.$json['list'][$_GET['brs']]);
}
}else{
$json = ['code'=> 0, 'msg'=>"解析失败!请检查视频地址是否正确(*^_^*)"];
}
echo json_encode($json, 480);
function music163_mv($url) {
$ch = curl_init() ;
curl_setopt($ch, CURLOPT_URL, $url );
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ;
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ;
$output = curl_exec($ch) ;
curl_close ($ch);
return $output;
}
{
"code": 1,
"msg": "解析成功",
"desc": "暂无简介",
"title": "这世界那么多人 (电影《我要我们在一起》主题曲)",
"list": {
"240": "https://vodkgeyttp8.vod.126.net/cloudmusic/08b0/core/4670/f6678cdf81445f0e505eb65a18469ceb.mp4?wsSecret=569333b018f80079b5ae507d25b487d4&wsTime=1655215107",
"480": "https://vodkgeyttp8.vod.126.net/cloudmusic/08b0/core/4670/e53f624135cbf89b1b663a8213dbb474.mp4?wsSecret=1d396b02d597b12aeb3786630f29ed6f&wsTime=1655215107",
"720": "https://vodkgeyttp8.vod.126.net/cloudmusic/08b0/core/4670/ca624963e49caa4e45e601e79d5de024.mp4?wsSecret=3fcb753ab9a935c7894913885190f9c5&wsTime=1655215107"
},
"artists": [
{
"name": "莫文蔚"
}
]
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
暂无评论内容