Skip to content

Commit 9ca611c

Browse files
committed
[1.2.5] 新增 cookie 接口,更新 Meting 库
- 新增用户自定义 cookie 设置 - 更新 Meting v1.5.8 - 更新 APlayer 1.6.1-beta - 修复 PHP notice 警告 - 修复一些 bug
1 parent 25f5f86 commit 9ca611c

File tree

5 files changed

+53
-29
lines changed

5 files changed

+53
-29
lines changed

Action.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,11 @@ private function musicjs(){
101101
$music=array_merge($music,$t);
102102
}
103103
$player=array(
104-
'theme' => $setting['theme']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->theme?:'red',
105-
'preload' => $setting['preload']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->preload?:'auto',
106-
'autoplay' => $setting['autoplay']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->autoplay?:'false',
107-
'height' => $setting['height']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->height?:'340px',
108-
'mode' => $setting['mode']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->mode?:'circulation',
104+
'theme' => isset($setting['theme'])?$setting['theme']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->theme?:'red',
105+
'preload' => isset($setting['preload'])?$setting['preload']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->preload?:'auto',
106+
'autoplay' => isset($setting['autoplay'])?$setting['autoplay']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->autoplay?:'false',
107+
'height' => isset($setting['height'])?$setting['height']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->height?:'340px',
108+
'mode' => isset($setting['mode'])?$setting['mode']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->mode?:'circulation',
109109
'music' => array(),
110110
);
111111
foreach($music as $vo){
@@ -143,15 +143,21 @@ private function url(){
143143
$id=$this->request->get('id');
144144
$site=$this->request->get('site');
145145
$rate=Typecho_Widget::widget('Widget_Options')->plugin('Meting')->bitrate;
146+
$cookie=Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cookie;
146147

147148
$cachekey="url/{$site}/{$id}/{$rate}";
148149
$data=self::cacheRead($cachekey,60*15);
149150
if(!$data){
150-
$data=(new \Metowolf\Meting($site))->format()->url($id,$rate);
151+
$api=(new \Metowolf\Meting($site));
152+
if($cookie!='')$api->cookie($cookie);
153+
$data=$api->format(true)->url($id,$rate);
151154
$data=json_decode($data,1);
152155
self::cacheWrite($cachekey,$data);
153156
}
154157
if(empty($data['url']))$data['url']="https://api.i-meto.com/Public/music/empty.mp3";
158+
if($site=='netease'){
159+
$data['url']=str_replace("http://","https://",$data['url']);
160+
}
155161
$this->response->redirect($data['url']);
156162
}
157163

@@ -230,6 +236,12 @@ private function cacheRead($k,$t=3600){
230236
else return false;
231237
}
232238

239+
/*private function cacheFlush(){
240+
$db=Typecho_Db::get();
241+
$delete=$db->delete('table.metingv1')->where('last<?',time());
242+
$db->query($delete);
243+
}*/
244+
233245
private function filterReferer(){
234246
if(isset($_SERVER['HTTP_REFERER'])&&strpos($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST'])===false){
235247
http_response_code(403);

Plugin.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
*
77
* @package Meting
88
* @author METO
9-
* @version 1.2.4
9+
* @version 1.2.5
1010
* @dependence 14.10.10-*
1111
* @link https://github.com/metowolf/Meting-Typecho-Plugin
1212
*
1313
*/
1414

15-
define('METING_VERSION','1.2.4');
15+
define('METING_VERSION','1.2.5');
1616

1717
class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
1818
{
@@ -91,6 +91,11 @@ public static function config(Typecho_Widget_Helper_Form $form){
9191
_t('默认音质'),
9292
_t(''));
9393
$form->addInput($t);
94+
$t = new Typecho_Widget_Helper_Form_Element_Text(
95+
'cookie', null, '',
96+
_t('自定义 Cookie (高级)'),
97+
_t('通过更改 Cookie,使其享受与客户端一样的体验'));
98+
$form->addInput($t);
9499
}
95100

96101
public static function personalConfig(Typecho_Widget_Helper_Form $form){}
@@ -107,15 +112,13 @@ public static function header(){
107112
$ver=METING_VERSION;
108113
echo "<!-- Meting Start -->\n";
109114
echo "<script type=\"text/javascript\" src=\"{$dir}APlayer.min.js?v={$ver}\"></script>\n";
110-
if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi=='true'){
111-
echo "<script src=\"https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js\"></script>\n";
112-
}
113115
echo "<!-- Meting End -->\n";
114116
}
115117

116118
public static function footer(){
119+
$ver=METING_VERSION;
117120
if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi=='true'){
118-
echo "<script type=\"text/javascript\" src=\"https://api.i-meto.com/music/player.js?v={$ver}\"></script>\n";
121+
echo "<script type=\"text/javascript\" src=\"https://api.i-meto.com/music/aplayer.min.js?v={$ver}\"></script>\n";
119122
}
120123
}
121124

README.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
![](http://ww2.sinaimg.cn/large/a15b4afegw1fbg1l7wn09j20fw05gq34)
1+
<p align="center">
2+
<img src="https://user-images.githubusercontent.com/2666735/28999701-04c6ba7e-7a84-11e7-804b-3ffa4f7d5d95.png" alt="Meting">
3+
</p>
24

3-
# Meting for Typecho
5+
# APlayer for Typecho (Meting)
46
在 Typecho 中使用 APlayer 播放在线音乐吧~
57
[发布页面](https://i-meto.com/meting-typecho/)
68

79
## 介绍
810
1. 支持国内五大音乐平台(网易云、QQ、虾米、百度、酷狗)的单曲/专辑/歌单播放
911
2. 简单快捷,复制音乐详情页面网址,后台自动生成播放代码
1012
3. **支持不同音乐平台歌曲混合播放**
11-
4. 前端 Aplayer,后端 Meting 及时更新,保证兼容性及 API 高可用性
13+
4. 前端 APlayer,后端 Meting 及时更新,保证兼容性及 API 高可用性
1214
5. 支持 MySql、SQLite 数据库
1315

1416
## 声明
@@ -65,4 +67,4 @@ A: 为了减少服务器压力,插件设置对歌单、歌词数据进行缓
6567
更多问题可以通过 issue 页面提交,或者通过 Telegram、邮件向我反馈
6668

6769
## LICENSE
68-
Meting-Typecho-Plugin is under the MIT license.
70+
APlayer-Typecho-Plugin is under the MIT license.

assets/APlayer.min.js

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

include/Meting.php

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Meting music framework
44
* https://i-meto.com
55
* https://github.com/metowolf/Meting
6-
* Version 1.3.6.1
6+
* Version 1.3.8
77
*
88
* Copyright 2017, METO Sheel <[email protected]>
99
* Released under the MIT license
@@ -106,7 +106,7 @@ private function pickup($array, $rule)
106106
{
107107
$t=explode('#', $rule);
108108
foreach ($t as $vo) {
109-
if (is_null($array)) {
109+
if (!isset($array[$vo])){
110110
return array();
111111
}
112112
$array=$array[$vo];
@@ -140,7 +140,7 @@ public function search($keyword, $page=1, $limit=30)
140140
'type' => 1,
141141
'limit' => $limit,
142142
'total' => 'true',
143-
'offset' => $page-1,
143+
'offset' => ($page-1)*$limit,
144144
),
145145
'url' => 'http://music.163.com/api/cloudsearch/pc',
146146
),
@@ -151,14 +151,15 @@ public function search($keyword, $page=1, $limit=30)
151151
case 'tencent':
152152
$API=array(
153153
'method' => 'GET',
154-
'url' => 'https://c.y.qq.com/soso/fcgi-bin/search_cp',
154+
'url' => 'https://c.y.qq.com/soso/fcgi-bin/client_search_cp',
155155
'body' => array(
156156
'p' => $page,
157157
'n' => $limit,
158158
'w' => $keyword,
159159
'aggr' => 1,
160160
'lossless' => 1,
161161
'cr' => 1,
162+
'platform' => 'yqq',
162163
),
163164
'decode' => 'jsonp2json',
164165
'format' => 'data#song#list',
@@ -245,8 +246,9 @@ public function song($id)
245246
'method' => 'GET',
246247
'url' => 'https://c.y.qq.com/v8/fcg-bin/fcg_play_single_song.fcg',
247248
'body' => array(
248-
'songmid' => $id,
249-
'format' => 'json',
249+
'songmid' => $id,
250+
'platform' => 'yqq',
251+
'format' => 'json',
250252
),
251253
'decode' => 'tencent_singlesong',
252254
'format' => 'data',
@@ -268,7 +270,7 @@ public function song($id)
268270
case 'kugou':
269271
$API=array(
270272
'method' => 'POST',
271-
'url' => 'http://m.kugou.com/app/i/getSongInfo.php?',
273+
'url' => 'http://m.kugou.com/app/i/getSongInfo.php',
272274
'body' => array(
273275
"cmd" => "playInfo",
274276
"hash" => $id,
@@ -322,6 +324,7 @@ public function album($id)
322324
'url' => 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_album_info_cp.fcg',
323325
'body' => array(
324326
'albummid' => $id,
327+
'platform' => 'yqq',
325328
),
326329
'format' => 'data#list',
327330
);
@@ -402,6 +405,8 @@ public function artist($id, $limit=50)
402405
'singermid' => $id,
403406
'begin' => 0,
404407
'num' => $limit,
408+
'order' => 'listen',
409+
'platform' => 'yqq',
405410
),
406411
'format' => 'data#list',
407412
);
@@ -481,9 +486,10 @@ public function playlist($id)
481486
'method' => 'GET',
482487
'url' => 'https://c.y.qq.com/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg',
483488
'body' => array(
484-
'disstid' => $id,
485-
'utf8' => 1,
486-
'type' => 1,
489+
'disstid' => $id,
490+
'utf8' => 1,
491+
'type' => 1,
492+
'platform' => 'yqq',
487493
),
488494
'decode' => 'jsonp2json',
489495
'format' => 'cdlist#0#songlist',
@@ -562,6 +568,7 @@ public function url($id, $br=320)
562568
'url' => 'https://c.y.qq.com/v8/fcg-bin/fcg_play_single_song.fcg',
563569
'body' => array(
564570
'songmid' => $id,
571+
'platform' => 'yqq',
565572
'format' => 'json',
566573
),
567574
'decode' => 'tencent_url',
@@ -743,8 +750,8 @@ private function curlset()
743750
'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
744751
),
745752
'tencent'=>array(
746-
'referer' => 'http://y.qq.com/portal/player.html',
747-
'cookie' => 'qqmusic_uin=12345678; qqmusic_key=12345678; qqmusic_fromtag=30; ts_last=y.qq.com/portal/player.html;',
753+
'referer' => 'https://y.qq.com/portal/player.html',
754+
'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',
748755
'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
749756
),
750757
'xiami'=>array(
@@ -862,6 +869,7 @@ private function tencent_url($result)
862869

863870
$type=array(
864871
'size_320mp3' => array(320,'M800','mp3'),
872+
'size_192aac' => array(192,'C600','m4a'),
865873
'size_128mp3' => array(128,'M500','mp3'),
866874
'size_96aac' => array(96 ,'C400','m4a'),
867875
'size_48aac' => array(48 ,'C200','m4a'),

0 commit comments

Comments
 (0)