Mercurial > ~darius > hgwebdir.cgi > cddb-stuff
comparison 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 |
comparison
equal
deleted
inserted
replaced
7:ad83a38c3f5a | 8:2c01c09bdc0f |
---|---|
110 set tracks(discid) $value; | 110 set tracks(discid) $value; |
111 # puts "Got ID as $value"; | 111 # puts "Got ID as $value"; |
112 } | 112 } |
113 | 113 |
114 "DTITLE" { | 114 "DTITLE" { |
115 if {[regexp {^(.*) / (.*)$} $value a tracks(albumartist) tracks(albumname)] != 1} { | 115 puts "Searching title - $value"; |
116 set tracks(albumname) $value; | 116 if {![regexp {^(.*) / (.*)$} $value a tracks(albumartist) tracks(albumname)]} { |
117 } else { | 117 if {![regexp {^(.*) - (.*)$} $value a tracks(albumartist) tracks(albumname)]} { |
118 puts "Atrist - $tracks(albumartist)"; | 118 set tracks(albumname) $value; |
119 } | |
119 } | 120 } |
121 puts "Artist - $tracks(albumartist)"; | |
120 puts "Title - $tracks(albumname)"; | 122 puts "Title - $tracks(albumname)"; |
121 } | 123 } |
122 | 124 |
123 "TTITLE([0-9]+)" { | 125 "TTITLE([0-9]+)" { |
124 regexp {TTITLE([0-9]+)} $key a t_no; | 126 regexp {TTITLE([0-9]+)} $key a t_no; |
181 set tracks(artist:$i) $ext($i); | 183 set tracks(artist:$i) $ext($i); |
182 # puts "setting artist to $ext($i) for $i"; | 184 # puts "setting artist to $ext($i) for $i"; |
183 continue; | 185 continue; |
184 } | 186 } |
185 | 187 |
186 set t_artist($i) "Unknown"; | 188 set tracks(artist:$i) ""; |
187 } | 189 } |
188 | 190 |
189 # puts "$tracks(number) tracks"; | 191 # puts "$tracks(number) tracks"; |
190 | 192 |
191 } | 193 } |
247 # Eat illegal characters | 249 # Eat illegal characters |
248 quoter tracks(artist:$t_no); | 250 quoter tracks(artist:$t_no); |
249 quoter tracks(title:$t_no); | 251 quoter tracks(title:$t_no); |
250 | 252 |
251 set oldname [ eval format {$oldbasename} {$t_no} ]; | 253 set oldname [ eval format {$oldbasename} {$t_no} ]; |
252 set newname [ eval format {$newbasename} {"$tracks(artist:$t_no) - $tracks(title:$t_no)"} ]; | 254 set newname [ eval format {$newbasename} {"[format %02d $t_no] $tracks(artist:$t_no) - $tracks(title:$t_no)"} ]; |
253 | 255 |
254 puts $out "mp3info -a \"$tracks(artist:$t_no)\" -t \"$tracks(title:$t_no)\" -l \"$tracks(albumname)\" -c \"Track $t_no\" -F 4 \"$oldname\""; | 256 puts $out "mp3info -a \"$tracks(artist:$t_no)\" -t \"$tracks(title:$t_no)\" -l \"$tracks(albumname)\" -c \"Track $t_no\" -F 4 \"$oldname\""; |
255 puts $out "mv \"$oldname\" \"$dirname/$newname\""; | 257 puts $out "mv \"$oldname\" \"$dirname/$newname\""; |
256 } | 258 } |
257 | 259 |
260 if {$infile != "-"} { | |
261 puts $out "mv \"$infile\" \"$dirname\""; | |
262 } | |
258 if {[catch {close $out} msg]} { | 263 if {[catch {close $out} msg]} { |
259 puts "Got $msg closing renamer"; | 264 puts "Got $msg closing renamer"; |
260 } | 265 } |
261 | 266 |
262 if {[info exists fh]} { | 267 if {[info exists fh]} { |