mirror of https://github.com/IoTcat/msc-api.git
parent
c829589b0a
commit
2f56858b55
21 changed files with 3064 additions and 0 deletions
@ -0,0 +1,5 @@ |
||||
{ |
||||
"require": { |
||||
"metowolf/meting": "^1.5" |
||||
} |
||||
} |
@ -0,0 +1,68 @@ |
||||
{ |
||||
"_readme": [ |
||||
"This file locks the dependencies of your project to a known state", |
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", |
||||
"This file is @generated automatically" |
||||
], |
||||
"content-hash": "70ff81c59564e9617fed0bf28f62fad1", |
||||
"packages": [ |
||||
{ |
||||
"name": "metowolf/meting", |
||||
"version": "v1.5.7", |
||||
"source": { |
||||
"type": "git", |
||||
"url": "https://github.com/metowolf/Meting.git", |
||||
"reference": "54178aa112da5db09f487d862d7ae62cbf7bc060" |
||||
}, |
||||
"dist": { |
||||
"type": "zip", |
||||
"url": "https://api.github.com/repos/metowolf/Meting/zipball/54178aa112da5db09f487d862d7ae62cbf7bc060", |
||||
"reference": "54178aa112da5db09f487d862d7ae62cbf7bc060", |
||||
"shasum": "" |
||||
}, |
||||
"require": { |
||||
"ext-curl": "*", |
||||
"ext-openssl": "*", |
||||
"php": ">=5.4.0" |
||||
}, |
||||
"suggest": { |
||||
"ext-bcmath": "Required to use BC Math calculate RSA.", |
||||
"ext-openssl": "Required to use OpenSSL encrypt params." |
||||
}, |
||||
"type": "library", |
||||
"autoload": { |
||||
"psr-4": { |
||||
"Metowolf\\": "src/" |
||||
} |
||||
}, |
||||
"notification-url": "https://packagist.org/downloads/", |
||||
"license": [ |
||||
"MIT" |
||||
], |
||||
"authors": [ |
||||
{ |
||||
"name": "metowolf", |
||||
"email": "i@i-meto.com", |
||||
"homepage": "https://i-meto.com" |
||||
} |
||||
], |
||||
"description": "A powerful music API framework to accelerate development.", |
||||
"homepage": "https://github.com/metowolf/Meting", |
||||
"keywords": [ |
||||
"lightweight", |
||||
"lighty", |
||||
"music api", |
||||
"php music" |
||||
], |
||||
"time": "2019-06-16T05:55:00+00:00" |
||||
} |
||||
], |
||||
"packages-dev": [], |
||||
"aliases": [], |
||||
"minimum-stability": "stable", |
||||
"stability-flags": [], |
||||
"prefer-stable": false, |
||||
"prefer-lowest": false, |
||||
"platform": [], |
||||
"platform-dev": [] |
||||
} |
@ -0,0 +1,142 @@ |
||||
<?php |
||||
header('Access-Control-Allow-Origin:*'); |
||||
|
||||
|
||||
/* anti ddos */ |
||||
/*if(!isset($_COOKIE['_token__']) || $_COOKIE['_token__'] != md5(date('Y-m-d-H'))) { |
||||
setcookie("_token__",md5(date('Y-m-d-H')),time()+1*3600); |
||||
header("Location: https://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'], true, 301); |
||||
}*/ |
||||
|
||||
|
||||
require 'vendor/autoload.php'; |
||||
include './functions.php'; |
||||
|
||||
header("Content-Type: application/json;charset=utf-8"); |
||||
|
||||
use Metowolf\Meting; |
||||
|
||||
$API = new Meting('netease'); |
||||
|
||||
$type = $_REQUEST['type']; |
||||
$id = $_REQUEST['id']; |
||||
$random = $_REQUEST['random']; |
||||
$limit = $_REQUEST['limit']; |
||||
|
||||
|
||||
if($type == "url"){ |
||||
if(!isset($id)){ |
||||
echo json_encode(array("code"=>500, "err"=>"You need to provide an id!!")); |
||||
die(); |
||||
} |
||||
$res = get_object_vars(json_decode($API->format(true)->url($id, 320))); |
||||
if(in_array("url", $res)){ |
||||
echo json_encode(array("code"=>404, "err"=>"No Found!!")); |
||||
die(); |
||||
} |
||||
$res['url'] = str_replace("http", "https", $res['url']); |
||||
log_api(); |
||||
header("Location: ".$res['url']); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($type == "cover"){ |
||||
if(!isset($id)){ |
||||
echo json_encode(array("code"=>500, "err"=>"You need to provide an id!!")); |
||||
die(); |
||||
} |
||||
$res = get_object_vars(json_decode($API->format(true)->pic($id))); |
||||
if(in_array("url", $res)){ |
||||
echo json_encode(array("code"=>404, "err"=>"No Found!!")); |
||||
die(); |
||||
} |
||||
log_api(); |
||||
header("Location: ".$res["url"]); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
|
||||
if($type == "lrc"){ |
||||
if(!isset($id)){ |
||||
echo json_encode(array("code"=>500, "err"=>"You need to provide an id!!")); |
||||
die(); |
||||
} |
||||
$res = get_object_vars(json_decode($API->format(true)->lyric($id))); |
||||
if(in_array("lyric", $res)){ |
||||
echo json_encode(array("code"=>404, "err"=>"No Found!!")); |
||||
die(); |
||||
} |
||||
log_api(); |
||||
header("Content-Type: text/plain;charset=utf-8"); |
||||
echo $res["lyric"]; |
||||
die(); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if($type == "single"){ |
||||
if(!isset($id)){ |
||||
echo json_encode(array("code"=>500, "err"=>"You need to provide an id!!")); |
||||
die(); |
||||
} |
||||
$content = get_object_vars(getSongInfo($id, $API)[0]); |
||||
//var_dump($content); |
||||
$o = array("id"=>$content["id"], "name"=>$content["name"], "artist"=>$content["artist"][0], "album"=>$content["album"], "url"=>"https://api.yimian.xyz/msc/?type=url&id=".$content["url_id"], "cover"=>"https://api.yimian.xyz/msc/?type=cover&id=".$content["pic_id"], "lrc"=>"https://api.yimian.xyz/msc/?type=lrc&id=".$content["lyric_id"]); |
||||
if(!$o){ |
||||
echo json_encode(array("code"=>404, "err"=>"Cannot find any songs!!")); |
||||
die(); |
||||
} |
||||
echo json_encode($o); |
||||
log_api(); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
if($type == "playlist"){ |
||||
/* 7.18 events */ |
||||
//$id="2889727316"; |
||||
if(!isset($id)){ |
||||
echo json_encode(array("code"=>500, "err"=>"You need to provide an id!!")); |
||||
die(); |
||||
} |
||||
$content = array(); |
||||
$o = array(); |
||||
|
||||
foreach (getPlaylistInfo($id, $API) as $key => $value) { |
||||
$content = get_object_vars($value); |
||||
array_push($o, array("id"=>$content["id"], "name"=>$content["name"], "artist"=>$content["artist"][0], "album"=>$content["album"], "url"=>"https://api.yimian.xyz/msc/?type=url&id=".$content["url_id"], "cover"=>"https://api.yimian.xyz/msc/?type=cover&id=".$content["pic_id"], "lrc"=>"https://api.yimian.xyz/msc/?type=lrc&id=".$content["lyric_id"])); |
||||
} |
||||
if(!$o){ |
||||
echo json_encode(array("code"=>404, "err"=>"Cannot find any songs!!")); |
||||
die(); |
||||
} |
||||
if($random) shuffle($o); |
||||
if($limit) $o = array_slice($o, 0, $limit); |
||||
echo json_encode($o); |
||||
log_api(); |
||||
die(); |
||||
} |
||||
|
||||
|
||||
echo json_encode(array("code"=>500, "err"=>"Cannot find such type!!")); |
||||
|
||||
|
||||
|
||||
function getSongInfo($id, $API){ |
||||
return json_decode($API->format(true)->song($id)); |
||||
} |
||||
|
||||
function getPlaylistInfo($id, $API){ |
||||
return json_decode($API->format(true)->playlist($id)); |
||||
} |
||||
|
||||
|
||||
|
||||
function log_api(){ |
||||
yimian__log("log_api", array("api" => "msc", "timestamp" => date('Y-m-d H:i:s', time()), "ip" => ip2long(getIp()), "_from" => get_from(), "content" => $_SERVER["QUERY_STRING"])); |
||||
return; |
||||
} |
@ -0,0 +1,58 @@ |
||||
<!doctype html> |
||||
<html> |
||||
|
||||
<head> |
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
||||
<title>音乐获取 API</title> |
||||
<meta name="theme-color" content="#fd4b5c"> |
||||
<script src="https://cdn.yimian.xyz/ushio-js/ushio-head.min.js"></script> |
||||
|
||||
</head> |
||||
|
||||
<body> |
||||
<style type="text/css">h3:hover {box-shadow:0px 0px 8px #D1D1D1;}</style> |
||||
<div style="box-shadow: 5px 5px 25px 0 rgba(46,61,73,.2);border-radius:15px;font-size:13px;width:950px;font-family:微软雅黑,'Helvetica Neue',Arial,sans-serif;margin:10px auto 0px;border:0px solid #eee;max-width:100%;"> |
||||
<div style="width:100%;background-color: #3174ed;background-image: linear-gradient(90deg, #3174ed 0%, #FA8BFF 35%, #3fd9fb 88%);color:#FFFFFF;border-radius:15px 15px 0 0;"> |
||||
<h2 style="font-size:15px;word-break:break-all;padding:20px 32px;margin:0;text-align:center">音乐获取 - API</h2></div> |
||||
<div style="margin:0px auto;width:90%"> |
||||
<h3 style="-webkit-transition: all .2s cubic-bezier(0, 0, 0, 0.48);-moz-transition: all .2s ease;border:.0625rem solid #fafafa;background:#fafafa repeating-linear-gradient(-45deg,#fff,#fff 1.125rem,transparent 1.125rem,transparent 2.25rem);margin:15px 0px;padding:20px;border-radius:5px;font-size:14px;color:#333;"># 音乐获取API请求方式 # |
||||
<ul> |
||||
<li>Method: GET/POST</li></ul> |
||||
<hr># 请求地址 # |
||||
<br/> |
||||
<a style="color:#fd4b5c;text-decoration:none;">https://api.yimian.xyz/msc</a> |
||||
<br/># 参数 # 【目前仅支持网易云音乐】 |
||||
<br/> |
||||
<li>type (必填)//type=single单曲信息/playlist歌单歌曲信息/url获取歌曲/cover获取封面/lrc获取歌词</li> |
||||
<li>id (必填,搭配type使用) //id=198401123</li> |
||||
<li>random //random=true 仅对playlist有效,返回的歌曲是否打乱顺序,默认false</li> |
||||
<li>limit //limit=10 返回歌单最大长度</li> |
||||
<hr> |
||||
# 返回数据(Json格式) #<br/><br/> |
||||
<li> single模式: {id: "歌曲id", name: "歌曲名称", artist: "第一作者", album: "专辑名称", url: "单曲地址", cover: "封面地址", lrc: "歌词地址"}</li><br/> |
||||
<li> playlist模式: [{id: "歌曲id", name: "歌曲名称", artist: "第一作者", album: "专辑名称", url: "单曲地址", cover: "封面地址", lrc: "歌词地址"}, {歌曲2..}, {歌曲3..}]</li><br/> |
||||
<li> 错误: {code: 500, err: "错误信息"}</li> |
||||
<hr># 备注 # |
||||
<br/>更多用法参考 |
||||
<a href="https://www.eee.dog/tech/rand-pic-api.html">https://www.eee.dog/tech/rand-pic-api.html</a> |
||||
<br/> |
||||
<hr># 示例 # |
||||
<br/> |
||||
<a style="color:#fd4b5c;text-decoration:none;" target="_blank">https://api.yimian.xyz/msc/?type=single&id=36308263</a> |
||||
<br/> |
||||
<a style="color:#fd4b5c;text-decoration:none;" target="_blank">https://api.yimian.xyz/msc/?type=playlist&id=808097971</a> |
||||
<br/> |
||||
<a style="color:#fd4b5c;text-decoration:none;" target="_blank">https://api.yimian.xyz/msc/?type=playlist&id=808097971&limit=14</a> |
||||
<br/> |
||||
<a style="color:#fd4b5c;text-decoration:none;" target="_blank">https://api.yimian.xyz/msc/?type=playlist&id=808097971&limit=14&random=true</a> |
||||
<br/> |
||||
<a style="color:#fd4b5c;text-decoration:none;" target="_blank">https://api.yimian.xyz/msc/?type=url&id=36308263</a> |
||||
<br/> |
||||
<a style="color:#fd4b5c;text-decoration:none;" target="_blank">https://api.yimian.xyz/msc/?type=cover&id=3384296792803059</a> |
||||
<br/> |
||||
<a style="color:#fd4b5c;text-decoration:none;" target="_blank">https://api.yimian.xyz/msc/?type=lrc&id=36308263</a></h3> |
||||
</div> |
||||
</div> |
||||
</body> |
||||
<script src="https://cdn.yimian.xyz/ushio-js/ushio-footer.min.js"></script> |
||||
</html> |
@ -0,0 +1,7 @@ |
||||
<?php |
||||
|
||||
// autoload.php @generated by Composer |
||||
|
||||
require_once __DIR__ . '/composer/autoload_real.php'; |
||||
|
||||
return ComposerAutoloaderInit7bd602fdce79cdf3c88e3cdb52a761f5::getLoader(); |
@ -0,0 +1,445 @@ |
||||
<?php |
||||
|
||||
/* |
||||
* This file is part of Composer. |
||||
* |
||||
* (c) Nils Adermann <naderman@naderman.de> |
||||
* Jordi Boggiano <j.boggiano@seld.be> |
||||
* |
||||
* For the full copyright and license information, please view the LICENSE |
||||
* file that was distributed with this source code. |
||||
*/ |
||||
|
||||
namespace Composer\Autoload; |
||||
|
||||
/** |
||||
* ClassLoader implements a PSR-0, PSR-4 and classmap class loader. |
||||
* |
||||
* $loader = new \Composer\Autoload\ClassLoader(); |
||||
* |
||||
* // register classes with namespaces |
||||
* $loader->add('Symfony\Component', __DIR__.'/component'); |
||||
* $loader->add('Symfony', __DIR__.'/framework'); |
||||
* |
||||
* // activate the autoloader |
||||
* $loader->register(); |
||||
* |
||||
* // to enable searching the include path (eg. for PEAR packages) |
||||
* $loader->setUseIncludePath(true); |
||||
* |
||||
* In this example, if you try to use a class in the Symfony\Component |
||||
* namespace or one of its children (Symfony\Component\Console for instance), |
||||
* the autoloader will first look for the class under the component/ |
||||
* directory, and it will then fallback to the framework/ directory if not |
||||
* found before giving up. |
||||
* |
||||
* This class is loosely based on the Symfony UniversalClassLoader. |
||||
* |
||||
* @author Fabien Potencier <fabien@symfony.com> |
||||
* @author Jordi Boggiano <j.boggiano@seld.be> |
||||
* @see http://www.php-fig.org/psr/psr-0/ |
||||
* @see http://www.php-fig.org/psr/psr-4/ |
||||
*/ |
||||
class ClassLoader |
||||
{ |
||||
// PSR-4 |
||||
private $prefixLengthsPsr4 = array(); |
||||
private $prefixDirsPsr4 = array(); |
||||
private $fallbackDirsPsr4 = array(); |
||||
|
||||
// PSR-0 |
||||
private $prefixesPsr0 = array(); |
||||
private $fallbackDirsPsr0 = array(); |
||||
|
||||
private $useIncludePath = false; |
||||
private $classMap = array(); |
||||
private $classMapAuthoritative = false; |
||||
private $missingClasses = array(); |
||||
private $apcuPrefix; |
||||
|
||||
public function getPrefixes() |
||||
{ |
||||
if (!empty($this->prefixesPsr0)) { |
||||
return call_user_func_array('array_merge', $this->prefixesPsr0); |
||||
} |
||||
|
||||
return array(); |
||||
} |
||||
|
||||
public function getPrefixesPsr4() |
||||
{ |
||||
return $this->prefixDirsPsr4; |
||||
} |
||||
|
||||
public function getFallbackDirs() |
||||
{ |
||||
return $this->fallbackDirsPsr0; |
||||
} |
||||
|
||||
public function getFallbackDirsPsr4() |
||||
{ |
||||
return $this->fallbackDirsPsr4; |
||||
} |
||||
|
||||
public function getClassMap() |
||||
{ |
||||
return $this->classMap; |
||||
} |
||||
|
||||
/** |
||||
* @param array $classMap Class to filename map |
||||
*/ |
||||
public function addClassMap(array $classMap) |
||||
{ |
||||
if ($this->classMap) { |
||||
$this->classMap = array_merge($this->classMap, $classMap); |
||||
} else { |
||||
$this->classMap = $classMap; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Registers a set of PSR-0 directories for a given prefix, either |
||||
* appending or prepending to the ones previously set for this prefix. |
||||
* |
||||
* @param string $prefix The prefix |
||||
* @param array|string $paths The PSR-0 root directories |
||||
* @param bool $prepend Whether to prepend the directories |
||||
*/ |
||||
public function add($prefix, $paths, $prepend = false) |
||||
{ |
||||
if (!$prefix) { |
||||
if ($prepend) { |
||||
$this->fallbackDirsPsr0 = array_merge( |
||||
(array) $paths, |
||||
$this->fallbackDirsPsr0 |
||||
); |
||||
} else { |
||||
$this->fallbackDirsPsr0 = array_merge( |
||||
$this->fallbackDirsPsr0, |
||||
(array) $paths |
||||
); |
||||
} |
||||
|
||||
return; |
||||
} |
||||
|
||||
$first = $prefix[0]; |
||||
if (!isset($this->prefixesPsr0[$first][$prefix])) { |
||||
$this->prefixesPsr0[$first][$prefix] = (array) $paths; |
||||
|
||||
return; |
||||
} |
||||
if ($prepend) { |
||||
$this->prefixesPsr0[$first][$prefix] = array_merge( |
||||
(array) $paths, |
||||
$this->prefixesPsr0[$first][$prefix] |
||||
); |
||||
} else { |
||||
$this->prefixesPsr0[$first][$prefix] = array_merge( |
||||
$this->prefixesPsr0[$first][$prefix], |
||||
(array) $paths |
||||
); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Registers a set of PSR-4 directories for a given namespace, either |
||||
* appending or prepending to the ones previously set for this namespace. |
||||
* |
||||
* @param string $prefix The prefix/namespace, with trailing '\\' |
||||
* @param array|string $paths The PSR-4 base directories |
||||
* @param bool $prepend Whether to prepend the directories |
||||
* |
||||
* @throws \InvalidArgumentException |
||||
*/ |
||||
public function addPsr4($prefix, $paths, $prepend = false) |
||||
{ |
||||
if (!$prefix) { |
||||
// Register directories for the root namespace. |
||||
if ($prepend) { |
||||
$this->fallbackDirsPsr4 = array_merge( |
||||
(array) $paths, |
||||
$this->fallbackDirsPsr4 |
||||
); |
||||
} else { |
||||
$this->fallbackDirsPsr4 = array_merge( |
||||
$this->fallbackDirsPsr4, |
||||
(array) $paths |
||||
); |
||||
} |
||||
} elseif (!isset($this->prefixDirsPsr4[$prefix])) { |
||||
// Register directories for a new namespace. |
||||
$length = strlen($prefix); |
||||
if ('\\' !== $prefix[$length - 1]) { |
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
||||
} |
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths; |
||||
} elseif ($prepend) { |
||||
// Prepend directories for an already registered namespace. |
||||
$this->prefixDirsPsr4[$prefix] = array_merge( |
||||
(array) $paths, |
||||
$this->prefixDirsPsr4[$prefix] |
||||
); |
||||
} else { |
||||
// Append directories for an already registered namespace. |
||||
$this->prefixDirsPsr4[$prefix] = array_merge( |
||||
$this->prefixDirsPsr4[$prefix], |
||||
(array) $paths |
||||
); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Registers a set of PSR-0 directories for a given prefix, |
||||
* replacing any others previously set for this prefix. |
||||
* |
||||
* @param string $prefix The prefix |
||||
* @param array|string $paths The PSR-0 base directories |
||||
*/ |
||||
public function set($prefix, $paths) |
||||
{ |
||||
if (!$prefix) { |
||||
$this->fallbackDirsPsr0 = (array) $paths; |
||||
} else { |
||||
$this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Registers a set of PSR-4 directories for a given namespace, |
||||
* replacing any others previously set for this namespace. |
||||
* |
||||
* @param string $prefix The prefix/namespace, with trailing '\\' |
||||
* @param array|string $paths The PSR-4 base directories |
||||
* |
||||
* @throws \InvalidArgumentException |
||||
*/ |
||||
public function setPsr4($prefix, $paths) |
||||
{ |
||||
if (!$prefix) { |
||||
$this->fallbackDirsPsr4 = (array) $paths; |
||||
} else { |
||||
$length = strlen($prefix); |
||||
if ('\\' !== $prefix[$length - 1]) { |
||||
throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); |
||||
} |
||||
$this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; |
||||
$this->prefixDirsPsr4[$prefix] = (array) $paths; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Turns on searching the include path for class files. |
||||
* |
||||
* @param bool $useIncludePath |
||||
*/ |
||||
public function setUseIncludePath($useIncludePath) |
||||
{ |
||||
$this->useIncludePath = $useIncludePath; |
||||
} |
||||
|
||||
/** |
||||
* Can be used to check if the autoloader uses the include path to check |
||||
* for classes. |
||||
* |
||||
* @return bool |
||||
*/ |
||||
public function getUseIncludePath() |
||||
{ |
||||
return $this->useIncludePath; |
||||
} |
||||
|
||||
/** |
||||
* Turns off searching the prefix and fallback directories for classes |
||||
* that have not been registered with the class map. |
||||
* |
||||
* @param bool $classMapAuthoritative |
||||
*/ |
||||
public function setClassMapAuthoritative($classMapAuthoritative) |
||||
{ |
||||
$this->classMapAuthoritative = $classMapAuthoritative; |
||||
} |
||||
|
||||
/** |
||||
* Should class lookup fail if not found in the current class map? |
||||
* |
||||
* @return bool |
||||
*/ |
||||
public function isClassMapAuthoritative() |
||||
{ |
||||
return $this->classMapAuthoritative; |
||||
} |
||||
|
||||
/** |
||||
* APCu prefix to use to cache found/not-found classes, if the extension is enabled. |
||||
* |
||||
* @param string|null $apcuPrefix |
||||
*/ |
||||
public function setApcuPrefix($apcuPrefix) |
||||
{ |
||||
$this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null; |
||||
} |
||||
|
||||
/** |
||||
* The APCu prefix in use, or null if APCu caching is not enabled. |
||||
* |
||||
* @return string|null |
||||
*/ |
||||
public function getApcuPrefix() |
||||
{ |
||||
return $this->apcuPrefix; |
||||
} |
||||
|
||||
/** |
||||
* Registers this instance as an autoloader. |
||||
* |
||||
* @param bool $prepend Whether to prepend the autoloader or not |
||||
*/ |
||||
public function register($prepend = false) |
||||
{ |
||||
spl_autoload_register(array($this, 'loadClass'), true, $prepend); |
||||
} |
||||
|
||||
/** |
||||
* Unregisters this instance as an autoloader. |
||||
*/ |
||||
public function unregister() |
||||
{ |
||||
spl_autoload_unregister(array($this, 'loadClass')); |
||||
} |
||||
|
||||
/** |
||||
* Loads the given class or interface. |
||||
* |
||||
* @param string $class The name of the class |
||||
* @return bool|null True if loaded, null otherwise |
||||
*/ |
||||
public function loadClass($class) |
||||
{ |
||||
if ($file = $this->findFile($class)) { |
||||
includeFile($file); |
||||
|
||||
return true; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Finds the path to the file where the class is defined. |
||||
* |
||||
* @param string $class The name of the class |
||||
* |
||||
* @return string|false The path if found, false otherwise |
||||
*/ |
||||
public function findFile($class) |
||||
{ |
||||
// class map lookup |
||||
if (isset($this->classMap[$class])) { |
||||
return $this->classMap[$class]; |
||||
} |
||||
if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { |
||||
return false; |
||||
} |
||||
if (null !== $this->apcuPrefix) { |
||||
$file = apcu_fetch($this->apcuPrefix.$class, $hit); |
||||
if ($hit) { |
||||
return $file; |
||||
} |
||||
} |
||||
|
||||
$file = $this->findFileWithExtension($class, '.php'); |
||||
|
||||
// Search for Hack files if we are running on HHVM |
||||
if (false === $file && defined('HHVM_VERSION')) { |
||||
$file = $this->findFileWithExtension($class, '.hh'); |
||||
} |
||||
|
||||
if (null !== $this->apcuPrefix) { |
||||
apcu_add($this->apcuPrefix.$class, $file); |
||||
} |
||||
|
||||
if (false === $file) { |
||||
// Remember that this class does not exist. |
||||
$this->missingClasses[$class] = true; |
||||
} |
||||
|
||||
return $file; |
||||
} |
||||
|
||||
private function findFileWithExtension($class, $ext) |
||||
{ |
||||
// PSR-4 lookup |
||||
$logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; |
||||
|
||||
$first = $class[0]; |
||||
if (isset($this->prefixLengthsPsr4[$first])) { |
||||
$subPath = $class; |
||||
while (false !== $lastPos = strrpos($subPath, '\\')) { |
||||
$subPath = substr($subPath, 0, $lastPos); |
||||
$search = $subPath . '\\'; |
||||
if (isset($this->prefixDirsPsr4[$search])) { |
||||
$pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); |
||||
foreach ($this->prefixDirsPsr4[$search] as $dir) { |
||||
if (file_exists($file = $dir . $pathEnd)) { |
||||
return $file; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
// PSR-4 fallback dirs |
||||
foreach ($this->fallbackDirsPsr4 as $dir) { |
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { |
||||
return $file; |
||||
} |
||||
} |
||||
|
||||
// PSR-0 lookup |
||||
if (false !== $pos = strrpos($class, '\\')) { |
||||
// namespaced class name |
||||
$logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) |
||||
. strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); |
||||
} else { |
||||
// PEAR-like class name |
||||
$logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; |
||||
} |
||||
|
||||
if (isset($this->prefixesPsr0[$first])) { |
||||
foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { |
||||
if (0 === strpos($class, $prefix)) { |
||||
foreach ($dirs as $dir) { |
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
||||
return $file; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
// PSR-0 fallback dirs |
||||
foreach ($this->fallbackDirsPsr0 as $dir) { |
||||
if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { |
||||
return $file; |
||||
} |
||||
} |
||||
|
||||
// PSR-0 include paths. |
||||
if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { |
||||
return $file; |
||||
} |
||||
|
||||
return false; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* Scope isolated include. |
||||
* |
||||
* Prevents access to $this/self from included files. |
||||
*/ |
||||
function includeFile($file) |
||||
{ |
||||
include $file; |
||||
} |
@ -0,0 +1,21 @@ |
||||
|
||||
Copyright (c) Nils Adermann, Jordi Boggiano |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is furnished |
||||
to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
||||
THE SOFTWARE. |
||||
|
@ -0,0 +1,9 @@ |
||||
<?php |
||||
|
||||
// autoload_classmap.php @generated by Composer |
||||
|
||||
$vendorDir = dirname(dirname(__FILE__)); |
||||
$baseDir = dirname($vendorDir); |
||||
|
||||
return array( |
||||
); |
@ -0,0 +1,9 @@ |
||||
<?php |
||||
|
||||
// autoload_namespaces.php @generated by Composer |
||||
|
||||
$vendorDir = dirname(dirname(__FILE__)); |
||||
$baseDir = dirname($vendorDir); |
||||
|
||||
return array( |
||||
); |
@ -0,0 +1,10 @@ |
||||
<?php |
||||
|
||||
// autoload_psr4.php @generated by Composer |
||||
|
||||
$vendorDir = dirname(dirname(__FILE__)); |
||||
$baseDir = dirname($vendorDir); |
||||
|
||||
return array( |
||||
'Metowolf\\' => array($vendorDir . '/metowolf/meting/src'), |
||||
); |
@ -0,0 +1,52 @@ |
||||
<?php |
||||
|
||||
// autoload_real.php @generated by Composer |
||||
|
||||
class ComposerAutoloaderInit7bd602fdce79cdf3c88e3cdb52a761f5 |
||||
{ |
||||
private static $loader; |
||||
|
||||
public static function loadClassLoader($class) |
||||
{ |
||||
if ('Composer\Autoload\ClassLoader' === $class) { |
||||
require __DIR__ . '/ClassLoader.php'; |
||||
} |
||||
} |
||||
|
||||
public static function getLoader() |
||||
{ |
||||
if (null !== self::$loader) { |
||||
return self::$loader; |
||||
} |
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit7bd602fdce79cdf3c88e3cdb52a761f5', 'loadClassLoader'), true, true); |
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader(); |
||||
spl_autoload_unregister(array('ComposerAutoloaderInit7bd602fdce79cdf3c88e3cdb52a761f5', 'loadClassLoader')); |
||||
|
||||
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); |
||||
if ($useStaticLoader) { |
||||
require_once __DIR__ . '/autoload_static.php'; |
||||
|
||||
call_user_func(\Composer\Autoload\ComposerStaticInit7bd602fdce79cdf3c88e3cdb52a761f5::getInitializer($loader)); |
||||
} else { |
||||
$map = require __DIR__ . '/autoload_namespaces.php'; |
||||
foreach ($map as $namespace => $path) { |
||||
$loader->set($namespace, $path); |
||||
} |
||||
|
||||
$map = require __DIR__ . '/autoload_psr4.php'; |
||||
foreach ($map as $namespace => $path) { |
||||
$loader->setPsr4($namespace, $path); |
||||
} |
||||
|
||||
$classMap = require __DIR__ . '/autoload_classmap.php'; |
||||
if ($classMap) { |
||||
$loader->addClassMap($classMap); |
||||
} |
||||
} |
||||
|
||||
$loader->register(true); |
||||
|
||||
return $loader; |
||||
} |
||||
} |
@ -0,0 +1,31 @@ |
||||
<?php |
||||
|
||||
// autoload_static.php @generated by Composer |
||||
|
||||
namespace Composer\Autoload; |
||||
|
||||
class ComposerStaticInit7bd602fdce79cdf3c88e3cdb52a761f5 |
||||
{ |
||||
public static $prefixLengthsPsr4 = array ( |
||||
'M' => |
||||
array ( |
||||
'Metowolf\\' => 9, |
||||
), |
||||
); |
||||
|
||||
public static $prefixDirsPsr4 = array ( |
||||
'Metowolf\\' => |
||||
array ( |
||||
0 => __DIR__ . '/..' . '/metowolf/meting/src', |
||||
), |
||||
); |
||||
|
||||
public static function getInitializer(ClassLoader $loader) |
||||
{ |
||||
return \Closure::bind(function () use ($loader) { |
||||
$loader->prefixLengthsPsr4 = ComposerStaticInit7bd602fdce79cdf3c88e3cdb52a761f5::$prefixLengthsPsr4; |
||||
$loader->prefixDirsPsr4 = ComposerStaticInit7bd602fdce79cdf3c88e3cdb52a761f5::$prefixDirsPsr4; |
||||
|
||||
}, null, ClassLoader::class); |
||||
} |
||||
} |
@ -0,0 +1,54 @@ |
||||
[ |
||||
{ |
||||
"name": "metowolf/meting", |
||||
"version": "v1.5.7", |
||||
"version_normalized": "1.5.7.0", |
||||
"source": { |
||||
"type": "git", |
||||
"url": "https://github.com/metowolf/Meting.git", |
||||
"reference": "54178aa112da5db09f487d862d7ae62cbf7bc060" |
||||
}, |
||||
"dist": { |
||||
"type": "zip", |
||||
"url": "https://api.github.com/repos/metowolf/Meting/zipball/54178aa112da5db09f487d862d7ae62cbf7bc060", |
||||
"reference": "54178aa112da5db09f487d862d7ae62cbf7bc060", |
||||
"shasum": "" |
||||
}, |
||||
"require": { |
||||
"ext-curl": "*", |
||||
"ext-openssl": "*", |
||||
"php": ">=5.4.0" |
||||
}, |
||||
"suggest": { |
||||
"ext-bcmath": "Required to use BC Math calculate RSA.", |
||||
"ext-openssl": "Required to use OpenSSL encrypt params." |
||||
}, |
||||
"time": "2019-06-16T05:55:00+00:00", |
||||
"type": "library", |
||||
"installation-source": "dist", |
||||
"autoload": { |
||||
"psr-4": { |
||||
"Metowolf\\": "src/" |
||||
} |
||||
}, |
||||
"notification-url": "https://packagist.org/downloads/", |
||||
"license": [ |
||||
"MIT" |
||||
], |
||||
"authors": [ |
||||
{ |
||||
"name": "metowolf", |
||||
"email": "i@i-meto.com", |
||||
"homepage": "https://i-meto.com" |
||||
} |
||||
], |
||||
"description": "A powerful music API framework to accelerate development.", |
||||
"homepage": "https://github.com/metowolf/Meting", |
||||
"keywords": [ |
||||
"lightweight", |
||||
"lighty", |
||||
"music api", |
||||
"php music" |
||||
] |
||||
} |
||||
] |
@ -0,0 +1,24 @@ |
||||
root = true |
||||
|
||||
[*] |
||||
charset = utf-8 |
||||
end_of_line = lf |
||||
insert_final_newline = true |
||||
indent_style = space |
||||
indent_size = 2 |
||||
trim_trailing_whitespace = true |
||||
|
||||
[*.md] |
||||
trim_trailing_whitespace = false |
||||
|
||||
[*.yml] |
||||
indent_style = space |
||||
indent_size = 2 |
||||
|
||||
[*.php] |
||||
indent_style = space |
||||
indent_size = 4 |
||||
|
||||
[*.sh] |
||||
indent_style = space |
||||
indent_size = 4 |
@ -0,0 +1,3 @@ |
||||
vendor/ |
||||
composer.lock |
||||
.idea/ |
@ -0,0 +1,28 @@ |
||||
language: php |
||||
|
||||
matrix: |
||||
fast_finish: true |
||||
|
||||
include: |
||||
- php: '5.4' |
||||
- php: '5.5' |
||||
- php: '5.6' |
||||
- php: '7.0' |
||||
- php: '7.1' |
||||
- php: '7.2' |
||||
- php: '7.3' |
||||
- php: 'nightly' |
||||
- php: 'hhvm' |
||||
|
||||
allow_failures: |
||||
- php: '5.4' |
||||
- php: '5.5' |
||||
- php: '5.6' |
||||
- php: '7.0' |
||||
- php: 'nightly' |
||||
- php: 'hhvm' |
||||
|
||||
sudo: false |
||||
|
||||
script: |
||||
- find -L . -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l |
@ -0,0 +1,21 @@ |
||||
MIT License |
||||
|
||||
Copyright (c) 2018 METO <i@i-meto.com> |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
SOFTWARE. |
@ -0,0 +1,92 @@ |
||||
<p align="center"> |
||||
<img src="https://user-images.githubusercontent.com/2666735/30165599-36623bea-93a6-11e7-8956-1ddf99ce0e6f.png" alt="Meting"> |
||||
</p> |
||||
|
||||
<p align="center"> |
||||
<a href="https://i-meto.com"><img alt="Author" src="https://img.shields.io/badge/Author-METO-blue.svg?style=flat-square"/></a> |
||||
<a href="https://packagist.org/packages/metowolf/Meting"><img alt="Version" src="https://img.shields.io/packagist/v/metowolf/Meting.svg?style=flat-square"/></a> |
||||
<a href="https://packagist.org/packages/metowolf/meting/stats"><img alt="Downloads" src="https://img.shields.io/packagist/dt/metowolf/Meting.svg?style=flat-square"/></a> |
||||
<a href="https://travis-ci.org/metowolf/Meting"><img alt="Travis" src="https://img.shields.io/travis/metowolf/Meting.svg?style=flat-square"></a> |
||||
<img alt="License" src="https://img.shields.io/packagist/l/metowolf/Meting.svg?style=flat-square"/> |
||||
</p> |
||||
|
||||
> :cake: Wow, such a powerful music API framework |
||||
|
||||
## Introduction |
||||
A powerful music API framework to accelerate your development |
||||
+ **Elegant** - Easy to use, a standardized format for all music platforms. |
||||
+ **Lightweight** - A single-file library that's less than 46KB. |
||||
+ **Powerful** - Support various music platforms, including Tencent, NetEase, Xiami, KuGou, Baidu and more. |
||||
+ **Free** - Under MIT license, need I say more? |
||||
|
||||
## Requirement |
||||
PHP 5.4+ and BCMath, Curl, OpenSSL extension installed. |
||||
|
||||
## Installation |
||||
Require this package, with [Composer](https://getcomposer.org), in the root directory of your project. |
||||
|
||||
```bash |
||||
$ composer require metowolf/meting |
||||
``` |
||||
|
||||
Then you can import the class into your application: |
||||
|
||||
```php |
||||
use Metowolf\Meting; |
||||
|
||||
$api = new Meting('netease'); |
||||
|
||||
$data = $api->format(true)->search('Soldier'); |
||||
``` |
||||
|
||||
> **Note:** Meting requires [BCMath](http://php.net/manual/en/book.bc.php), [cURL](http://php.net/manual/en/book.curl.php) and [OpenSSL](http://php.net/manual/en/book.openssl.php) extension in order to work. |
||||
|
||||
|
||||
## Quick Start |
||||
```php |
||||
require 'vendor/autoload.php'; |
||||
// require 'Meting.php'; |
||||
|
||||
use Metowolf\Meting; |
||||
|
||||
// Initialize to netease API |
||||
$api = new Meting('netease'); |
||||
|
||||
// Use custom cookie (option) |
||||
// $api->cookie('paste your cookie'); |
||||
|
||||
// Get data |
||||
$data = $api->format(true)->search('Soldier', [ |
||||
'page' => 1, |
||||
'limit' => 50 |
||||
]); |
||||
|
||||
echo $data; |
||||
// [{"id":35847388,"name":"Hello","artist":["Adele"],"album":"Hello","pic_id":"1407374890649284","url_id":35847388,"lyric_id":35847388,"source":"netease"},{"id":33211676,"name":"Hello","artist":["OMFG"],"album":"Hello",... |
||||
|
||||
// Parse link |
||||
$data = $api->format(true)->url(35847388); |
||||
|
||||
echo $data; |
||||
// {"url":"http:\/\/...","size":4729252,"br":128} |
||||
``` |
||||
|
||||
## More usage |
||||
- [docs](https://github.com/metowolf/Meting/wiki) |
||||
- [special for netease](https://github.com/metowolf/Meting/wiki/special-for-netease) |
||||
|
||||
## Join the Discussion |
||||
- [Telegram Group](https://t.me/adplayer) |
||||
- [Official website](https://i-meto.com) |
||||
|
||||
## Related Projects |
||||
- [Hermit-X (Wordpress)](https://github.com/MoePlayer/Hermit-X) |
||||
- [APlayer-Typecho](https://github.com/MoePlayer/APlayer-Typecho) |
||||
- [MKOnlineMusicPlayer](https://github.com/mengkunsoft/MKOnlineMusicPlayer) |
||||
- [WP-Player](https://github.com/webjyh/WP-Player) |
||||
|
||||
## Author |
||||
|
||||
**Meting** © [metowolf](https://github.com/metowolf), Released under the [MIT](./LICENSE) License.<br> |
||||
|
||||
> Blog [@meto](https://i-meto.com) · GitHub [@metowolf](https://github.com/metowolf) · Twitter [@metowolf](https://twitter.com/metowolf) · Telegram Channel [@metooooo](https://t.me/metooooo) |
@ -0,0 +1,38 @@ |
||||
{ |
||||
"name": "metowolf/meting", |
||||
"type": "library", |
||||
"description": "A powerful music API framework to accelerate development.", |
||||
"keywords": [ |
||||
"php music", |
||||
"music api", |
||||
"lighty", |
||||
"lightweight" |
||||
], |
||||
"homepage": "https://github.com/metowolf/Meting", |
||||
"license": "MIT", |
||||
"authors": [ |
||||
{ |
||||
"name": "metowolf", |
||||
"email": "i@i-meto.com", |
||||
"homepage": "https://i-meto.com" |
||||
} |
||||
], |
||||
"support": { |
||||
"issues": "https://github.com/metowolf/Meting/issues", |
||||
"source": "https://github.com/metowolf/Meting" |
||||
}, |
||||
"require": { |
||||
"php": ">=5.4.0", |
||||
"ext-curl": "*", |
||||
"ext-openssl": "*" |
||||
}, |
||||
"suggest": { |
||||
"ext-bcmath": "Required to use BC Math calculate RSA.", |
||||
"ext-openssl": "Required to use OpenSSL encrypt params." |
||||
}, |
||||
"autoload": { |
||||
"psr-4": { |
||||
"Metowolf\\" : "src/" |
||||
} |
||||
} |
||||
} |
File diff suppressed because it is too large
Load Diff
Loading…
Reference in new issue