<?php
/**
* Meting music framework
* https://i-meto.com
* https://github.com/metowolf/Meting
* Version 1.5.2.
*
* Copyright 2018, METO Sheel <[email protected]>
* Released under the MIT license
*/
namespace Metowolf;
class Meting
{
const VERSION = '1.5.2';
public $raw;
public $data;
public $info;
public $error;
public $status;
public $server;
public $format = false;
public $header = array(
'Accept' => '*/*',
'Accept-Encoding' => 'gzip, deflate',
'Accept-Language' => 'zh-CN,zh;q=0.8,gl;q=0.6,zh-TW;q=0.4',
'Connection' => 'keep-alive',
'Content-Type' => 'application/x-www-form-urlencoded',
);
public function __construct($value = 'netease')
{
$this->site($value);
}
public function site($value)
{
$suppose = array('netease', 'tencent', 'xiami', 'kugou', 'baidu');
$this->server = in_array($value, $suppose) ? $value : 'netease';
$this->header = $this->curlset();
return $this;
}
public function cookie($value)
{
$this->header['Cookie'] = $value;
return $this;
}
public function format($value = true)
{
$this->format = $value;
return $this;
}
private function exec($api)
{
if (isset($api['encode'])) {
$api = call_user_func_array(array($this, $api['encode']), array($api));
}
if ($api['method'] == 'GET') {
if (isset($api['body'])) {
$api['url'] .= '?'.http_build_query($api['body']);
$api['body'] = null;
}
}
$this->curl($api['url'], $api['body']);
if (!$this->format) {
return $this->raw;
}
$this->data = $this->raw;
if (isset($api['decode'])) {
$this->data = call_user_func_array(array($this, $api['decode']), array($this->data));
}
if (isset($api['format'])) {
$this->data = $this->clean($this->data, $api['format']);
}
return $this->data;
}
private function curl($url, $payload = null, $headerOnly = 0)
{
$header = array_map(function ($k, $v) {
return $k.': '.$v;
}, array_keys($this->header), $this->header);
$curl = curl_init();
if (!is_null($payload)) {
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, is_array($payload) ? http_build_query($payload) : $payload);
}
curl_setopt($curl, CURLOPT_HEADER, $headerOnly);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
curl_setopt($curl, CURLOPT_IPRESOLVE, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_HTTPHEADER, $header);
for ($i = 0; $i < 3; $i++) {
$this->raw = curl_exec($curl);
$this->info = curl_getinfo($curl);
$this->error = curl_errno($curl);
$this->status = $this->error ? curl_error($curl) : '';
if (!$this->error) {
break;
}
}
curl_close($curl);
return $this;
}
private function pickup($array, $rule)
{
$t = explode('.', $rule);
foreach ($t as $vo) {
if (!isset($array[$vo])) {
return array();
}
$array = $array[$vo];
}
return $array;
}
private function clean($raw, $rule)
{
$raw = json_decode($raw, true);
if (!empty($rule)) {
$raw = $this->pickup($raw, $rule);
}
if (!isset($raw[0]) && count($raw)) {
$raw = array($raw);
}
$result = array_map(array($this, 'format_'.$this->server), $raw);
return json_encode($result);
}
public function search($keyword, $option = null)
{
switch ($this->server) {
case 'netease':
$api = array(
'method' => 'POST',
'url' => 'http://music.163.com/api/cloudsearch/pc',
'body' => array(
's' => $keyword,
'type' => isset($option['type']) ? $option['type'] : 1,
'limit' => isset($option['limit']) ? $option['limit'] : 30,
'total' => 'true',
'offset' => isset($option['page']) && isset($option['limit']) ? ($option['page'] - 1) * $option['limit'] : 0,
),
'encode' => 'netease_AESCBC',
'format' => 'result.songs',
);
break;
case 'tencent':
$api = array(
'method' => 'GET',
'url' => 'https://c.y.qq.com/soso/fcgi-bin/client_search_cp',
'body' => array(
'format' => 'json',
'p' => isset($option['page']) ? $option['page'] : 1,
'n' => isset($option['limit']) ? $option['limit'] : 30,
'w' => $keyword,
'aggr' => 1,
'lossless' => 1,
'cr' => 1,
'new_json' => 1,
),
'format' => 'data.song.list',
);
break;
case 'xiami':
$api = array(
'method' => 'GET',
'url' => 'http://h5api.m.xiami.com/h5/mtop.alimusic.search.searchservice.searchsongs/1.0/',
'body' => array(
'data' => array(
'key' => $keyword,
'pagingVO' => array(
'page' => isset($option['page']) ? $option['page'] : 1,
'pageSize' => isset($option['limit']) ? $option['limit'] : 30,
),
),
'r' => 'mtop.alimusic.search.searchservice.searchsongs',
),
'encode' => 'xiami_sign',
'format' => 'data.data.songs',
);
break;
case 'kugou':
$api = array(
'method' => 'GET',
'url' => 'http://ioscdn.kugou.com/api/v3/search/song',
'body' => array(
'iscorrect' => 1,
'pagesize' => isset($option['limit']) ? $option['limit'] : 30,
'plat' => 2,
'tag' => 1,
'sver' => 5,
'showtype' => 10,
'page' => isset($option['page']) ? $option['page'] : 1,
'keyword' => $keyword,
'version' => 8550,
),
'format' => 'data.info',
);
break;
case 'baidu':
$api = array(
'method' => 'GET',
'url' => 'https://gss2.baidu.com/6Ls1aze90MgYm2Gp8IqW0jdnxx1xbK/v1/restserver/ting',
'body' => array(
'from' => 'qianqianmini',
'method' => 'baidu.ting.search.merge',
'isNew' => 1,
'platform' => 'darwin',
'page_no' => isset($option['page']) ? $option['page'] : 1,
'query' => $keyword,
'version' => '11.0.2',
'page_size' => isset($option['limit']) ? $option['limit'] : 30,
),
'format' => 'result.song_info.song_list',
);
break;
}
return $this->exec($api);
}
public function song($id)
{
switch ($this->
没有合适的资源?快使用搜索试试~ 我知道了~
基于html+css+js的音乐网站
共88个文件
png:22个
js:21个
css:11个
需积分: 0 2 下载量 21 浏览量
2023-08-04
15:22:50
上传
评论 2
收藏 31.89MB ZIP 举报
温馨提示
内包含web端和移动端,直接丢到服务器里就能访问,如有其他需求可自己修改,仅供学习和参考
资源推荐
资源详情
资源评论
收起资源包目录
music.zip (88个子文件)
music
api.php 6KB
m.php 7KB
apk
随身助手2.8.5.apk 31.91MB
js
jquery.mCustomScrollbar.concat.min.js 44KB
function1s.js 32KB
ajax.js 16KB
player.js 15KB
layer.js 21KB
functions.js 32KB
background-blur.min.js 5KB
musicList.js 6KB
lyric.js 3KB
jquery.min.js 94KB
pc.php 6KB
css
player.css 16KB
jquery.mCustomScrollbar.min.css 42KB
small.css 4KB
404.html 3KB
access.xml 948B
favicon.ico 17KB
index.php 616B
images
player_cover.png 2KB
wave.gif 622B
icon_list_menu.png 4KB
album_cover_player.png 3KB
player.png 5KB
history.png 2KB
static
picture
f-leeleo.jpg 63KB
js
jquery.mCustomScrollbar.concat.min.js 44KB
ajax.js 16KB
player.js 15KB
layer.js 21KB
functions.js 33KB
background-blur.min.js 5KB
musicList.js 6KB
lyric.js 3KB
jquery.min.js 94KB
css
jquery.mcustomscrollbar.min.css 42KB
font_595659_ks3cn25ecqhq6w29.css 2KB
font_739179_za2rgs3veo8.css 2KB
layer.css 18KB
font_603611_ebbfwmiq121q0k9.css 1KB
leeleo.css 24KB
images
random.png 4KB
more.png 2KB
loading-2.gif 2KB
prev.png 3KB
one.png 4KB
wavem.gif 2KB
loading-1.gif 701B
s-netease.png 13KB
loading-0.gif 6KB
playm.png 2KB
next.png 2KB
icon-ext.png 6KB
stopm.png 2KB
list.png 3KB
s-kugou.png 10KB
s-baidu.png 10KB
s-qq.png 11KB
icon.png 11KB
s-xiami.png 9KB
fonts
font_739179_za2rgs3veo8.ttf 13KB
font_595659_ks3cn25ecqhq6w29.eot 10KB
font_603611_ebbfwmiq121q0k9.svg 10KB
font_603611_ebbfwmiq121q0k9.eot 5KB
font_603611_ebbfwmiq121q0k9.ttf 5KB
font_595659_ks3cn25ecqhq6w29.svg 33KB
font_739179_za2rgs3veo8.svg 65KB
font_739179_za2rgs3veo8.eot 13KB
font_595659_ks3cn25ecqhq6w29.ttf 10KB
plugns
Meting.php 45KB
killie
img
top.jpg 79KB
opera.jpg 2KB
360.jpg 21KB
firefox.jpg 3KB
safari.jpg 3KB
chrome.jpg 2KB
index.html 3KB
layer
mobile
layer.js 3KB
need
layer.css 5KB
layer.js 21KB
skin
default
loading-2.gif 2KB
loading-1.gif 701B
loading-0.gif 6KB
icon-ext.png 6KB
layer.css 14KB
icon.png 11KB
共 88 条
- 1
资源评论
Atopeclipse
- 粉丝: 5
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功