[GH-ISSUE #428] Enhancement Request: Option to grab album cover from last.fm while syncing #304

Closed
opened 2026-02-26 02:32:45 +03:00 by kerem · 3 comments
Owner

Originally created by @lejafar on GitHub (Aug 26, 2016).
Original GitHub issue: https://github.com/koel/koel/issues/428

First of all, thanks for creating Koel, I absolutely love it!

But I'm really obsessive when it comes to album covers and currently as far as I understand from the code bellow Koel will not grab the album cover from Last.fm while syncing ...

if (!$album->has_cover) {
    // If the album has no cover, we try to get the cover image from existing tag data
    if (!empty($info['cover'])) {
        try {
            $album->generateCover($info['cover']);
        } catch (Exception $e) {
            Log::error($e);
        }
    }
    // or, if there's a cover image under the same directory, use it.
    elseif ($cover = $this->getCoverFileUnderSameDirectory()) {
        $album->copyCoverFile($cover);
    }
}

Only when the album is played, the cover will be updated using Last.fm ... I assume this was done to avoid slowing down the syncing process? As far as API limitation go, their TOS states "You will not make more than 5 requests per originating IP address per second, averaged over a 5 minute period"

So grabbing while syncing looks feasible? Could this be made an option?

Originally created by @lejafar on GitHub (Aug 26, 2016). Original GitHub issue: https://github.com/koel/koel/issues/428 First of all, thanks for creating Koel, I absolutely love it! But I'm really obsessive when it comes to album covers and currently as far as I understand from the code bellow Koel will not grab the album cover from Last.fm while syncing ... ``` php if (!$album->has_cover) { // If the album has no cover, we try to get the cover image from existing tag data if (!empty($info['cover'])) { try { $album->generateCover($info['cover']); } catch (Exception $e) { Log::error($e); } } // or, if there's a cover image under the same directory, use it. elseif ($cover = $this->getCoverFileUnderSameDirectory()) { $album->copyCoverFile($cover); } } ``` Only when the album is played, the cover will be updated using Last.fm ... I assume this was done to avoid slowing down the syncing process? As far as API limitation go, their [TOS](http://www.last.fm/api/tos) states _"You will not make more than 5 requests per originating IP address per second, averaged over a 5 minute period"_ So grabbing while syncing looks feasible? Could this be made an option?
kerem closed this issue 2026-02-26 02:32:45 +03:00
Author
Owner

@BernardGoldberger commented on GitHub (Aug 26, 2016):

One of the benefits of Last.fm is that the album/artist art is always being updated, in your senecio this will stop happening, it will be especially annoying for an album that at the time of the sync did not have art or had the wrong art and was later updated.

<!-- gh-comment-id:242774714 --> @BernardGoldberger commented on GitHub (Aug 26, 2016): One of the benefits of Last.fm is that the album/artist art is always being updated, in your senecio this will stop happening, it will be especially annoying for an album that at the time of the sync did not have art or had the wrong art and was later updated.
Author
Owner

@lejafar commented on GitHub (Aug 26, 2016):

I'm not saying checking for album art when an album is played should disappear. Just an optional grab while syncing, otherwise the album art is incomplete until you played all your albums ...

I'm thinking about something like:

if (!$album->has_cover) {
    // If the album has no cover, we try to get the cover image from existing tag data
    if (!empty($info['cover'])) {
        try {
            $album->generateCover($info['cover']);
        } catch (Exception $e) {
            Log::error($e);
        }
    }
    // or, if there's a cover image under the same directory, use it.
    elseif ($cover = $this->getCoverFileUnderSameDirectory()) {
        $album->copyCoverFile($cover);
    }
    // Else get it from Last.fm.
    else {
        try {
            $album->getInfo();
        } catch (Exception $e) {
            Log::error($e);
        }
    }
}
<!-- gh-comment-id:242782943 --> @lejafar commented on GitHub (Aug 26, 2016): I'm not saying checking for album art when an album is played should disappear. Just an optional _grab while syncing_, otherwise the album art is incomplete until you played all your albums ... I'm thinking about something like: ``` php if (!$album->has_cover) { // If the album has no cover, we try to get the cover image from existing tag data if (!empty($info['cover'])) { try { $album->generateCover($info['cover']); } catch (Exception $e) { Log::error($e); } } // or, if there's a cover image under the same directory, use it. elseif ($cover = $this->getCoverFileUnderSameDirectory()) { $album->copyCoverFile($cover); } // Else get it from Last.fm. else { try { $album->getInfo(); } catch (Exception $e) { Log::error($e); } } } ```
Author
Owner

@phanan commented on GitHub (Aug 28, 2016):

Yes, this would slow down the whole syncing process significantly. Maybe a .env option (GET_LASTFM_COVER_WHEN_SYNC?) instead, but I don't have time for it right now. Feel free to send a PR over ;)

<!-- gh-comment-id:242955768 --> @phanan commented on GitHub (Aug 28, 2016): Yes, this would slow down the whole syncing process significantly. Maybe a `.env` option (`GET_LASTFM_COVER_WHEN_SYNC`?) instead, but I don't have time for it right now. Feel free to send a PR over ;)
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/koel-koel#304
No description provided.