COVERS_LOCATION = os.getenv ("HOME") + "/.cache/media-art/"
THUMBS_LOCATION = os.getenv ("HOME") + "/.thumbnails/cropped/"
+# Hardcoded locations for testing in scratchbox
+#
+#COVERS_LOCATION = "/home/user/.cache/media-art/"
+#THUMBS_LOCATION = "/home/user/.thumbnails/cropped/"
+
def getCoverArtFileName (album):
"""Returns the cover art's filename that is formed from the album name."""
album = unicode (album)
def getCoverArtThumbFileName (album):
artFile = getCoverArtFileName(album)
- thumbFile = THUMBS_LOCATION + md5.new(artFile).hexdigest()+".jpeg"
+ if not artFile.startswith ("file://"):
+ artFile = "file://" + artFile
+ thumbFile = THUMBS_LOCATION + md5.new(artFile).hexdigest() + ".jpeg"
return thumbFile
def get_thumb_filename_for_path (path):
+ if not path.startswith ("file://"):
+ path = "file://" + path
thumbnail = THUMBS_LOCATION + md5.new (path).hexdigest () + ".jpeg"
return thumbnail
return s
if __name__ == "__main__":
+ import sys
+ from optparse import OptionParser
+
+ parser = OptionParser()
+ parser.add_option ("-a", "--artist", dest="artist", type="string",
+ help="ARTIST to look for", metavar="ARTIST")
+ parser.add_option ("-b", "--album", dest="album", type="string",
+ help="ALBUM to look for", metavar="ALBUM")
+
+ (options, args) = parser.parse_args ()
+ print options
+ if (not options.artist and not options.album):
+ parser.print_help ()
+ sys.exit (-1)
- print "album art: %s" % (getCoverArtFileName (unicode("Absolution")))
- print "thumbnail: %s" % (getCoverArtThumbFileName (u"Absolution"))
+ print "Album art :", getCoverArtFileName (options.album)
+ print "Thumbnail (album):", getCoverArtThumbFileName (options.album)
+ print "Thumbnail (path) :", get_thumb_filename_for_path (getCoverArtFileName(options.album))