本代码可实现输入MV的id,直接解析出mp4的地址来,可以下载观看。
1 | <? php <br>header('Content-type: text/json;charset=utf-8');< br >$mv_id = '14316913';//这里写mv的id< br >$array = parse_url('https://music.163.com/mv?id='.$mv_id);< br >$id = str_replace("id=", "",$array['query']);< br >$html = music163_mv('http://music.163.com/api/mv/detail/?id='.$id.'&type=mp4');< br >$mv = json_decode($html, true);< br >if($mv['code'] == '200'){< br > $json = ['code'=> 1, 'msg'=>"解析成功"];< br > $json['desc'] = empty($mv['data']['desc']) ? '暂无简介' : $mv['data']['desc'];< br > $json['title'] = $mv['data']['name'];< br > $json['list'] = array_map(function($url){< br > return str_replace("http://", "https://", $url);< br > }, $mv['data']['brs']);< br > foreach($mv['data']['artists'] as $pron){< br > $json['artists'][] = ['name' => $pron['name']];< br > }< br > if (!empty($_GET['brs']) && $json['list'][$_GET['brs']] != '') {< br > header('location:'.$json['list'][$_GET['brs']]);< br > }< br >}else{< br > $json = ['code'=> 0, 'msg'=>"解析失败!请检查视频地址是否正确(*^_^*)"];< br >}< br >echo json_encode($json, 480);< br >function music163_mv($url) {< br > $ch = curl_init() ;< br > curl_setopt($ch, CURLOPT_URL, $url );< br > curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);< br > curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);< br > curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ;< br > curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ;< br > $output = curl_exec($ch) ;< br > curl_close ($ch);< br > return $output;< br >}< br >
|
解析出来是这个样子:
1 | { "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": "莫文蔚" } ]}< br >
|
TAGS
PHP源码
PHP源码
网易云音乐MV在线解析代码
网易云音乐MV在线解析代码