Help - Search - Members - Calendar
Full Version: CoverDownloader
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Uploads - (fb2k)
Pages: 1, 2, 3, 4, 5, 6
david_dl
New Version (Experimental):
Here's a new version I've been working on. For this you'll require .NET framework 2.0 installed.

Please report any bugs/glitches.

Latest version (Supports iTMS)
Download: Click to view attachment
Source (GPL): Click to view attachment

If you create anything useful with the source, it would be a good idea to upload it here for everyone to benefit. Note that I probably won't be updating this project again, except maybe to add scripts.
The license requires that you include full sourcecode with any modified version distributed.
It's messy code, and the first and only time I've used C#, so I hope it's of use to someone.

Included site scripts:
  • Walmart.com
  • Buy.com
  • Amazon.com
  • RateYourMusic.com
  • iTunes Music Store
Screenshot:
IPB Image

---------Old Version-----------

This version uses Python scripts to specify sources for cover art. Look in the CoverSources\Scripts folder for more details. Walmart.py is a good template if you wish to write your own (Amazon.py is a mess)

The commandline syntax is quite simple, just coverart.exe <Artist> <Album> <File to save to>
The second two parameters are optional, if a path is not specified it will prompt you with a Save As dialog.

You shouldn't require any VC8 runtimes; it's linked statically.

Extract the entire archive into one folder, there is no need to unzip or do anything with Python24.zip, this is the library for the built-in interpreter and can be read from the zip file.

Note: The scripts in this download file are NOT up to date. Use the scripts attached to this post. Put them in coversources\scripts
Download links:
Download here
Download source here

Updated Scripts for Rate Your Music and Amazon are attached (these are recommended over the ones included in the download archive, for example the Amazon script no longer returns results that don't have valid thumbnails)

Commandline for foo_run:
CODE
"C:\Program Files\foobar2000\coverart\coverart.exe" "%artist%" "%album%" "$replace(%_path%,%_filename_ext%,)folder.jpg"


Screenshot:

IPB Image[/s]
david_dl
And it won't work on Windows 98/95/ME 'cos it's unicode.
The Link
The Amazon.dll doesn't seem to work. I only get Walmart results. Disabling Walmart.dll gives no results at all.
SpaceChief
Thanks! Works great so far!
drbeachboy
With Amazon, I get a window panel that says "Done", but blank inside. Walmart works like a champ!

On the Walmart side, is this better or the same as the gui "albumart.exe" that you wrote back in January?



Regards,
Dirk
david_dl
Hmm, it would seem that the Amazon site's behaviour varies wildly depending on cookies you have set and possibly geographical location. What happens if you visit http://www.amazon.com/exec/obidos/search-h...ece%20of%20mind
using Internet Explorer (not firefox). Do you get results? And does coverdownloader work after that?

QUOTE

On the Walmart side, is this better or the same as the gui "albumart.exe" that you wrote back in January?


If you mean the .NET one, its almost the same except written in C++ so you don't require the .NET framework. You should get identical results.
The Link
Your link gives results here using IE but coverart still doesn't give me any amazon results after that (only Walmart works).
david_dl
Could you send me the HTML source of that results page?
Thanks for your help.
tool++
Ah, been waiting for something like this.

However, Amazon doesnt work, and the wallmart searching is rubbish.
The Link
QUOTE(david_dl @ Apr 9 2006, 12:01 AM) *

Could you send me the HTML source of that results page?
Thanks for your help.

See PM.
david_dl
Thanks for that. I've had a look at the page Amazon.com served you, and I'm unable to get it to serve me one that looks anything like that. As these pages tend to change quite frequently anyway, I think it would be best to implement some sort of scripting instead of using compiled DLLs. What scripting languages would you like me to try to support? Anything that supports regular expressions should work well for parsing the pages, and as long as the integration into a C/C++ application isn't too difficult I'm willing to support it. I can provide the HTTP and file IO services needed if the scripting language doesn't support them.

ATM I'm thinking python and/or lua, however I don't actually know how to write script in either of these languages biggrin.gif
fluffy
How am I supposed to install this? I copied everything that was in the rar into my components directroy, and I don't get any errors when foobar starts up. But, what do I do now? There is no mention of this component in my preferences now, when I right-click on the albumart panel there is no option to download art...
david_dl
It's not a foobar component... yet. Run coverart.exe from the commandline.

QUOTE(tool++ @ Apr 9 2006, 11:11 AM) *

the wallmart searching is rubbish.


I know what you mean. If you know of any better sites, please post them here.
Skates
Another source of info:

http://www.allmusic.com/
fluffy
Not sure if this could be added, but hi-res and easy (for a human) to use: http://www.thejosher.net/iTunes/search.php
francesco
does it work with foobar 0.8.3
because to me it does not work mad.gif
kalmark
QUOTE(francesco @ Apr 13 2006, 10:57 AM) *

does it work with foobar 0.8.3
because to me it does not work mad.gif

QUOTE(david_dl @ Apr 9 2006, 12:47 AM) *

It's not a foobar component... yet. Run coverart.exe from the commandline.
reprehensible
QUOTE(david_dl @ Apr 8 2006, 04:47 PM) *

Thanks for that. I've had a look at the page Amazon.com served you, and I'm unable to get it to serve me one that looks anything like that. As these pages tend to change quite frequently anyway, I think it would be best to implement some sort of scripting instead of using compiled DLLs. What scripting languages would you like me to try to support? Anything that supports regular expressions should work well for parsing the pages, and as long as the integration into a C/C++ application isn't too difficult I'm willing to support it. I can provide the HTTP and file IO services needed if the scripting language doesn't support them.


Okay, wait. Are you trying to screen-scrape Amazon pages? Why?! They have an API specifically for querying their database, and it is very easy to download cover art with it.

http://www.amazon.com/gp/aws/landing.html

There are a number of examples out on the web. You can write a reasonably okay version in an hour or so, including the time it takes to register with Amazon.
hexonn
QUOTE(david_dl @ Apr 8 2006, 04:47 PM) *

It's not a foobar component... yet. Run coverart.exe from the commandline.

QUOTE(tool++ @ Apr 9 2006, 11:11 AM) *

the wallmart searching is rubbish.


I know what you mean. If you know of any better sites, please post them here.
coconuts.com has 500x500 covers
karit
QUOTE(fluffy @ Apr 12 2006, 06:53 AM) *

Not sure if this could be added, but hi-res and easy (for a human) to use: http://www.thejosher.net/iTunes/search.php

http://www.hydrogenaudio.org/forums/index....showtopic=40067
HAs commandline. And also a gui but haven't used the gui
mazy
david_dl, please, would you consider using lua language for scripting? it has good support for regular expressions - and foosion did quite some work on his foo_lua component to implement unicode support to them.

on a sidenote, it would be great if you could port his old foo_lua sources to foobar 0.9. i really miss it, it could be used for so many useful things (and maybe one could even implement some sort of service so other plugins could use that lua core too).
david_dl
Thanks for all the suggestions of cover sources.
I'm just posting to let you know I haven't abandoned this, just been busy with other stuff. I had some time today so I started playing with scripting. I thought python looked quite good, so I've created a coversource DLL that uses a python script to retrieve covers. It needs a bit of work before I can release it, but that will happen sometime soon.
I don't actually know python, but after a bit of playing around I found it to be quite a fun language, and very intuitive to use. Just to show you how easy it is, this script, when run by the python coversource provides all the functionality of Walmart.dll in a few lines:
CODE

import urllib
import re

# GetThumbs(): 'artist' & 'album' are unicode strings
# must return a list of elements in this format:
# (all returned strings can be standard or unicode)
# [string: name,string: url to thumbnail OR buffer containing image data (prefixed with 'data://'): thumbnail data,anything: callback data]
# The callback data will be passed to DownloadArt if/when it is called

def GetThumbs(artist,album):
out=[]
params = urllib.urlencode({'search_query': artist + "+" + album})
f = urllib.urlopen("http://www.walmart.com/catalog/search-ng.gsp?Continue.x=0&Continue.y=0&Continue=Find&ics=20&ico=0&search_constraint=4104&" + params)
rfirst = re.compile("<a\\shref=\"/catalog/product\\.do\\?product_id=[0-9]+\"><img\\ssrc=\"([^\"]+)60X60.gif\"[^>]+alt=\"([^\"]*)\"[^>]*>",re.MULTILINE)
text = buffer(f.read())
iterator = rfirst.finditer(text)
for match in iterator:
out.append([match.group(2),u"150x150",match.group(1)+"150X150.jpg",match.group(1)])
return out

# alternate 'for' loop contents:
# f = urllib.urlopen(match.group(1)+"150X150.jpg")
# out.append([match.group(2),u"150x150","data://"+f.read(),match.group(1)])

# GetCover(): 'userdata' is the last item in the array representing
# the desired thumbnail in the list you returned in GetThumbs()
# must return either the URL of the full-size art
# or, the actual image data (prefixed with 'data://') as before

def GetCover(param):
return param + "500X500.jpg"


moderation: Converted code to codebox to preserve forum layout.
DoXer
How can i send the parameters for %artist% and %title% from foobar to the downloader. Ist there a plugin required?
Skates
Cannot wait until this is turned into an actual plug-in or merged with the other album art plugin!!!
david_dl
Well, the python scripting kinda works. But I no longer can work on this, and its become kind of a mess.
Here's a binary and the source code, use parts of it in your own project if you want.

To use, run coverart.exe from the commandline. The zip file python24.zip contains python libraries, there is no need to unzip it, as it can be read from as is.

If you want to write your own script, see coversources\scripts\walmart.py for details. The amazon script is a mess.
topdownjimmy
QUOTE(DoXer @ Apr 23 2006, 14:48) *

How can i send the parameters for %artist% and %title% from foobar to the downloader. Ist there a plugin required?

once we get foo_openwith ported to 0.9, this will be very simple



i'd also like to suggest http://www.rateyourmusic.com/ for finding album art, it's far and away the most comprehensive collection of album art i've found, i find everything except super, super rare stuff on there. fantastic resource.
david_dl
QUOTE(topdownjimmy @ May 14 2006, 13:58) *

i'd also like to suggest http://www.rateyourmusic.com/ for finding album art, it's far and away the most comprehensive collection of album art i've found, i find everything except super, super rare stuff on there. fantastic resource.


Here's a script for that. Save as "Rate Your Music.py" in coversources\scripts:
CODE

import urllib
import re

def GetThumbs(artist,album):
    try:
        out = []
        query = album
        params = urllib.urlencode({'searchterm': query.encode('utf8')}) + "&type=l"
        f = urllib.urlopen("http://rateyourmusic.com/search?" + params)
        r = re.compile("<img[^>]*?alt=\"([^\"]*)\"[^>]*?src=\"/album_images[0-9]*/s([0-9]+).jpg\">",re.MULTILINE)
        text = f.read()
        iterator = r.finditer(text)
        for match in iterator:
            out.append([match.group(1),u"Unknown","http://rateyourmusic.com/album_images/s"+match.group(2)+".jpg",match.group(2)])
        return out
    except:
        return []

def GetCover(param):
    return "http://rateyourmusic.com/album_images/o"+param+".jpg"


parive3
Is there some readme.txt file for noobs like me too know where to place the extracted folders and how to use the program?

Edit - Ok got its only a Command line app
david_dl
Sorry for the belated reply. Now that foo_run has been ported, the easiest way to use it is with the code I have added to the first post. Then rightclick the track for which you need art, select Run->Get Art (or whatever you called it in foo_run).

Rate Your Music is indeed an excellent source of coverart, I recommend adding the python script for it I posted above.

Edit: Everything is now on the first post, including updated scripts
Tich
thanks for your fantastic work smile.gif

edit: I'm having some problems downloading certain coverart.
For example I tried downloading the cover for "Macka B - Sign Of The Times" which yields one correct result on amazon. When clicking the picture to save it everything seems fine, but the picture is a 1x1 pixel white gif (as far as Irfanview goes)

This occurs using the latest version of your amazon script and the following command prompt using foo_run:
"C:\Programme\foobar2000\coverart\coverart.exe" "%artist%" "%album%" "$replace(%_path%,%_filename_ext%,)%artist% - %album% - Front.jpg"
I've also downloaded other cover images which work fine, as far as I can tell this only happens with amazon sad.gif
Chaser
Indeed!
Thank you very much!

A little question: What is done, if the specified file (i.e. folder.jpg) already exists? Is it overwritten?
A little request: What about letting the uppopping window with covers hide the command-box and put out the errors and such not to the command-box, but rather to this window in some way? But this is only eyecandy...

I saw a few times, that a coverpreview was empty, with a black border and a few horizontal lines. If I see this again I'll report you the artist and album!
topdownjimmy
A million thank yous for this program, and for providing RateYourMusic support. It all makes me very very happy. smile.gif

One question: with free registration at RateYourMusic, you sometimes have access to higher-resolution images. Is it at all possible to integrate logging in to the script to get these bigger images?

edit: another request, can you make the program close automatically when the art is saved?
david_dl
QUOTE(Tich @ Jun 2 2006, 03:48) *

edit: I'm having some problems downloading certain coverart.
For example I tried downloading the cover for "Macka B - Sign Of The Times" which yields one correct result on amazon. When clicking the picture to save it everything seems fine, but the picture is a 1x1 pixel white gif (as far as Irfanview goes)

This occurs using the latest version of your amazon script and the following command prompt using foo_run:
"C:\Programme\foobar2000\coverart\coverart.exe" "%artist%" "%album%" "$replace(%_path%,%_filename_ext%,)%artist% - %album% - Front.jpg"
I've also downloaded other cover images which work fine, as far as I can tell this only happens with amazon sad.gif


Does that result show an image in the thumbnail? Are you using the latest version of the Amazon script (It's at the very bottom of the first post.) If the problem persists i'll have another fiddle with the script when I get home tonight (It uses the Web Services API and the URLs it gives me are, for some reason, not very reliable


QUOTE(Chaser @ Jun 2 2006, 04:41) *

Indeed!
Thank you very much!

A little question: What is done, if the specified file (i.e. folder.jpg) already exists? Is it overwritten?
A little request: What about letting the uppopping window with covers hide the command-box and put out the errors and such not to the command-box, but rather to this window in some way? But this is only eyecandy...

Hmm yes, that would be better. If i have time, I'll work on it tonight.

QUOTE(Chaser @ Jun 2 2006, 04:41) *

I saw a few times, that a coverpreview was empty, with a black border and a few horizontal lines. If I see this again I'll report you the artist and album!

Thanks, that would be very helpful.

QUOTE(topdownjimmy @ Jun 2 2006, 06:05) *

A million thank yous for this program, and for providing RateYourMusic support. It all makes me very very happy. smile.gif

One question: with free registration at RateYourMusic, you sometimes have access to higher-resolution images. Is it at all possible to integrate logging in to the script to get these bigger images?

Hi, when I wrote the script I signed up for an account, and noticed that while it was necessary to login to get the link to the larger images, once you had the URL anyone could access it. I also found that the URL was very predictable, and therefore logging in wasn't necessary at all.
However out of fairness to the Rate Your Music site, please only use the script if you are a regular user who participates on the site biggrin.gif

QUOTE(topdownjimmy @ Jun 2 2006, 06:05) *

edit: another request, can you make the program close automatically when the art is saved?


Sure, would it be good to have this as a commandline argument? Ie. coverart.exe --auto-close "artist"
topdownjimmy
QUOTE(david_dl @ Jun 1 2006, 15:30) *

QUOTE(topdownjimmy @ Jun 2 2006, 06:05) *

edit: another request, can you make the program close automatically when the art is saved?


Sure, would it be good to have this as a commandline argument? Ie. coverart.exe --auto-close "artist"

perfect, thanks!
bsommer
when you guys say run coverart.exe from the commandline what do you mean?

I extracted it into a folder but how do i run the .exe from the "commandline"?
roentgen
QUOTE(bsommer @ Jun 2 2006, 00:16) *

when you guys say run coverart.exe from the commandline what do you mean?

I extracted it into a folder but how do i run the .exe from the "commandline"?


start /run / write 'cmd' then enter something like "C:\Program Files\fb2k\coverart\coverart.exe" "your artist" "your album" "path where to save the cover art"

but there's a simpler way... using foo_run
add a new entry with this command line
CODE
"C:\Program Files\fb2k\coverart\coverart.exe" "%artist%" "%album%" "E:\%artist%.%album%.folder.jpg"

(modify the paths with those on your system)
bsommer
"alert, error writing file"

thats the error message i get when i click on the cover image to save it to the folder designated sad.gif
topdownjimmy
QUOTE(bsommer @ Jun 1 2006, 20:51) *

"alert, error writing file"

thats the error message i get when i click on the cover image to save it to the folder designated sad.gif

make sure there are no characters in the intended filename that can't actually be in a filename (for example, forward slashes or question marks in an album title)
pepito
thank you!
working fine with foo_run
there is also an albumart.exe ,took on the forum http://www.hydrogenaudio.org/forums/index....howtopic=40054#
david_dl
I should have mentioned that it is possible to right click on a thumbnail to use "Save As..." if you wish to save it elsewhere.

Also, if anyone has suggestions for sites with covers that I haven't written scripts for yet, please suggest them here.
Note while it is possible to access the art on allmusic.com, they strictly forbid this, and shut down another software programme that did this. And they only have 200x200 covers.
Chaser
I just had the problem mit blank albumart again. The horizontal lines come out of a "repainting"-problem.
One more thing: Let the program remember it's windowsize!


QUOTE
"alert, error writing file"

I get this, if I don't wait long enough (all albumart is loaded) and click on one too quickly... This could be optimized?!
Perhaps a small progressbar, where you see, how far the program has gotten?
david_dl
Hmmm, the GUI definately needs some work. The trouble is, python is way more fun than C++ tongue.gif
Well I'm not really in a state to work on it now, and it's queen's birthday weekend. I might have some time sunday morning, i'll see how it goes.
Chaser
Thank you for looking into it!
Chaser
Hi david,

"Excrementory Grindfuckers" - "Fertig machen, Szeneputzen", there is a cover found on rate your music. However it doesn't stop [searching]. Thus I can't save it...
(I have all of the three scripts in my folder..)
Tich
QUOTE(david_dl @ Jun 1 2006, 21:30) *


Does that result show an image in the thumbnail? Are you using the latest version of the Amazon script (It's at the very bottom of the first post.) If the problem persists i'll have another fiddle with the script when I get home tonight (It uses the Web Services API and the URLs it gives me are, for some reason, not very reliable



The result does show an image in the thumbnail, yes.
I'm also using the latest version of the amazon script, but it seems like the picture isn't saved correctly.

Thanks for your effort smile.gif

Tich
david_dl
Hi. Sorry, I haven't worked on the problems with the Amazon script or the coverart GUI yet, but I do have an updated version of walmart (Just noticed an error in the original that means it would miss many covers), and a script for Buy.com, which has awesome 500x500px covers.

Both are attached to the first post. This means that none of the scripts in the original download archive are now up to date.

Buy.com script:

CODE

import urllib
import re

def GetThumbs(artist,album):
        out = []
        query = artist+" "+album
        params = urllib.urlencode({'qu': query.encode('utf8')}) + "&search_store=6&querytype=music&loc=109&dclksa=1"
        f = urllib.urlopen("http://www.buy.com/retail/searchresults.asp?" + params)
        r = re.compile("<img[^>]*src=\"http://ak.buy.com/db_assets/ad_images/([0-9]+)/([0-9]+).gif\">.*?<a[^>]*class=\"medBlueText\"><b>([^>]*)</b>",re.MULTILINE)
        r2 = re.compile("java script:largeIM\\(\'http://ak.buy.com/db_assets/large_images/([0-9]+)/([0-9]+).jpg\'\\)[^>]+><img[^>]*src=\"http://ak.buy.com/db_assets/prod_images/\\1/\\2.jpg\"[^>]*alt=\"([^\">]+)\"",re.MULTILINE)
        text = f.read()
        result = re.search(r2,text)
        if result!=None:
            return [[result.group(3),u"500x500","http://ak.buy.com/db_assets/prod_images/"+result.group(1)+"/"+result.group(2)+".jpg",[result.group(1),result.group(2)]]]
        iterator = r.finditer(text)
        for match in iterator:
            out.append([match.group(3),u"500x500","http://ak.buy.com/db_assets/prod_images/"+match.group(1)+"/"+match.group(2)+".jpg",[match.group(1),match.group(2)]])
        return out
def GetCover(param):
    return "http://ak.buy.com/db_assets/large_images/"+param[0]+"/"+param[1]+".jpg"

Chaser
Thank you! Will try this out, when I'm back in my "studying-city"!

edit:
It seems that the coverdownloader has problems saving to the folder.jpg, if there's already one present in the target-directory! I get a messagebox...
topdownjimmy
hmm, came across a failed search...artist "asobi seksu," album "citrus" didn't retrieve the image from rateyourmusic (though the album and art exist on the site)
parive3
QUOTE(david_dl @ Apr 8 2006, 15:30) *

The commandline syntax is quite simple, just coverart.exe <Artist> <Album> <File to save to>
The second two parameters are optional, if a path is not specified it will prompt you with a Save As dialog.


Is it possible to have a syntax :
coverart.exe <SearchName> <File to save to>

Because sometimes I just want to search for the album because it might be a Various Artists one. And I would like to save the cover with filename syntax I provide.

If this is impossible because the way optional parameters are structured can you have it so if you put #Ignore# in the second parameter it will function like I mentioned above?
coverart.exe <SearchName> #Ignore# <File to save to>

Also the remembering Window size will be great.

Thanks
Tich
if you want to search for an album only just use this command:
CODE
coverart.exe "" "%album%" "$replace(%_path%,%_filename_ext%,)front.jpg"


this will search for the album, ignoring the artist tag, and save the result to the same folder your music files are in. smile.gif

Tich
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.