thumbnails: create thumbnail dirs if needed

This commit is contained in:
Bruno Cauet 2015-01-27 16:22:51 +01:00
parent 5b8a846d1f
commit 55fd2d2886

View file

@ -31,6 +31,11 @@ from beets.util import syspath, displayable_path
from beets.util.artresizer import ArtResizer
BASE_DIR = os.path.join(BaseDirectory.xdg_cache_home, "thumbnails")
NORMAL_DIR = os.path.join(BASE_DIR, "normal")
LARGE_DIR = os.path.join(BASE_DIR, "large")
class ThumbnailsPlugin(BeetsPlugin):
def __init__(self):
super(ThumbnailsPlugin, self).__init__()
@ -56,6 +61,11 @@ class ThumbnailsPlugin(BeetsPlugin):
self._log.warning("No local image resizing capabilities, "
"cannot generate thumbnails")
return False
for dir in (NORMAL_DIR, LARGE_DIR):
if not os.path.exists(dir):
os.makedirs(dir)
return True
def process_album(self, album):
@ -68,8 +78,6 @@ class ThumbnailsPlugin(BeetsPlugin):
self._log.info(u'album {0} has no art', album)
return
# FIXME should create dirs if needed?
# FIXME should handle covers smaller than 256x256
# see http://standards.freedesktop.org/thumbnail-spec/latest/x122.html