parent
404f1dadae
commit
3ce5b8facf
|
@ -1,11 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
/*!
|
/**
|
||||||
* Meting music framework
|
* Meting music framework
|
||||||
* https://i-meto.com
|
* https://i-meto.com
|
||||||
* https://github.com/metowolf/Meting
|
* 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
|
* Released under the MIT license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ class Meting
|
||||||
if (!empty($v)) {
|
if (!empty($v)) {
|
||||||
$this->_TEMP['cookie'] = $v;
|
$this->_TEMP['cookie'] = $v;
|
||||||
}
|
}
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function format($v = true)
|
public function format($v = true)
|
||||||
|
@ -70,8 +71,15 @@ class Meting
|
||||||
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
|
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
|
||||||
curl_setopt($curl, CURLOPT_URL, $API['url']);
|
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_COOKIE, isset($this->_TEMP['cookie'])?$this->_TEMP['cookie']:$BASE['cookie']);
|
||||||
curl_setopt($curl, CURLOPT_REFERER, $BASE['referer']);
|
curl_setopt($curl, CURLOPT_HTTPHEADER, [
|
||||||
curl_setopt($curl, CURLOPT_USERAGENT, $BASE['useragent']);
|
'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++) {
|
for ($i=0;$i<=$this->_RETRY;$i++) {
|
||||||
$data = curl_exec($curl);
|
$data = curl_exec($curl);
|
||||||
$info = curl_getinfo($curl);
|
$info = curl_getinfo($curl);
|
||||||
|
@ -126,7 +134,7 @@ class Meting
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function search($keyword, $page=1, $limit=30)
|
public function search($keyword, $option = null)
|
||||||
{
|
{
|
||||||
switch ($this->_SITE) {
|
switch ($this->_SITE) {
|
||||||
case 'netease':
|
case 'netease':
|
||||||
|
@ -137,10 +145,10 @@ class Meting
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'params' => array(
|
'params' => array(
|
||||||
's' => $keyword,
|
's' => $keyword,
|
||||||
'type' => 1,
|
'type' => isset($option['type']) ? $option['type'] : 1,
|
||||||
'limit' => $limit,
|
'limit' => isset($option['limit']) ? $option['limit'] : 30,
|
||||||
'total' => 'true',
|
'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',
|
'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',
|
'url' => 'https://c.y.qq.com/soso/fcgi-bin/client_search_cp',
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'format' => 'json',
|
'format' => 'json',
|
||||||
'p' => $page,
|
'p' => isset($option['page']) ? $option['page'] : 1,
|
||||||
'n' => $limit,
|
'n' => isset($option['limit']) ? $option['limit'] : 30,
|
||||||
'w' => $keyword,
|
'w' => $keyword,
|
||||||
'aggr' => 1,
|
'aggr' => 1,
|
||||||
'lossless' => 1,
|
'lossless' => 1,
|
||||||
|
@ -173,8 +181,8 @@ class Meting
|
||||||
'v' => '2.0',
|
'v' => '2.0',
|
||||||
'app_key' => '1',
|
'app_key' => '1',
|
||||||
'key' => $keyword,
|
'key' => $keyword,
|
||||||
'page' => $page,
|
'page' => isset($option['page']) ? $option['page'] : 1,
|
||||||
'limit' => $limit,
|
'limit' => isset($option['limit']) ? $option['limit'] : 30,
|
||||||
'r' => 'search/songs',
|
'r' => 'search/songs',
|
||||||
),
|
),
|
||||||
'format' => 'data#songs',
|
'format' => 'data#songs',
|
||||||
|
@ -186,12 +194,12 @@ class Meting
|
||||||
'url' => 'http://ioscdn.kugou.com/api/v3/search/song',
|
'url' => 'http://ioscdn.kugou.com/api/v3/search/song',
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'iscorrect' => 1,
|
'iscorrect' => 1,
|
||||||
'pagesize' => $limit,
|
'pagesize' => isset($option['limit']) ? $option['limit'] : 30,
|
||||||
'plat' => 2,
|
'plat' => 2,
|
||||||
'tag' => 1,
|
'tag' => 1,
|
||||||
'sver' => 5,
|
'sver' => 5,
|
||||||
'showtype' => 10,
|
'showtype' => 10,
|
||||||
'page' => $page,
|
'page' => isset($option['page']) ? $option['page'] : 1,
|
||||||
'keyword' => $keyword,
|
'keyword' => $keyword,
|
||||||
'version' => 8550
|
'version' => 8550
|
||||||
),
|
),
|
||||||
|
@ -206,9 +214,9 @@ class Meting
|
||||||
'method' => 'baidu.ting.search.merge',
|
'method' => 'baidu.ting.search.merge',
|
||||||
'isNew' => 1,
|
'isNew' => 1,
|
||||||
'query' => $keyword,
|
'query' => $keyword,
|
||||||
'page_size' => $limit,
|
'page_size' => isset($option['limit']) ? $option['limit'] : 30,
|
||||||
'page_no' => $page,
|
'page_no' => isset($option['page']) ? $option['page'] : 1,
|
||||||
'type' => 0,
|
'type' => isset($option['type']) ? $option['type'] : 0,
|
||||||
'format' => 'json',
|
'format' => 'json',
|
||||||
'from' => 'ios',
|
'from' => 'ios',
|
||||||
'channel' => '(null)',
|
'channel' => '(null)',
|
||||||
|
@ -233,9 +241,9 @@ class Meting
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'params' => array(
|
'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',
|
'encode' => 'netease_AESECB',
|
||||||
'format' => 'songs',
|
'format' => 'songs',
|
||||||
|
@ -310,7 +318,12 @@ class Meting
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'params' => array(
|
'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,
|
'url' => 'http://music.163.com/api/v1/album/'.$id,
|
||||||
),
|
),
|
||||||
|
@ -389,9 +402,11 @@ class Meting
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'method' => 'GET',
|
'method' => 'GET',
|
||||||
'params' => array(
|
'params' => array(
|
||||||
'top' => $limit,
|
|
||||||
"id" => $id,
|
|
||||||
"ext" => "true",
|
"ext" => "true",
|
||||||
|
"private_cloud" => "true",
|
||||||
|
"ext" => "true",
|
||||||
|
"top" => $limit,
|
||||||
|
"id" => $id
|
||||||
),
|
),
|
||||||
'url' => 'http://music.163.com/api/v1/artist/'.$id,
|
'url' => 'http://music.163.com/api/v1/artist/'.$id,
|
||||||
),
|
),
|
||||||
|
@ -475,8 +490,10 @@ class Meting
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'method' => 'POST',
|
'method' => 'POST',
|
||||||
'params' => array(
|
'params' => array(
|
||||||
'id' => $id,
|
"s" => "0",
|
||||||
"n" => 1000,
|
"id" => $id,
|
||||||
|
"n" => "1000",
|
||||||
|
"t" => "0"
|
||||||
),
|
),
|
||||||
'url' => 'http://music.163.com/api/v3/playlist/detail',
|
'url' => 'http://music.163.com/api/v3/playlist/detail',
|
||||||
),
|
),
|
||||||
|
@ -749,31 +766,31 @@ class Meting
|
||||||
case 'netease':
|
case 'netease':
|
||||||
return array(
|
return array(
|
||||||
'referer' => 'https://music.163.com/',
|
'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',
|
'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/56.0.2924.87 Safari/537.36',
|
'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36',
|
||||||
);
|
);
|
||||||
case 'tencent':
|
case 'tencent':
|
||||||
return array(
|
return array(
|
||||||
'referer' => 'https://y.qq.com/portal/player.html',
|
'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',
|
'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':
|
case 'xiami':
|
||||||
return array(
|
return array(
|
||||||
'referer' => 'http://h.xiami.com/',
|
'referer' => 'http://h.xiami.com/',
|
||||||
'cookie' => 'user_from=2;XMPLAYER_addSongsToggler=0;XMPLAYER_isOpen=0;_xiamitoken=123456789' . $this->getRandomHex(32) . ';',
|
'cookie' => '_xiamitoken=' . $this->getRandomHex(32) . '; _unsign_token=' . $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',
|
'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':
|
case 'kugou':
|
||||||
return array(
|
return array(
|
||||||
'referer' => 'http://www.kugou.com/webkugouplayer/flash/webKugou.swf',
|
'referer' => 'http://www.kugou.com/webkugouplayer/flash/webKugou.swf',
|
||||||
'cookie' => '_WCMID=123456789',
|
'cookie' => 'kg_mid=' . $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',
|
'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':
|
case 'baidu':
|
||||||
return array(
|
return array(
|
||||||
'referer' => 'http://ting.baidu.com/',
|
'referer' => 'http://ting.baidu.com/',
|
||||||
'cookie' => 'BAIDUID=123456789',
|
'cookie' => 'BAIDUID=' . $this->getRandomHex(32),
|
||||||
'useragent' => 'ios_5.9.12',
|
'useragent' => 'ios_5.9.12',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -781,11 +798,11 @@ class Meting
|
||||||
|
|
||||||
private function getRandomHex($length)
|
private function getRandomHex($length)
|
||||||
{
|
{
|
||||||
$val = '';
|
if (function_exists('openssl_random_pseudo_bytes')) {
|
||||||
for( $i=0; $i<$length; $i++ ) {
|
return bin2hex(openssl_random_pseudo_bytes($length));
|
||||||
$val .= chr( rand( 65, 90 ) );
|
} else {
|
||||||
|
return bin2hex(mcrypt_create_iv($length, MCRYPT_DEV_URANDOM));
|
||||||
}
|
}
|
||||||
return $val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue