Album art: screen for 1x1 gif from Amazon
authorAndrew Strong <andrew.david.strong@gmail.com>
Sun, 10 May 2015 10:02:30 +0000 (20:02 +1000)
committerAndrew Strong <andrew.david.strong@gmail.com>
Sun, 10 May 2015 10:02:30 +0000 (20:02 +1000)
When there is no cover image on Amazon there should be an error
message. Instead a 1x1 pixel gif is provided for download which
is used by abcde as album art. This patch provides a simple size
test which will delete the troublesome gif and then allow glyrc
to download. Thanks to Johannes Gernemann for the patch which
resolves Issue 141.

abcde

diff --git a/abcde b/abcde
index 370e327..cffeb41 100755 (executable)
--- a/abcde
+++ b/abcde
@@ -3014,6 +3014,14 @@ do_getalbumart()
                                                $HTTPGET "$ALBUMARTURL" > "$ABCDETEMPDIR/$ALBUMARTFILE"
                                                if [ $? -ne 0 ]; then
                                                        vecho "could not download cover from amazon" >&2
+                                               else
+                                                       # Check that size is reasonable; sometimes when there is no cover image
+                                                       # on amazon.com a 1x1 pixel gif image will be downloaded instead:
+                                                       FILESIZE=$(wc -c < "$ABCDETEMPDIR/$ALBUMARTFILE")
+                                                       if [ "$FILESIZE" -lt 1024 ]; then
+                                                               rm "$ABCDETEMPDIR/$ALBUMARTFILE"
+                                                               vecho "could not download cover from amazon" >&2
+                                                       fi
                                                fi
                                        else
                                                vecho "no amazon ID found" >&2