Skip to content

Commit

Permalink
🍉 1.5.6, Updated tencent API (#67) · metowolf/Meting@5d0b6b4
Browse files Browse the repository at this point in the history
  • Loading branch information
lwl12 committed Jan 12, 2019
1 parent 73b3333 commit eb07dd2
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 27 deletions.
4 changes: 2 additions & 2 deletions hermit.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
Plugin Name: Hermit X
Plugin URI: https://blog.lwl12.com/read/hermit-x.html
Description: 音乐播放器 Hermit music player build for wordpress with APlayer
Version: 2.9.3
Version: 2.9.4
Author: Hermit X Developer Team
Author URI: https://blog.lwl12.com/read/hermit-x.html#developer
*/

define('HERMIT_FILE', __FILE__);
define('HERMIT_VERSION', '2.9.3');
define('HERMIT_VERSION', '2.9.4');
define('HERMIT_URL', plugins_url('', __FILE__));
define('HERMIT_PATH', dirname(__FILE__));
define('HERMIT_ADMIN_URL', admin_url());
Expand Down
77 changes: 52 additions & 25 deletions include/Meting.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
* Meting music framework
* https://i-meto.com
* https://github.com/metowolf/Meting
* Version 1.5.4.
* Version 1.5.6.
*
* Copyright 2018, METO Sheel <i@i-meto.com>
* Copyright 2019, METO Sheel <i@i-meto.com>
* Released under the MIT license
*/

namespace Metowolf;

class Meting
{
const VERSION = '1.5.5';
const VERSION = '1.5.6';

public $raw;
public $data;
Expand Down Expand Up @@ -1006,34 +1006,61 @@ private function tencent_url($result)
{
$data = json_decode($result, true);
$guid = mt_rand() % 10000000000;

$type = array(
array('size_320mp3', 320, 'M800', 'mp3'),
array('size_192aac', 192, 'C600', 'm4a'),
array('size_128mp3', 128, 'M500', 'mp3'),
array('size_96aac', 96, 'C400', 'm4a'),
array('size_48aac', 48, 'C200', 'm4a'),
array('size_24aac', 24, 'C100', 'm4a'),
);

$payload = array(
'req_0' => array(
'module' => 'vkey.GetVkeyServer',
'method' => 'CgiGetVkey',
'param' => array(
'guid' => (string) $guid,
'songmid' => array(),
'filename' => array(),
'songtype' => array(),
'uin' => '0',
'loginflag' => 1,
'platform' => '20',
),
),
);

foreach ($type as $vo) {
$payload['req_0']['param']['songmid'][] = $data['data'][0]['mid'];
$payload['req_0']['param']['filename'][] = $vo[2].$data['data'][0]['file']['media_mid'].'.'.$vo[3];
$payload['req_0']['param']['songtype'][] = $data['data'][0]['type'];
}

$api = array(
'method' => 'GET',
'url' => 'https://c.y.qq.com/base/fcgi-bin/fcg_musicexpress.fcg',
'url' => 'https://u.y.qq.com/cgi-bin/musicu.fcg',
'body' => array(
'json' => 3,
'guid' => $guid,
'format' => 'json',
'format' => 'json',
'platform' => 'yqq.json',
'needNewCode' => 0,
'data' => json_encode($payload),
),
);
$key = json_decode($this->exec($api), true);
$key = $key['key'];
$response = json_decode($this->exec($api), true);
$vkeys = $response['req_0']['data']['midurlinfo'];

$type = array(
'size_320mp3' => array(320, 'M800', 'mp3'),
'size_192aac' => array(192, 'C600', 'm4a'),
'size_128mp3' => array(128, 'M500', 'mp3'),
'size_96aac' => array(96, 'C400', 'm4a'),
'size_48aac' => array(48, 'C200', 'm4a'),
'size_24aac' => array(24, 'C100', 'm4a'),
);
foreach ($type as $index => $vo) {
if ($data['data'][0]['file'][$index] && $vo[0] <= $this->temp['br']) {
$url = array(
'url' => 'https://dl.stream.qqmusic.qq.com/'.$vo[1].$data['data'][0]['file']['media_mid'].'.'.$vo[2].'?vkey='.$key.'&guid='.$guid.'&uid=0&fromtag=30',
'size' => $data['data'][0]['file'][$index],
'br' => $vo[0],
);
break;
if ($data['data'][0]['file'][$vo[0]] && $vo[1] <= $this->temp['br']) {
if (!empty($vkeys[$index]['vkey'])) {
$url = array(
'url' => $response['req_0']['data']['sip'][0].$vkeys[$index]['purl'],
'size' => $data['data'][0]['file'][$vo[0]],
'br' => $vo[1],
);
break;
}
}
}
if (!isset($url['url'])) {
Expand Down Expand Up @@ -1335,4 +1362,4 @@ private function format_baidu($data)

return $result;
}
}
}

0 comments on commit eb07dd2

Please sign in to comment.