This site has been retired. For up to date information, see handbook.gnome.org or gitlab.gnome.org.


[Home] [TitleIndex] [WordIndex

Media Art Storage Spec

Version: This is a Draft

Authors

Goal

This specification provides a mechanism for applications to store and retrieve artwork associated with media content, like music from an album, the logo for a radio station, or a graphic representing a podcast. The storage medium for artwork is a file system, inside a user's home directory.

UPDATE 2010-02-18: Banshee now implements a simplified version of this spec, see bug 520516, comment 58

UPDATE 2013-10-02: There is now a GNOME platform library which implements this spec, see https://git.gnome.org/browse/libmediaart/

Things to think about

Dependencies

This specification depends on the XDG Base Directory Specification for the definition of the XDG_CACHE_HOME variable.

Generating a unique and safe file name

Stripping characters

For any identifier being mentioned below you need to strip unwanted characters

Also check out the sample character strip code in C.

Identifiers

You have to create two identifiers for the media. What to use is specified here:

If you want to store custom named art, you are required to use your productname as A, and the MD5 of whatever your come up with as B, and the MD5 of whatever your come up with as C. Any prefix A that you choose should match [a-z0-9]+. These self-chosen prefixes should not be mentioned here unless you plan to follow the exact specification for the prefix as defined in this specification (consider this specification as a global registration for prefixes).

Digests are calculated using the text encoded in UTF-8.

The storage

The location of the album-art image files is $XDG_CACHE_HOME/media-art. To determine the filename, concatenate A, "-", B, "-", C and ".jpeg".

$XDG_CACHE_HOME/media-art/A-B-C.jpeg

Additionally, when an application is writing data to this file, it should further append a .part suffix to the path. Only when the application is done writing to the file (i.e. it is downloading from a web service), should the file be moved to the final path. This prevents other applications from reading partially downloaded artwork.

However, applications which will download and store artwork according to this specification should check for the .part file before downloading, in case another application is already downloading the same artwork.

Example: Album of Metallica, And Justice For All

Lowercase of "Metallica" is "metallica" and for "And Justice For All" is "and justice for all. The MD5 for those two are 3c2234a7ce973bc1700e0c743d6a819c and 3d422ba022ae0daa8f5454ba7dfa0f9a. We separate them with a dash, we prepend to them $XDG_CACHE_HOME/media-art/, the kind (which is "album"), a dash and we append to them ".jpeg". That gives us:

A = album
B = "metallica"
C = "and justice for all"

/home/user/.cache/media-art/album-3c2234a7ce973bc1700e0c743d6a819c-3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg

Example: Artist art for Metallica, And Justice For All

Lowercase of "Metallica" is "metallica" and for "And Justice For All" is "and justice for all. The MD5 for those two are 3c2234a7ce973bc1700e0c743d6a819c and 3d422ba022ae0daa8f5454ba7dfa0f9a. We separate them with a dash, we prepend to them $XDG_CACHE_HOME/media-art/, the kind (which is "artist"), a dash and we append to them ".jpeg". That gives us:

A = artist
B = "metallica"
C = "and justice for all"

/home/user/.cache/media-art/artist-3c2234a7ce973bc1700e0c743d6a819c-3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg

The difference with album-art is that artist art focuses on the artist, instead of on the album.

Example: Radio ga ga

A = radio
B = "radio ga ga"
C = " "

/home/user/.cache/media-art/radio-b924ce08955675c6a30c745d18286d21-7215ee9c7d9dc229d2921a40e899ec5f.jpeg 

Example: World Soccer - Daily Podcast

A = podcast
B = "world soccer"
C = "daily podcast"

/home/user/.cache/media-art/podcast-d717b10ec8fb35b11644995deb04b721-08d299536e562915eb133e2676396d3f.jpeg

Local media art

In some situations it is desirable to have a local media art repository. This is a read-only collection of media art that is shared among different users or different computers. For example a CD-ROM with images, could include the media art for this media such that they do not need to be generated for every user or computer accessing this CD-ROM.

Because the URI of such media is not constant (a CD-ROM for example can be mounted at different locations) the media art should be in a relative path from the original image.

The location for local media art will be a subdirectory .mediaartlocal/ in the same directory as where the album's files are located. To determine the filename part you use the same rules as above.

* This can be tricky, because albums aren't necessarily contained in one directory. Whether art for an album is detected would depend on whether art is treated as a per-album or per-track object.

Example: Album of Metallica, And Justice For All on a USB stick

Lowercase of "Metallica" and "And Justice For All" are "metallica" and "and justice for all". The MD5 for those are 3c2234a7ce973bc1700e0c743d6a819c and 3d422ba022ae0daa8f5454ba7dfa0f9a. We separate them with a dash, we prepend to these /media/USBStick/Metallica/And Justice For All/.mediaartlocal/, the kind (which is "album"), a dash and we append ".jpeg". That gives us:

/media/USBStick/Metallica/And Justice For All/.mediaartlocal/album-3c2234a7ce973bc1700e0c743d6a819c-3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg

Thumbnails of media art

Thumbnails of media art follows the thumbnail-spec. The URI used to determine the thumbnail path is the full URI pointing to the original media art. For the path to the thumbnail refer to the thumbnail-spec itself. A media art fetcher is allowed to store the normal and large thumbnails immediately after download of the media art is completed. A media art fetcher is however not required to do this by itself (the thumbnail infrastructure will or should take care of this, if the media art isn't thumbnailed yet).

Example: Thumbnails of the media art for Metallica, And Justice For All

Path to the original media art (see above):

/home/user/.cache/media-art/album-3c2234a7ce973bc1700e0c743d6a819c-3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg

As a URI (just prepend file:// in this case):

file:///home/user/.cache/media-art/album-3c2234a7ce973bc1700e0c743d6a819c-3d422ba022ae0daa8f5454ba7dfa0f9a.jpeg

Paths to the thumbnails according to the Thumbnail spec:

/home/user/.thumbnails/normal/d76be6150d0684adeb46cc42c0f2648c.png
/home/user/.thumbnails/large/d76be6150d0684adeb46cc42c0f2648c.png

Heuristics for finding media art

The heuristics for media art are:


2024-10-23 11:04