mirror of
https://github.com/MoePlayer/APlayer-Typecho.git
synced 2024-12-21 20:30:24 +08:00
🎉 支持 APlayer 1.7
- 升级 MetingJS 1.1.1 - 增强接口安全性 - 修复虾米音乐 HTTPS
This commit is contained in:
parent
0776242e6f
commit
00f8c05a65
20
Action.php
20
Action.php
@ -71,11 +71,11 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do
|
||||
}
|
||||
|
||||
// auth 验证
|
||||
$EID = $server.'/'.$type.'/'.$id;
|
||||
$EID = $server.$type.$id;
|
||||
$salt = Typecho_Widget::widget('Widget_Options')->plugin('Meting')->salt;
|
||||
|
||||
if (!empty($salt) && in_array($type, array('lrc','pic','url'))) {
|
||||
$auth1 = md5($salt.$type.$id.$salt);
|
||||
if (!empty($salt)) {
|
||||
$auth1 = md5($salt.$EID.$salt);
|
||||
$auth2 = $this->request->get('auth');
|
||||
if (strcmp($auth1, $auth2)) {
|
||||
http_response_code(403);
|
||||
@ -129,6 +129,10 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do
|
||||
$url = str_replace('http://m10.', 'https://m10.', $url);
|
||||
}
|
||||
|
||||
if ($server == 'xiami') {
|
||||
$url = str_replace('http://', 'https://', $url);
|
||||
}
|
||||
|
||||
if ($server == 'baidu') {
|
||||
$url = str_replace('http://zhangmenshiting.qianqian.com', 'https://gss3.baidu.com/y0s1hSulBw92lNKgpU_Z2jR7b2w6buu', $url);
|
||||
}
|
||||
@ -155,11 +159,11 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do
|
||||
$music = array();
|
||||
foreach ($data as $vo) {
|
||||
$music[] = array(
|
||||
'title' => $vo['name'],
|
||||
'author' => implode(' / ', $vo['artist']),
|
||||
'url' => $url.'?server='.$vo['source'].'&type=url&id='.$vo['url_id'].'&auth='.md5($salt.'url'.$vo['url_id'].$salt),
|
||||
'pic' => $url.'?server='.$vo['source'].'&type=pic&id='.$vo['pic_id'].'&auth='.md5($salt.'pic'.$vo['pic_id'].$salt),
|
||||
'lrc' => $url.'?server='.$vo['source'].'&type=lrc&id='.$vo['lyric_id'].'&auth='.md5($salt.'lrc'.$vo['lyric_id'].$salt),
|
||||
'name' => $vo['name'],
|
||||
'artist' => implode(' / ', $vo['artist']),
|
||||
'url' => $url.'?server='.$vo['source'].'&type=url&id='.$vo['url_id'].'&auth='.md5($salt.$vo['source'].'url'.$vo['url_id'].$salt),
|
||||
'cover' => $url.'?server='.$vo['source'].'&type=pic&id='.$vo['pic_id'].'&auth='.md5($salt.$vo['source'].'pic'.$vo['pic_id'].$salt),
|
||||
'lrc' => $url.'?server='.$vo['source'].'&type=lrc&id='.$vo['lyric_id'].'&auth='.md5($salt.$vo['source'].'lrc'.$vo['lyric_id'].$salt),
|
||||
);
|
||||
}
|
||||
header("Content-Type: application/javascript");
|
||||
|
26
Plugin.php
26
Plugin.php
@ -8,13 +8,13 @@ if (!defined('__TYPECHO_ROOT_DIR__')) {
|
||||
*
|
||||
* @package APlayer for Typecho | Meting
|
||||
* @author METO
|
||||
* @version 2.1.1
|
||||
* @version 2.1.2
|
||||
* @dependence 14.10.10-*
|
||||
* @link https://github.com/MoePlayer/APlayer-Typecho
|
||||
*
|
||||
*/
|
||||
|
||||
define('METING_VERSION', '2.1.1');
|
||||
define('METING_VERSION', '2.1.2');
|
||||
|
||||
class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
|
||||
{
|
||||
@ -84,9 +84,9 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
|
||||
);
|
||||
$form->addInput($t);
|
||||
$t = new Typecho_Widget_Helper_Form_Element_Radio(
|
||||
'mode',
|
||||
array('circulation' => _t('循环'),'single' => _t('单曲'),'order' => _t('列表'),'random' => _t('随机')),
|
||||
'circulation',
|
||||
'order',
|
||||
array('list' => _t('列表'), 'random' => _t('随机')),
|
||||
'list',
|
||||
_t('全局播放模式'),
|
||||
_t('')
|
||||
);
|
||||
@ -143,7 +143,7 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
|
||||
$t = new Typecho_Widget_Helper_Form_Element_Text(
|
||||
'api',
|
||||
null,
|
||||
Typecho_Common::url('action/metingapi', Helper::options()->index)."?server=:server&type=:type&id=:id&r=:r",
|
||||
Typecho_Common::url('action/metingapi', Helper::options()->index)."?server=:server&type=:type&id=:id&auth=:auth&r=:r",
|
||||
_t('* 云解析地址'),
|
||||
_t('示例:https://api.i-meto.com/meting/api?server=:server&type=:type&id=:id&r=:r')
|
||||
);
|
||||
@ -177,7 +177,7 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
|
||||
{
|
||||
if (!$is_init) {
|
||||
if (empty($config['api'])) {
|
||||
$config['api'] = Typecho_Common::url('action/metingapi', Helper::options()->index)."?server=:server&type=:type&id=:id&r=:r";
|
||||
$config['api'] = Typecho_Common::url('action/metingapi', Helper::options()->index)."?server=:server&type=:type&id=:id&auth=:auth&r=:r";
|
||||
}
|
||||
if ($config['cachetype'] != 'none') {
|
||||
require_once 'driver/cache.interface.php';
|
||||
@ -215,6 +215,7 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
|
||||
$api = Typecho_Widget::widget('Widget_Options')->plugin('Meting')->api;
|
||||
$dir = Helper::options()->pluginUrl.'/Meting/assets';
|
||||
$ver = METING_VERSION;
|
||||
echo "<link rel=\"stylesheet\" href=\"{$dir}/APlayer.min.css?v={$ver}\">\n";
|
||||
echo "<script type=\"text/javascript\" src=\"{$dir}/APlayer.min.js?v={$ver}\"></script>\n";
|
||||
echo "<script>var meting_api=\"{$api}\";</script>";
|
||||
}
|
||||
@ -258,8 +259,8 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
|
||||
'theme' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->theme?:'red',
|
||||
'preload' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->preload?:'auto',
|
||||
'autoplay' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->autoplay?:'false',
|
||||
'listmaxheight' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->height?:'340px',
|
||||
'mode' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->mode?:'circulation',
|
||||
'listMaxHeight' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->height?:'340px',
|
||||
'order' => Typecho_Widget::widget('Widget_Options')->plugin('Meting')->order?:'list',
|
||||
);
|
||||
if (isset($t['server'])) {
|
||||
if (!in_array($t['server'], array('netease','tencent','xiami','baidu','kugou'))) {
|
||||
@ -270,7 +271,10 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
|
||||
}
|
||||
$data = $t;
|
||||
|
||||
$str .= "<div class=\"aplayer\" data-id=\"{$data['id']}\" data-server=\"{$data['server']}\" data-type=\"{$data['type']}\"";
|
||||
$salt = Typecho_Widget::widget('Widget_Options')->plugin('Meting')->salt;
|
||||
$auth = md5($salt.$data['server'].$data['type'].$data['id'].$salt);
|
||||
|
||||
$str .= "<div class=\"aplayer\" data-id=\"{$data['id']}\" data-server=\"{$data['server']}\" data-type=\"{$data['type']}\" data-auth=\"{$auth}\"";
|
||||
if (is_array($setting)) {
|
||||
foreach ($setting as $key => $vo) {
|
||||
$player[$key] = $vo;
|
||||
@ -283,7 +287,7 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
|
||||
} else {
|
||||
$data = $t;
|
||||
|
||||
$str .= "<div class=\"aplayer\" data-title=\"{$data['title']}\" data-author=\"{$data['author']}\" data-url=\"{$data['url']}\" data-pic=\"{$data['pic']}\" data-lrc=\"{$data['lrc']}\"";
|
||||
$str .= "<div class=\"aplayer\" data-name=\"{$data['title']}\" data-artist=\"{$data['author']}\" data-url=\"{$data['url']}\" data-cover=\"{$data['pic']}\" data-lrc=\"{$data['lrc']}\"";
|
||||
if (is_array($setting)) {
|
||||
foreach ($setting as $key => $vo) {
|
||||
$player[$key] = $vo;
|
||||
|
69
README.md
69
README.md
@ -10,7 +10,7 @@
|
||||
2. 简单快捷,复制音乐详情页面网址,后台自动生成播放代码
|
||||
3. 前端 APlayer,后端 Meting 及时更新,保证兼容性及 API 高可用性
|
||||
4. 支持 MySql、SQLite 数据库
|
||||
5. **支持 Redis 缓存**
|
||||
5. **支持 Redis, Memcached 缓存**
|
||||
6. 支持自定义歌曲播放
|
||||
7. **自定义 API 支持**
|
||||
|
||||
@ -36,32 +36,37 @@
|
||||
- 榜单 http://music.163.com/#/discover/toplist?id=60198
|
||||
|
||||
QQ 音乐 https://y.qq.com
|
||||
- 单曲 https://y.qq.com/n/yqq/song/000jDQWP4JiB3y.html
|
||||
- 专辑 https://y.qq.com/n/yqq/album/003rytri2FHG3V.html
|
||||
- 歌手 https://y.qq.com/n/yqq/singer/003Nz2So3XXYek.html
|
||||
- 歌单 https://y.qq.com/n/yqq/playlist/1144188779.html
|
||||
- 单曲 https://y.qq.com/n/yqq/song/000jDQWP4JiB3y.html
|
||||
- 专辑 https://y.qq.com/n/yqq/album/003rytri2FHG3V.html
|
||||
- 歌手 https://y.qq.com/n/yqq/singer/003Nz2So3XXYek.html
|
||||
- 歌单 https://y.qq.com/n/yqq/playlist/1144188779.html
|
||||
|
||||
虾米音乐 http://www.xiami.com or http://h.xiami.com
|
||||
- 单曲 http://www.xiami.com/song/bf08DNT3035f
|
||||
- 专辑 http://www.xiami.com/album/ddOZW6a10eb
|
||||
- 歌手 http://www.xiami.com/artist/be6yda0f8
|
||||
- 歌单 http://www.xiami.com/collect/254478782
|
||||
- 单曲 http://www.xiami.com/song/bf08DNT3035f
|
||||
- 专辑 http://www.xiami.com/album/ddOZW6a10eb
|
||||
- 歌手 http://www.xiami.com/artist/be6yda0f8
|
||||
- 歌单 http://www.xiami.com/collect/254478782
|
||||
|
||||
酷狗音乐 http://www.kugou.com
|
||||
- 单曲 http://www.kugou.com/song/#hash=09E8DE70A24C97B92A29F6A19F3528A2
|
||||
- 专辑 http://www.kugou.com/yy/album/single/1645030.html
|
||||
- 歌手 http://www.kugou.com/yy/singer/home/3520.html
|
||||
- 歌单 http://www.kugou.com/yy/special/single/119859.html
|
||||
- 单曲 http://www.kugou.com/song/#hash=09E8DE70A24C97B92A29F6A19F3528A2
|
||||
- 专辑 http://www.kugou.com/yy/album/single/1645030.html
|
||||
- 歌手 http://www.kugou.com/yy/singer/home/3520.html
|
||||
- 歌单 http://www.kugou.com/yy/special/single/119859.html
|
||||
|
||||
百度音乐 http://music.baidu.com/
|
||||
- 单曲 http://music.baidu.com/song/268275324
|
||||
- 专辑 http://music.baidu.com/album/268275533
|
||||
- 歌手 http://music.baidu.com/artist/1219
|
||||
- 歌单 http://music.baidu.com/songlist/364201689
|
||||
- 单曲 http://music.baidu.com/song/268275324
|
||||
- 专辑 http://music.baidu.com/album/268275533
|
||||
- 歌手 http://music.baidu.com/artist/1219
|
||||
- 歌单 http://music.baidu.com/songlist/364201689
|
||||
|
||||
## FAQ
|
||||
Q: pjax 页面切换无法停止播放?
|
||||
A: 需要另外在主题的回调函数中添加
|
||||
|
||||
<details><summary>PJAX 页面切换问题?</summary><br>
|
||||
|
||||
需要视情况在主题设置中添加回调函数
|
||||
|
||||
### 停止播放
|
||||
|
||||
```
|
||||
if (typeof aplayers !== 'undefined'){
|
||||
for (var i = 0; i < aplayers.length; i++) {
|
||||
@ -70,14 +75,28 @@ if (typeof aplayers !== 'undefined'){
|
||||
}
|
||||
```
|
||||
|
||||
Q: 不支持混合歌单?
|
||||
A: 由于 2.0 版本重写了实现方式,旧的混合歌单将不再支持,建议通过各音乐平台创建歌单的方式添加。
|
||||
### 重载播放器
|
||||
|
||||
Q: 部分歌曲失效?
|
||||
A: 可能 API 失效导致的,可以尝试点击插件升级按钮升级到最新,或填写 cookie 信息。
|
||||
```
|
||||
loadMeting();
|
||||
```
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
<details><summary>不支持混合歌单?</summary><br>
|
||||
|
||||
由于 2.x 版本重写了实现方式,旧的混合歌单将不再支持,建议通过各音乐平台创建歌单的方式添加。
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
<details><summary>升级问题?</summary><br>
|
||||
|
||||
目前插件支持在设置页面差量升级,但由于某些版本做了较大调整,可能造成插件无法使用,可以禁用插件再启用修复。
|
||||
|
||||
</details>
|
||||
|
||||
Q: PJAX 中播放器不加载?
|
||||
A: 需要在主题回调函数中添加 `loadMeting();`
|
||||
|
||||
更多问题可以通过 issue 页面提交,或者通过 Telegram、邮件向我反馈
|
||||
|
||||
|
2
assets/APlayer.min.css
vendored
Normal file
2
assets/APlayer.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
assets/APlayer.min.css.map
Normal file
1
assets/APlayer.min.css.map
Normal file
File diff suppressed because one or more lines are too long
3
assets/APlayer.min.js
vendored
3
assets/APlayer.min.js
vendored
File diff suppressed because one or more lines are too long
1
assets/APlayer.min.js.map
Normal file
1
assets/APlayer.min.js.map
Normal file
File diff suppressed because one or more lines are too long
2
assets/Meting.min.js
vendored
2
assets/Meting.min.js
vendored
@ -1 +1 @@
|
||||
"use strict";console.log("\n %c MetingJS 1.0.1 %c https://github.com/metowolf/MetingJS \n\n","color: #fff; background-image: linear-gradient(90deg, rgb(47, 172, 178) 0%, rgb(45, 190, 96) 100%); padding:5px 1px;","background-image: linear-gradient(90deg, rgb(45, 190, 96) 0%, rgb(255, 255, 255) 100%); padding:5px 0;");var aplayers=[];function loadMeting(){function a(a,b){var c=[],d=a.dataset;c.element=a,c.music=b,c.showlrc=c.music[0].lrc?3:0,c.narrow="true"===d.narrow,c.autoplay="true"===d.autoplay,c.mutex="false"!==d.mutex,c.mode=d.mode||"circulation",c.preload=d.preload||"auto",c.listmaxheight=d.listmaxheight||"340px",c.theme=d.theme||"#ad7a86",aplayers.push(new APlayer(c))}var b="https://api.i-meto.com/meting/api?server=:server&type=:type&id=:id&r=:r";"undefined"!=typeof meting_api&&(b=meting_api);var c=document.querySelectorAll(".aplayer"),d=!0,e=!1,f=void 0;try{for(var g,h=function(){var c=g.value,d=c.dataset.id;if(d){var e=b;e=e.replace(":server",c.dataset.server),e=e.replace(":type",c.dataset.type),e=e.replace(":id",c.dataset.id),e=e.replace(":r",Math.random());var f=new XMLHttpRequest;f.onreadystatechange=function(){if(4===f.readyState&&(200<=f.status&&300>f.status||304===f.status)){var b=JSON.parse(f.responseText);a(c,b)}},f.open("get",e,!0),f.send(null)}else{var h=[{title:c.dataset.title,author:c.dataset.author,url:c.dataset.url,pic:c.dataset.pic,lrc:c.dataset.lrc}];a(c,h)}},i=c[Symbol.iterator]();!(d=(g=i.next()).done);d=!0)h()}catch(a){e=!0,f=a}finally{try{!d&&i.return&&i.return()}finally{if(e)throw f}}}document.addEventListener("DOMContentLoaded",loadMeting,!1);
|
||||
'use strict';console.log('\n %c MetingJS 1.1.1 %c https://github.com/metowolf/MetingJS \n\n','color: #fadfa3; background: #030307; padding:5px 0;','background: #fadfa3; padding:5px 0;');var aplayers=[],loadMeting=function(){function a(a,b){var c={container:a,audio:b,mini:!1,autoplay:!1,mutex:!0,lrc:3,preload:'auto',theme:'#2980b9',loop:'all',order:'list',volume:0.7,listFolded:!1,listMaxHeight:'340px'};for(var d in c)c.hasOwnProperty(d)&&a.dataset.hasOwnProperty(d)&&(c[d]=a.dataset[d],('true'===c[d]||'false'===c[d])&&(c[d]='true'==c[d]));b.length&&(!0===c.mini&&(c.lrc=0,c.listFolded=!0),aplayers.push(new APlayer(c)))}var b='https://api.i-meto.com/meting/api?server=:server&type=:type&id=:id&r=:r';'undefined'!=typeof meting_api&&(b=meting_api);for(var f=0;f<aplayers.length;f++)try{aplayers[f].destroy()}catch(a){console.log(a)}aplayers=[];for(var c=document.querySelectorAll('.aplayer'),d=function(d){var e=c[d],f=e.dataset.id;if(f){var g=e.dataset.api||b;g=g.replace(':server',e.dataset.server),g=g.replace(':type',e.dataset.type),g=g.replace(':id',e.dataset.id),g=g.replace(':auth',e.dataset.auth),g=g.replace(':r',Math.random());var h=new XMLHttpRequest;h.onreadystatechange=function(){if(4===h.readyState&&(200<=h.status&&300>h.status||304===h.status)){var b=JSON.parse(h.responseText);a(e,b)}},h.open('get',g,!0),h.send(null)}else if(e.dataset.url){var i=[{name:e.dataset.name||e.dataset.title,artist:e.dataset.artist||e.dataset.author,url:e.dataset.url,cover:e.dataset.cover||e.dataset.pic,lrc:e.dataset.lrc}];a(e,i)}},e=0;e<c.length;e++)d(e)};document.addEventListener('DOMContentLoaded',loadMeting,!1);
|
||||
|
13
shasum.txt
13
shasum.txt
@ -1,7 +1,10 @@
|
||||
437cbad1f79ae3fa930c35e5ba6a194ed77cce1cb35a3560af0c7279d33fdbd1 ./Action.php
|
||||
aa3c0deef2f5b5524f9e7cbd1809d14d51e0a5eae8f21e183483c84c28b86e46 ./assets/APlayer.min.js
|
||||
b5e044389607e8f84fd905de535233c89b772b78e25ca688c8be187924f73c40 ./Action.php
|
||||
54da4b647319dc1b0178af5f525c885ff21ad63bd8257a3b5d7e93c4a64246fd ./assets/APlayer.min.css
|
||||
c11d9bad20d24fd840ff9b0824d9c64937b0997f9eff536c9fe91916d4fb6e66 ./assets/APlayer.min.css.map
|
||||
37b5ee9b65198cf14f1b2242ef849ec4296ddb85b443537a30586fac06d61f31 ./assets/APlayer.min.js
|
||||
23967c59266b852967c0ab617d4cafa4232c6a36c6acf8015b6cb9b5cf52621e ./assets/APlayer.min.js.map
|
||||
6c1db3ae0b983df3e9395aa133875e64c7cb6321064c982d507fa7d82f7258f3 ./assets/editer.js
|
||||
efd4f31c32ad090a109c0fb30a04c007093aa3d304e26adcc2cb75153812ecb1 ./assets/Meting.min.js
|
||||
452891bfd9b92a27eb46e5b36925796067dfaf6bcfbf44b66fcf93ea2e0f6e85 ./assets/Meting.min.js
|
||||
9129314ad52bf9a010e5a0287b0609595d2a85cb95e08f3ad68463107c82bc42 ./driver/cache.interface.php
|
||||
59561acde0f21b536d3511591eca46a338db8df836ed260b0c21cb06e68b1043 ./driver/memcached.class.php
|
||||
e83fbbfc27352142f610b9cf5600b510ee44deaf42f390893250fdc79adc98ba ./driver/mysql.class.php
|
||||
@ -9,5 +12,5 @@ a8521663ed1f5d4a1cf37290081155e1682fb5aa9a0f0e07e0f7b83cc98c0a00 ./driver/redis
|
||||
12f663ca0f4515566448ac6cd96304df038224eb10b8aafb66e49f051495fe98 ./driver/sqlite.class.php
|
||||
8f730be87f6605716d86925d3066b6fe0df5c8ae1b09f7229b4070fdd1962510 ./include/Meting.php
|
||||
a237e65d8cc7c5b00008db5977b28e525caeffadfee0808408034f8959c6de20 ./LICENSE
|
||||
211c2f194dba153b3fd34f74b3961eb8d7e4d29801327c3010e226ec97706a81 ./Plugin.php
|
||||
0d5007fa131cc51053b5239c449136eb5a6047dce856b9eabe9e01e6c18a505d ./README.md
|
||||
ca3ae7b8d93c535178645b24683f32105aed134154619398c87f7b61c8dac613 ./Plugin.php
|
||||
a99f175376aff13edfd1aaf9fb730c184e9fb82404c8bd7317bb3b8045f369e7 ./README.md
|
||||
|
Loading…
Reference in New Issue
Block a user