Updated album-art thumbnail path calculation
authorIvan Frade <ivan.frade@gmail.com>
Tue, 15 Sep 2009 20:53:12 +0000 (23:53 +0300)
committerIvan Frade <ivan.frade@gmail.com>
Tue, 15 Sep 2009 20:53:12 +0000 (23:53 +0300)
Now MAFW is using the uri to request the album art

src/album_art_spec.py

index 6896465..4f1c90c 100644 (file)
@@ -6,6 +6,11 @@ import string
 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)
@@ -42,10 +47,14 @@ def getCoverArtFileName (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
 
@@ -57,6 +66,21 @@ def dropInsideContent(s, startMarker, endMarker):
     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))