Skip to content

Commit 00f8c05

Browse files
committed
🎉 支持 APlayer 1.7
- 升级 MetingJS 1.1.1 - 增强接口安全性 - 修复虾米音乐 HTTPS
1 parent 0776242 commit 00f8c05

File tree

9 files changed

+86
-51
lines changed

9 files changed

+86
-51
lines changed

Action.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ private function api()
7171
}
7272

7373
// auth 验证
74-
$EID = $server.'/'.$type.'/'.$id;
74+
$EID = $server.$type.$id;
7575
$salt = Typecho_Widget::widget('Widget_Options')->plugin('Meting')->salt;
7676

77-
if (!empty($salt) && in_array($type, array('lrc','pic','url'))) {
78-
$auth1 = md5($salt.$type.$id.$salt);
77+
if (!empty($salt)) {
78+
$auth1 = md5($salt.$EID.$salt);
7979
$auth2 = $this->request->get('auth');
8080
if (strcmp($auth1, $auth2)) {
8181
http_response_code(403);
@@ -129,6 +129,10 @@ private function api()
129129
$url = str_replace('http://m10.', 'https://m10.', $url);
130130
}
131131

132+
if ($server == 'xiami') {
133+
$url = str_replace('http://', 'https://', $url);
134+
}
135+
132136
if ($server == 'baidu') {
133137
$url = str_replace('http://zhangmenshiting.qianqian.com', 'https://gss3.baidu.com/y0s1hSulBw92lNKgpU_Z2jR7b2w6buu', $url);
134138
}
@@ -155,11 +159,11 @@ private function api()
155159
$music = array();
156160
foreach ($data as $vo) {
157161
$music[] = array(
158-
'title' => $vo['name'],
159-
'author' => implode(' / ', $vo['artist']),
160-
'url' => $url.'?server='.$vo['source'].'&type=url&id='.$vo['url_id'].'&auth='.md5($salt.'url'.$vo['url_id'].$salt),
161-
'pic' => $url.'?server='.$vo['source'].'&type=pic&id='.$vo['pic_id'].'&auth='.md5($salt.'pic'.$vo['pic_id'].$salt),
162-
'lrc' => $url.'?server='.$vo['source'].'&type=lrc&id='.$vo['lyric_id'].'&auth='.md5($salt.'lrc'.$vo['lyric_id'].$salt),
162+
'name' => $vo['name'],
163+
'artist' => implode(' / ', $vo['artist']),
164+
'url' => $url.'?server='.$vo['source'].'&type=url&id='.$vo['url_id'].'&auth='.md5($salt.$vo['source'].'url'.$vo['url_id'].$salt),
165+
'cover' => $url.'?server='.$vo['source'].'&type=pic&id='.$vo['pic_id'].'&auth='.md5($salt.$vo['source'].'pic'.$vo['pic_id'].$salt),
166+
'lrc' => $url.'?server='.$vo['source'].'&type=lrc&id='.$vo['lyric_id'].'&auth='.md5($salt.$vo['source'].'lrc'.$vo['lyric_id'].$salt),
163167
);
164168
}
165169
header("Content-Type: application/javascript");

Plugin.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
*
99
* @package APlayer for Typecho | Meting
1010
* @author METO
11-
* @version 2.1.1
11+
* @version 2.1.2
1212
* @dependence 14.10.10-*
1313
* @link https://github.com/MoePlayer/APlayer-Typecho
1414
*
1515
*/
1616

17-
define('METING_VERSION', '2.1.1');
17+
define('METING_VERSION', '2.1.2');
1818

1919
class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
2020
{
@@ -84,9 +84,9 @@ public static function config(Typecho_Widget_Helper_Form $form)
8484
);
8585
$form->addInput($t);
8686
$t = new Typecho_Widget_Helper_Form_Element_Radio(
87-
'mode',
88-
array('circulation' => _t('循环'),'single' => _t('单曲'),'order' => _t('列表'),'random' => _t('随机')),
89-
'circulation',
87+
'order',
88+
array('list' => _t('列表'), 'random' => _t('随机')),
89+
'list',
9090
_t('全局播放模式'),
9191
_t('')
9292
);
@@ -143,7 +143,7 @@ public static function config(Typecho_Widget_Helper_Form $form)
143143
$t = new Typecho_Widget_Helper_Form_Element_Text(
144144
'api',
145145
null,
146-
Typecho_Common::url('action/metingapi', Helper::options()->index)."?server=:server&type=:type&id=:id&r=:r",
146+
Typecho_Common::url('action/metingapi', Helper::options()->index)."?server=:server&type=:type&id=:id&auth=:auth&r=:r",
147147
_t('* 云解析地址'),
148148
_t('示例:https://api.i-meto.com/meting/api?server=:server&type=:type&id=:id&r=:r')
149149
);
@@ -177,7 +177,7 @@ public static function configHandle($config, $is_init)
177177
{
178178
if (!$is_init) {
179179
if (empty($config['api'])) {
180-
$config['api'] = Typecho_Common::url('action/metingapi', Helper::options()->index)."?server=:server&type=:type&id=:id&r=:r";
180+
$config['api'] = Typecho_Common::url('action/metingapi', Helper::options()->index)."?server=:server&type=:type&id=:id&auth=:auth&r=:r";
181181
}
182182
if ($config['cachetype'] != 'none') {
183183
require_once 'driver/cache.interface.php';
@@ -215,6 +215,7 @@ public static function header()
215215
$api = Typecho_Widget::widget('Widget_Options')->plugin('Meting')->api;
216216
$dir = Helper::options()->pluginUrl.'/Meting/assets';
217217
$ver = METING_VERSION;
218+
echo "<link rel=\"stylesheet\" href=\"{$dir}/APlayer.min.css?v={$ver}\">\n";
218219
echo "<script type=\"text/javascript\" src=\"{$dir}/APlayer.min.js?v={$ver}\"></script>\n";
219220
echo "<script>var meting_api=\"{$api}\";</script>";
220221
}
@@ -258,8 +259,8 @@ public static function parseMusic($matches, $setting)
258259
'theme' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->theme?:'red',
259260
'preload' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->preload?:'auto',
260261
'autoplay' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->autoplay?:'false',
261-
'listmaxheight' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->height?:'340px',
262-
'mode' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->mode?:'circulation',
262+
'listMaxHeight' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->height?:'340px',
263+
'order' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->order?:'list',
263264
);
264265
if (isset($t['server'])) {
265266
if (!in_array($t['server'], array('netease','tencent','xiami','baidu','kugou'))) {
@@ -270,7 +271,10 @@ public static function parseMusic($matches, $setting)
270271
}
271272
$data = $t;
272273

273-
$str .= "<div class=\"aplayer\" data-id=\"{$data['id']}\" data-server=\"{$data['server']}\" data-type=\"{$data['type']}\"";
274+
$salt = Typecho_Widget::widget('Widget_Options')->plugin('Meting')->salt;
275+
$auth = md5($salt.$data['server'].$data['type'].$data['id'].$salt);
276+
277+
$str .= "<div class=\"aplayer\" data-id=\"{$data['id']}\" data-server=\"{$data['server']}\" data-type=\"{$data['type']}\" data-auth=\"{$auth}\"";
274278
if (is_array($setting)) {
275279
foreach ($setting as $key => $vo) {
276280
$player[$key] = $vo;
@@ -283,7 +287,7 @@ public static function parseMusic($matches, $setting)
283287
} else {
284288
$data = $t;
285289

286-
$str .= "<div class=\"aplayer\" data-title=\"{$data['title']}\" data-author=\"{$data['author']}\" data-url=\"{$data['url']}\" data-pic=\"{$data['pic']}\" data-lrc=\"{$data['lrc']}\"";
290+
$str .= "<div class=\"aplayer\" data-name=\"{$data['title']}\" data-artist=\"{$data['author']}\" data-url=\"{$data['url']}\" data-cover=\"{$data['pic']}\" data-lrc=\"{$data['lrc']}\"";
287291
if (is_array($setting)) {
288292
foreach ($setting as $key => $vo) {
289293
$player[$key] = $vo;

README.md

Lines changed: 44 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
2. 简单快捷,复制音乐详情页面网址,后台自动生成播放代码
1111
3. 前端 APlayer,后端 Meting 及时更新,保证兼容性及 API 高可用性
1212
4. 支持 MySql、SQLite 数据库
13-
5. **支持 Redis 缓存**
13+
5. **支持 Redis, Memcached 缓存**
1414
6. 支持自定义歌曲播放
1515
7. **自定义 API 支持**
1616

@@ -36,32 +36,37 @@
3636
- 榜单 http://music.163.com/#/discover/toplist?id=60198
3737

3838
QQ 音乐 https://y.qq.com
39-
- 单曲 https://y.qq.com/n/yqq/song/000jDQWP4JiB3y.html
40-
- 专辑 https://y.qq.com/n/yqq/album/003rytri2FHG3V.html
41-
- 歌手 https://y.qq.com/n/yqq/singer/003Nz2So3XXYek.html
42-
- 歌单 https://y.qq.com/n/yqq/playlist/1144188779.html
39+
- 单曲 https://y.qq.com/n/yqq/song/000jDQWP4JiB3y.html
40+
- 专辑 https://y.qq.com/n/yqq/album/003rytri2FHG3V.html
41+
- 歌手 https://y.qq.com/n/yqq/singer/003Nz2So3XXYek.html
42+
- 歌单 https://y.qq.com/n/yqq/playlist/1144188779.html
4343

4444
虾米音乐 http://www.xiami.com or http://h.xiami.com
45-
- 单曲 http://www.xiami.com/song/bf08DNT3035f
46-
- 专辑 http://www.xiami.com/album/ddOZW6a10eb
47-
- 歌手 http://www.xiami.com/artist/be6yda0f8
48-
- 歌单 http://www.xiami.com/collect/254478782
45+
- 单曲 http://www.xiami.com/song/bf08DNT3035f
46+
- 专辑 http://www.xiami.com/album/ddOZW6a10eb
47+
- 歌手 http://www.xiami.com/artist/be6yda0f8
48+
- 歌单 http://www.xiami.com/collect/254478782
4949

5050
酷狗音乐 http://www.kugou.com
51-
- 单曲 http://www.kugou.com/song/#hash=09E8DE70A24C97B92A29F6A19F3528A2
52-
- 专辑 http://www.kugou.com/yy/album/single/1645030.html
53-
- 歌手 http://www.kugou.com/yy/singer/home/3520.html
54-
- 歌单 http://www.kugou.com/yy/special/single/119859.html
51+
- 单曲 http://www.kugou.com/song/#hash=09E8DE70A24C97B92A29F6A19F3528A2
52+
- 专辑 http://www.kugou.com/yy/album/single/1645030.html
53+
- 歌手 http://www.kugou.com/yy/singer/home/3520.html
54+
- 歌单 http://www.kugou.com/yy/special/single/119859.html
5555

5656
百度音乐 http://music.baidu.com/
57-
- 单曲 http://music.baidu.com/song/268275324
58-
- 专辑 http://music.baidu.com/album/268275533
59-
- 歌手 http://music.baidu.com/artist/1219
60-
- 歌单 http://music.baidu.com/songlist/364201689
57+
- 单曲 http://music.baidu.com/song/268275324
58+
- 专辑 http://music.baidu.com/album/268275533
59+
- 歌手 http://music.baidu.com/artist/1219
60+
- 歌单 http://music.baidu.com/songlist/364201689
6161

6262
## FAQ
63-
Q: pjax 页面切换无法停止播放?
64-
A: 需要另外在主题的回调函数中添加
63+
64+
<details><summary>PJAX 页面切换问题?</summary><br>
65+
66+
需要视情况在主题设置中添加回调函数
67+
68+
### 停止播放
69+
6570
```
6671
if (typeof aplayers !== 'undefined'){
6772
for (var i = 0; i < aplayers.length; i++) {
@@ -70,14 +75,28 @@ if (typeof aplayers !== 'undefined'){
7075
}
7176
```
7277

73-
Q: 不支持混合歌单?
74-
A: 由于 2.0 版本重写了实现方式,旧的混合歌单将不再支持,建议通过各音乐平台创建歌单的方式添加。
78+
### 重载播放器
79+
80+
```
81+
loadMeting();
82+
```
83+
84+
</details>
85+
86+
87+
<details><summary>不支持混合歌单?</summary><br>
88+
89+
由于 2.x 版本重写了实现方式,旧的混合歌单将不再支持,建议通过各音乐平台创建歌单的方式添加。
90+
91+
</details>
92+
93+
94+
<details><summary>升级问题?</summary><br>
95+
96+
目前插件支持在设置页面差量升级,但由于某些版本做了较大调整,可能造成插件无法使用,可以禁用插件再启用修复。
7597

76-
Q: 部分歌曲失效?
77-
A: 可能 API 失效导致的,可以尝试点击插件升级按钮升级到最新,或填写 cookie 信息。
98+
</details>
7899

79-
Q: PJAX 中播放器不加载?
80-
A: 需要在主题回调函数中添加 `loadMeting();`
81100

82101
更多问题可以通过 issue 页面提交,或者通过 Telegram、邮件向我反馈
83102

0 commit comments

Comments
 (0)