mirror of
https://github.com/MoePlayer/APlayer-Typecho.git
synced 2024-12-21 20:30:24 +08:00
[1.0.2] 修正缓存规则,优化编辑器按钮 UI
This commit is contained in:
parent
c2a8b00f6c
commit
7a99e21825
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
if(!defined('__TYPECHO_ROOT_DIR__'))exit;
|
||||
if (!extension_loaded('Meting'))include_once 'include/Meting.php';
|
||||
if(!extension_loaded('Meting'))include_once 'include/Meting.php';
|
||||
|
||||
class Meting_Action extends Typecho_Widget implements Widget_Interface_Do {
|
||||
|
||||
@ -25,6 +25,7 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do {
|
||||
if(strpos($url,'163.com')!==false){
|
||||
$server='netease';
|
||||
if(preg_match('/playlist\?id=(\d+)/i',$url,$id))list($id,$type)=array($id[1],'playlist');
|
||||
elseif(preg_match('/toplist\?id=(\d+)/i',$url,$id))list($id,$type)=array($id[1],'playlist');
|
||||
elseif(preg_match('/album\?id=(\d+)/i',$url,$id))list($id,$type)=array($id[1],'album');
|
||||
elseif(preg_match('/song\?id=(\d+)/i',$url,$id))list($id,$type)=array($id[1],'song');
|
||||
elseif(preg_match('/artist\?id=(\d+)/i',$url,$id))list($id,$type)=array($id[1],'artist');
|
||||
@ -142,7 +143,7 @@ var Meting{$PID} = new APlayer({
|
||||
$site=$this->request->get('site');
|
||||
$rate=Typecho_Widget::widget('Widget_Options')->plugin('Meting')->bitrate;
|
||||
|
||||
$cachekey="url/{$site}/{$id}";
|
||||
$cachekey="url/{$site}/{$id}/{$rate}";
|
||||
$data=self::cacheRead($cachekey,60*15);
|
||||
if(!$data){
|
||||
$data=(new Meting($site))->url($id,$rate);
|
||||
@ -207,7 +208,7 @@ var Meting{$PID} = new APlayer({
|
||||
$result = $db->fetchAll($query);
|
||||
if(sizeof($result)){
|
||||
if(time()-$result[0]['date']>$t){
|
||||
$delete = $db->delete('value','date')->from($prefix.'meting')->where('date<?',time()-$t);
|
||||
$delete=$db->delete($prefix.'meting')->where('date<?',time()-$t);
|
||||
$db->query($delete);
|
||||
return false;
|
||||
}
|
||||
|
20
Plugin.php
20
Plugin.php
@ -2,17 +2,17 @@
|
||||
if(!defined('__TYPECHO_ROOT_DIR__'))exit;
|
||||
|
||||
/**
|
||||
* Meting for Typecho
|
||||
* Meting for Typecho | 在 Typecho 中使用 APlayer 播放在线音乐吧~
|
||||
*
|
||||
* @package Meting
|
||||
* @author METO
|
||||
* @version 1.0.1
|
||||
* @version 1.0.2
|
||||
* @dependence 13.12.12-*
|
||||
* @link https://github.com/metowolf/Meting
|
||||
*
|
||||
*/
|
||||
|
||||
define('METING_VERSION','1.0.1');
|
||||
define('METING_VERSION','1.0.2');
|
||||
|
||||
class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
|
||||
{
|
||||
@ -58,9 +58,9 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
|
||||
*/
|
||||
public static function config(Typecho_Widget_Helper_Form $form){
|
||||
$t = new Typecho_Widget_Helper_Form_Element_Text(
|
||||
'theme', null, '#e9e9e9',
|
||||
'theme', null, '#ad7a86',
|
||||
_t('播放器颜色'),
|
||||
_t('播放器默认的主题颜色,支持如 #372e21、#75c、red,该设定会被[Meting]标签中的theme属性覆盖,默认为 #e9e9e9'));
|
||||
_t('播放器默认的主题颜色,支持如 #372e21、#75c、red,该设定会被[Meting]标签中的theme属性覆盖,默认为 #ad7a86'));
|
||||
$form->addInput($t);
|
||||
$t = new Typecho_Widget_Helper_Form_Element_Text(
|
||||
'height', null, '340px',
|
||||
@ -102,7 +102,12 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
|
||||
*/
|
||||
public static function header(){
|
||||
$dir=Helper::options()->pluginUrl.'/Meting/assets/';
|
||||
echo "<!-- Meting ".METING_VERSION." Start -->\n<script type=\"text/javascript\" src=\"{$dir}APlayer.min.js\"></script>\n<!-- Meting End -->";
|
||||
$ver=METING_VERSION;
|
||||
echo <<<EOF
|
||||
<!-- Meting Start -->
|
||||
<script type="text/javascript" src="{$dir}APlayer.min.js?v={$ver}"></script>
|
||||
<!-- Meting End -->
|
||||
EOF;
|
||||
}
|
||||
|
||||
public static function footer(){}
|
||||
@ -154,7 +159,7 @@ EOF;
|
||||
echo <<<EOF
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
if($('#wmd-button-row').length>0)$('#wmd-button-row').append('<li class="wmd-spacer wmd-spacer1" id="wmd-spacer5"></li><li class="wmd-button" id="wmd-music-button" style="" title="插入音乐">音乐</li>');
|
||||
if($('#wmd-button-row').length>0)$('#wmd-button-row').append('<li class="wmd-spacer wmd-spacer1" id="wmd-spacer5"></li><li class="wmd-button" id="wmd-music-button" style="" title="插入音乐"><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAABBVBMVEUAAADS1NVVVVVKS0pWVldZWVpJSkrHyctlZmaxs7RlZmZgYWFfX1/GyMrLzc7P0dJiY2PO0NJaWlqWmJpYV1dVVVXQ09TIystJSkpXV1fMzs9QUFCYmpxVVla3ubmoqqqdnp+jpaaSlJZqamtmZmbP0dLCxMbBw8TLzc65vL1VV1dSU1PBw8XFx8nR09SOkJKipaeho6RjZWW7vL2ys7SusLHGyMpZWVp4eHisrrBqamrCxMapq6yusLJ5enrP0tNtbm+ipafGyMpJSkqmp6iZmptXV1dZWVnJy8zS1NWmqKrLzc7R09TFx8m3ubuqrK6hpKWcnqCVlpeXmZuSk5SDhIWDg4QW1XxpAAAATXRSTlMABEgFAvxPFv79+vrGsrGurpKNaFlOTTQ0MyMc/v367e3p6OPizczMyLetrKeemYSDg4F/fn59fXt5eW5ubGtpZ2BdTEI+NzYrKBYMC1kKAkAAAAC1SURBVBjTRY7VEoMwEEWh7sUKFOru7u6OVv7/U7oh7bAPOblnktlL/IYkMfE8eDoSofn7P1+jKfP9efnDF5ylipFnOI4pmGXJ+t1Kh87oEg9lmiRQKB5k/FQ+lgTAOmovaMzhGPQJpwsll5OYdoGzFVsTkRDr7GYMnGR1tweJfTKR6wGHioaFw/3U28CRogaxCBp6B7hT1EDMEgFN2wK9YdWHhc9fvRHILKmT1ZRaeHEduwfMF0K7E1YSv1vLAAAAAElFTkSuQmCC"/></li>');
|
||||
$(document).on('click', '#wmd-music-button', function() {
|
||||
$('body').append(
|
||||
'<div id="MetingPanel">'+
|
||||
@ -286,7 +291,6 @@ EOF;
|
||||
}
|
||||
}catch(Typecho_Db_Exception $e){
|
||||
$code=$e->getCode();
|
||||
if($code=='42S01')return;
|
||||
throw new Typecho_Plugin_Exception('数据表清空失败,插件禁用失败。错误号: '.$code);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
4. 后台启用插件
|
||||
|
||||
## 使用
|
||||
在文章编辑页面,点击编辑器上的 **音乐** 按钮,在弹出的窗口中输入音乐地址(见支持列表),最后点击确定即可
|
||||
在文章编辑页面,点击编辑器上的 **音乐图标** 按钮,在弹出的窗口中输入音乐地址(见支持列表),最后点击确定即可
|
||||
**歌曲混合特性:** 允许添加多个音乐地址,每行一个,插件会自动将所有歌曲合并在同一个歌单进行播放。
|
||||
|
||||
## 支持列表
|
||||
@ -28,6 +28,7 @@
|
||||
- 专辑 http://music.163.com/#/album?id=34808540
|
||||
- 歌手 http://music.163.com/#/artist?id=3681
|
||||
- 歌单 http://music.163.com/#/playlist?id=436843836
|
||||
- 榜单 http://music.163.com/#/discover/toplist?id=60198
|
||||
|
||||
QQ 音乐 http://y.qq.com
|
||||
- 单曲 https://y.qq.com/portal/song/000jDQWP4JiB3y.html
|
||||
|
@ -44,7 +44,7 @@ class Meting
|
||||
}
|
||||
curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
|
||||
curl_setopt($curl,CURLOPT_CONNECTTIMEOUT,10);
|
||||
curl_setopt($curl,CURLOPT_TIMEOUT,10);
|
||||
curl_setopt($curl,CURLOPT_TIMEOUT,20);
|
||||
curl_setopt($curl,CURLOPT_COOKIE,$BASE['cookie']);
|
||||
curl_setopt($curl,CURLOPT_REFERER,$BASE['referer']);
|
||||
curl_setopt($curl,CURLOPT_USERAGENT,$BASE['useragent']);
|
||||
@ -854,14 +854,14 @@ class Meting
|
||||
private function format_kugou($data){
|
||||
$result=array(
|
||||
'id' => $data['hash'],
|
||||
'name' => "",
|
||||
'name' => $data['filename']?:$data['fileName'],
|
||||
'artist' => array(),
|
||||
'url_id' => $data['hash'],
|
||||
'pic_id' => $data['hash'],
|
||||
'lyric_id' => $data['hash'],
|
||||
'source' => 'kugou',
|
||||
);
|
||||
list($result['artist'],$result['name'])=explode(' - ',$data['filename']?:$data['fileName']);
|
||||
list($result['artist'],$result['name'])=explode(' - ',$result['name'],2);
|
||||
$result['artist']=explode('、',$result['artist']);
|
||||
return $result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user