stephan-strate / php-cover-art-archive-api
PHP对CoverArtArchive api的封装。支持使用存储库和工厂进行面向对象访问。
v1.0.3
2022-08-06 10:56 UTC
Requires
- php: ^7.4 || ^8.0
- ext-gd: *
- ext-json: *
- doctrine/annotations: ^1.11
- php-http/client-common: ^2.3
- php-http/client-implementation: ^1.0
- php-http/discovery: ^1.10
- php-http/httplug: ^2.2
- symfony/property-access: ^5.2
- symfony/serializer: ^5.2
Requires (Dev)
- guzzlehttp/guzzle: ^7.2
- guzzlehttp/psr7: ^1.2 || ^2.0
- http-interop/http-factory-guzzle: ^1.0
- php-http/mock-client: ^1.4.1
- phpstan/phpstan: ^0.12.75 || ^1.0.0
- phpunit/phpunit: ^9.3
- dev-master
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- v0.0.3-alpha
- v0.0.2-alpha
- v0.0.1-alpha
- dev-dependabot/composer/phpstan/phpstan-1.10.11
- dev-dependabot/composer/symfony/property-access-5.4.22
- dev-dependabot/composer/phpunit/phpunit-9.6.6
- dev-dependabot/composer/doctrine/annotations-2.0.1
- dev-dependabot/composer/php-http/client-common-2.6.0
This package is auto-updated.
Last update: 2024-09-04 23:11:49 UTC
README
CoverArtArchive API包装器
CoverArtArchive是Internet Archive和MusicBrainz的联合项目。该项目的目标是让封面艺术图片对每个人可用。
使用此API包装器,您可以使用MusicBrainz的发布MBID检索封面艺术图片。
建议与stephan-strate/php-music-brainz-api一起使用。
受php-github-api和php-tmdb的启发。
安装
使用composer
$ composer require stephan-strate/php-cover-art-archive-api php-http/guzzle7-adapter:^1.0 http-interop/http-factory-guzzle:^1.0
为什么使用php-http/guzzle7-adapter:^1.0
?这个库使用HTTPlug与任何HTTP客户端解耦。
用法
首先创建客户端
$client = new \CoverArtArchive\Client();
使用此客户端,您可以检索所有其他对象/API。
存储库
存储库实现将解码的JSON响应映射到匹配的模型。这是使用库的首选方式。
$repository = new \CoverArtArchive\Repository\ReleaseGroupRepository($client); $repository->coverArt('19e6209b-2ddc-30b8-9273-484bd075fe7b');
图片
由于CoverArtArchive提供的是图片,因此存储库还可以返回图片资源。
$repository = new \CoverArtArchive\Repository\ReleaseRepository($client); $image = $repository->coverArtFront('7416e707-94b5-3810-b6b8-4229ab2182ec'); // outputs the image to the user if ($image !== false) { header('Content-Type: image/png'); imagepng($image); imagedestroy($image); }
API
API实现返回端点的原始JSON响应。您可能想使用存储库实现来获取解析的对象。
$release = $client->release(); $release->coverArt('7416e707-94b5-3810-b6b8-4229ab2182ec');
贡献
帮助与捐赠
我非常好奇使用我的库的项目。请给我发一条简短的信息,说明您如何使用这个库。您可以在我的个人资料(LinkedIn,电子邮件)上找到我的联系信息。
如果这个项目为您节省了时间和金钱,或者您只是欣赏我所做的事情,请考虑赞助我 😊