Skip to content

ppxko/Meting

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

103 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Meting

Author Version Downloads Travis License

🍰 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 51KB.
  • Powerful - Support various music platforms, including Tencent, NetEase, Xiami, KuGou, Baidu, Kuwo 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, in the root directory of your project.

$ composer require metowolf/meting

Then you can import the class into your application:

use Metowolf\Meting;

$api = new Meting('netease');

$data = $api->format(true)->search('Soldier');

Note: Meting requires BCMath, cURL and OpenSSL extension in order to work.

Quick Start

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

Join the Discussion

Related Projects

Author

Meting © metowolf, Released under the MIT License.

Blog @meto · GitHub @metowolf · Twitter @metowolf

Summary

仓库根目录下主要有以下文件和文件夹:

路径 作用说明 src/ 存放核心 PHP 源码,包含单文件 Meting.php,定义 Metowolf\Meting 类。 .github/workflows/ GitHub Actions 配置目录,其中 test.yml 用于在不同 PHP 版本下执行依赖安装及语法检查。 composer.json PHP 包描述与自动加载信息,声明 Metowolf\ 命名空间映射到 src/。 README.md 项目说明文档,介绍框架特性、安装方法等。 LICENSE 项目采用的 MIT 许可协议文件。 .git/ Git 版本控制数据(通常无需关注)。 整体来看,该项目结构非常简洁:源代码均位于 src/,使用 Composer 管理依赖和自动加载,并通过 .github 下的工作流在 CI 环境中执行基础的语法检查。

只包含 src/Meting.php 这一份库文件。该文件实现了多个与外部音乐平台交互的方法,其中不同平台的 API 地址通过 switch ($this->server) 语句指定。主要方法和对应的外部接口示例如下:

search($keyword, $option = null):用于搜索歌曲。根据平台不同,内部会访问:

http://music.163.com/api/cloudsearch/pc(网易云)

https://c.y.qq.com/soso/fcgi-bin/client_search_cp(腾讯)

https://acs.m.xiami.com/h5/mtop.alimusic.search.searchservice.searchsongs/1.0/(虾米)

http://mobilecdn.kugou.com/api/v3/search/song(酷狗)

http://musicapi.taihe.com/v1/restserver/ting(百度)

http://www.kuwo.cn/api/www/search/searchMusicBykeyWord(酷我)

song($id):查询歌曲详情。

http://music.163.com/api/v3/song/detail/(网易云)

https://c.y.qq.com/v8/fcg-bin/fcg_play_single_song.fcg(腾讯)

其余平台同理。

还有 album($id)、artist($id)、playlist($id)、url($id, $br = 320)、lyric($id)、pic($id, $size = 300) 等方法,每个方法内部根据平台会访问不同的外部地址(如网易云、腾讯、虾米、酷狗、百度、酷我等域名的接口)。

因此,该仓库只是一个用于调用外部音乐 API 的 PHP 库,没有内部页面路由或服务器端 API 接口。所有可用的“接口”体现在 Meting 类的公有方法上,以及其内部声明的外部请求地址。

Notes

The Meting library implements multiple music-platform APIs, including a set of NetEase Cloud Music interfaces. Each NetEase call is wrapped in a switch statement throughout src/Meting.php.

Summary

NetEase Cloud API endpoints in this project include:

Search songs – POST http://music.163.com/api/cloudsearch/pc

Song details – POST http://music.163.com/api/v3/song/detail/

Album tracks – POST http://music.163.com/api/v1/album/$id

Artist’s songs – POST http://music.163.com/api/v1/artist/$id

Playlist info – POST http://music.163.com/api/v6/playlist/detail

Get song URL – POST http://music.163.com/api/song/enhance/player/url

Lyrics – POST http://music.163.com/api/song/lyric

Album art – Constructed URL https://p3.music.126.net/{encryptId}/{id}.jpg

These lines show the specific NetEase endpoints leveraged by the library.

About

🍰 Wow, such a powerful music API framework

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • PHP 100.0%