Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

koel/koel

16858 stars
2 code files
View koel/koel on GitHub

app/Listeners/DownloadArtistImage.php

Open in GitHub
use App\Events\ArtistInformationFetched;
use App\Services\MediaMetadataService;
use Throwable;
 
class DownloadArtistImage
{
private MediaMetadataService $mediaMetadataService;
 
public function __construct(MediaMetadataService $mediaMetadataService)
{
$this->mediaMetadataService = $mediaMetadataService;
}
 
public function handle(ArtistInformationFetched $event): void
{
$info = $event->getInformation();
$artist = $event->getArtist();
 
$image = array_get($info, 'image');
 
if (!$artist->has_image && $image && ini_get('allow_url_fopen')) {
try {
$this->mediaMetadataService->downloadArtistImage($artist, $image);
} catch (Throwable $e) {
}
}
}
}

app/Providers/EventServiceProvider.php

Open in GitHub
use App\Events\ArtistInformationFetched;
use App\Listeners\DownloadArtistImage;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
 
class EventServiceProvider extends ServiceProvider
{
protected $listen = [
ArtistInformationFetched::class => [
DownloadArtistImage::class,
],
];
//
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.