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('dateselect('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('lastquery($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\n \n \n \n '},this.isMobile=/mobile/i.test(window.navigator.userAgent),this.isMobile&&(a.autoplay=!1);var s={element:document.getElementsByClassName("aplayer")[0],narrow:!1,autoplay:!1,mutex:!0,showlrc:0,theme:"#b7daff",mode:"circulation"};for(var p in s)s.hasOwnProperty(p)&&!a.hasOwnProperty(p)&&(a[p]=s[p]);if(this.playIndex="[object Array]"===Object.prototype.toString.call(a.music)?0:-1,this.option=a,this.audios=[],this.mode=a.mode,this.secondToTime=function(e){if(isNaN(e))return"00:00";var a=function(e){return e<10?"0"+e:""+e},t=parseInt(e/60),l=parseInt(e-60*t),r=parseInt(t/60),i=parseInt(e/60-60*parseInt(e/60/60));return e>=3600?a(r)+":"+a(i)+":"+a(l):a(t)+":"+a(l)},this.element=this.option.element,2===this.option.showlrc||this.option.showlrc===!0){this.savelrc=[];for(var c=0;c0?a:0,a=a<1?a:1,m[e+"Bar"].style[t]=100*a+"%"},this.updateLrc=function(){var e=arguments.length<=0||void 0===arguments[0]?n.audio.currentTime:arguments[0];if(n.lrcIndex>n.lrc.length-1||e=n.lrc[n.lrcIndex+1][0])for(var a=0;a=n.lrc[a][0]&&(!n.lrc[a+1]||e-1,this.music=this.multiple?this.option.music[this.playIndex]:this.option.music,this.option.showlrc&&this.element.classList.add("aplayer-withlrc"),this.option.music.length>1&&this.element.classList.add("aplayer-list"),this.multiple||"circulation"===this.mode||"order"===this.mode||(this.mode="circulation"),this.getRandomOrder();var y='\n
\n
\n \n
\n
\n
\n
\n \n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n \n - 00:00 / 00:00\n \n
\n \n
\n
\n
\n
\n
\n
\n \n "+(this.multiple?'":"")+"\n
\n
\n
");if(this.multiple){y+='\n
\n
    ';for(var h=0;h\n \n '+(h+1)+'\n '+this.option.music[h].title+'\n '+this.option.music[h].author+"\n ";y+="\n
\n
"}this.element.innerHTML=y,this.element.offsetWidth<300&&(this.element.getElementsByClassName("aplayer-icon-mode")[0].style.display="none"),this.ptime=this.element.getElementsByClassName("aplayer-ptime")[0],this.element.getElementsByClassName("aplayer-info")[0].offsetWidth<200&&this.element.getElementsByClassName("aplayer-time")[0].classList.add("aplayer-time-narrow");var m={};m.barWrap=this.element.getElementsByClassName("aplayer-bar-wrap")[0],this.option.narrow&&this.element.classList.add("aplayer-narrow"),this.button=this.element.getElementsByClassName("aplayer-button")[0],this.button.addEventListener("click",function(e){n.toggle()}),this.multiple&&!function(){for(var e=n.element.getElementsByClassName("aplayer-list")[0].getElementsByTagName("li"),a=function(a){e[a].addEventListener("click",function(){var t=parseInt(e[a].getElementsByClassName("aplayer-list-index")[0].innerHTML)-1;t!==n.playIndex?(n.setMusic(t),n.play()):n.toggle()})},t=0;t0?l:0,l=l<1?l:1,n.updateBar("played",l,"width"),n.option.showlrc&&n.updateLrc(parseFloat(m.playedBar.style.width)/100*n.audio.duration),n.element.getElementsByClassName("aplayer-ptime")[0].innerHTML=n.secondToTime(l*n.audio.duration)},b=function E(){document.removeEventListener("mouseup",E),document.removeEventListener("mousemove",g),isNaN(n.audio.duration)?n.updateBar("played",0,"width"):(n.audio.currentTime=parseFloat(m.playedBar.style.width)/100*n.audio.duration,n.playedTime=setInterval(function(){n.updateBar("played",n.audio.currentTime/n.audio.duration,"width"),n.option.showlrc&&n.updateLrc(),n.element.getElementsByClassName("aplayer-ptime")[0].innerHTML=n.secondToTime(n.audio.currentTime),n.trigger("playing")},100))};f.addEventListener("mousedown",function(){v=m.barWrap.clientWidth,clearInterval(n.playedTime),document.addEventListener("mousemove",g),document.addEventListener("mouseup",b)}),m.volumeBar=this.element.getElementsByClassName("aplayer-volume")[0];var x=this.element.getElementsByClassName("aplayer-volume-bar")[0];this.volumeicon=this.element.getElementsByClassName("aplayer-time")[0].getElementsByTagName("button")[0];var w=35;this.element.getElementsByClassName("aplayer-volume-bar-wrap")[0].addEventListener("click",function(e){var a=e||window.event,t=(w-a.clientY+r(x))/w;t=t>0?t:0,t=t<1?t:1,n.volume(t)}),this.volumeicon.addEventListener("click",function(){n.audio.muted?(n.audio.muted=!1,n.volumeicon.className=1===n.audio.volume?"aplayer-icon aplayer-icon-volume-up":"aplayer-icon aplayer-icon-volume-down",1===n.audio.volume?(n.volumeicon.className="aplayer-icon aplayer-icon-volume-up",n.volumeicon.innerHTML=n.getSVG("volume-up")):(n.volumeicon.className="aplayer-icon aplayer-icon-volume-down",n.volumeicon.innerHTML=n.getSVG("volume-down")),n.updateBar("volume",n.audio.volume,"height")):(n.audio.muted=!0,n.volumeicon.className="aplayer-icon aplayer-icon-volume-off",n.volumeicon.innerHTML=n.getSVG("volume-off"),n.updateBar("volume",0,"height"))});var A=this.element.getElementsByClassName("aplayer-icon-mode")[0];A.addEventListener("click",function(){n.multiple?"random"===n.mode?n.mode="single":"single"===n.mode?n.mode="order":"order"===n.mode?n.mode="circulation":"circulation"===n.mode&&(n.mode="random"):"circulation"===n.mode?n.mode="order":n.mode="circulation",A.innerHTML=n.getSVG(n.mode),n.audio.loop=!(n.multiple||"order"===n.mode)}),this.multiple&&!function(){var e=n.element.getElementsByClassName("aplayer-list")[0];e.style.height=e.offsetHeight+"px",n.element.getElementsByClassName("aplayer-icon-menu")[0].addEventListener("click",function(){e.classList.contains("aplayer-list-hide")?e.classList.remove("aplayer-list-hide"):e.classList.add("aplayer-list-hide")})}(),"random"===this.mode?this.setMusic(this.randomOrder[0]):this.setMusic(0),i.push(this)}return r(e,[{key:"setMusic",value:function(e){var a=this;this.multiple&&"undefined"!=typeof e&&(this.playIndex=e);var t=this.playIndex;this.music=this.multiple?this.option.music[t]:this.option.music,this.music.pic&&(this.element.getElementsByClassName("aplayer-pic")[0].style.backgroundImage="url('"+this.music.pic+"')"),this.element.getElementsByClassName("aplayer-title")[0].innerHTML=this.music.title,this.element.getElementsByClassName("aplayer-author")[0].innerHTML=" - "+this.music.author,this.multiple&&(this.element.getElementsByClassName("aplayer-list-light")[0]&&this.element.getElementsByClassName("aplayer-list-light")[0].classList.remove("aplayer-list-light"),this.element.getElementsByClassName("aplayer-list")[0].getElementsByTagName("li")[t].classList.add("aplayer-list-light")),this.audio&&(this.pause(),this.audio.currentTime=0),this.multiple&&(this.element.getElementsByClassName("aplayer-list")[0].scrollTop=33*t),this.multiple&&!this.audios[t]||this.playIndex===-1?(this.audio=document.createElement("audio"),this.audio.src=this.music.url,this.audio.preload=this.option.preload?this.option.preload:"auto",this.audio.addEventListener("play",function(){if(a.button.classList.contains("aplayer-play")){if(a.button.classList.remove("aplayer-play"),a.button.classList.add("aplayer-pause"),a.button.innerHTML="",setTimeout(function(){a.button.innerHTML='\n "},100),a.option.mutex)for(var e=0;e'+a.getSVG("play")+" "},100),clearInterval(a.playedTime),a.trigger("pause"))}),this.audio.addEventListener("durationchange",function(){1!==a.audio.duration&&(a.element.getElementsByClassName("aplayer-dtime")[0].innerHTML=a.secondToTime(a.audio.duration))}),this.audio.addEventListener("progress",function(){var e=a.audio.buffered.length?a.audio.buffered.end(a.audio.buffered.length-1)/a.audio.duration:0;a.updateBar("loaded",e,"width")}),this.audio.addEventListener("error",function(){a.element.getElementsByClassName("aplayer-author")[0].innerHTML=" - Error happens ╥﹏╥",a.trigger("pause")}),this.audio.addEventListener("canplay",function(){a.trigger("canplay")}),this.ended=!1,this.multiple?this.audio.addEventListener("ended",function(){return a.isMobile?(a.ended=!0,void a.pause()):void(0!==a.audio.currentTime&&("random"===a.mode?a.setMusic(a.nextRandomNum()):"single"===a.mode?a.setMusic(a.playIndex):"order"===a.mode?a.playIndex=200&&r.status<300||304===r.status){t=r.responseText,a.lrcs[e]=l(t),a.lrc=a.lrcs[e];var i="";a.lrcContents=a.element.getElementsByClassName("aplayer-lrc-contents")[0];for(var n=0;n"+a.lrc[n][1]+"

";a.lrcContents.innerHTML=i,a.lrcIndex||(a.lrcIndex=0),a.lrcContents.getElementsByTagName("p")[0].classList.add("aplayer-lrc-current"),a.lrcContents.style.transform="translateY(0px)",a.lrcContents.style.webkitTransform="translateY(0px)"}else console.log("Request was unsuccessful: "+r.status)};var i=void 0;i=a.multiple?a.option.music[e].lrc:a.option.music.lrc,r.open("get",i,!0),r.send(null)}(),t?a.lrcs[e]=l(t):a.lrcs[e]=[["00:00","Loading"]]}(),a.lrc=a.lrcs[e];var r="";a.lrcContents=a.element.getElementsByClassName("aplayer-lrc-contents")[0];for(var i=0;i"+a.lrc[i][1]+"

";a.lrcContents.innerHTML=r,a.lrcIndex||(a.lrcIndex=0),a.lrcContents.getElementsByTagName("p")[0].classList.add("aplayer-lrc-current"),a.lrcContents.style.transform="translateY(0px)",a.lrcContents.style.webkitTransform="translateY(0px)"}(),1!==this.audio.duration&&(this.element.getElementsByClassName("aplayer-dtime")[0].innerHTML=this.audio.duration?this.secondToTime(this.audio.duration):"00:00"),this.option.autoplay&&!this.isMobile&&this.play(),this.option.autoplay=!0,this.isMobile&&this.pause()}},{key:"play",value:function(e){"[object Number]"===Object.prototype.toString.call(e)&&(this.audio.currentTime=e),this.audio.paused&&this.audio.play()}},{key:"pause",value:function(){this.audio.paused||this.audio.pause()}},{key:"volume",value:function(e){this.updateBar("volume",e,"height"),this.audio.volume=e,this.audio.muted&&(this.audio.muted=!1),1===e?(this.volumeicon.className="aplayer-icon aplayer-icon-volume-up",this.volumeicon.innerHTML=this.getSVG("volume-up")):(this.volumeicon.className="aplayer-icon aplayer-icon-volume-down",this.volumeicon.innerHTML=this.getSVG("volume-down"))}},{key:"on",value:function(e,a){"function"==typeof a&&this.event[e].push(a)}},{key:"toggle",value:function(){this.button.classList.contains("aplayer-play")?this.play():this.button.classList.contains("aplayer-pause")&&this.pause()}},{key:"getRandomOrder",value:function(){function e(e,a){return null==a&&(a=e,e=0),e+Math.floor(Math.random()*(a-e+1))}function a(a){for(var t,l=a.length,r=new Array(l),i=0;i=0&&b.splice(a,1)}function o(e){var a=document.createElement("style");return a.type="text/css",i(e,a),a}function s(e){var a=document.createElement("link");return a.rel="stylesheet",i(e,a),a}function p(e,a){var t,l,r;if(a.singleton){var i=g++;t=v||(v=o(a)),l=c.bind(null,t,i,!1),r=c.bind(null,t,i,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(t=s(a),l=u.bind(null,t),r=function(){n(t),t.href&&URL.revokeObjectURL(t.href)}):(t=o(a),l=d.bind(null,t),r=function(){n(t)});return l(e),function(a){if(a){if(a.css===e.css&&a.media===e.media&&a.sourceMap===e.sourceMap)return;l(e=a)}else r()}}function c(e,a,t,l){var r=t?"":l.css;if(e.styleSheet)e.styleSheet.cssText=x(a,r);else{var i=document.createTextNode(r),n=e.childNodes;n[a]&&e.removeChild(n[a]),n.length?e.insertBefore(i,n[a]):e.appendChild(i)}}function d(e,a){var t=a.css,l=a.media;if(l&&e.setAttribute("media",l),e.styleSheet)e.styleSheet.cssText=t;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(t))}}function u(e,a){var t=a.css,l=a.sourceMap;l&&(t+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(l))))+" */");var r=new Blob([t],{type:"text/css"}),i=e.href;e.href=URL.createObjectURL(r),i&&URL.revokeObjectURL(i)}var y={},h=function(e){var a;return function(){return"undefined"==typeof a&&(a=e.apply(this,arguments)),a}},m=h(function(){return/msie [6-9]\b/.test(window.navigator.userAgent.toLowerCase())}),f=h(function(){return document.head||document.getElementsByTagName("head")[0]}),v=null,g=0,b=[];e.exports=function(e,a){a=a||{},"undefined"==typeof a.singleton&&(a.singleton=m()),"undefined"==typeof a.insertAt&&(a.insertAt="bottom");var t=r(e);return l(t,a),function(e){for(var i=[],n=0;n0)throw new Error("Invalid string. Length must be a multiple of 4");return"="===e[t-2]?2:"="===e[t-1]?1:0}function a(e){return 3*e.length/4-r(e)}function i(e){var t,n,a,i,o,l,s=e.length;o=r(e),l=new c(3*s/4-o),a=o>0?s-4:s;var u=0;for(t=0,n=0;t>16&255,l[u++]=i>>8&255,l[u++]=255&i;return 2===o?(i=p[e.charCodeAt(t)]<<2|p[e.charCodeAt(t+1)]>>4,l[u++]=255&i):1===o&&(i=p[e.charCodeAt(t)]<<10|p[e.charCodeAt(t+1)]<<4|p[e.charCodeAt(t+2)]>>2,l[u++]=i>>8&255,l[u++]=255&i),l}function o(e){return u[e>>18&63]+u[e>>12&63]+u[e>>6&63]+u[63&e]}function l(e,t,n){for(var r,a=[],i=t;ip?p:s+o));return 1===r?(t=e[n-1],a+=u[t>>2],a+=u[t<<4&63],a+="=="):2===r&&(t=(e[n-2]<<8)+e[n-1],a+=u[t>>10],a+=u[t>>4&63],a+=u[t<<2&63],a+="="),i.push(a),i.join("")}t.byteLength=a,t.toByteArray=i,t.fromByteArray=s;for(var u=[],p=[],c="undefined"!=typeof Uint8Array?Uint8Array:Array,h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,d=h.length;f=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function m(e){return+e!=e&&(e=0),o.alloc(+e)}function g(e,t){if(o.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return G(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return Q(e).length;default:if(r)return G(e).length;t=(""+t).toLowerCase(),r=!0}}function v(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if(n>>>=0,t>>>=0,n<=t)return"";for(e||(e="utf8");;)switch(e){case"hex":return k(this,t,n);case"utf8":case"utf-8":return L(this,t,n);case"ascii":return S(this,t,n);case"latin1":case"binary":return N(this,t,n);case"base64":return I(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function b(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function w(e,t,n,r,a){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=a?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(a)return-1;n=e.length-1}else if(n<0){if(!a)return-1;n=0}if("string"==typeof t&&(t=o.from(t,r)),o.isBuffer(t))return 0===t.length?-1:A(e,t,n,r,a);if("number"==typeof t)return t&=255,o.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?a?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):A(e,[t],n,r,a);throw new TypeError("val must be string, number or Buffer")}function A(e,t,n,r,a){function i(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}var o=1,l=e.length,s=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,l/=2,s/=2,n/=2}var u;if(a){var p=-1;for(u=n;ul&&(n=l-s),u=n;u>=0;u--){for(var c=!0,h=0;ha&&(r=a):r=a;var i=t.length;if(i%2!=0)throw new TypeError("Invalid hex string");r>i/2&&(r=i/2);for(var o=0;o239?4:i>223?3:i>191?2:1;if(a+l<=n){var s,u,p,c;switch(l){case 1:i<128&&(o=i);break;case 2:s=e[a+1],128==(192&s)&&(c=(31&i)<<6|63&s)>127&&(o=c);break;case 3:s=e[a+1],u=e[a+2],128==(192&s)&&128==(192&u)&&(c=(15&i)<<12|(63&s)<<6|63&u)>2047&&(c<55296||c>57343)&&(o=c);break;case 4:s=e[a+1],u=e[a+2],p=e[a+3],128==(192&s)&&128==(192&u)&&128==(192&p)&&(c=(15&i)<<18|(63&s)<<12|(63&u)<<6|63&p)>65535&&c<1114112&&(o=c)}}null===o?(o=65533,l=1):o>65535&&(o-=65536,r.push(o>>>10&1023|55296),o=56320|1023&o),r.push(o),a+=l}return C(r)}function C(e){var t=e.length;if(t<=ee)return String.fromCharCode.apply(String,e);for(var n="",r=0;rr)&&(n=r);for(var a="",i=t;in)throw new RangeError("Trying to access beyond buffer length")}function Y(e,t,n,r,a,i){if(!o.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>a||te.length)throw new RangeError("Index out of range")}function O(e,t,n,r){t<0&&(t=65535+t+1);for(var a=0,i=Math.min(e.length-n,2);a>>8*(r?a:1-a)}function q(e,t,n,r){t<0&&(t=4294967295+t+1);for(var a=0,i=Math.min(e.length-n,4);a>>8*(r?a:3-a)&255}function j(e,t,n,r,a,i){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function z(e,t,n,r,a){return a||j(e,t,n,4,3.4028234663852886e38,-3.4028234663852886e38),X.write(e,t,n,r,23,4),n+4}function D(e,t,n,r,a){return a||j(e,t,n,8,1.7976931348623157e308,-1.7976931348623157e308),X.write(e,t,n,r,52,8),n+8}function J(e){if(e=H(e).replace(te,""),e.length<2)return"";for(;e.length%4!=0;)e+="=";return e}function H(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}function _(e){return e<16?"0"+e.toString(16):e.toString(16)}function G(e,t){t=t||1/0;for(var n,r=e.length,a=null,i=[],o=0;o55295&&n<57344){if(!a){if(n>56319){(t-=3)>-1&&i.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&i.push(239,191,189);continue}a=n;continue}if(n<56320){(t-=3)>-1&&i.push(239,191,189),a=n;continue}n=65536+(a-55296<<10|n-56320)}else a&&(t-=3)>-1&&i.push(239,191,189);if(a=null,n<128){if((t-=1)<0)break;i.push(n)}else if(n<2048){if((t-=2)<0)break;i.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;i.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;i.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return i}function Z(e){for(var t=[],n=0;n>8,a=n%256,i.push(a),i.push(r);return i}function Q(e){return W.toByteArray(J(e))}function V(e,t,n,r){for(var a=0;a=t.length||a>=e.length);++a)t[a+n]=e[a];return a}function K(e){return e!==e}/*! + * The buffer module from node.js, for the browser. + * + * @author Feross Aboukhadijeh + * @license MIT + */ +var W=n(1),X=n(6),$=n(7);t.Buffer=o,t.SlowBuffer=m,t.INSPECT_MAX_BYTES=50,o.TYPED_ARRAY_SUPPORT=void 0!==e.TYPED_ARRAY_SUPPORT?e.TYPED_ARRAY_SUPPORT:r(),t.kMaxLength=a(),o.poolSize=8192,o._augment=function(e){return e.__proto__=o.prototype,e},o.from=function(e,t,n){return l(null,e,t,n)},o.TYPED_ARRAY_SUPPORT&&(o.prototype.__proto__=Uint8Array.prototype,o.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&o[Symbol.species]===o&&Object.defineProperty(o,Symbol.species,{value:null,configurable:!0})),o.alloc=function(e,t,n){return u(null,e,t,n)},o.allocUnsafe=function(e){return p(null,e)},o.allocUnsafeSlow=function(e){return p(null,e)},o.isBuffer=function(e){return!(null==e||!e._isBuffer)},o.compare=function(e,t){if(!o.isBuffer(e)||!o.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var n=e.length,r=t.length,a=0,i=Math.min(n,r);a0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),""},o.prototype.compare=function(e,t,n,r,a){if(!o.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===a&&(a=this.length),t<0||n>e.length||r<0||a>this.length)throw new RangeError("out of range index");if(r>=a&&t>=n)return 0;if(r>=a)return-1;if(t>=n)return 1;if(t>>>=0,n>>>=0,r>>>=0,a>>>=0,this===e)return 0;for(var i=a-r,l=n-t,s=Math.min(i,l),u=this.slice(r,a),p=e.slice(t,n),c=0;ca)&&(n=a),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var i=!1;;)switch(r){case"hex":return E(this,e,t,n);case"utf8":case"utf-8":return x(this,e,t,n);case"ascii":return T(this,e,t,n);case"latin1":case"binary":return B(this,e,t,n);case"base64":return M(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,t,n);default:if(i)throw new TypeError("Unknown encoding: "+r);r=(""+r).toLowerCase(),i=!0}},o.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var ee=4096;o.prototype.slice=function(e,t){var n=this.length;e=~~e,t=void 0===t?n:~~t,e<0?(e+=n)<0&&(e=0):e>n&&(e=n),t<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(a*=256);)r+=this[e+--t]*a;return r},o.prototype.readUInt8=function(e,t){return t||P(e,1,this.length),this[e]},o.prototype.readUInt16LE=function(e,t){return t||P(e,2,this.length),this[e]|this[e+1]<<8},o.prototype.readUInt16BE=function(e,t){return t||P(e,2,this.length),this[e]<<8|this[e+1]},o.prototype.readUInt32LE=function(e,t){return t||P(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},o.prototype.readUInt32BE=function(e,t){return t||P(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},o.prototype.readIntLE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=this[e],a=1,i=0;++i=a&&(r-=Math.pow(2,8*t)),r},o.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||P(e,t,this.length);for(var r=t,a=1,i=this[e+--r];r>0&&(a*=256);)i+=this[e+--r]*a;return a*=128,i>=a&&(i-=Math.pow(2,8*t)),i},o.prototype.readInt8=function(e,t){return t||P(e,1,this.length),128&this[e]?(255-this[e]+1)*-1:this[e]},o.prototype.readInt16LE=function(e,t){t||P(e,2,this.length);var n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt16BE=function(e,t){t||P(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},o.prototype.readInt32LE=function(e,t){return t||P(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},o.prototype.readInt32BE=function(e,t){return t||P(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},o.prototype.readFloatLE=function(e,t){return t||P(e,4,this.length),X.read(this,e,!0,23,4)},o.prototype.readFloatBE=function(e,t){return t||P(e,4,this.length),X.read(this,e,!1,23,4)},o.prototype.readDoubleLE=function(e,t){return t||P(e,8,this.length),X.read(this,e,!0,52,8)},o.prototype.readDoubleBE=function(e,t){return t||P(e,8,this.length),X.read(this,e,!1,52,8)},o.prototype.writeUIntLE=function(e,t,n,r){if(e=+e,t|=0,n|=0,!r){Y(this,e,t,n,Math.pow(2,8*n)-1,0)}var a=1,i=0;for(this[t]=255&e;++i=0&&(i*=256);)this[t+a]=e/i&255;return t+n},o.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||Y(this,e,t,1,255,0),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},o.prototype.writeUInt16LE=function(e,t,n){return e=+e,t|=0,n||Y(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},o.prototype.writeUInt16BE=function(e,t,n){return e=+e,t|=0,n||Y(this,e,t,2,65535,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},o.prototype.writeUInt32LE=function(e,t,n){return e=+e,t|=0,n||Y(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):q(this,e,t,!0),t+4},o.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||Y(this,e,t,4,4294967295,0),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):q(this,e,t,!1),t+4},o.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);Y(this,e,t,n,a-1,-a)}var i=0,o=1,l=0;for(this[t]=255&e;++i>0)-l&255;return t+n},o.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var a=Math.pow(2,8*n-1);Y(this,e,t,n,a-1,-a)}var i=n-1,o=1,l=0;for(this[t+i]=255&e;--i>=0&&(o*=256);)e<0&&0===l&&0!==this[t+i+1]&&(l=1),this[t+i]=(e/o>>0)-l&255;return t+n},o.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||Y(this,e,t,1,127,-128),o.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},o.prototype.writeInt16LE=function(e,t,n){return e=+e,t|=0,n||Y(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},o.prototype.writeInt16BE=function(e,t,n){return e=+e,t|=0,n||Y(this,e,t,2,32767,-32768),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},o.prototype.writeInt32LE=function(e,t,n){return e=+e,t|=0,n||Y(this,e,t,4,2147483647,-2147483648),o.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):q(this,e,t,!0),t+4},o.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||Y(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),o.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):q(this,e,t,!1),t+4},o.prototype.writeFloatLE=function(e,t,n){return z(this,e,t,!0,n)},o.prototype.writeFloatBE=function(e,t,n){return z(this,e,t,!1,n)},o.prototype.writeDoubleLE=function(e,t,n){return D(this,e,t,!0,n)},o.prototype.writeDoubleBE=function(e,t,n){return D(this,e,t,!1,n)},o.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t=0;--a)e[a+t]=this[a+n];else if(i<1e3||!o.TYPED_ARRAY_SUPPORT)for(a=0;a>>=0,n=void 0===n?this.length:n>>>0,e||(e=0);var i;if("number"==typeof e)for(i=t;i>1,p=-7,c=n?a-1:0,h=n?-1:1,f=e[t+c];for(c+=h,i=f&(1<<-p)-1,f>>=-p,p+=l;p>0;i=256*i+e[t+c],c+=h,p-=8);for(o=i&(1<<-p)-1,i>>=-p,p+=r;p>0;o=256*o+e[t+c],c+=h,p-=8);if(0===i)i=1-u;else{if(i===s)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,r),i-=u}return(f?-1:1)*o*Math.pow(2,i-r)},t.write=function(e,t,n,r,a,i){var o,l,s,u=8*i-a-1,p=(1<>1,h=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,f=r?0:i-1,d=r?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(l=isNaN(t)?1:0,o=p):(o=Math.floor(Math.log(t)/Math.LN2),t*(s=Math.pow(2,-o))<1&&(o--,s*=2),t+=o+c>=1?h/s:h*Math.pow(2,1-c),t*s>=2&&(o++,s/=2),o+c>=p?(l=0,o=p):o+c>=1?(l=(t*s-1)*Math.pow(2,a),o+=c):(l=t*Math.pow(2,c-1)*Math.pow(2,a),o=0));a>=8;e[n+f]=255&l,f+=d,l/=256,a-=8);for(o=o<0;e[n+f]=255&o,f+=d,o/=256,u-=8);e[n+f-d]|=128*y}},function(e,t){var n={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==n.call(e)}},function(e,t,n){(function(e){function n(e,t){for(var n=0,r=e.length-1;r>=0;r--){var a=e[r];"."===a?e.splice(r,1):".."===a?(e.splice(r,1),n++):n&&(e.splice(r,1),n--)}if(t)for(;n--;n)e.unshift("..");return e}function r(e,t){if(e.filter)return e.filter(t);for(var n=[],r=0;r=-1&&!a;i--){var o=i>=0?arguments[i]:e.cwd();if("string"!=typeof o)throw new TypeError("Arguments to path.resolve must be strings");o&&(t=o+"/"+t,a="/"===o.charAt(0))}return t=n(r(t.split("/"),function(e){return!!e}),!a).join("/"),(a?"/":"")+t||"."},t.normalize=function(e){var a=t.isAbsolute(e),i="/"===o(e,-1);return e=n(r(e.split("/"),function(e){return!!e}),!a).join("/"),e||a||(e="."),e&&i&&(e+="/"),(a?"/":"")+e},t.isAbsolute=function(e){return"/"===e.charAt(0)},t.join=function(){var e=Array.prototype.slice.call(arguments,0);return t.normalize(r(e,function(e,t){if("string"!=typeof e)throw new TypeError("Arguments to path.join must be strings");return e}).join("/"))},t.relative=function(e,n){function r(e){for(var t=0;t=0&&""===e[n];n--);return t>n?[]:e.slice(t,n-t+1)}e=t.resolve(e).substr(1),n=t.resolve(n).substr(1);for(var a=r(e.split("/")),i=r(n.split("/")),o=Math.min(a.length,i.length),l=o,s=0;s1)for(var n=1;n=0&&v.splice(t,1)}function o(e){var t=document.createElement("style");return t.type="text/css",a(e,t),t}function l(e){var t=document.createElement("link");return t.rel="stylesheet",a(e,t),t}function s(e,t){var n,r,a;if(t.singleton){var s=g++;n=m||(m=o(t)),r=u.bind(null,n,s,!1),a=u.bind(null,n,s,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=l(t),r=c.bind(null,n),a=function(){i(n),n.href&&URL.revokeObjectURL(n.href)}):(n=o(t),r=p.bind(null,n),a=function(){i(n)});return r(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;r(e=t)}else a()}}function u(e,t,n,r){var a=n?"":r.css;if(e.styleSheet)e.styleSheet.cssText=b(t,a);else{var i=document.createTextNode(a),o=e.childNodes;o[t]&&e.removeChild(o[t]),o.length?e.insertBefore(i,o[t]):e.appendChild(i)}}function p(e,t){var n=t.css,r=t.media;if(r&&e.setAttribute("media",r),e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}function c(e,t){var n=t.css,r=t.sourceMap;r&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var a=new Blob([n],{type:"text/css"}),i=e.href;e.href=URL.createObjectURL(a),i&&URL.revokeObjectURL(i)}var h={},f=function(e){var t;return function(){return void 0===t&&(t=e.apply(this,arguments)),t}},d=f(function(){return/msie [6-9]\b/.test(self.navigator.userAgent.toLowerCase())}),y=f(function(){return document.head||document.getElementsByTagName("head")[0]}),m=null,g=0,v=[];e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");t=t||{},void 0===t.singleton&&(t.singleton=d()),void 0===t.insertAt&&(t.insertAt="bottom");var a=r(e);return n(a,t),function(e){for(var i=[],o=0;o\n \n \n \n '},this.isMobile=/mobile/i.test(window.navigator.userAgent),this.isMobile&&(t.autoplay=!1);var s={element:document.getElementsByClassName("aplayer")[0],narrow:!1,autoplay:!1,mutex:!0,showlrc:0,theme:"#b7daff",mode:"circulation"};for(var u in s)s.hasOwnProperty(u)&&!t.hasOwnProperty(u)&&(t[u]=s[u]);if(this.option=t,this.audios=[],this.mode=t.mode,this.secondToTime=function(e){if(isNaN(e))return"00:00";var t=function(e){return e<10?"0"+e:""+e},n=parseInt(e/60),r=parseInt(e-60*n),a=parseInt(n/60),i=parseInt(e/60-60*parseInt(e/60/60));return e>=3600?t(a)+":"+t(i)+":"+t(r):t(n)+":"+t(r)},this.element=this.option.element,2===this.option.showlrc||this.option.showlrc===!0){this.savelrc=[];for(var p=0;p0?t:0,t=t<1?t:1,y[e+"Bar"].style[n]=100*t+"%"},this.updateLrc=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i.audio.currentTime;if(i.lrcIndex>i.lrc.length-1||e=i.lrc[i.lrcIndex+1][0])for(var t=0;t=i.lrc[t][0]&&(!i.lrc[t+1]||e1&&this.element.classList.add("aplayer-withlist"),this.multiple||"circulation"===this.mode||"order"===this.mode||(this.mode="circulation"),this.getRandomOrder();for(var f='\n
\n
\n \n
\n
\n
\n
\n \n \n
\n
\n
\n
\n
\n
\n
\n
\n
\n \n
\n
\n
\n
\n \n - 00:00 / 00:00\n \n
\n \n
\n
\n
\n
\n
\n
\n \n \n
\n
\n
\n
\n
    ',d=0;d\n \n '+(d+1)+'\n '+this.option.music[d].title+'\n '+this.option.music[d].author+"\n ";f+="\n
\n
",this.element.innerHTML=f,this.element.offsetWidth<300&&(this.element.getElementsByClassName("aplayer-icon-mode")[0].style.display="none"),this.ptime=this.element.getElementsByClassName("aplayer-ptime")[0],this.element.getElementsByClassName("aplayer-info")[0].offsetWidth<200&&this.element.getElementsByClassName("aplayer-time")[0].classList.add("aplayer-time-narrow");var y={};y.barWrap=this.element.getElementsByClassName("aplayer-bar-wrap")[0],this.option.narrow&&this.element.classList.add("aplayer-narrow"),this.button=this.element.getElementsByClassName("aplayer-button")[0],this.button.addEventListener("click",function(e){i.toggle()});var m=this.element.getElementsByClassName("aplayer-list")[0];m.addEventListener("click",function(e){var t=void 0;t="LI"===e.target.tagName.toUpperCase()?e.target:e.target.parentElement;var n=parseInt(t.getElementsByClassName("aplayer-list-index")[0].innerHTML)-1;n!==i.playIndex?(i.setMusic(n),i.play()):i.toggle()}),y.playedBar=this.element.getElementsByClassName("aplayer-played")[0],y.loadedBar=this.element.getElementsByClassName("aplayer-loaded")[0];var g=this.element.getElementsByClassName("aplayer-thumb")[0],v=void 0;y.barWrap.addEventListener("click",function(e){var t=e||window.event;v=y.barWrap.clientWidth;var r=(t.clientX-n(y.barWrap))/v;isNaN(i.audio.duration)?i.updateBar("played",0,"width"):(i.updateBar("played",r,"width"),i.element.getElementsByClassName("aplayer-ptime")[0].innerHTML=i.secondToTime(r*i.audio.duration),i.audio.currentTime=parseFloat(y.playedBar.style.width)/100*i.audio.duration)}),g.addEventListener("mouseover",function(){g.style.background=i.option.theme}),g.addEventListener("mouseout",function(){g.style.background="#fff"});var b=function(e){var t=e||window.event,r=(t.clientX-n(y.barWrap))/v;r=r>0?r:0,r=r<1?r:1,i.updateBar("played",r,"width"),i.option.showlrc&&i.updateLrc(parseFloat(y.playedBar.style.width)/100*i.audio.duration),i.element.getElementsByClassName("aplayer-ptime")[0].innerHTML=i.secondToTime(r*i.audio.duration)},w=function e(){document.removeEventListener("mouseup",e),document.removeEventListener("mousemove",b),isNaN(i.audio.duration)?i.updateBar("played",0,"width"):(i.audio.currentTime=parseFloat(y.playedBar.style.width)/100*i.audio.duration,i.playedTime=setInterval(function(){i.updateBar("played",i.audio.currentTime/i.audio.duration,"width"),i.option.showlrc&&i.updateLrc(),i.element.getElementsByClassName("aplayer-ptime")[0].innerHTML=i.secondToTime(i.audio.currentTime),i.trigger("playing")},100))};g.addEventListener("mousedown",function(){v=y.barWrap.clientWidth,clearInterval(i.playedTime),document.addEventListener("mousemove",b),document.addEventListener("mouseup",w)}),y.volumeBar=this.element.getElementsByClassName("aplayer-volume")[0];var A=this.element.getElementsByClassName("aplayer-volume-bar")[0];this.volumeicon=this.element.getElementsByClassName("aplayer-time")[0].getElementsByTagName("button")[0];var E=35;this.element.getElementsByClassName("aplayer-volume-bar-wrap")[0].addEventListener("click",function(e){var t=e||window.event,n=(E-t.clientY+r(A))/E;n=n>0?n:0,n=n<1?n:1,i.volume(n)}),this.volumeicon.addEventListener("click",function(){i.audio.muted?(i.audio.muted=!1,i.volumeicon.className=1===i.audio.volume?"aplayer-icon aplayer-icon-volume-up":"aplayer-icon aplayer-icon-volume-down",1===i.audio.volume?(i.volumeicon.className="aplayer-icon aplayer-icon-volume-up",i.volumeicon.innerHTML=i.getSVG("volume-up")):(i.volumeicon.className="aplayer-icon aplayer-icon-volume-down",i.volumeicon.innerHTML=i.getSVG("volume-down")),i.updateBar("volume",i.audio.volume,"height")):(i.audio.muted=!0,i.volumeicon.className="aplayer-icon aplayer-icon-volume-off",i.volumeicon.innerHTML=i.getSVG("volume-off"),i.updateBar("volume",0,"height"))});var x=this.element.getElementsByClassName("aplayer-icon-mode")[0];x.addEventListener("click",function(){i.multiple?"random"===i.mode?i.mode="single":"single"===i.mode?i.mode="order":"order"===i.mode?i.mode="circulation":"circulation"===i.mode&&(i.mode="random"):"circulation"===i.mode?i.mode="order":i.mode="circulation",x.innerHTML=i.getSVG(i.mode),i.audio.loop=!(i.multiple||"order"===i.mode)}),m.style.height=m.offsetHeight+"px",this.element.getElementsByClassName("aplayer-icon-menu")[0].addEventListener("click",function(){m.classList.contains("aplayer-list-hide")?m.classList.remove("aplayer-list-hide"):m.classList.add("aplayer-list-hide")}),"random"===this.mode?this.setMusic(this.randomOrder[0]):this.setMusic(0),o.push(this)}return i(e,[{key:"setMusic",value:function(e){var t=this;void 0!==e&&(this.playIndex=e);var n=this.playIndex;this.music=this.option.music[n],this.music.pic&&(this.element.getElementsByClassName("aplayer-pic")[0].style.backgroundImage="url('"+this.music.pic+"')"),this.element.getElementsByClassName("aplayer-title")[0].innerHTML=this.music.title,this.element.getElementsByClassName("aplayer-author")[0].innerHTML=" - "+this.music.author,this.element.getElementsByClassName("aplayer-list-light")[0]&&this.element.getElementsByClassName("aplayer-list-light")[0].classList.remove("aplayer-list-light"),this.element.getElementsByClassName("aplayer-list")[0].getElementsByTagName("li")[n].classList.add("aplayer-list-light"),this.audio&&(this.pause(),this.audio.currentTime=0),this.element.getElementsByClassName("aplayer-list")[0].scrollTop=33*n,this.audios[n]?(this.audio=this.audios[n],this.audio.volume=parseInt(this.element.getElementsByClassName("aplayer-volume")[0].style.height)/100,this.audio.currentTime=0):(this.audio=document.createElement("audio"),this.audio.src=this.music.url,this.audio.preload=this.option.preload?this.option.preload:"auto",this.audio.addEventListener("play",function(){if(t.button.classList.contains("aplayer-play")){if(t.button.classList.remove("aplayer-play"),t.button.classList.add("aplayer-pause"),t.button.innerHTML="",setTimeout(function(){t.button.innerHTML='\n "},100),t.option.mutex)for(var e=0;e'+t.getSVG("play")+" "},100),clearInterval(t.playedTime),t.trigger("pause"))}),this.audio.addEventListener("durationchange",function(){1!==t.audio.duration&&(t.element.getElementsByClassName("aplayer-dtime")[0].innerHTML=t.secondToTime(t.audio.duration))}),this.audio.addEventListener("progress",function(){var e=t.audio.buffered.length?t.audio.buffered.end(t.audio.buffered.length-1)/t.audio.duration:0;t.updateBar("loaded",e,"width")}),this.audio.addEventListener("error",function(){t.element.getElementsByClassName("aplayer-author")[0].innerHTML=" - Error happens ╥﹏╥",t.trigger("pause")}),this.audio.addEventListener("canplay",function(){t.trigger("canplay")}),this.ended=!1,this.audio.addEventListener("ended",function(){if(t.multiple){if(t.isMobile)return t.ended=!0,void t.pause();0!==t.audio.currentTime&&("random"===t.mode?t.setMusic(t.nextRandomNum()):"single"===t.mode?t.setMusic(t.playIndex):"order"===t.mode?t.playIndex=200&&l.status<300||304===l.status?(i=l.responseText,t.lrcs[a]=r(i)):(console.log("Request was unsuccessful: "+l.status),t.lrcs[a]=[["00:00","Not available"]]),t.lrc=t.lrcs[a];var e="";t.lrcContents=t.element.getElementsByClassName("aplayer-lrc-contents")[0];for(var n=0;n"+t.lrc[n][1]+"

";t.lrcContents.innerHTML=e,t.lrcIndex||(t.lrcIndex=0),t.lrcContents.getElementsByTagName("p")[0].classList.add("aplayer-lrc-current"),t.lrcContents.style.transform="translateY(0px)",t.lrcContents.style.webkitTransform="translateY(0px)"}};var s=void 0;s=this.option.music[a].lrc,l.open("get",s,!0),l.send(null)}i?this.lrcs[a]=r(i):3===this.option.showlrc?this.lrcs[a]=[["00:00","Loading"]]:this.lrcs[a]=[["00:00","Not available"]]}this.lrc=this.lrcs[a];var u="";this.lrcContents=this.element.getElementsByClassName("aplayer-lrc-contents")[0];for(var p=0;p"+this.lrc[p][1]+"

";this.lrcContents.innerHTML=u,this.lrcIndex||(this.lrcIndex=0),this.lrcContents.getElementsByTagName("p")[0].classList.add("aplayer-lrc-current"),this.lrcContents.style.transform="translateY(0px)",this.lrcContents.style.webkitTransform="translateY(0px)"}1!==this.audio.duration&&(this.element.getElementsByClassName("aplayer-dtime")[0].innerHTML=this.audio.duration?this.secondToTime(this.audio.duration):"00:00"),this.option.autoplay&&!this.isMobile&&this.play(),this.option.autoplay=!0,this.isMobile&&this.pause()}},{key:"play",value:function(e){"[object Number]"===Object.prototype.toString.call(e)&&(this.audio.currentTime=e),this.audio.paused&&this.audio.play()}},{key:"pause",value:function(){this.audio.paused||this.audio.pause()}},{key:"volume",value:function(e){this.updateBar("volume",e,"height"),this.audio.volume=e,this.audio.muted&&(this.audio.muted=!1),1===e?(this.volumeicon.className="aplayer-icon aplayer-icon-volume-up",this.volumeicon.innerHTML=this.getSVG("volume-up")):(this.volumeicon.className="aplayer-icon aplayer-icon-volume-down",this.volumeicon.innerHTML=this.getSVG("volume-down"))}},{key:"on",value:function(e,t){"function"==typeof t&&this.event[e].push(t)}},{key:"toggle",value:function(){this.button.classList.contains("aplayer-play")?this.play():this.button.classList.contains("aplayer-pause")&&this.pause()}},{key:"getRandomOrder",value:function(){function e(e,t){return null==t&&(t=e,e=0),e+Math.floor(Math.random()*(t-e+1))}function t(t){for(var n,r=t.length,a=new Array(r),i=0;i\n \n '+(this.option.music.length-e.length+a+1)+'\n '+e[a].title+'\n '+e[a].author+"\n ";n.innerHTML+=r,this.multiple||(this.multiple=!0,this.element.classList.add("aplayer-withlist"),this.audio.loop=!1),t.style.height="auto",t.style.height=t.offsetHeight+"px",this.getRandomOrder()}}]),e}();e.exports=l}])}); //# sourceMappingURL=APlayer.min.js.map \ No newline at end of file diff --git a/include/Meting.php b/include/Meting.php index 323a925..4a52ac6 100644 --- a/include/Meting.php +++ b/include/Meting.php @@ -2,12 +2,12 @@ /*! * Meting music framework * https://i-meto.com - * Version 1.3.0 + * Version 1.3.2.1 * * Copyright 2017, METO Sheel * Released under the MIT license */ - +namespace Metowolf; class Meting { protected $_SITE; @@ -72,13 +72,15 @@ class Meting } curl_close($curl); if ($error) { - return json_encode(array( - 'error' => $error, - 'info' => $info, - 'status' => $status, - )); + return json_encode( + array( + 'error' => $error, + 'info' => $info, + 'status' => $status, + ) + ); } - if (isset($API['decode'])) { + if ($this->_FORMAT&&isset($API['decode'])) { $data=call_user_func_array(array($this,$API['decode']), array($data)); } if ($this->_FORMAT&&isset($API['format'])) { @@ -557,7 +559,7 @@ class Meting case 'xiami': $API=array( 'method' => 'GET', - 'url' => 'http://api.xiami.com/web', + 'url' => 'http://www.xiami.com/song/gethqsong/sid/'.$id, 'body' => array( 'v' => '2.0', 'app_key' => '1', @@ -698,14 +700,16 @@ class Meting $format=$this->_FORMAT; $data=$this->format(false)->song($id); $this->format($format); - $url=json_decode($data, 1)['data']['song']['logo']; - $url=str_replace(['_1.','http:','img.'], ['.','https:','pic.'], $url).'@'.$size.'h_'.$size.'w_100q_1c.jpg'; + $data=json_decode($data, 1); + $url=$data['data']['song']['logo']; + $url=str_replace(array('_1.','http:','img.'), array('.','https:','pic.'), $url).'@'.$size.'h_'.$size.'w_100q_1c.jpg'; break; case 'kugou': $format=$this->_FORMAT; $data=$this->format(false)->song($id); $this->format($format); - $url=json_decode($data, 1)['imgUrl']; + $data=json_decode($data, 1); + $url=$data['imgUrl']; $url=str_replace('{size}', '400', $url); break; case 'baidu': @@ -723,7 +727,7 @@ class Meting { $BASE=array( 'netease'=>array( - 'referer' => 'http://music.163.com/', + 'referer' => 'https://music.163.com/', 'cookie' => 'os=linux; appver=1.0.0.1026; osver=Ubuntu%2016.10; MUSIC_U=78d411095f4b022667bc8ec49e9a44cca088df057d987f5feaf066d37458e41c4a7d9447977352cf27ea9fee03f6ec4441049cea1c6bb9b6; __remember_me=true', 'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36', ), @@ -760,7 +764,7 @@ class Meting $KEY='7246674226682325323F5E6544673A51'; $body=json_encode($API['body']); if (function_exists('openssl_encrypt')) { - $body=openssl_encrypt($body, 'aes-128-ecb', hex2bin($KEY)); + $body=openssl_encrypt($body, 'aes-128-ecb', pack('H*', $KEY)); } else { $PAD=16-(strlen($body)%16); $body=base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_128, hex2bin($KEY), $body.str_repeat(chr($PAD), $PAD), MCRYPT_MODE_ECB)); @@ -801,7 +805,7 @@ class Meting $song_id[$i]=chr(ord($song_id[$i])^ord($magic[$i%count($magic)])); } $result=base64_encode(md5(implode('', $song_id), 1)); - $result=str_replace(['/','+'], ['_','-'], $result); + $result=str_replace(array('/','+'), array('_','-'), $result); return $result; } /** @@ -811,10 +815,18 @@ class Meting private function netease_url($result) { $data=json_decode($result, 1); - $url=array( - 'url' => str_replace('http:', 'https:', $data['data'][0]['url']), - 'br' => $data['data'][0]['br']/1000, - ); + if($data['data'][0]['uf'] != null) { + $url=array( + 'url' => str_replace('http:', 'https:', $data['data'][0]['uf']['url']), + 'br' =>$data['data'][0]['uf']['br']/1000, + ); + } + else{ + $url=array( + 'url' => str_replace('http:', 'https:', $data['data'][0]['url']), + 'br' => $data['data'][0]['br']/1000, + ); + } return json_encode($url); } private function tencent_url($result) @@ -830,13 +842,14 @@ class Meting ), 'decode' => 'jsonp2json', ); - $KEY=json_decode($this->curl($API), 1)['key']; + $KEY=json_decode($this->curl($API), 1); + $KEY=$KEY['key']; $type=array( - 'size_320mp3'=>array(320,'M800','mp3'), - 'size_128mp3'=>array(128,'M500','mp3'), - 'size_96aac'=>array(96,'C400','m4a'), - 'size_48aac'=>array(48,'C200','m4a'), + 'size_320mp3' => array(320,'M800','mp3'), + 'size_128mp3' => array(128,'M500','mp3'), + 'size_96aac' => array(96 ,'C400','m4a'), + 'size_48aac' => array(48 ,'C200','m4a'), ); foreach ($type as $key=>$vo) { if ($data['data'][0]['file'][$key]&&$vo[0]<=$this->_temp['br']) { @@ -852,10 +865,42 @@ class Meting private function xiami_url($result) { $data=json_decode($result, 1); - $url=array( - 'url' => str_replace('http:', 'https:', $data['data']['song']['listen_file']), - 'br' => 128, - ); + if(isset($data['location'])) { + $location = $data['location']; + $num = (int)$location[0]; + $str = substr($location, 1); + $len = floor(strlen($str)/$num); + $sub = strlen($str) % $num; + $qrc = array(); + $tmp = 0; + $urlt = ''; + for(;$tmp<$sub;$tmp++){ + $qrc[$tmp] = substr($str, $tmp*($len+1), $len+1); + } + for(;$tmp<$num;$tmp++){ + $qrc[$tmp] = substr($str, $len*$tmp+$sub, $len); + } + for($tmpa=0;$tmpa<$len+1;$tmpa++){ + for($tmpb=0;$tmpb<$num;$tmpb++){ + if(isset($qrc[$tmpb][$tmpa])) { $urlt.=$qrc[$tmpb][$tmpa]; + } + } + } + for($tmp=0;$tmp<$sub;$tmp++){ + //if(isset($qrc[$tmp][$len])) (string)$urlt.=(string)$qrc[$tmp][$len]; + } + $urlt=str_replace('^', '0', urldecode($urlt)); + $url=array( + 'url' => urldecode($urlt), + 'br' => 320, + ); + } + else{ + $url=array( + 'url' => "error",//str_replace('http:', 'https:', $data['data']['song']['listen_file']), + 'br' => 0, + ); + } return json_encode($url); } private function kugou_url($result) @@ -904,18 +949,18 @@ class Meting * 歌词处理模块 * 用于规范化歌词输出 */ - private function netease_lyric($result) - { - if (!$this->_FORMAT) { - return $result; - } - $result=json_decode($result, 1); - $data=array( - 'lyric' => (@$result['lrc']['lyric'])?:'', - 'tlyric' => (@$result['tlyric']['lyric'])?:'', - ); - return json_encode($data); - } + private function netease_lyric($result) + { + if (!$this->_FORMAT) { + return $result; + } + $result=json_decode($result, 1); + $data=array( + 'lyric' => (@$result['lrc']['lyric'])?:'', + 'tlyric' => (@$result['tlyric']['lyric'])?:'', + ); + return json_encode($data); + } private function tencent_lyric($result) { $result=$this->jsonp2json($result); diff --git a/include/install.sql b/include/install.sql deleted file mode 100644 index 2eb16ea..0000000 --- a/include/install.sql +++ /dev/null @@ -1,6 +0,0 @@ -CREATE TABLE typecho_meting ( - id binary(40) NOT NULL, - value TEXT NOT NULL, - date int(11) NOT NULL -)ENGINE=MYISAM DEFAULT CHARSET=utf8; -ALTER TABLE typecho_meting ADD UNIQUE(id); diff --git a/include/uninstall.sql b/include/uninstall.sql deleted file mode 100644 index cbcff3b..0000000 --- a/include/uninstall.sql +++ /dev/null @@ -1 +0,0 @@ -DROP TABLE typecho_meting;