🌰 cookie enhanced

This commit is contained in:
meto
2018-01-02 21:30:54 +08:00
parent 416ebf187e
commit 8ebe1d5c43
2 changed files with 50 additions and 31 deletions

View File

@@ -3,7 +3,7 @@
* Meting music framework
* https://i-meto.com
* https://github.com/metowolf/Meting
* Version 1.3.9
* Version 1.3.10
*
* Copyright 2017, METO Sheel <i@i-meto.com>
* Released under the MIT license
@@ -745,34 +745,47 @@ class Meting
private function curlset()
{
$BASE=array(
'netease'=>array(
'referer' => 'https://music.163.com/',
'cookie' => 'os=linux; appver=1.0.0.1026; osver=Ubuntu%2016.10; MUSIC_U=78d411095f4b022667bc8ec49e9a44cca088df057d987f5feaf066d37458e41c4a7d9447977352cf27ea9fee03f6ec4441049cea1c6bb9b6; __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',
),
'tencent'=>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',
),
'xiami'=>array(
'referer' => 'http://h.xiami.com/',
'cookie' => 'user_from=2;XMPLAYER_addSongsToggler=0;XMPLAYER_isOpen=0;_xiamitoken=123456789;',
'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
),
'kugou'=>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',
),
'baidu'=>array(
'referer' => 'http://ting.baidu.com/',
'cookie' => 'BAIDUID=123456789',
'useragent' => 'ios_5.9.12',
),
);
return $BASE[$this->_SITE];
switch ($this->_SITE) {
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',
);
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',
);
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',
);
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',
);
case 'baidu':
return array(
'referer' => 'http://ting.baidu.com/',
'cookie' => 'BAIDUID=123456789',
'useragent' => 'ios_5.9.12',
);
}
}
private function getRandomHex($length)
{
$val = '';
for( $i=0; $i<$length; $i++ ) {
$val .= chr( rand( 65, 90 ) );
}
return $val;
}
/**

View File

@@ -9,8 +9,9 @@ class NeteaseTest extends TestCase
{
$api = new Meting('netease');
$data = $api->format(true)->search('hello');
$data = json_decode($data,1);
$data = json_decode($data,true);
$this->assertNotEmpty($data);
$this->assertEquals('Hello',$data[0]['name']);
}
public function testSong(){
@@ -18,6 +19,7 @@ class NeteaseTest extends TestCase
$data = $api->format(true)->song('35847388');
$data = json_decode($data,1);
$this->assertNotEmpty($data);
$this->assertEquals('35847388',$data[0]['id']);
}
public function testPic(){
@@ -25,13 +27,16 @@ class NeteaseTest extends TestCase
$data = $api->format(true)->pic('3388694837506899');
$data = json_decode($data,1);
$this->assertNotEmpty($data);
$pic = 'https://p3.music.126.net/br3IrdCvT7-GjCyUVNONiA==/3388694837506899.jpg?param=300y300';
$this->assertEquals($pic,$data['url']);
}
public function testUrl(){
$api = new Meting('netease');
$data = $api->format(true)->url('418603133');
$data = $api->format(true)->url('35847388');
$data = json_decode($data,1);
$this->assertNotEmpty($data);
$this->assertNotEmpty($data['url']);
}
public function testLyric(){
@@ -39,5 +44,6 @@ class NeteaseTest extends TestCase
$data = $api->format(true)->lyric('418603133');
$data = json_decode($data,1);
$this->assertNotEmpty($data);
$this->assertNotEmpty($data['lyric']);
}
}