yeboahnanaosei / acoust
acoustid.org API 的简单单类包装器
v1.0.1
2018-08-19 21:51 UTC
Requires
- php: >=7.1
This package is auto-updated.
Last update: 2024-09-20 11:56:15 UTC
README
此包能做什么 🔨
- 使用 chromaprint 生成或检索歌曲的指纹和时长
- 使用歌曲的指纹在 acoustid.org 数据库中执行查找
安装
只需运行
composer require yeboahnanaosei/acoust
如何使用此包
您可以通过两种方式使用此包
- 执行查找。 (您需要从 acoustid.org 获取应用程序 API 密钥)
- 生成歌曲的指纹和时长以用于其他目的。
1. 执行查找
执行查找非常简单,只需调用一个方法。
重要提示:要在 acoustid.org 数据库中查找歌曲,您应该已经从 acoustid.org 获取了
应用程序 API 密钥
try { // Set the needed parameters $song = 'Path to song'; # Always required $apiKey = 'API key'; # Required when performing a lookup $format = 'json or xml' # Optional. Defaults to 'json' if not supplied // Create instance of acoust // $format is optional and can be omitted // In that case $format will default to 'json' $acoust = new Acoust($apiKey, $song, $format); // All you need to do is to just call query() method // This method will return data from acoustid.org in // json format by default or in xml if you set your // format to xml $response = $acoust->query(); } catch (Throwable $e) { echo $e->getMessage(); }
2. 生成指纹或时长
要仅生成歌曲的指纹或时长,您只需要歌曲。不需要 API 密钥或响应格式
try { // Set needed parameters $song = 'Path to song'; // Create an instance of acoust $acoust = new Acoust($song) // Generate fingerprint or duration of the song as you wish $fingerprint = $acoust->getFingerprint(); $duration = $acoust->getDuration(); } catch (Throwable $e) { echo $e->getMessage(); }
贡献 ❤️
- 一如既往,欢迎提交拉取请求
- 请随时报告错误并提出改进建议