Last active
August 29, 2015 14:24
-
-
Save underr/1da659375026dd85cafb to your computer and use it in GitHub Desktop.
lastfm cover (requires feh and a last.fm API key)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mpd import MPDClient | |
from requests import get | |
from json import loads | |
import subprocess | |
client = MPDClient(use_unicode=True) | |
client.connect("localhost", 6600) | |
p = False | |
SIZE = 3 # small: 0; medium: 1; large: 2; extralarge: 3; mega: 4; | |
def get_cover(): | |
song = client.currentsong() | |
l = loads(get('http://ws.audioscrobbler.com/2.0/', { | |
'format': 'json', | |
'method': 'album.getInfo', | |
'album': song["album"], | |
'artist': song["artist"], | |
'api_key': 'API_KEY' | |
}).text) | |
cover = l["album"]["image"][SIZE]["#text"] | |
return cover | |
c = get_cover() | |
p = subprocess.Popen("feh " + c, shell=True) | |
while True: | |
if client.idle('player'): | |
if p: | |
p.kill() | |
c = get_cover() | |
p = subprocess.Popen("feh " + c, shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment