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:
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:
<?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:
<?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:
<?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).