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. Setos.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. UseMPDClient.currentsong()
to return uch a dictionary .Returns: A string representation of the local file path to the image file for song
orNone
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 fromMPDClient.currentsong()
Returns: A string representation of the local file path to the largest image file for song
found insong_folder
, orNone
if no results found