Skip to content
Snippets Groups Projects
Commit a6439c0b authored by ale's avatar ale
Browse files

serve an empty (transparent) jpeg when no album art is found

parent fe9a0c6f
No related branches found
No related tags found
No related merge requests found
...@@ -8,6 +8,10 @@ from lxml import etree ...@@ -8,6 +8,10 @@ from lxml import etree
from djrandom import utils from djrandom import utils
# A transparent 1x1 JPEG image, used when no album art is found.
NULL_JPEG = '\xff\xd8\xff\xe0\x00\x10JFIF\x00\x01\x01\x01\x00H\x00H\x00\x00\xff\xdb\x00C\x00\x03\x02\x02\x02\x02\x02\x03\x02\x02\x02\x03\x03\x03\x03\x04\x06\x04\x04\x04\x04\x04\x08\x06\x06\x05\x06\t\x08\n\n\t\x08\t\t\n\x0c\x0f\x0c\n\x0b\x0e\x0b\t\t\r\x11\r\x0e\x0f\x10\x10\x11\x10\n\x0c\x12\x13\x12\x10\x13\x0f\x10\x10\x10\xff\xc0\x00\x0b\x08\x00\x01\x00\x01\x01\x01\x11\x00\xff\xc4\x00\x14\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\t\xff\xc4\x00\x14\x10\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xda\x00\x08\x01\x01\x00\x00?\x00T\xdf\xff\xd9'
class AlbumImageDiskCache(object): class AlbumImageDiskCache(object):
"""Cache album art on disk. """Cache album art on disk.
...@@ -38,7 +42,8 @@ class AlbumImageDiskCache(object): ...@@ -38,7 +42,8 @@ class AlbumImageDiskCache(object):
return path return path
def set_negative_match(self, artist, album): def set_negative_match(self, artist, album):
open(self._path(artist, album), 'w').close() with open(self._path(artist, album), 'w') as fd:
fd.write(NULL_JPEG)
def download(self, artist, album, url): def download(self, artist, album, url):
"""Download url and convert to JPEG.""" """Download url and convert to JPEG."""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment