mpd_album_art Module

copyright:2013 Jamie Macdonald
license:GNU General Public License (GPL) version 3
class mpd_album_art.Grabber(save_dir, library_dir=None, link_path=None)[source]

Bases: object

An object to grab artwork for MPD songs

Parameters:
  • save_dir (str) – Directory into which Grabber should download new images.
  • library_dir (str) – Directory MPD is currently playing from.
  • link_path (str) – Path to symlink to current image file. By default, os.path.join(save_dir, "current")

Construct a Grabber with save_dir = ~/.covers:

>>> import os
>>> home_dir = os.environ['HOME']
>>> cover_path = os.path.join(home_dir, '.covers')
>>> grabber = Grabber(cover_path)

specify more stuff:

>>> music_path = os.path.join(home_dir, 'Music/Library')
>>> current_cover_link = os.path.join(home_dir, '.current_cover')
>>> grabber = Grabber(save_dir=cover_path, library_dir=music_path,
...                   link_path=current_cover_link)
get_art(song)[source]

Get artwork from LastFM.

Before connecting to network, if there exists a file whose name begins with _sanitize(song['artist'] + ' ' + song['album']), return that file path. Do not overwrite existing files. Set os.path.join(save_dir, 'current') as symlink to image file.

Parameters:song (dict) – A dictionary with keys 'album' and 'artist' to correspond with string representations of the album and artist (resp.) of interest. Use MPDClient.currentsong() to return uch a dictionary .
Returns:A string representation of the local file path to the image file for song or None if no results found
get_local_art(song)[source]

Get artwork from song folder.

Parameters:song (dict) – A dictionary with keys 'album' and 'artist' to correspond with string representations of the album and artist (resp.) of interest. Such a dictionary returns from MPDClient.currentsong()
Returns:A string representation of the local file path to the largest image file for song found in song_folder, or None if no results found

Delete current artwork symlink.

Set current artwork symlink. :param file_path:

Path to artwork to be set as current.