I took a swing at this. Got a diff attached. It is about the absolute laziest possible solution to the problem I could see.
(No error checking, no nothing. Probably fails inelegantly if there's nothing there when it tries to pull the metadata. But it's working for me so far, for my nice, sanitized files.)
Here's the change, for the file subsonic-main/src/main/java/net/sourceforge/subsonic/service/TranscodingService.java. (Sorry, I'm not too well-versed in submitting patches.)
- Code: Select all
*** TranscodingService.java 2010-08-06 14:04:11.430636532 -0500
--- TranscodingService.java.mod 2010-08-06 14:03:55.266555633 -0500
***************
*** 256,261 ****
--- 256,266 ----
private String[] createCommand(String command, TranscodeScheme transcodeScheme, MusicFile musicFile) {
if (musicFile != null) {
command = command.replace("%s", '"' + musicFile.getFile().getAbsolutePath() + '"');
+ command = command.replace("%a", '"' + musicFile.getMetaData().getArtist() + '"');
+ command = command.replace("%l", '"' + musicFile.getMetaData().getAlbum() + '"');
+ command = command.replace("%t", '"' + musicFile.getMetaData().getTitle() + '"');
+ command = command.replace("%y", '"' + musicFile.getMetaData().getYear().toString() + '"');
+ command = command.replace("%n", '"' + musicFile.getMetaData().getTrackNumber().toString() + '"');
}
// If no transcoding scheme is specified, use 128 Kbps.
In addition to the code change, the downsample (and transcode) commands need updating. My downsample arguments look thus, now:
- Code: Select all
lame -S -h -b %b --add-id3v2 --pad-id3v2 --ta %a --tt %t --tl %l --ty %y --tn %n %s -
Edit: OK, not sure about things with no metadata (haven't had a problem there yet), but if something's got a quotation mark (") in any field, it doesn't get escaped, and lame just fails. Howzat for inelegant?
...Now to teach myself how to modify strings in java.