[1.2.5] 新增 cookie 接口,更新 Meting 库

- 新增用户自定义 cookie 设置
 - 更新 Meting v1.5.8
 - 更新 APlayer 1.6.1-beta
 - 修复 PHP notice 警告
 - 修复一些 bug
This commit is contained in:
METO 2017-09-05 23:37:59 +08:00
parent 25f5f864d9
commit 9ca611c898
5 changed files with 53 additions and 29 deletions

View File

@ -101,11 +101,11 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do {
$music=array_merge($music,$t);
}
$player=array(
'theme' => $setting['theme']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->theme?:'red',
'preload' => $setting['preload']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->preload?:'auto',
'autoplay' => $setting['autoplay']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->autoplay?:'false',
'height' => $setting['height']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->height?:'340px',
'mode' => $setting['mode']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->mode?:'circulation',
'theme' => isset($setting['theme'])?$setting['theme']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->theme?:'red',
'preload' => isset($setting['preload'])?$setting['preload']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->preload?:'auto',
'autoplay' => isset($setting['autoplay'])?$setting['autoplay']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->autoplay?:'false',
'height' => isset($setting['height'])?$setting['height']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->height?:'340px',
'mode' => isset($setting['mode'])?$setting['mode']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->mode?:'circulation',
'music' => array(),
);
foreach($music as $vo){
@ -143,15 +143,21 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do {
$id=$this->request->get('id');
$site=$this->request->get('site');
$rate=Typecho_Widget::widget('Widget_Options')->plugin('Meting')->bitrate;
$cookie=Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cookie;
$cachekey="url/{$site}/{$id}/{$rate}";
$data=self::cacheRead($cachekey,60*15);
if(!$data){
$data=(new \Metowolf\Meting($site))->format()->url($id,$rate);
$api=(new \Metowolf\Meting($site));
if($cookie!='')$api->cookie($cookie);
$data=$api->format(true)->url($id,$rate);
$data=json_decode($data,1);
self::cacheWrite($cachekey,$data);
}
if(empty($data['url']))$data['url']="https://api.i-meto.com/Public/music/empty.mp3";
if($site=='netease'){
$data['url']=str_replace("http://","https://",$data['url']);
}
$this->response->redirect($data['url']);
}
@ -230,6 +236,12 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do {
else return false;
}
/*private function cacheFlush(){
$db=Typecho_Db::get();
$delete=$db->delete('table.metingv1')->where('last<?',time());
$db->query($delete);
}*/
private function filterReferer(){
if(isset($_SERVER['HTTP_REFERER'])&&strpos($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST'])===false){
http_response_code(403);

View File

@ -6,13 +6,13 @@ if(!defined('__TYPECHO_ROOT_DIR__'))exit;
*
* @package Meting
* @author METO
* @version 1.2.4
* @version 1.2.5
* @dependence 14.10.10-*
* @link https://github.com/metowolf/Meting-Typecho-Plugin
*
*/
define('METING_VERSION','1.2.4');
define('METING_VERSION','1.2.5');
class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
{
@ -91,6 +91,11 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
_t('默认音质'),
_t(''));
$form->addInput($t);
$t = new Typecho_Widget_Helper_Form_Element_Text(
'cookie', null, '',
_t('自定义 Cookie (高级)'),
_t('通过更改 Cookie使其享受与客户端一样的体验'));
$form->addInput($t);
}
public static function personalConfig(Typecho_Widget_Helper_Form $form){}
@ -107,15 +112,13 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
$ver=METING_VERSION;
echo "<!-- Meting Start -->\n";
echo "<script type=\"text/javascript\" src=\"{$dir}APlayer.min.js?v={$ver}\"></script>\n";
if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi=='true'){
echo "<script src=\"https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js\"></script>\n";
}
echo "<!-- Meting End -->\n";
}
public static function footer(){
$ver=METING_VERSION;
if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi=='true'){
echo "<script type=\"text/javascript\" src=\"https://api.i-meto.com/music/player.js?v={$ver}\"></script>\n";
echo "<script type=\"text/javascript\" src=\"https://api.i-meto.com/music/aplayer.min.js?v={$ver}\"></script>\n";
}
}

View File

@ -1,6 +1,8 @@
![](http://ww2.sinaimg.cn/large/a15b4afegw1fbg1l7wn09j20fw05gq34)
<p align="center">
<img src="https://user-images.githubusercontent.com/2666735/28999701-04c6ba7e-7a84-11e7-804b-3ffa4f7d5d95.png" alt="Meting">
</p>
# Meting for Typecho
# APlayer for Typecho (Meting)
在 Typecho 中使用 APlayer 播放在线音乐吧~
[发布页面](https://i-meto.com/meting-typecho/)
@ -8,7 +10,7 @@
1. 支持国内五大音乐平台网易云、QQ、虾米、百度、酷狗的单曲/专辑/歌单播放
2. 简单快捷,复制音乐详情页面网址,后台自动生成播放代码
3. **支持不同音乐平台歌曲混合播放**
4. 前端 Aplayer后端 Meting 及时更新,保证兼容性及 API 高可用性
4. 前端 APlayer后端 Meting 及时更新,保证兼容性及 API 高可用性
5. 支持 MySql、SQLite 数据库
## 声明
@ -65,4 +67,4 @@ A: 为了减少服务器压力,插件设置对歌单、歌词数据进行缓
更多问题可以通过 issue 页面提交,或者通过 Telegram、邮件向我反馈
## LICENSE
Meting-Typecho-Plugin is under the MIT license.
APlayer-Typecho-Plugin is under the MIT license.

File diff suppressed because one or more lines are too long

View File

@ -3,7 +3,7 @@
* Meting music framework
* https://i-meto.com
* https://github.com/metowolf/Meting
* Version 1.3.6.1
* Version 1.3.8
*
* Copyright 2017, METO Sheel <i@i-meto.com>
* Released under the MIT license
@ -106,7 +106,7 @@ class Meting
{
$t=explode('#', $rule);
foreach ($t as $vo) {
if (is_null($array)) {
if (!isset($array[$vo])){
return array();
}
$array=$array[$vo];
@ -140,7 +140,7 @@ class Meting
'type' => 1,
'limit' => $limit,
'total' => 'true',
'offset' => $page-1,
'offset' => ($page-1)*$limit,
),
'url' => 'http://music.163.com/api/cloudsearch/pc',
),
@ -151,7 +151,7 @@ class Meting
case 'tencent':
$API=array(
'method' => 'GET',
'url' => 'https://c.y.qq.com/soso/fcgi-bin/search_cp',
'url' => 'https://c.y.qq.com/soso/fcgi-bin/client_search_cp',
'body' => array(
'p' => $page,
'n' => $limit,
@ -159,6 +159,7 @@ class Meting
'aggr' => 1,
'lossless' => 1,
'cr' => 1,
'platform' => 'yqq',
),
'decode' => 'jsonp2json',
'format' => 'data#song#list',
@ -245,8 +246,9 @@ class Meting
'method' => 'GET',
'url' => 'https://c.y.qq.com/v8/fcg-bin/fcg_play_single_song.fcg',
'body' => array(
'songmid' => $id,
'format' => 'json',
'songmid' => $id,
'platform' => 'yqq',
'format' => 'json',
),
'decode' => 'tencent_singlesong',
'format' => 'data',
@ -268,7 +270,7 @@ class Meting
case 'kugou':
$API=array(
'method' => 'POST',
'url' => 'http://m.kugou.com/app/i/getSongInfo.php?',
'url' => 'http://m.kugou.com/app/i/getSongInfo.php',
'body' => array(
"cmd" => "playInfo",
"hash" => $id,
@ -322,6 +324,7 @@ class Meting
'url' => 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_album_info_cp.fcg',
'body' => array(
'albummid' => $id,
'platform' => 'yqq',
),
'format' => 'data#list',
);
@ -402,6 +405,8 @@ class Meting
'singermid' => $id,
'begin' => 0,
'num' => $limit,
'order' => 'listen',
'platform' => 'yqq',
),
'format' => 'data#list',
);
@ -481,9 +486,10 @@ class Meting
'method' => 'GET',
'url' => 'https://c.y.qq.com/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg',
'body' => array(
'disstid' => $id,
'utf8' => 1,
'type' => 1,
'disstid' => $id,
'utf8' => 1,
'type' => 1,
'platform' => 'yqq',
),
'decode' => 'jsonp2json',
'format' => 'cdlist#0#songlist',
@ -562,6 +568,7 @@ class Meting
'url' => 'https://c.y.qq.com/v8/fcg-bin/fcg_play_single_song.fcg',
'body' => array(
'songmid' => $id,
'platform' => 'yqq',
'format' => 'json',
),
'decode' => 'tencent_url',
@ -743,8 +750,8 @@ class Meting
'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' => 'http://y.qq.com/portal/player.html',
'cookie' => 'qqmusic_uin=12345678; qqmusic_key=12345678; qqmusic_fromtag=30; ts_last=y.qq.com/portal/player.html;',
'referer' => 'https://y.qq.com/portal/player.html',
'cookie' => 'pgv_pvi=3832878080; pgv_si=s4066364416; pgv_pvid=3938077488; yplayer_open=1; qqmusic_fromtag=66; ts_last=y.qq.com/portal/player.html; ts_uid=5141451452; player_exist=1; yq_index=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(
@ -862,6 +869,7 @@ class Meting
$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'),