Skip to content

Commit

Permalink
[1.2.5] 新增 cookie 接口,更新 Meting 库
Browse files Browse the repository at this point in the history
 - 新增用户自定义 cookie 设置
 - 更新 Meting v1.5.8
 - 更新 APlayer 1.6.1-beta
 - 修复 PHP notice 警告
 - 修复一些 bug
  • Loading branch information
metowolf committed Sep 5, 2017
1 parent 25f5f86 commit 9ca611c
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 29 deletions.
24 changes: 18 additions & 6 deletions Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,11 @@ private function musicjs(){
$music=array_merge($music,$t);
}
$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',
'theme' => isset($setting['theme'])?$setting['theme']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->theme?:'red',
'preload' => isset($setting['preload'])?$setting['preload']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->preload?:'auto',
'autoplay' => isset($setting['autoplay'])?$setting['autoplay']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->autoplay?:'false',
'height' => isset($setting['height'])?$setting['height']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->height?:'340px',
'mode' => isset($setting['mode'])?$setting['mode']:Typecho_Widget::widget('Widget_Options')->plugin('Meting')->mode?:'circulation',
'music' => array(),
);
foreach($music as $vo){
Expand Down Expand Up @@ -143,15 +143,21 @@ private function url(){
$id=$this->request->get('id');
$site=$this->request->get('site');
$rate=Typecho_Widget::widget('Widget_Options')->plugin('Meting')->bitrate;
$cookie=Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cookie;

$cachekey="url/{$site}/{$id}/{$rate}";
$data=self::cacheRead($cachekey,60*15);
if(!$data){
$data=(new \Metowolf\Meting($site))->format()->url($id,$rate);
$api=(new \Metowolf\Meting($site));
if($cookie!='')$api->cookie($cookie);
$data=$api->format(true)->url($id,$rate);
$data=json_decode($data,1);
self::cacheWrite($cachekey,$data);
}
if(empty($data['url']))$data['url']="https://api.i-meto.com/Public/music/empty.mp3";
if($site=='netease'){
$data['url']=str_replace("http://","https://",$data['url']);
}
$this->response->redirect($data['url']);
}

Expand Down Expand Up @@ -230,6 +236,12 @@ private function cacheRead($k,$t=3600){
else return false;
}

/*private function cacheFlush(){
$db=Typecho_Db::get();
$delete=$db->delete('table.metingv1')->where('last<?',time());
$db->query($delete);
}*/

private function filterReferer(){
if(isset($_SERVER['HTTP_REFERER'])&&strpos($_SERVER['HTTP_REFERER'],$_SERVER['HTTP_HOST'])===false){
http_response_code(403);
Expand Down
15 changes: 9 additions & 6 deletions Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
*
* @package Meting
* @author METO
* @version 1.2.4
* @version 1.2.5
* @dependence 14.10.10-*
* @link https://github.com/metowolf/Meting-Typecho-Plugin
*
*/

define('METING_VERSION','1.2.4');
define('METING_VERSION','1.2.5');

class Meting_Plugin extends Typecho_Widget implements Typecho_Plugin_Interface
{
Expand Down Expand Up @@ -91,6 +91,11 @@ public static function config(Typecho_Widget_Helper_Form $form){
_t('默认音质'),
_t(''));
$form->addInput($t);
$t = new Typecho_Widget_Helper_Form_Element_Text(
'cookie', null, '',
_t('自定义 Cookie (高级)'),
_t('通过更改 Cookie,使其享受与客户端一样的体验'));
$form->addInput($t);
}

public static function personalConfig(Typecho_Widget_Helper_Form $form){}
Expand All @@ -107,15 +112,13 @@ public static function header(){
$ver=METING_VERSION;
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=='true'){
echo "<script src=\"https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js\"></script>\n";
}
echo "<!-- Meting End -->\n";
}

public static function footer(){
$ver=METING_VERSION;
if(Typecho_Widget::widget('Widget_Options')->plugin('Meting')->cloudapi=='true'){
echo "<script type=\"text/javascript\" src=\"https://api.i-meto.com/music/player.js?v={$ver}\"></script>\n";
echo "<script type=\"text/javascript\" src=\"https://api.i-meto.com/music/aplayer.min.js?v={$ver}\"></script>\n";
}
}

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
![](http://ww2.sinaimg.cn/large/a15b4afegw1fbg1l7wn09j20fw05gq34)
<p align="center">
<img src="https://user-images.githubusercontent.com/2666735/28999701-04c6ba7e-7a84-11e7-804b-3ffa4f7d5d95.png" alt="Meting">
</p>

# Meting for Typecho
# APlayer for Typecho (Meting)
在 Typecho 中使用 APlayer 播放在线音乐吧~
[发布页面](https://i-meto.com/meting-typecho/)

## 介绍
1. 支持国内五大音乐平台(网易云、QQ、虾米、百度、酷狗)的单曲/专辑/歌单播放
2. 简单快捷,复制音乐详情页面网址,后台自动生成播放代码
3. **支持不同音乐平台歌曲混合播放**
4. 前端 Aplayer,后端 Meting 及时更新,保证兼容性及 API 高可用性
4. 前端 APlayer,后端 Meting 及时更新,保证兼容性及 API 高可用性
5. 支持 MySql、SQLite 数据库

## 声明
Expand Down Expand Up @@ -65,4 +67,4 @@ A: 为了减少服务器压力,插件设置对歌单、歌词数据进行缓
更多问题可以通过 issue 页面提交,或者通过 Telegram、邮件向我反馈

## LICENSE
Meting-Typecho-Plugin is under the MIT license.
APlayer-Typecho-Plugin is under the MIT license.
1 change: 0 additions & 1 deletion assets/APlayer.min.js

Large diffs are not rendered by default.

32 changes: 20 additions & 12 deletions include/Meting.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Meting music framework
* https://i-meto.com
* https://github.com/metowolf/Meting
* Version 1.3.6.1
* Version 1.3.8
*
* Copyright 2017, METO Sheel <[email protected]>
* Released under the MIT license
Expand Down Expand Up @@ -106,7 +106,7 @@ private function pickup($array, $rule)
{
$t=explode('#', $rule);
foreach ($t as $vo) {
if (is_null($array)) {
if (!isset($array[$vo])){
return array();
}
$array=$array[$vo];
Expand Down Expand Up @@ -140,7 +140,7 @@ public function search($keyword, $page=1, $limit=30)
'type' => 1,
'limit' => $limit,
'total' => 'true',
'offset' => $page-1,
'offset' => ($page-1)*$limit,
),
'url' => 'http://music.163.com/api/cloudsearch/pc',
),
Expand All @@ -151,14 +151,15 @@ public function search($keyword, $page=1, $limit=30)
case 'tencent':
$API=array(
'method' => 'GET',
'url' => 'https://c.y.qq.com/soso/fcgi-bin/search_cp',
'url' => 'https://c.y.qq.com/soso/fcgi-bin/client_search_cp',
'body' => array(
'p' => $page,
'n' => $limit,
'w' => $keyword,
'aggr' => 1,
'lossless' => 1,
'cr' => 1,
'platform' => 'yqq',
),
'decode' => 'jsonp2json',
'format' => 'data#song#list',
Expand Down Expand Up @@ -245,8 +246,9 @@ public function song($id)
'method' => 'GET',
'url' => 'https://c.y.qq.com/v8/fcg-bin/fcg_play_single_song.fcg',
'body' => array(
'songmid' => $id,
'format' => 'json',
'songmid' => $id,
'platform' => 'yqq',
'format' => 'json',
),
'decode' => 'tencent_singlesong',
'format' => 'data',
Expand All @@ -268,7 +270,7 @@ public function song($id)
case 'kugou':
$API=array(
'method' => 'POST',
'url' => 'http://m.kugou.com/app/i/getSongInfo.php?',
'url' => 'http://m.kugou.com/app/i/getSongInfo.php',
'body' => array(
"cmd" => "playInfo",
"hash" => $id,
Expand Down Expand Up @@ -322,6 +324,7 @@ public function album($id)
'url' => 'https://c.y.qq.com/v8/fcg-bin/fcg_v8_album_info_cp.fcg',
'body' => array(
'albummid' => $id,
'platform' => 'yqq',
),
'format' => 'data#list',
);
Expand Down Expand Up @@ -402,6 +405,8 @@ public function artist($id, $limit=50)
'singermid' => $id,
'begin' => 0,
'num' => $limit,
'order' => 'listen',
'platform' => 'yqq',
),
'format' => 'data#list',
);
Expand Down Expand Up @@ -481,9 +486,10 @@ public function playlist($id)
'method' => 'GET',
'url' => 'https://c.y.qq.com/qzone/fcg-bin/fcg_ucc_getcdinfo_byids_cp.fcg',
'body' => array(
'disstid' => $id,
'utf8' => 1,
'type' => 1,
'disstid' => $id,
'utf8' => 1,
'type' => 1,
'platform' => 'yqq',
),
'decode' => 'jsonp2json',
'format' => 'cdlist#0#songlist',
Expand Down Expand Up @@ -562,6 +568,7 @@ public function url($id, $br=320)
'url' => 'https://c.y.qq.com/v8/fcg-bin/fcg_play_single_song.fcg',
'body' => array(
'songmid' => $id,
'platform' => 'yqq',
'format' => 'json',
),
'decode' => 'tencent_url',
Expand Down Expand Up @@ -743,8 +750,8 @@ private function curlset()
'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
),
'tencent'=>array(
'referer' => 'http://y.qq.com/portal/player.html',
'cookie' => 'qqmusic_uin=12345678; qqmusic_key=12345678; qqmusic_fromtag=30; ts_last=y.qq.com/portal/player.html;',
'referer' => 'https://y.qq.com/portal/player.html',
'cookie' => 'pgv_pvi=3832878080; pgv_si=s4066364416; pgv_pvid=3938077488; yplayer_open=1; qqmusic_fromtag=66; ts_last=y.qq.com/portal/player.html; ts_uid=5141451452; player_exist=1; yq_index=1',
'useragent' => 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36',
),
'xiami'=>array(
Expand Down Expand Up @@ -862,6 +869,7 @@ private function tencent_url($result)

$type=array(
'size_320mp3' => array(320,'M800','mp3'),
'size_192aac' => array(192,'C600','m4a'),
'size_128mp3' => array(128,'M500','mp3'),
'size_96aac' => array(96 ,'C400','m4a'),
'size_48aac' => array(48 ,'C200','m4a'),
Expand Down

0 comments on commit 9ca611c

Please sign in to comment.