Last Updated or created 2023-01-15
I’ve got a large Folk Music collection. And i wanted to have an overview of the Audio CD’s (mp3/flac) i’ve got from every Band or Artist.
So I made some PHP scripts and a scraping tool. To get a nice overview.
A part of it looks like this:
Most is auto-generated:
The scraper part needs eyed3 (made at a later date)
PHP Files
:::::::::::::: artist.php :::::::::::::: <html><head><title></title> <style type="text/css"> img.clams { border: black dotted 1px; } </style> </head><body vlink=black alink=black link=black> <? $filebak=$file; ?> <center><P> <table border=2><tr><td bgcolor="#cccccc"> <P> <?php include "list.php"; ?> </td></tr></table> <P> <table> <?php $file=$filebak; echo "<tr><td bgcolor=black><a name=\"$file\"><font color=white face=tahoma><b>$file</b></font></a></td></tr>"; include "readcovers.php"; ?> </table> <P> <?php if (file_exists("thumbs/$file/info.txt")){ include "thumbs/$file/info.txt"; } ?> </body></html> :::::::::::::: index.php :::::::::::::: <html><head><title></title> <style type="text/css"> img.clams { border: black dotted 1px; } </style> </head><body vlink=black alink=black link=black> <a name="top"> <font face=tahoma color=red>missing</font> :: <font face=tahoma color=orange>not complete</font> :: <font face=tahoma color=blue>special</font> :: <font face=tahoma color=green>got this one</font><P> <center><P> <font face=Tahoma>TODO: List artists, per-page covers (per artist)<BR> Sort A-Z<BR>Counters<BR>filter <i>got this one / Missing</i> <table border=2><tr><td bgcolor="#cccccc"> <P> <?php include "list.php"; ?> </td></tr></table> <P> <table> <?php $dir = "thumbs/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { $dh = opendir($dir); while (($file = readdir($dh)) !==false) { #echo "filename: $file : filetype: " . filetype($dir . $file) . "\n"; if (filetype($dir . $file)=="dir" && $file!=="." && $file!=="..") { echo "<tr><td bgcolor=black><a name=\"$file\"><font color=white face=tahoma><b>$file</b></font></a><a href=\"#top\"> <f ont face=tahoma color=\"grey\"><small>(top)</small></a></td></tr>"; include "readcovers.php"; } } } closedir($dh); ?> </table> </body></html> :::::::::::::: list.php :::::::::::::: <html><head><title></title> <style> <!-- A:link {text-decoration: none; color: "#000000";} A:visited {text-decoration: none; color: "#000000";} A:hover {text-decoration: none; } //--> </style> </head><body> <center><P> <?php $countart=0; $dir = "thumbs/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { $dh = opendir($dir); while (($file = readdir($dh)) !==false) { if (filetype($dir . $file)=="dir" && $file!=="." && $file!=="..") { echo "<a href=\"index.php#$file\"><font color=black face=tahoma><b>$file</b></font></a><a href=\"artist.php?file=$file\ ">@</a> "; $countart=$countart+1; if ($countart==4) { $countart=0; echo "<BR>";} else { echo ":: ";} } } } closedir($dh); ?> </body></html> :::::::::::::: readcovers.php :::::::::::::: <tr><td align=left> <table><tr><td width=30></td> <?php $dir1 = "thumbs/$file"; $counter=0; // Open a known directory, and proceed to read its contents if (is_dir($dir1)) { if ($dh1 = opendir($dir1)) { while (($file1 = readdir($dh1)) !==false) { #echo "filename: $file : filetype: " . filetype($dir1 . $file) . "<BR>"; $fileinfo="leeg"; if ($counter==7) { echo "</tr><tr><td width=30></td>"; $counter=0; } if ($file1!=="." && $file1!=="..") { if (stristr("$file1", ".jpg")) { echo "<td valign=top width=105><center><img src=\"$dir1/$file1\" class=\"clams\">"; $fileinfo = str_replace("jpg", "txt", $file1); $counter=$counter+1;} if (file_exists("$dir1/$fileinfo")) { echo "<br><font face=tahoma><small>"; include "$dir1/$fileinfo"; } echo "</small></td>"; } } closedir($dh1); } } ?> </tr></table> </td></tr>
Scraper
mkdir -p /tmp/1 find celtic/Celtic/ -type d | while read ; do countmp3=$(ls "$REPLY" | egrep -i mp3$ | wc -l) if [ $countmp3 -gt 0 ] ; then rm -f /tmp/1/* album=$( echo $REPLY | rev | cut -f1 -d/ | rev) artist=$( echo $REPLY | rev | cut -f2 -d/ | rev) countslash=$(echo "$REPLY" | tr -cd '/' | wc -c) if [ $countslash -lt 4 ] ; then artist=$album album="" fi echo "artist : $artist - Album : $album" mkdir -p "thumbs/$artist" ls "$REPLY" | egrep -i "mp3$|flac$" | while read biggest; do eyeD3 --write-images=/tmp/1 "$REPLY/$biggest" if [ ! "$( ls -A /tmp/1/ )" ] ; then cp empty.jpg /tmp/1/FRONT.jpg ;fi deze=$(ls -S /tmp/1/* | head -1) convert -resize 200x200 "$deze" "thumbs/$artist/$album.jpg" echo "$album" > "thumbs/$artist/$album.txt" done fi done
I’m planning to make an version which shows every individual mp3, and shows me if they are valid mp3’s/flac and have a good over.
(Using tiny thumbnails)