Skip to main content
Topic: Walmart' 500x500 album covers download script (Read 47495 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Walmart' 500x500 album covers download script

Reply #25
Quote
Here is the "sample command" generated by foo_openwith:
Code: [Select]
C:\Program Files\foobar2000\walmart.py "Alice In Chains Jar Of Flies" "E:\FLAC\Alice In Chains\Jar Of Flies" folder

[a href="index.php?act=findpost&pid=298930"][{POST_SNAPBACK}][/a]


It works for me. Check out the version from previous post.

Walmart' 500x500 album covers download script

Reply #26
Quote
Quote
Here is the "sample command" generated by foo_openwith:
Code: [Select]
C:\Program Files\foobar2000\walmart.py "Alice In Chains Jar Of Flies" "E:\FLAC\Alice In Chains\Jar Of Flies" folder

[a href="index.php?act=findpost&pid=298930"][{POST_SNAPBACK}][/a]


It works for me. Check out the version from previous post.
[a href="index.php?act=findpost&pid=304815"][{POST_SNAPBACK}][/a]


Are you going to replace the code box you deleted?  In the alternative, you could PM me a text file.

Walmart' 500x500 album covers download script

Reply #27
Quote
Quote
Quote
Here is the "sample command" generated by foo_openwith:
Code: [Select]
C:\Program Files\foobar2000\walmart.py "Alice In Chains Jar Of Flies" "E:\FLAC\Alice In Chains\Jar Of Flies" folder

[{POST_SNAPBACK}][/a]


It works for me. Check out the version from previous post.
[a href="index.php?act=findpost&pid=304815"][{POST_SNAPBACK}][/a]


Are you going to replace the code box you deleted?  In the alternative, you could PM me a text file.
[a href="index.php?act=findpost&pid=304984"][{POST_SNAPBACK}][/a]


Here it is.
Open the link and save the file [a href="http://sokrates.mimuw.edu.pl/~filon/walmart.py]walmart.py[/url].

Cheers!

Walmart' 500x500 album covers download script

Reply #28
I find the search terms aren't exact, I keep getting random stuff - for instance "NOFX The War on Errorism" gets random ones with "war" in

So when I search for "Norther Mirror of Madness", it comes up with 8 random files with madness in them, and doesn't actually get the Mirror of Madness album cover - http://www.amazon.com/exec/obidos/tg/detai...=music&n=507846

Oh right, its wallmart.

Why not do amazon?
hi

Walmart' 500x500 album covers download script

Reply #29
Yes, search results are not always precise but there is nothing I can do about that.

The main reason why I wrote script for Walmart is their 500x500 image resoultion. Amazon offers about 200x200 or something like that, so Walmarts are a lot more detailed.

The script is easily extensible. It's (mainly) just a matter of adding host definition like this:

Code: [Select]
walmart =
{ 'search' :
 { 'url'   : 'http://www.walmart.com/catalog/search-ng.gsp?',
   'query' : 'search_query',
   'args'  : { 'search_constraint': '4104', 'ics' : '5', 'ico': '0' },
   're'    : [ r'<input type="hidden" name="product_id" value="(\d+)">' ] },
 
 'result' :
 { 'url'   : 'http://www.walmart.com/catalog/product.gsp?',
   'query' : 'product_id',
   'args'  : { },
   're'    : [ r'<a href="javascript:photo_opener\(\'(\S+.jpg)&product_id=',
               r'<meta name="Description" content="(.+) at Wal-Mart.*">' ] }
  }
}


If you know another site with quality covers and better search engine, I can add support for it.

Walmart' 500x500 album covers download script

Reply #30
Well I know no python but I'll have a go.

With respect to not downloading loose matches, you could always see if the page contains the string "We did not find any matches for your search, but we did find the following matches for" then the script would know that the album has not been found.


E: Christ, amazon is hell-a confusing

Code: [Select]
amazon = { 'search' : { 'url'   : 'http://www.amazon.com/exec/obidos/search-handle-form/',
   'query' : 'field-keywords',
   'args'  : { 'index': 'music', },
   're' :
     [ r'<img src="http://images.amazon.com/images/P/(\d+).01.' ] },
           'result' : { 'url'   : 'http://www.amazon.com/gp/product/images/',
                 'query' : 'product_id',
   'args'  : { },
   're' :
     [ r'<img src="(http://images.amazon.com/images/P/\S+.01._SCLZZZZZZZ_.jpg)',
    r'' ] }


Ok, thats all I could come up with, and it doesn't work. I don't understand how the script works and what vars it needs.

I dunno if you can "fix" that. :S
hi

Walmart' 500x500 album covers download script

Reply #31
Quite right. The "right" code would be:
Code: [Select]
amazon = { 'search' : { 'url'   : 'http://www.amazon.com/exec/obidos/external-search/',
  'query' : 'field-keywords',
  'args'  : { 'index': 'music', },
  're' :
 [ r'<img src="http://images.amazon.com/images/P/([\d\w]+).01.' ] },
          'result' : { 'url'   : 'http://www.amazon.com/gp/product/images/',
                'query' : '',
  'args'  : { },
  're' :
 [ r'<img src="(http://images.amazon.com/images/P/[\d\w]+.01._SCLZZZZZZZ_.jpg)',
   r'<meta name="description" content="Image: (.+)" />' ] }


But there is a problem, that in the second search, there is no query field, so the script would add an unnecessary '=' which is wrong and different from the walmart script.

I did two things, for me and all the others out here:
    1. I converted the script into PHP. I like it more and I have more skills in this language. I tried to keep the source nearly the same as the python script. Sure there could be some PHP specialized optimizations, but I wanted to keep it equal.
To run the PHP script you can use either PHP4 or PHP5. For PHP4 you'll only need the php.exe and the php4ts.dll - for PHP5 you'll need the php-win.exe  and the php4ts.dll. There are only two differences between 4 and 5: (1) is the function http_build_query which is not available in PHP4, so I emulated it. The other thing is the missing try/catch support in PHP4. So I commented some lines. If you use PHP5 you should uncomment these 4-5 lines for better error handling.
    2. I included the amazon search engine. So as there are more than one search engine, I also changed the name of the script to getcover.php To use either your favorite, I implemented another paramater. There you simply can type 'walmart' or 'amazon'. This modification needed to change some lines. But not that worried much.
Code: [Select]
Usage: getcover.php "keyword ... keyword" [dest_dir] [image_name_no_extension] [search_engine]


Give it a try. [attachment=1579:attachment]

Walmart' 500x500 album covers download script

Reply #32
I never thought about running php scripts by opening them with the parser :o

I <3 <3 <3 PHP.

You fucking own. *goes to test*

Edit - how do you actually run the damn thing? I've never tried to "run" a script  in this way without a server :S

I've tried associating it with php-win.exe but nothing happens :S

My firewall doesn't do anything - does it even connect to the net?


Is the dest dir in quotes (because many many paths have spaces)

Ok, I got it working. Now to edit to get less false positive ;)

Open with app path:
D:\php5\php

Open with params:
-f D:\foobar2000\getcover.php "%artist% - %album%" "$replace(%_path%,\%_filename_ext%,)" folder amazon
hi

Walmart' 500x500 album covers download script

Reply #33
I don't need the -f command.
I run it with Open With Plugin just like this:

Command name:  Download Cover (Walmart)
Application path:  "E:\Programme\_Internet\PHP 5\php-win.exe"
Pre paramaters:  "E:\Programme\_Audio\foobar2000\getcover.php"[SPACE]
Main paramaters:  "%artist% %album%" "$replace(%_path%,\%_filename_ext%,)" cover walmart
Post parameters:

Command name:  Download Cover (Amazon)
Application path:  "E:\Programme\_Internet\PHP 5\php-win.exe"
Pre paramaters:  "E:\Programme\_Audio\foobar2000\getcover.php"[SPACE]
Main paramaters:  "%artist% %album%" "$replace(%_path%,\%_filename_ext%,)" cover amazon
Post parameters:

Walmart' 500x500 album covers download script

Reply #34
php script works great. but from amazon i got 14 covers for pink floyd's "wish you were here". most of them were variations of the same cover, but there were also a couple of different covers, as well as the dark side of the moon cover, the wall cover, and animals cover. 14 images total. haha. is there a way to make it so the script only accepts covers that both fit the album and the artist?

edit:
oh, and if you do download cover (amazon) and then download cover (walmart) (or vice versa) the files over write each other.

Walmart' 500x500 album covers download script

Reply #35
is there a way to run the script window minimized ?

Walmart' 500x500 album covers download script

Reply #36
Quote
is there a way to run the script window minimized ?
[a href="index.php?act=findpost&pid=305812"][{POST_SNAPBACK}][/a]


use the php script. nothing pops up or anything. just the little hour glass next to your cursor for a second.



Walmart' 500x500 album covers download script

Reply #39
Quote
Dunno if you know this yet, but there is a program which implements walmart cover search here:
http://louhi.kempele.fi/~skyostil/projects/albumart/

Looks like they got the idea from your script.
[a href="index.php?act=findpost&pid=306016"][{POST_SNAPBACK}][/a]


Well, seems like there are several programs and scripts out there.

Album Cover Art Downloader
Album Art Aggregator
The python script
The php script

Walmart' 500x500 album covers download script

Reply #40
Thanks for all the good work.  This is a pretty neat little setup, especially alongside foo_toaster and foo_albumart.

I made one little modification that users may wish to add:
Code: [Select]
FIND:
# search for albums

AFTER, ADD
if(file_exists($base_dir . "\folder.jpg")) exit(0);

(assuming windows).

This will prevent the script from executing if a folder.jpg already exists.

It's probably pretty abusive to amazon/walmart, but a quick way to get all of your albums done (assuming you have tracknumbers tagged) is to sort by track number using columns UI, and just select all the track 01's and run this script on them.  This took care of several hundred albums at once for me (I'd do about 100, then wait, then another 100, etc).  Make sure you deselect the option in foo_openwith to "call the command once per group"

Here's my foo_openwith settings:
Command name: Art
Application path: C:\Program Files\foobar2000\php-win.exe
Pre parameters: getcover.phpx
Main parameters: "%artist% %album%" "$replace(%_path%,\%_filename_ext%,)" folder

Notes:
as I said, UNCHECK the "call the command once per group" setting if you plan to grab covers for more than one at a time.

There's a single space after getcover.phpx in pre-parameters

Your paths and filenames will vary (I renamed mine to phpx while testing because I have existing associations for .php that I prefer to preserve).

I downloaded php5 from www.php.net (the zipfile one) but it didn't include php4ts.dll which I believe this script requires.  That file can of course be grabbed from the php4 package (or probably googled for a single download).

I hope this helps someone.  I might write a script to go through downloaded images in folders that have more than one result (I've found that most of these are albums for which a "real" cover could not be located).

Hope this is helpful.

edit - made those scripts:

index.php:
Code: [Select]
<?php

$dir = "e:\\lossless\\";

if(!$_GET) {
    echo "Or you can <a href=\"clean.php\">clean up</a> this folder.<hr>";
    echo "<table>";
    if (is_dir($dir)) {
   if ($dh = opendir($dir)) {
       while (($file = readdir($dh)) !== false) {
    if(filetype($dir . $file) == "dir" && $file != "." && $file != "..")
    {
      $dh2 = opendir($dir . $file . "\\");
      while(($file2 = readdir($dh2)) !== false)
      {
       if(strpos($file2, "folder") === 0 && strpos($file2, ".jpg") !== false)
       {
        $path = urlencode($dir . $file . "\\" . $file2);
        echo "<tr><td><a href=\"del.php?path=$path\"><img src=\"". $file . "/" . $file2 . "\"></a></td><td>" . $dir.$file."\\".$file2 . "</td></tr>\n";
       }
      }
    
    }
       }
       closedir($dh);
   }
    }
    echo "</table>";
}

?>


clean.php:
Code: [Select]
<?php
$dir = "e:\\lossless\\";
$doneFolders = array();
    if (is_dir($dir)) {
   if ($dh = opendir($dir)) {
       while (($file = readdir($dh)) !== false) {
    if(filetype($dir . $file) == "dir" && $file != "." && $file != "..")
    {
      $dh2 = opendir($dir . $file . "\\");
      while(($file2 = readdir($dh2)) !== false)
      {
       if($file2 == 'folder.jpg' && !in_array($file, $doneFolders))
       {
        shell_exec("move \"" . $dir . $file . "\\folder.jpg\" \"" . $dir . $file . "\\glargh.jpg\"");
        shell_exec("del \"" . $dir . $file . "\\folder?.jpg\"");
        shell_exec("move \"" . $dir . $file . "\\glargh.jpg\" \"" . $dir . $file . "\\folder.jpg\"");
        $doneFolders[] = $file;
       }
       elseif(strpos($file2, "folder") === 0 && strpos($file2, ".jpg") !== false && !in_array($file, $doneFolders)) {
        shell_exec("move \"" . $dir . $file . "\\" . $file2 . "\" \"" . $dir . $file . "\\glargh.jpg\"");
        shell_exec("del \"" . $dir . $file . "\\folder?.jpg\"");
        shell_exec("move \"" . $dir . $file . "\\glargh.jpg\" \"" . $dir . $file . "\\folder.jpg\"");
        $doneFolders[] = $file;
       }
      }
    
    }
       }
       closedir($dh);
   }
    }    
?>


del.php:
Code: [Select]
<?php
    shell_exec("del \"" . $_GET['path'] . "\"");
    header("Location: index.php");
?>


Basically, you install EasyPHP (http://www.easyphp.org/), set DocumentRoot and the <Directory> directive below it in the apache config file to your audio dir, eg. "C:\lossless".  Then, put those three php files in that directory (again, eg. C:\lossless).  Visit http://localhost in your browser, and assuming that the directories under c:\lossless contain your album art, you'll get a list of current art.  Clicking an album cover will delete it.  Delete images until the first one in the list for a given album is the one you want.  Finally, click the link at the top to run cleanup, and it'll delete remaining files (eg. you deleted folder.jpg, folder1.jpg and folder2.jpg - it'll remove folder4.jpg through folder9.jpg).  It also renames your desired image to folder.jpg.

Sounds complicated, and it forces you to use folder.jpg for your image name with this plugin, but it works.  I just got images all set for some 80 albums in a matter of minutes.

Remember, you have to have your albums only one directory below DocumentRoot - so in our example, C:\incoming\Pink Floyd - The Wall\ would work, but C:\incoming\Pink Floyd\The Wall will not (unless the artwork's in \Pink Floyd\ - unlikely).

Walmart' 500x500 album covers download script

Reply #41
can any1 help me i have foo open with set up as below, with php 5 installed yet it does not retrieve any covers!

Quote
I don't need the -f command.
I run it with Open With Plugin just like this:

Command name:   Download Cover (Walmart)
Application path:   "C:\php\php-win.exe"
Pre paramaters:   "C:\Program Files\foobar2000\getcover.php"[SPACE]
Main paramaters:   "%artist% %album%" "$replace(%_path%,\%_filename_ext%,)" cover walmart
Post parameters:

Walmart' 500x500 album covers download script

Reply #42
Quote
is there a way to run the script window minimized ?
[a href="index.php?act=findpost&pid=305812"][{POST_SNAPBACK}][/a]

you might try to rename the script from .py to .pyw (and obviously do accordingly in the fb2k configuration); in that case no console window will open.

Walmart' 500x500 album covers download script

Reply #43
The python script is no more working for me. It runs, but can't get any cover


Walmart' 500x500 album covers download script

Reply #45
Quote
pretty soon you're all scripted away so much you're better off with a foobar component
[a href="index.php?act=findpost&pid=352103"][{POST_SNAPBACK}][/a]


Sounds like someone's volunteering

 
SimplePortal 1.0.0 RC1 © 2008-2019