From a7547d64045bd923ff642d78d331dad59a087e0c Mon Sep 17 00:00:00 2001 From: METO Date: Sat, 1 Jul 2017 11:54:31 +0800 Subject: [PATCH] =?UTF-8?q?[1.2.0]=20=E6=96=B0=E5=A2=9E=E4=BA=91=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Action.php | 4 +++- Plugin.php | 54 +++++++++++++++++++++++++++++++++++----------- include/Meting.php | 34 ++++++++++++++++++++++------- 3 files changed, 70 insertions(+), 22 deletions(-) diff --git a/Action.php b/Action.php index d2d32b7..323c751 100644 --- a/Action.php +++ b/Action.php @@ -1,6 +1,5 @@ request->get('id'); $site=$this->request->get('site'); @@ -154,6 +154,7 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do { } private function pic(){ + if(!extension_loaded('Meting'))include_once 'include/Meting.php'; self::filterReferer(); $id=$this->request->get('id'); $site=$this->request->get('site'); @@ -169,6 +170,7 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do { } private function lrc(){ + if(!extension_loaded('Meting'))include_once 'include/Meting.php'; self::filterReferer(); $id=$this->request->get('id'); $site=$this->request->get('site'); diff --git a/Plugin.php b/Plugin.php index b5db8eb..7d1814c 100644 --- a/Plugin.php +++ b/Plugin.php @@ -6,13 +6,13 @@ if(!defined('__TYPECHO_ROOT_DIR__'))exit; * * @package Meting * @author METO - * @version 1.1.2 + * @version 1.2.0 * @dependence 14.10.10-* * @link https://github.com/metowolf/Meting-Typecho-Plugin * */ -define('METING_VERSION','1.1.2'); +define('METING_VERSION','1.2.0'); class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface { @@ -56,6 +56,11 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface * @return void */ public static function config(Typecho_Widget_Helper_Form $form){ + $t = new Typecho_Widget_Helper_Form_Element_Radio( + 'cloudapi', array('true'=>_t('是'),'false'=>_t('否')),'false', + _t('METO 云解析 (beta)'), + _t('当插件无法正常工作时,可以勾选开启。歌单混播、音质调节将失效')); + $form->addInput($t); $t = new Typecho_Widget_Helper_Form_Element_Text( 'theme', null, '#ad7a86', _t('播放器颜色'), @@ -100,12 +105,19 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface public static function header(){ $dir=Helper::options()->pluginUrl.'/Meting/assets/'; $ver=METING_VERSION; - echo " - - "; + echo "\n"; + echo "\n"; + if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi){ + echo "\n"; + } + echo "\n"; } - public static function footer(){} + public static function footer(){ + if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi){ + echo "\n"; + } + } public static function getPID(){ return ++self::$PID; @@ -122,9 +134,7 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface } public static function parseCallback($matches){ - $t=self::shortcode_parse_atts(htmlspecialchars_decode($matches[3])); - $setting=base64_encode(json_encode($t)); - + $setting=self::shortcode_parse_atts(htmlspecialchars_decode($matches[3])); $matches[5]=htmlspecialchars_decode($matches[5]); $pattern=self::get_shortcode_regex(array('Music')); preg_match_all("/$pattern/",$matches[5],$all); @@ -135,15 +145,33 @@ class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface $data=array(); foreach($matches as $vo){ $t=self::shortcode_parse_atts(htmlspecialchars_decode($vo)); - if(!in_array($t['server'],array('netease','tencent','xiami','baidu','kugou','kuwo')))continue; + if(!in_array($t['server'],array('netease','tencent','xiami','baidu','kugou')))continue; if(!in_array($t['type'],array('search','album','playlist','artist','song')))continue; $data[]=$t; } $id=self::getPID(); $dir=Typecho_Common::url('MetingAPI',Helper::options()->index); - $data=base64_encode(json_encode($data)); - return "
- "; + if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi){ + $str="
$setting['theme']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->theme?:'red', + 'preload' => $setting['preload']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->preload?:'auto', + 'autoplay' => $setting['autoplay']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->autoplay?:'false', + 'height' => $setting['height']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->height?:'340px', + 'mode' => $setting['mode']?:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->mode?:'circulation', + ); + foreach($player as $key=>$vo){ + $str.=" data-{$key}=\"{$vo}\""; + } + $str.=">
\n"; + return $str; + } + else{ + $setting=base64_encode(json_encode($setting)); + $data=base64_encode(json_encode($data)); + return "
+ "; + } } public static function addButton(){ diff --git a/include/Meting.php b/include/Meting.php index a9b9f6e..a6434e7 100644 --- a/include/Meting.php +++ b/include/Meting.php @@ -3,7 +3,7 @@ * Meting music framework * https://i-meto.com * https://github.com/metowolf/Meting - * Version 1.3.5.1 + * Version 1.3.6.1 * * Copyright 2017, METO Sheel * Released under the MIT license @@ -869,7 +869,7 @@ class Meting foreach ($type as $key=>$vo) { if ($data['data'][0]['file'][$key]&&$vo[0]<=$this->_TEMP['br']) { $url=array( - 'url' => 'http://dl.stream.qqmusic.qq.com/'.$vo[1].$data['data'][0]['file']['media_mid'].'.'.$vo[2].'?vkey='.$KEY.'&guid='.$GUID.'&uid=0&fromtag=30', + 'url' => 'https://dl.stream.qqmusic.qq.com/'.$vo[1].$data['data'][0]['file']['media_mid'].'.'.$vo[2].'?vkey='.$KEY.'&guid='.$GUID.'&uid=0&fromtag=30', 'br' => $vo[0], ); break; @@ -886,7 +886,7 @@ class Meting private function xiami_url($result) { $data=json_decode($result, 1); - if (isset($data['location'])) { + if (!empty($data['location'])) { $location = $data['location']; $num = (int)$location[0]; $str = substr($location, 1); @@ -910,7 +910,7 @@ class Meting } $urlt=str_replace('^', '0', urldecode($urlt)); $url=array( - 'url' => urldecode($urlt), + 'url' => str_replace('http://','https://',urldecode($urlt)), 'br' => 320, ); } else { @@ -1017,10 +1017,23 @@ class Meting $data=$this->curl($API); $data=preg_replace('/<[^>]+>/', '', $data); } - $arr=array( - 'lyric' => $data, - 'tlyric' => '', - ); + preg_match_all('/\[([\d:\.]+)\](.*)\s\[x-trans\](.*)/i',$data,$match); + if(sizeof($match[0])){ + for($i=0;$i str_replace($match[0],$A,$data), + 'tlyric' => str_replace($match[0],$B,$data), + ); + } + else{ + $arr=array( + 'lyric' => $data, + 'tlyric' => '', + ); + } return json_encode($arr); } private function kugou_lyric($result) @@ -1056,6 +1069,7 @@ class Meting 'id' => $data['id'], 'name' => $data['name'], 'artist' => array(), + 'album' => $data['al']['name'], 'pic_id' => isset($data['al']['pic_str'])?$data['al']['pic_str']:$data['al']['pic'], 'url_id' => $data['id'], 'lyric_id' => $data['id'], @@ -1079,6 +1093,7 @@ class Meting 'id' => $data['songmid'], 'name' => $data['songname'], 'artist' => array(), + 'album' => isset($data['albumname'])?$data['albumname']:$data['album']['name'], 'pic_id' => $data['albummid'], 'url_id' => $data['songmid'], 'lyric_id' => $data['songmid'], @@ -1095,6 +1110,7 @@ class Meting 'id' => $data['song_id'], 'name' => $data['song_name'], 'artist' => explode(';', isset($data['singers'])?$data['singers']:$data['artist_name']), + 'album' => $data['album_name'], 'pic_id' => $data['song_id'], 'url_id' => $data['song_id'], 'lyric_id' => $data['song_id'], @@ -1108,6 +1124,7 @@ class Meting 'id' => $data['hash'], 'name' => isset($data['filename'])?$data['filename']:$data['fileName'], 'artist' => array(), + 'album' => isset($data['album_name'])?$data['album_name']:'', 'url_id' => $data['hash'], 'pic_id' => $data['hash'], 'lyric_id' => $data['hash'], @@ -1123,6 +1140,7 @@ class Meting 'id' => $data['song_id'], 'name' => $data['title'], 'artist' => explode(',', $data['author']), + 'album' => $data['album_title'], 'pic_id' => $data['song_id'], 'url_id' => $data['song_id'], 'lyric_id' => $data['song_id'],