A Laravel 5.* package to search the Gracenote Web API.
atomescrochus/laravel-gracenote package provide and easy way to interact with the Gracenote Web API from any Laravel 5.* application.
This package is usable in production, but should still be considered a work in progress (contribution welcomed!). It required PHP >=
You can install this package via composer:
$ composer require atomescrochus/laravel-gracenote
Then you have to install the package' service provider and alias, unless you are running Laravel >=5.5, then the package will auto discover itself:
// config/app.php 'providers' => [ ... Atomescrochus\Gracenote\GracenoteServiceProvider::class, ]; 'aliases' => [ .... 'GracenoteAPI' => Atomescrochus\Gracenote\Facades\Gracenote::class, ];
You will have to publish the configuration files also if you want to change the default value:
php artisan vendor:publish --provider="Atomescrochus\Gracenote\GracenoteServiceProvider" --tag="config"
You are also required to put the values you can fetch in your Gracenote developer account in your .env files:
GRACENOTE_CLIENT_ID=12345678 GRACENOTE_CLIENT_TAG=abcdefg12345678 GRACENOTE_USER_ID=wxyz-9876
NOTE: If you don't have your Gracenote user id, you can get it by setting the
GRACENOTE_CLIENT_TAG value, then run
php artisan gracenote:user-id. This will run the appropriate API call to fetch your user id so you can add it to your .env file.
use Atomescrochus\Gracenote\Facades\Gracenote as GracenoteAPI; // $results will be an object containing a collection of results and raw response data from Gracenote // here is an example query to search in the Gracenote database $results = GracenoteAPI::lang('eng') // natural language of metadata ->cache(120) // integer representing minutes to cache results for ->searchMode('single_best') // OPTIONAL. Can be 'single_best' or 'single_best_cover' ->searchType('track_title') //either 'track_title', 'album_title', or 'artist' ->query('Poker face') // the search query ->search(); // do some magic // if you happen to have a gracenote id, you can search for it in this fashion // you need not to set other options, it is all set by default to be sure the search by ID // won't fail on Gracenote's part. $results = GracenoteAPI::lang('eng') // natural language of metadata ->cache(120) // integer representing minutes to cache results for ->getTrackById('167695000-B4D3EE5FF9011CCFCF0296FF1D8E8131');
Some tests are provided. I don't think it's as extensive as it could be, but it shows expected behavior works well, assuming that Gracenote API is responding. The tests are also thought to be ran while the package is installed in Laravel, and not standalone. If anyone wants to improve on the current test, please do!
Please see CHANGELOG for more information on what has changed recently.
If you discover any security related issues, please email email@example.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.