升级 Meting 至最新版

修复网易云音乐失效
pull/21/head
mengkunsoft 2018-02-06 10:21:27 +08:00
parent 404f1dadae
commit 3ce5b8facf
1 changed files with 595 additions and 578 deletions

View File

@ -1,11 +1,11 @@
<?php
/*!
/**
* Meting music framework
* https://i-meto.com
* https://github.com/metowolf/Meting
* Version 1.3.10
* Version 1.4.0
*
* Copyright 2017, METO Sheel <i@i-meto.com>
* Copyright 2018, METO Sheel <i@i-meto.com>
* Released under the MIT license
*/
@ -35,6 +35,7 @@ class Meting
if (!empty($v)) {
$this->_TEMP['cookie'] = $v;
}
return $this;
}
public function format($v = true)
@ -70,8 +71,15 @@ class Meting
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl, CURLOPT_URL, $API['url']);
curl_setopt($curl, CURLOPT_COOKIE, isset($this->_TEMP['cookie'])?$this->_TEMP['cookie']:$BASE['cookie']);
curl_setopt($curl, CURLOPT_REFERER, $BASE['referer']);
curl_setopt($curl, CURLOPT_USERAGENT, $BASE['useragent']);
curl_setopt($curl, CURLOPT_HTTPHEADER, [
'Accept: */*',
'Accept-Encoding: gzip, deflate',
'Accept-Language: zh-CN,zh;q=0.8,gl;q=0.6,zh-TW;q=0.4',
'Connection: keep-alive',
'Content-Type: application/x-www-form-urlencoded',
'Referer: ' . $BASE['referer'],
'User-Agent: ' . $BASE['useragent']
]);
for ($i=0;$i<=$this->_RETRY;$i++) {
$data = curl_exec($curl);
$info = curl_getinfo($curl);
@ -126,7 +134,7 @@ class Meting
return $result;
}
public function search($keyword, $page=1, $limit=30)
public function search($keyword, $option = null)
{
switch ($this->_SITE) {
case 'netease':
@ -137,10 +145,10 @@ class Meting
'method' => 'POST',
'params' => array(
's' => $keyword,
'type' => 1,
'limit' => $limit,
'type' => isset($option['type']) ? $option['type'] : 1,
'limit' => isset($option['limit']) ? $option['limit'] : 30,
'total' => 'true',
'offset' => ($page-1)*$limit,
'offset' => isset($option['page']) && isset($option['limit']) ? ($option['page'] - 1) * $option['limit'] : 0,
),
'url' => 'http://music.163.com/api/cloudsearch/pc',
),
@ -154,8 +162,8 @@ class Meting
'url' => 'https://c.y.qq.com/soso/fcgi-bin/client_search_cp',
'body' => array(
'format' => 'json',
'p' => $page,
'n' => $limit,
'p' => isset($option['page']) ? $option['page'] : 1,
'n' => isset($option['limit']) ? $option['limit'] : 30,
'w' => $keyword,
'aggr' => 1,
'lossless' => 1,
@ -173,8 +181,8 @@ class Meting
'v' => '2.0',
'app_key' => '1',
'key' => $keyword,
'page' => $page,
'limit' => $limit,
'page' => isset($option['page']) ? $option['page'] : 1,
'limit' => isset($option['limit']) ? $option['limit'] : 30,
'r' => 'search/songs',
),
'format' => 'data#songs',
@ -186,12 +194,12 @@ class Meting
'url' => 'http://ioscdn.kugou.com/api/v3/search/song',
'body' => array(
'iscorrect' => 1,
'pagesize' => $limit,
'pagesize' => isset($option['limit']) ? $option['limit'] : 30,
'plat' => 2,
'tag' => 1,
'sver' => 5,
'showtype' => 10,
'page' => $page,
'page' => isset($option['page']) ? $option['page'] : 1,
'keyword' => $keyword,
'version' => 8550
),
@ -206,9 +214,9 @@ class Meting
'method' => 'baidu.ting.search.merge',
'isNew' => 1,
'query' => $keyword,
'page_size' => $limit,
'page_no' => $page,
'type' => 0,
'page_size' => isset($option['limit']) ? $option['limit'] : 30,
'page_no' => isset($option['page']) ? $option['page'] : 1,
'type' => isset($option['type']) ? $option['type'] : 0,
'format' => 'json',
'from' => 'ios',
'channel' => '(null)',
@ -233,9 +241,9 @@ class Meting
'body' => array(
'method' => 'POST',
'params' => array(
'c' => '[{"id":'.$id.'}]',
'c' => '[{"id":'.$id.',"v":0}]',
),
'url' => 'http://music.163.com/api/v3/song/detail',
'url' => 'http://music.163.com/api/v3/song/detail/',
),
'encode' => 'netease_AESECB',
'format' => 'songs',
@ -310,7 +318,12 @@ class Meting
'body' => array(
'method' => 'GET',
'params' => array(
'id' => $id,
"total" => "true",
"offset" => "0",
"id" => $id,
"limit" => "1000",
"ext" => "true",
"private_cloud" => "true"
),
'url' => 'http://music.163.com/api/v1/album/'.$id,
),
@ -389,9 +402,11 @@ class Meting
'body' => array(
'method' => 'GET',
'params' => array(
'top' => $limit,
"id" => $id,
"ext" => "true",
"private_cloud" => "true",
"ext" => "true",
"top" => $limit,
"id" => $id
),
'url' => 'http://music.163.com/api/v1/artist/'.$id,
),
@ -475,8 +490,10 @@ class Meting
'body' => array(
'method' => 'POST',
'params' => array(
'id' => $id,
"n" => 1000,
"s" => "0",
"id" => $id,
"n" => "1000",
"t" => "0"
),
'url' => 'http://music.163.com/api/v3/playlist/detail',
),
@ -749,31 +766,31 @@ class Meting
case 'netease':
return array(
'referer' => 'https://music.163.com/',
'cookie' => 'os=linux; appver=1.0.0.1026; osver=Ubuntu%2016.10; MUSIC_U=' . $this->getRandomHex(112) . '; __remember_me=true',
'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
'cookie' => 'os=linux; deviceId=' . $this->getRandomHex(52) . '; osver=Ubuntu%2016.04.3%20LTS; appver=1.1.0.1232; channel=netease; MUSIC_A=' . $this->getRandomHex(208) . '; __csrf=' . $this->getRandomHex(32),
'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
);
case 'tencent':
return array(
'referer' => 'https://y.qq.com/portal/player.html',
'cookie' => 'pgv_pvi=22038528; pgv_si=s3156287488; pgv_pvid=5535248600; yplayer_open=1; ts_last=y.qq.com/portal/player.html; ts_uid=4847550686; yq_index=0; qqmusic_fromtag=66; player_exist=1',
'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
'useragent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36',
);
case 'xiami':
return array(
'referer' => 'http://h.xiami.com/',
'cookie' => 'user_from=2;XMPLAYER_addSongsToggler=0;XMPLAYER_isOpen=0;_xiamitoken=123456789' . $this->getRandomHex(32) . ';',
'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
'cookie' => '_xiamitoken=' . $this->getRandomHex(32) . '; _unsign_token=' . $this->getRandomHex(32),
'useragent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36',
);
case 'kugou':
return array(
'referer' => 'http://www.kugou.com/webkugouplayer/flash/webKugou.swf',
'cookie' => '_WCMID=123456789',
'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
'cookie' => 'kg_mid=' . $this->getRandomHex(32),
'useragent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36',
);
case 'baidu':
return array(
'referer' => 'http://ting.baidu.com/',
'cookie' => 'BAIDUID=123456789',
'cookie' => 'BAIDUID=' . $this->getRandomHex(32),
'useragent' => 'ios_5.9.12',
);
}
@ -781,11 +798,11 @@ class Meting
private function getRandomHex($length)
{
$val = '';
for( $i=0; $i<$length; $i++ ) {
$val .= chr( rand( 65, 90 ) );
if (function_exists('openssl_random_pseudo_bytes')) {
return bin2hex(openssl_random_pseudo_bytes($length));
} else {
return bin2hex(mcrypt_create_iv($length, MCRYPT_DEV_URANDOM));
}
return $val;
}
/**