Skip to content

Add secondary source for covert art images in order to increase coverage #507

@eric-gilbertson

Description

@eric-gilbertson

Add a secondary source for covert art images in order to increase coverage. Currently there is no cover art image for a fair number of library disks. The coverage could be increased by adding a secondary lookup against another source such as YouTube or MusicBrainz in cases where there is no Discogs image. Example code for doing this using the YouTube API is as follows:

Python example of album cover lookup using the YTMusic libraray

def findCoverArtUrl(artist, title):
yt = YTMusic()
search_key = '"' + artist + '" "' + title + '"'
search_results = yt.search(search_key, "albums")
print("YouTube search for -{}- found {} items".format(search_key, len(search_results)))

titleLC = title.lower().strip()
artistLC = artist.lower().strip()
singleResult = len(search_results) == 1 # assume perfect match if only 1 result
for item in search_results:
    itemTitleLC = item['title'].lower().strip()
    itemArtistLC = item['artists'][0]['name'].lower().strip()
    if singleResult or (itemTitleLC  == titleLC and artistLC == itemArtistLC):
        thumbnails = item['thumbnails']
        if len(thumbnails) >= 3:
            return item['thumbnails'][2]['url']
        else:
            print("No thumbnail")

return None

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions