diff --git a/Action.php b/Action.php
index c203b65..1f1d138 100644
--- a/Action.php
+++ b/Action.php
@@ -96,7 +96,7 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do {
$EID=md5('js/'.$vo['server'].'/'.$vo['type'].'/'.$vo['id']);
$t=self::cacheRead($EID,60*60*24*3);
if(!$t){
- $API=(new Meting($vo['server']))->format(true);
+ $API=(new \Metowolf\Meting($vo['server']))->format(true);
$t=call_user_func_array(array($API,$vo['type']),array($vo['id']));
$t=json_decode($t,1);
self::cacheWrite($EID,$t);
@@ -149,11 +149,11 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do {
$cachekey="url/{$site}/{$id}/{$rate}";
$data=self::cacheRead($cachekey,60*15);
if(!$data){
- $data=(new Meting($site))->url($id,$rate);
+ $data=(new \Metowolf\Meting($site))->format()->url($id,$rate);
$data=json_decode($data,1);
self::cacheWrite($cachekey,$data);
}
- if(empty($data['url']))$data['url']='https://oc1pe0tot.qnssl.com/copyright.m4a';
+ if(empty($data['url']))$data['url']="https://api.i-meto.com/music/copyright?s={$site}id={$id}";
$this->response->redirect($data['url']);
}
@@ -165,7 +165,7 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do {
$cachekey="pic/{$site}/{$id}";
$data=self::cacheRead($cachekey,60*60*24*30);
if(!$data){
- $data=(new Meting($site))->pic($id,90);
+ $data=(new \Metowolf\Meting($site))->pic($id,90);
$data=json_decode($data,1);
self::cacheWrite($cachekey,$data);
}
@@ -180,7 +180,7 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do {
$cachekey="lyric/{$site}/{$id}";
$data=self::cacheRead($cachekey,60*60*24*10);
if(!$data){
- $data=(new Meting($site))->format(true)->lyric($id);
+ $data=(new \Metowolf\Meting($site))->format(true)->lyric($id);
$data=json_decode($data,1);
self::cacheWrite($cachekey,$data);
}
@@ -208,25 +208,24 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do {
}
private function cacheWrite($k,$v){
- if(!is_array($v))return;
+ if(!is_array($v)||is_null($v))return;
$db=Typecho_Db::get();
- $prefix=$db->getPrefix();
- $insert=$db->insert($prefix.'meting')->rows(array('id'=>sha1($k),'value'=>serialize($v),'date'=>time()));
+ $insert=$db->insert('table.metingv1')->rows(array('id'=>md5($k),'value'=>serialize($v),'last'=>time()));
return $db->query($insert);
}
private function cacheRead($k,$t=60*60){
$db=Typecho_Db::get();
- $prefix=$db->getPrefix();
- $query=$db->select('value','date')->from($prefix.'meting')->where('id=?',sha1($k));
- $result=$db->fetchAll($query);
- if(sizeof($result)){
- if(time()-$result[0]['date']>$t){
- $delete=$db->delete($prefix.'meting')->where('date',time()-$t);
+ $query=$db->select('value','last')->from('table.metingv1')->where('id=?',md5($k));
+ $result=$db->fetchRow($query);
+
+ if(isset($result['value'])){
+ if(time()-$result['last']>$t){
+ $delete=$db->delete('table.metingv1')->where('last',time()-$t);
$db->query($delete);
return false;
}
- return unserialize($result[0]['value']);
+ return unserialize($result['value']);
}
else return false;
}
diff --git a/Plugin.php b/Plugin.php
index 9eecd22..d2426d1 100644
--- a/Plugin.php
+++ b/Plugin.php
@@ -6,13 +6,13 @@ if(!defined('__TYPECHO_ROOT_DIR__'))exit;
*
* @package Meting
* @author METO
- * @version 1.0.5
+ * @version 1.1.0
* @dependence 14.10.10-*
* @link https://github.com/metowolf/Meting-Typecho-Plugin
*
*/
-define('METING_VERSION','1.0.5');
+define('METING_VERSION','1.1.0');
class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
{
@@ -192,40 +192,27 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
public static function install(){
$db=Typecho_Db::get();
- $prefix=$db->getPrefix();
- $scripts=file_get_contents(__DIR__.'/include/install.sql');
- $scripts=str_replace('typecho_',$prefix,$scripts);
- $scripts=explode(';', $scripts);
+ $dbname=$db->getPrefix().'metingv1';
try{
- foreach($scripts as $script){
- $script=trim($script);
- if($script){
- $db->query($script,Typecho_Db::WRITE);
- }
- }
+ $db->query("CREATE TABLE IF NOT EXISTS {$dbname} (
+ id CHAR(32) PRIMARY KEY NOT NULL UNIQUE,
+ value TEXT NOT NULL,
+ last int NOT NULL
+ )");
}catch(Typecho_Db_Exception $e){
$code=$e->getCode();
- if($code=='42S01'||$code==1050)return;
- throw new Typecho_Plugin_Exception('数据表建立失败,插件启用失败。错误号: '.$code);
+ throw new Typecho_Plugin_Exception('插件启用失败。错误号:'.$code);
}
}
public static function uninstall(){
$db=Typecho_Db::get();
- $prefix=$db->getPrefix();
- $scripts=file_get_contents(__DIR__.'/include/uninstall.sql');
- $scripts=str_replace('typecho_',$prefix,$scripts);
- $scripts=explode(';', $scripts);
+ $dbname=$db->getPrefix().'metingv1';
try{
- foreach($scripts as $script){
- $script=trim($script);
- if($script){
- $db->query($script,Typecho_Db::WRITE);
- }
- }
+ $db->query("DROP TABLE IF EXISTS {$dbname};");
}catch(Typecho_Db_Exception $e){
$code=$e->getCode();
- throw new Typecho_Plugin_Exception('数据表清空失败,插件禁用失败。错误号: '.$code);
+ throw new Typecho_Plugin_Exception('插件禁用失败。错误号:'.$code);
}
}
}
diff --git a/README.md b/README.md
index 5f41075..9fb8ca5 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,16 @@
+![](http://ww2.sinaimg.cn/large/a15b4afegw1fbg1l7wn09j20fw05gq34)
+
# Meting for Typecho
在 Typecho 中使用 APlayer 播放在线音乐吧~
-[在线演示](http://demo.i-meto.com)
+[发布页面](https://i-meto.com/meting-typecho/)
+[在线演示](https://demo.i-meto.com)
## 介绍
1. 支持国内五大音乐平台(网易云、QQ、虾米、百度、酷狗)的单曲/专辑/歌单播放
2. 简单快捷,复制音乐详情页面网址,后台自动生成播放代码
3. **支持不同音乐平台歌曲混合播放**
4. 前端 Aplayer,后端 Meting 及时更新,保证兼容性及 API 高可用性
+ 5. 支持 MySql、SQLite 数据库
## 声明
本作品仅供个人学习研究使用,请勿将其用作商业用途。
diff --git a/assets/APlayer.min.js b/assets/APlayer.min.js
index 6042ea9..33c2ab3 100644
--- a/assets/APlayer.min.js
+++ b/assets/APlayer.min.js
@@ -1,3 +1,8 @@
-!function(e,a){"object"==typeof exports&&"object"==typeof module?module.exports=a():"function"==typeof define&&define.amd?define("APlayer",[],a):"object"==typeof exports?exports.APlayer=a():e.APlayer=a()}(this,function(){return function(e){function a(l){if(t[l])return t[l].exports;var r=t[l]={exports:{},id:l,loaded:!1};return e[l].call(r.exports,r,r.exports,a),r.loaded=!0,r.exports}var t={};return a.m=e,a.c=t,a.p="",a(0)}([function(e,a,t){"use strict";function l(e,a){if(!(e instanceof a))throw new TypeError("Cannot call a class as a function")}var r=function(){function e(e,a){for(var t=0;t';for(var h=0;h
\n