diff cddb2.tcl @ 8:2c01c09bdc0f

Handle "artist - title" as well as "artist / title". Add track number to filename. If the infile isn't stdin, move it to the mp3 directory.
author darius
date Thu, 18 Jul 2002 06:33:52 +0000
parents f5daa3cdeb58
children
line wrap: on
line diff
--- a/cddb2.tcl	Thu Jul 18 06:29:35 2002 +0000
+++ b/cddb2.tcl	Thu Jul 18 06:33:52 2002 +0000
@@ -112,11 +112,13 @@
 		}
 
 		"DTITLE" {
-		    if {[regexp {^(.*) / (.*)$} $value a tracks(albumartist) tracks(albumname)] != 1} {
-			set tracks(albumname) $value;
-		    } else {
-			puts "Atrist - $tracks(albumartist)";
+		    puts "Searching title - $value";
+		    if {![regexp {^(.*) / (.*)$} $value a tracks(albumartist) tracks(albumname)]} {
+			if  {![regexp {^(.*) - (.*)$} $value a tracks(albumartist) tracks(albumname)]} {
+			    set tracks(albumname) $value;
+			}
 		    }
+		    puts "Artist - $tracks(albumartist)";
 		    puts "Title - $tracks(albumname)";
 		}
 
@@ -183,7 +185,7 @@
 		continue;
 	    }
 
-	    set t_artist($i) "Unknown";
+	    set tracks(artist:$i) "";
 	}
 
 #	puts "$tracks(number) tracks";
@@ -249,12 +251,15 @@
 	quoter tracks(title:$t_no);
 
 	set oldname [ eval format {$oldbasename} {$t_no} ];
-	set newname [ eval format {$newbasename} {"$tracks(artist:$t_no) - $tracks(title:$t_no)"} ];
+	set newname [ eval format {$newbasename} {"[format %02d $t_no] $tracks(artist:$t_no) - $tracks(title:$t_no)"} ];
 
 	puts $out "mp3info -a \"$tracks(artist:$t_no)\" -t \"$tracks(title:$t_no)\" -l \"$tracks(albumname)\" -c \"Track $t_no\" -F 4 \"$oldname\"";
 	puts $out "mv \"$oldname\" \"$dirname/$newname\"";
     }
 
+    if {$infile != "-"} {
+	puts $out "mv \"$infile\" \"$dirname\"";
+    }
     if {[catch {close $out} msg]} {
 	puts "Got $msg closing renamer";
     }