desbma / sacad

Smart Automatic Cover Art Downloader
Mozilla Public License 2.0
318 stars 17 forks source link

script to help with selecting the best cover art #72

Closed hboetes closed 2 years ago

hboetes commented 2 years ago

I've created this little scriptlet to help me select the best of two files, since sacad usually finds the better image, but sometimes finds the wrong image.

So use find . -name 'cover.jpg' -size -100 -exec mv '{}' '{}.toosmall' \; to rename all too small cover files cover.jpg file to cover.jpg.toosmall, and then run the script.

I don't know if this is useful to anyone, perhaps just something to get you started. Currently works great with sway (the window manager), see screenshot.

#!/bin/zsh
swaymsg 'for_window [instance="feh"] floating disable'
swaymsg 'no_focus [instance="feh"]'

find . -name 'cover.jpg.toosmall' | while read dir; do
    (
        cd "${dir%/cover.jpg.toosmall}"
        pwd
        if [[ -e cover.jpg ]]; then
            # feh -D 1 cover.jpg.toosmall cover.jpg
            feh -w cover.jpg.toosmall cover.jpg &
            swaymsg focus floating
            echo -n 'Like the big one? [y/N]'
            read -sk1 a
            echo
            pkill -u $USER feh
            case $a in
                y|Y)
                    rm cover.jpg.toosmall
                    ;;
                n|N|*)
                    rm cover.jpg
                    mv cover.jpg.toosmall cover.jpg
                    ;;
            esac
        else
            mv cover.jpg.toosmall cover.jpg
        fi
    )
done
swaymsg 'for_window [instance="feh"] floating enable'

screenshot_2022-08-07_21-07-57_057584209

hboetes commented 2 years ago

So what you can see in the screenshot is left the original but very small cover art for the album the burning world, of the swans and the right side the downloaded new album art for a completely different album. Floating over the middle is the directory to give a hint what the right album is and the question which one to keep.

Now all you have to do is press the N button and you'll restore the original album and the new one gets deleted

desbma commented 2 years ago

This seems highly specific to your usage and environment, so I will not add this kind of script in the Sacad repository.

However I would appreciate examples of queries with parameters passed to Sacad that give wrong results when there is a better result available that is not picked. Looking at those closely can allow me to fix bugs and improve the selection algorithm.

hboetes commented 2 years ago

This seems highly specific to your usage and environment, so I will not add this kind of script in the Sacad repository.

I fully understand, it was meant as a showcase of how to do things and what I ran into.

However I would appreciate examples of queries with parameters passed to Sacad that give wrong results when there is a better result available that is not picked. Looking at those closely can allow me to fix bugs and improve the selection algorithm.

I simply ran: sacad_r . 900 cover.jpg, is that pushing it? Also I've got a collection with lots of rare albums, sometimes with rather unspecific band names. The success rate was about 90%, you don't hear me complain. Though I must say, Amazon was the source for the most misses.

desbma commented 2 years ago

Can you give me some examples of those rare albums, where sacad fails to choose the right cover?

hboetes commented 2 years ago

Sure:

desbma commented 2 years ago

For Aldous Harding / Designer, 900 px, JPEG search I get https://e-cdns-images.dzcdn.net/images/cover/aafbd2319ea669ed5aeaaafe5405684c/1000x1000-000000-80-0-0.jpg as a result. Isn't it the correct cover?

hboetes commented 2 years ago

Yes, it is, it showed up in the list because even a high res image of that picture will be below 50k, since there's barely anything on it. Sorry for the false positive.

desbma commented 2 years ago

For Arcana / Cantar De Procella, Sacad correctly identifies https://lastfm.freetls.fastly.net/i/u/300x300/0d35404b4cab1aaf95ac5714eb7398d6.jpg as the reference image, but can not use it directly because it is 300x300 and you requested 900x900 with a 25% delta tolerance (the default), so 675x675 minimum.

The result that is downloaded, https://e-cdns-images.dzcdn.net/images/cover/58347ef9ea58c0a7698ed39242695b57/1000x1000-000000-80-0-0.jpg, is correctly identified as NOT similar to reference (using a perceptual hash), you can see it if you pass -v debug:

DEBUG [Cover] DeezerCoverSourceResult 'https://e-cdns-images.dzcdn.net/images/cover/58347ef9ea58c0a7698ed39242695b57/1000x1000-000000-80-0-0.jpg' is NOT similar to reference

But unfortunately this is the best cover available that match set search criterias.

If you want the correct result, with a smaller size only if needed, pass -t 75 which increases size toleance, see sacad -h:

  -t SIZE_TOLERANCE_PRCT, --size-tolerance SIZE_TOLERANCE_PRCT
                        Tolerate this percentage of size difference with the target size. Note that covers with size above or close to the target size will still be preferred if available
                        (default: 25)

I have not looked at your other examples, but I suspect this is often the same issue.

hboetes commented 2 years ago

I tried your suggestion with Sigur Ros - Ba Ba Ti Ki Di Do and the right image is: https://www.discogs.com/master/22939-Sigur-R%C3%B3s-Ba-Ba-Ti-Ki-Di-Do/image/SW1hZ2U6NTI4NTkx

But it found this image https://www.discogs.com/master/22939-Sigur-R%C3%B3s-Ba-Ba-Ti-Ki-Di-Do/image/SW1hZ2U6NTkyNzA0MzE=

Pretty close, since it's art from the same album, but it's not the cover art. Does sacad use discogs as a potential source?

desbma commented 2 years ago

I get a blank cover for that query (https://e-cdns-images.dzcdn.net/images/cover/d8cd9a32f4f393a589b9067a41ad5917/1000x1000-000000-80-0-0.jpg), because that is what Deezer has : https://www.deezer.com/fr/album/312444

Amazon has what you describe as the right cover as its first result: https://m.media-amazon.com/images/I/71jrw2hq0oL.jpg but Sacad considers Deezer as more reliable source than Amazon which has a tendency to return images of unrelated products for difficult queries. In that case Last.fm has no results, so Sacad can not use perceptual hashes to discriminate what looks like right/wrong covers, so this is what we get.

I don't see any way to improve the choice algorithm in this case without hurting result quality for some other queries.

wbtcpip2 commented 2 years ago

hi, i'm on windows 10 and when i issue this command line: sacad.exe -v quiet -t 75 "BOLCHI" "HANDLE LOVE" 320 "D:\GB32\Pictures\BOLCHI - HANDLE LOVE.jpg"

i expect to get this cover: https://www.discogs.com/it/release/2609772-Bolchi-City-Trippin but instead i get a pic from nowhere 2022-08-13_162624

am im doing something wrong?

hboetes commented 2 years ago

I think you miss a great source of images in discogs,

for example, sacad -t 75 "herman van veen" "nu en dan" 900 cover_sacad.jpg resulted in this picture: cover2 Whilst I found https://i.discogs.com/RPnEkAkMHfKzwgKhz-FlZM-cgb_lLmWka5UsY7U8-mE/rs:fit/g:sm/q:90/h:599/w:600/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTczNzQy/OS0xNjMwOTY3OTQy/LTk2MTYuanBlZw.jpeg on discogs.

desbma commented 2 years ago

hi, i'm on windows 10 and when i issue this command line: sacad.exe -v quiet -t 75 "BOLCHI" "HANDLE LOVE" 320 "D:\GB32\Pictures\BOLCHI - HANDLE LOVE.jpg"

i expect to get this cover: https://www.discogs.com/it/release/2609772-Bolchi-City-Trippin but instead i get a pic from nowhere 2022-08-13_162624

am im doing something wrong?

You are searching for a track name.

desbma commented 2 years ago

I think you miss a great source of images in discogs,

for example, sacad -t 75 "herman van veen" "nu en dan" 900 cover_sacad.jpg resulted in this picture: cover2 Whilst I found https://i.discogs.com/RPnEkAkMHfKzwgKhz-FlZM-cgb_lLmWka5UsY7U8-mE/rs:fit/g:sm/q:90/h:599/w:600/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTczNzQy/OS0xNjMwOTY3OTQy/LTk2MTYuanBlZw.jpeg on discogs.

I agree with you for Discogs (I am looking into it), but your example is not very convincing. ~Sacad returns https://e-cdns-images.dzcdn.net/images/cover/560ac499910d200228975204c6338bae/1000x1000-000000-80-0-0.jpg for me.~ (actually its the same as your image with -t 75) As for your 2 images they look the same to me, and discogs also returns the first one: https://i.discogs.com/XQcs6QEkFGF6jPPErGCDOISVcnMqsPsh-g4pT5xmmLM/rs:fit/g:sm/q:90/h:514/w:579/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTczNzQy/OS0xMjk0NTg4MzEy/LmpwZWc.jpeg.

wbtcpip2 commented 2 years ago

if you search for BOLCHI - HANDLE LOVE on google it return imemdiately the right result, why sacad cannot do the same?

2022-08-14_151319

desbma commented 2 years ago

Because the Google Images source is currently broken :)

But worry not, I have added a source for Discogs, which returns that result, will push it in a few minutes.

desbma commented 2 years ago

@hboetes Discogs source has been added in 416569051834977d7fffc30b020fc2998f3adeb6, please test and I will release a new version soon.

hboetes commented 2 years ago

Thanks! Of course this is a very rare album.

Mind over 4, out here:

Right cover art: https://www.discogs.com/master/599452-Mind-Over-4-Out-Here/image/SW1hZ2U6MTc5ODk3NjI= But I got: https://m.media-amazon.com/images/I/61jmTxMF8YL.jpg

Can you reproduce that?

hboetes commented 2 years ago

Ah, one that came from discogs:

Marillion, Marbles

Right coverart: https://www.rockshop.ro/images/product/475-marillion-marblesjpg.jpg I got this one: https://i.discogs.com/rkL4BkUxgSQNL29aJRzxpJTWjvjD3mlI-SSXylwx1Cw/rs:fit/g:sm/q:90/h:689/w:600/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTk4Nzkw/MjQtMTQ4Nzg0NzE0/OC01NjQxLnBuZw.jpeg

the more modest request of 600 instead of 900 results in: https://i.discogs.com/IGhmK6q8Q6yS27SVwAzZs-Gd6rtprLmoDQRf_e70fPQ/rs:fit/g:sm/q:90/h:614/w:600/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTE4MDQ0/MzQ3LTE2MTcxNjgy/OTgtMTUxNC5qcGVn.jpeg

desbma commented 2 years ago

For Marillon / Marbles I always get https://m.media-amazon.com/images/I/81pbhP3-LsL.jpg

desbma commented 2 years ago

For Mind over 4 / out here, it works if you spell "Mind over Four". Don't ask me why, the Discogs API returns results for this and not with a "4".

hboetes commented 2 years ago

For Marillon / Marbles I always get https://m.media-amazon.com/images/I/81pbhP3-LsL.jpg

which options did you use? I used sacad_r -v -t75 . 600 cover2.jpg

hboetes commented 2 years ago

For Mind over 4 / out here, it works if you spell "Mind over Four". Don't ask me why, the Discogs API returns results for this and not with a "4".

Go figure, I always thought it was written with 4: https://en.wikipedia.org/wiki/Mind_Over_Four

wbtcpip2 commented 2 years ago

thank you, i will test it tomorrow!

desbma commented 2 years ago

For Marillon / Marbles I always get https://m.media-amazon.com/images/I/81pbhP3-LsL.jpg

which options did you use? I used sacad_r -v -t75 . 600 cover2.jpg

$ python -m sacad Marillon Marbles 600 /tmp/a.jpg -t 75
AmazonDigitalCoverSource: Got 16 relevant (0 excluded) results from source 'AmazonDigitalCoverSource'
DeezerCoverSource: Got 0 relevant (0 excluded) results from source 'DeezerCoverSource'
LastFmCoverSource: Got 0 relevant (0 excluded) results from source 'LastFmCoverSource'
DiscogsCoverSource: Got 0 relevant (0 excluded) results from source 'DiscogsCoverSource'
GoogleImagesWebScrapeCoverSource: Got 0 relevant (0 excluded) results from source 'GoogleImagesWebScrapeCoverSource'
AmazonCdCoverSource: Got 0 relevant (0 excluded) results from source 'AmazonCdCoverSource'
Cover: Removed 14 duplicate results
Cover: No reference result found
Cover: Downloading cover 'https://m.media-amazon.com/images/I/81pbhP3-LsL.jpg' (part 1/1)...
Cover: Resizing from 2560x2560 to 600x600...
Cover: Crunching JPEG image...

Maybe you have been blocked by Amazon for doing too many requests?

hboetes commented 2 years ago

Nah, I figured it out: DNSSEC was enabled on my unbound server. Not a good idea.

desbma commented 2 years ago

Sacad 2.6.0 has been released, with the added Discogs source, and a few improvements around result sorting with regard to source quality.

I am closing this issue.

For next "result quality" issues, instead of overly broad problems, next time please open issue with: