SEARCH

Enter your search query in the box above ^, or use the forum search tool.

You are not logged in.

#1 2011-03-26 12:12:43

Tunafish
#! Die Hard
From: the Netherlands
Registered: 2010-03-07
Posts: 1,201

mpd album art in conky

I had some trouble with the mpd-album-art-conky-script from http://crunchbanglinux.org/forums/topic/4686/howto-mpd/     Well... trouble... it didn't show many images...

So i searched these and other forums and created (well... copy/paste mostly) this one. It's capable of showing a file when no image is found. And it's also possible to use 'artist-only' images, which will show when no specific album image is found. Of course... someone (you) has to put the images in the folder.

Maybe there are similar scripts around. If so... post them here.
And improvements to mine are welcome as well.

Tuna.

#!/usr/bin/python

import os
import shutil
import commands
import urllib

# Path where the images are saved
imgpath = "/home/nn/.config/ario/covers/"

# Path where 'artist-only' images can be found
artistimgpath = "/home/nn/.config/ario/covers/"

# Image displayed when no image found
noimg = "/home/nn/.config/conky/nocover.png"

# Cover displayed by conky
cover = "/tmp/cover.jpg"

def copycover(currentalbum, src, artistsrc, dest, defaultfile):
    searchstring = currentalbum.replace(" ", "+")
    if not os.path.exists(src):
        url = "http://www.albumart.org/index.php?srchkey=" + searchstring + "&itempage=1&newsearch=1&searchindex=Music"
        cover = urllib.urlopen(url).read()
        image = ""
        for line in cover.split("\n"):
            if "http://www.albumart.org/images/zoom-icon.jpg" in line:
                image = line.partition('src="')[2].partition('"')[0]
                break
        if image:
            urllib.urlretrieve(image, src)
    if os.path.exists(src):
        shutil.copy(src, dest)
    elif os.path.exists(artistsrc):
        shutil.copy(artistsrc, dest)    
    elif os.path.exists(defaultfile):
        shutil.copy(defaultfile, dest)
    else:
        print ""

# Name of current album
album = commands.getoutput("mpc --format %artist%-%album% | head -n 1")
artist = commands.getoutput("mpc --format %artist% | head -n 1")

# If tags are empty, use noimg. 
# Hieronder stond steeds conkycover ipv cover, heb ik gewijzigd.
if album == "":
    if os.path.exists(cover):
        os.remove(cover)
    if os.path.exists(noimg):
        shutil.copy(noimg, cover)
    else:
        print ""
else:

    filename = imgpath + album + ".jpg"
    artistfilename = artistimgpath + artist + ".jpg"
    if os.path.exists("/tmp/nowplaying") and os.path.exists("/tmp/cover.jpg"):
        nowplaying = open("/tmp/nowplaying").read()
        if nowplaying == album:
            pass
        else:
            copycover(album, filename, artistfilename, cover, noimg)
            open("/tmp/nowplaying", "w").write(album)
    else:
        copycover(album, filename, artistfilename, cover, noimg)
        open("/tmp/nowplaying", "w").write(album)

sed 's/stress/relaxation/g'
Privacy & Security on #!

Offline

Help fund CrunchBang, donate to the project!

#2 2011-03-28 00:18:46

benj1
Wiki Wizard
From: Yorkshire, England
Registered: 2009-09-05
Posts: 1,084

Re: mpd album art in conky

is http://www.albumart.org better than amazon?

My current 'solution' isn't perfect i agree, I have periodically looked around for better solutions unfortunately the only way ive found is screenscraping  neutral


- - - - - - - - Wiki Pages - - - - - - -
#! install guide           *autostart programs, modify the menu & keybindings
configuring Conky       *installing scripts

Offline

#3 2011-03-28 06:03:51

Tunafish
#! Die Hard
From: the Netherlands
Registered: 2010-03-07
Posts: 1,201

Re: mpd album art in conky

benj1 wrote:

is http://www.albumart.org better than amazon?

Albumart also takes images from amazon. I don't know if it's better or not. 
It would be great to add more sources to the script.
Tuna


sed 's/stress/relaxation/g'
Privacy & Security on #!

Offline

#4 2011-03-28 15:38:45

iggykoopa
Script Master
Registered: 2008-12-13
Posts: 1,480

Re: mpd album art in conky

here's the one I wrote a while ago http://crunchbanglinux.org/forums/post/31045/#p31045 those are the instructions...but grab the copy of the script from the end of that thread... It also does artist art and similar artists


I say never be complete, I say stop being perfect, I say lets evolve, let the chips fall where they may.

Offline

#5 2011-03-28 18:08:08

benj1
Wiki Wizard
From: Yorkshire, England
Registered: 2009-09-05
Posts: 1,084

Re: mpd album art in conky

iggykoopa wrote:

here's the one I wrote a while ago http://crunchbanglinux.org/forums/post/31045/#p31045 those are the instructions...but grab the copy of the script from the end of that thread... It also does artist art and similar artists

nice, the lastfm api didn't occur to me, I will have to have a play... and with http://www.albumart.org/ too.


- - - - - - - - Wiki Pages - - - - - - -
#! install guide           *autostart programs, modify the menu & keybindings
configuring Conky       *installing scripts

Offline

#6 2011-09-10 21:55:34

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 9,727
Website

Re: mpd album art in conky

I apologize for reviving an old thread but I have created an updated way of doing this..

First and foremost, I tried every solution presented by Tunafish, benji1 and iggykoopa and could not get any to work...  I will spend more time trying to trouble shoot the iggykoopa scripts because of the massive options it has..

With Ario, as Tunafish pointed out, keeps it's covers in ~/.config/ario/covers/ directory

I created a simple bash to find the latest that was created in that directory and copy it to /tmp/covers and then pull that file from my conky

Here is how.. 

First open your favorite editor and copy the following to cover.sh and save it to your home directory and make sure it is executable

cover.sh

find ~/.config/ario/covers -iname "*.jpg" -size +10k -amin -1 -exec cp {} /tmp/covers \; &
wait
rm ~/.config/ario/covers/*.jpg

-iname is ignoring the case  looking for all png files with a -size of greater than 10k created within the last minute and then copies the results {} to the file /tmp/covers

the rm line is to to remove *.jpg files from ~/.config/ario/covers...   Without this, if you were to replay an artist that was already played before, Ario does not recreate the file so clearing all jpg files guarantees it.. You could set this up to cp to a different location if you wanted to

Here is how I load it

.conkympdrc

# .conkyrc - Edited from various examples across the 'net
# Used by VastOne on #!
 
# Create own window instead of using desktop (required in nautilus)
#own_window yes
#own_window_type normal
#own_window_transparent no
#own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
 
# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes
 
# fiddle with window
use_spacer right

# Use Xft?
use_xft yes
xftfont Caviar Dreams Bold:size=15
xftalpha 0.9
text_buffer_size 4096

# Update interval in seconds
update_interval 1

# This is the number of times Conky will update before quitting.
# Set to zero to run forever.
total_run_times 0

# Use double buffering (reduces flicker, may not work for everyone)
double_buffer yes

# Minimum size of text area
minimum_size 336 700
maximum_width 336
#maximum_width 1024
imlib_cache_size 0

# Draw shades?
draw_shades no

# Draw outlines?
draw_outline no

# Draw borders around text
background no
draw_borders no
own_window_argb_visual yes
own_window_argb_value 255
own_window_type desktop
own_window_hints below,sticky,skip_taskbar,skip_pager
own_window yes
own_window_transparent yes
# own_window_class Conky

# Stippled borders?
stippled_borders 0

# border margins
border_margin 0

# border width
border_width 1

# Default colors and also border colors
#default_color grey
#color2=white
#color3=grey
default_shade_color black
#default_outline_color grey
#own_window_colour 070809

# Text alignment, other possible values are commented
#alignment top_middle
#alignment top_left
alignment top_right
#alignment bottom_left
#alignment bottom_right

# Gap between borders of screen and text
# same thing as passing -x at command line
gap_x 7
gap_y 24

# Subtract file system buffers from used memory?
no_buffers yes

# set to yes if you want all text to be in uppercase
uppercase no

# number of cpu samples to average set to 1 to disable averaging
cpu_avg_samples 2

# number of net samples to average
# set to 1 to disable averaging
net_avg_samples 2

# Force UTF8? note that UTF8 support required XFT
override_utf8_locale yes

# Add spaces to keep things from moving about?  This only affects certain objects.
use_spacer none

TEXT

#MPD $mpd_status
${if_mpd_playing}
${color #F6F6F6}$mpd_artist
${color #F6F6F6}$mpd_album
${color #F6F6F6}${mpd_title 25}
${color #F6F6F6}$mpd_elapsed/$mpd_length
${color light blue}${mpd_bar 9,335}
${execi 1 /home/vastone/cover.sh}${image /tmp/covers -p 0,130 -s 335x335}
$endif

This is what it looks like

screenshot-09102011-045102pm.php

I know this is specific to Ario, but if you know where whatever mpd front end you are using keeps it's covers cache, you could apply the same..  For me, I am glad I found Ario, it and mpd runs my 30k of music in just under 40 meg...


VSIDO
If you build it, they will come...
Words That Build Or Destroy

Offline

#7 2011-09-11 20:08:20

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 9,727
Website

Re: mpd album art in conky

Tunafish wrote:

I had some trouble with the mpd-album-art-conky-script from http://crunchbanglinux.org/forums/topic/4686/howto-mpd/     Well... trouble... it didn't show many images...

So i searched these and other forums and created (well... copy/paste mostly) this one. It's capable of showing a file when no image is found. And it's also possible to use 'artist-only' images, which will show when no specific album image is found. Of course... someone (you) has to put the images in the folder.

Maybe there are similar scripts around. If so... post them here.
And improvements to mine are welcome as well.

Tuna.

#!/usr/bin/python

import os
import shutil
import commands
import urllib

# Path where the images are saved
imgpath = "/home/nn/.config/ario/covers/"

# Path where 'artist-only' images can be found
artistimgpath = "/home/nn/.config/ario/covers/"

# Image displayed when no image found
noimg = "/home/nn/.config/conky/nocover.png"

# Cover displayed by conky
cover = "/tmp/cover.jpg"

def copycover(currentalbum, src, artistsrc, dest, defaultfile):
    searchstring = currentalbum.replace(" ", "+")
    if not os.path.exists(src):
        url = "http://www.albumart.org/index.php?srchkey=" + searchstring + "&itempage=1&newsearch=1&searchindex=Music"
        cover = urllib.urlopen(url).read()
        image = ""
        for line in cover.split("\n"):
            if "http://www.albumart.org/images/zoom-icon.jpg" in line:
                image = line.partition('src="')[2].partition('"')[0]
                break
        if image:
            urllib.urlretrieve(image, src)
    if os.path.exists(src):
        shutil.copy(src, dest)
    elif os.path.exists(artistsrc):
        shutil.copy(artistsrc, dest)    
    elif os.path.exists(defaultfile):
        shutil.copy(defaultfile, dest)
    else:
        print ""

# Name of current album
album = commands.getoutput("mpc --format %artist%-%album% | head -n 1")
artist = commands.getoutput("mpc --format %artist% | head -n 1")

# If tags are empty, use noimg. 
# Hieronder stond steeds conkycover ipv cover, heb ik gewijzigd.
if album == "":
    if os.path.exists(cover):
        os.remove(cover)
    if os.path.exists(noimg):
        shutil.copy(noimg, cover)
    else:
        print ""
else:

    filename = imgpath + album + ".jpg"
    artistfilename = artistimgpath + artist + ".jpg"
    if os.path.exists("/tmp/nowplaying") and os.path.exists("/tmp/cover.jpg"):
        nowplaying = open("/tmp/nowplaying").read()
        if nowplaying == album:
            pass
        else:
            copycover(album, filename, artistfilename, cover, noimg)
            open("/tmp/nowplaying", "w").write(album)
    else:
        copycover(album, filename, artistfilename, cover, noimg)
        open("/tmp/nowplaying", "w").write(album)

Is this script specifically and only for Ario?

imgpath = "/home/nn/.config/ario/covers/"

If that was changed to where my music directory is, this should work?


VSIDO
If you build it, they will come...
Words That Build Or Destroy

Offline

#8 2011-09-13 09:31:56

Tunafish
#! Die Hard
From: the Netherlands
Registered: 2010-03-07
Posts: 1,201

Re: mpd album art in conky

VastOne wrote:

Is this script specifically and only for Ario?

imgpath = "/home/nn/.config/ario/covers/"

If that was changed to where my music directory is, this should work?

You can change it to any folder where you want to store the cover art. E.g.: /home/username/.config/covers/

The script will get the cover art from the internet and store it in that specific folder.

Tuna


sed 's/stress/relaxation/g'
Privacy & Security on #!

Offline

#9 2011-09-13 15:47:13

pvsage
Internal Affairs
From: North Carolina
Registered: 2009-10-18
Posts: 9,027

Re: mpd album art in conky

@Tune-O-Fish:  I think The Vast One means he wants the script to be able to use local images, e.g. "~/music/$artist/$album/cover.jpg" instead of having to suck them through t3h Intertubz..


while ( ! ( succeed = try() ) );
We've earned a reputation as a nice, friendly community; please help us keep it that way.

Offline

#10 2011-09-13 16:02:58

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 9,727
Website

Re: mpd album art in conky

pvsage is correct...

Having a either/or option..

Thanks


VSIDO
If you build it, they will come...
Words That Build Or Destroy

Offline

#11 2011-09-13 16:32:33

Tunafish
#! Die Hard
From: the Netherlands
Registered: 2010-03-07
Posts: 1,201

Re: mpd album art in conky

VastOne wrote:

pvsage is correct...

Having a either/or option..

Thanks

That's what the script does... It first searches for images on the disk, if nothing is found it tries to grab an image online.
That's why i had it pointed to the Ario folder, as it already contained images downloaded by Ario.

Last edited by Tunafish (2011-09-13 16:33:14)


sed 's/stress/relaxation/g'
Privacy & Security on #!

Offline

#12 2011-09-13 16:42:54

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 9,727
Website

Re: mpd album art in conky

Tunafish wrote:
VastOne wrote:

pvsage is correct...

Having a either/or option..

Thanks

That's what the script does... It first searches for images on the disk, if nothing is found it tries to grab an image online.
That's why i had it pointed to the Ario folder, as it already contained images downloaded by Ario.

That is what I thought it should do, but all I ever get it to do is pull from the net.

I will look at it more in depth to see what is happening

my directory structure is

/media/storage/Music/mp3new/

with artist/album where each cover resides

Will report back if I find the cause..

Thanks


VSIDO
If you build it, they will come...
Words That Build Or Destroy

Offline

#13 2011-09-13 17:53:45

Tunafish
#! Die Hard
From: the Netherlands
Registered: 2010-03-07
Posts: 1,201

Re: mpd album art in conky

VastOne wrote:
Tunafish wrote:
VastOne wrote:

pvsage is correct...

Having a either/or option..

Thanks

That's what the script does... It first searches for images on the disk, if nothing is found it tries to grab an image online.
That's why i had it pointed to the Ario folder, as it already contained images downloaded by Ario.

That is what I thought it should do, but all I ever get it to do is pull from the net.

I will look at it more in depth to see what is happening

my directory structure is

/media/storage/Music/mp3new/

with artist/album where each cover resides

Will report back if I find the cause..

Thanks

The script puts the covers in imgpath and names them artist-album.jpg
So if imgpath is set to /media/storage/Music/mp3new/
files will be named: /media/storage/Music/mp3new/A Perfect Circle-Acoustic.jpg etc

It's not very hard to change the script to your preferred structure.


sed 's/stress/relaxation/g'
Privacy & Security on #!

Offline

#14 2011-09-13 18:03:31

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 9,727
Website

Re: mpd album art in conky

Tunafish wrote:
VastOne wrote:
Tunafish wrote:

That's what the script does... It first searches for images on the disk, if nothing is found it tries to grab an image online.
That's why i had it pointed to the Ario folder, as it already contained images downloaded by Ario.

That is what I thought it should do, but all I ever get it to do is pull from the net.

I will look at it more in depth to see what is happening

my directory structure is

/media/storage/Music/mp3new/

with artist/album where each cover resides

Will report back if I find the cause..

Thanks

The script puts the covers in imgpath and names them artist-album.jpg
So if imgpath is set to /media/storage/Music/mp3new/
files will be named: /media/storage/Music/mp3new/A Perfect Circle-Acoustic.jpg etc

It's not very hard to change the script to your preferred structure.

Correct.. and this is working perfectly..  But the only images ever created are what is returned from the net.  Still looking into ..

Thanks


VSIDO
If you build it, they will come...
Words That Build Or Destroy

Offline

#15 2011-09-13 18:50:12

Tunafish
#! Die Hard
From: the Netherlands
Registered: 2010-03-07
Posts: 1,201

Re: mpd album art in conky

VastOne wrote:

Correct.. and this is working perfectly..  But the only images ever created are what is returned from the net.  Still looking into ..
Thanks

Not sure what you mean.... how else would images be created?


sed 's/stress/relaxation/g'
Privacy & Security on #!

Offline

#16 2011-09-13 18:57:37

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 9,727
Website

Re: mpd album art in conky

Tunafish wrote:
VastOne wrote:

Correct.. and this is working perfectly..  But the only images ever created are what is returned from the net.  Still looking into ..
Thanks

Not sure what you mean.... how else would images be created?

I mean that if it finds a local image first, it should use it and not create one from the net.

For whatever reasons, it is not finding my images in

/media/storage/Music/mp3new/Pink Floyd/Wish You Were Here/

directory when a song from that directory is playing...  Or any song is playing

It appears to me that it is not parsing all the way down to the directories that the music is in

Note - I have images in every single directory I have already.. No need to ever create one..


VSIDO
If you build it, they will come...
Words That Build Or Destroy

Offline

#17 2011-09-13 19:14:33

Tunafish
#! Die Hard
From: the Netherlands
Registered: 2010-03-07
Posts: 1,201

Re: mpd album art in conky

VastOne wrote:

For whatever reasons, it is not finding my images in

/media/storage/Music/mp3new/Pink Floyd/Wish You Were Here/

That's because the script only looks for /media/storage/Music/mp3new/Pink Floyd-Wish You Were Here.jpg


sed 's/stress/relaxation/g'
Privacy & Security on #!

Offline

#18 2011-09-13 19:15:39

VastOne
#! Ranger
From: #! Fringe Division
Registered: 2011-04-26
Posts: 9,727
Website

Re: mpd album art in conky

Tunafish wrote:
VastOne wrote:

For whatever reasons, it is not finding my images in

/media/storage/Music/mp3new/Pink Floyd/Wish You Were Here/

That's because the script only looks for /media/storage/Music/mp3new/Pink Floyd-Wish You Were Here.jpg

OK..  Thanks

I will look into having it just go after cover.jpg and the likes...


VSIDO
If you build it, they will come...
Words That Build Or Destroy

Offline

Board footer

Powered by FluxBB

Copyright © 2012 CrunchBang Linux.
Proudly powered by Debian. Hosted by Linode.
Debian is a registered trademark of Software in the Public Interest, Inc.

Debian Logo