mirror of
https://github.com/MoePlayer/APlayer-Typecho.git
synced 2025-02-19 20:50:23 +08:00
[1.2.0] 新增云解析功能
This commit is contained in:
parent
2967afd567
commit
a7547d6404
@ -1,6 +1,5 @@
|
||||
<?php
|
||||
if(!defined('__TYPECHO_ROOT_DIR__'))exit;
|
||||
if(!extension_loaded('Meting'))include_once 'include/Meting.php';
|
||||
|
||||
class Meting_Action extends Typecho_Widget implements Widget_Interface_Do {
|
||||
|
||||
@ -137,6 +136,7 @@ class Meting_Action extends Typecho_Widget implements Widget_Interface_Do {
|
||||
}
|
||||
|
||||
private function url(){
|
||||
if(!extension_loaded('Meting'))include_once 'include/Meting.php';
|
||||
self::filterReferer();
|
||||
$id=$this->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');
|
||||
|
54
Plugin.php
54
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('当插件无法正常工作时,可以勾选开启。<b>歌单混播、音质调节将失效</b>'));
|
||||
$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 "<!-- Meting Start -->
|
||||
<script type=\"text/javascript\" src=\"{$dir}APlayer.min.js?v={$ver}\"></script>
|
||||
<!-- Meting End -->";
|
||||
echo "<!-- Meting Start -->\n";
|
||||
echo "<script type=\"text/javascript\" src=\"{$dir}APlayer.min.js?v={$ver}\"></script>\n";
|
||||
if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi){
|
||||
echo "<script src=\"https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js\"></script>\n";
|
||||
}
|
||||
echo "<!-- Meting End -->\n";
|
||||
}
|
||||
|
||||
public static function footer(){}
|
||||
public static function footer(){
|
||||
if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi){
|
||||
echo "<script type=\"text/javascript\" src=\"https://api.i-meto.com/music/player.js?v={$ver}\"></script>\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 "<div id=\"MetingPlayer{$id}\" class=\"aplayer\" /></div>
|
||||
<script type=\"text/javascript\" src=\"{$dir}?do=musicjs&s={$setting}&d={$data}&id={$id}\" async defer></script>";
|
||||
if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi){
|
||||
$str="<div class=\"aplayer\" data-id=\"{$data[0]['id']}\" data-server=\"{$data[0]['server']}\" data-type=\"{$data[0]['type']}\"";
|
||||
$player=array(
|
||||
'theme' => $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.="></div>\n";
|
||||
return $str;
|
||||
}
|
||||
else{
|
||||
$setting=base64_encode(json_encode($setting));
|
||||
$data=base64_encode(json_encode($data));
|
||||
return "<div id=\"MetingPlayer{$id}\" class=\"aplayer\" /></div>
|
||||
<script type=\"text/javascript\" src=\"{$dir}?do=musicjs&s={$setting}&d={$data}&id={$id}\" async defer></script>";
|
||||
}
|
||||
}
|
||||
|
||||
public static function addButton(){
|
||||
|
@ -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 <i@i-meto.com>
|
||||
* 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<sizeof($match[0]);$i++){
|
||||
$A[]='['.$match[1][$i].']'.$match[2][$i];
|
||||
$B[]='['.$match[1][$i].']'.$match[3][$i];
|
||||
}
|
||||
$arr=array(
|
||||
'lyric' => 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'],
|
||||
|
Loading…
Reference in New Issue
Block a user