@The Vern:
Thanks for the offer of allowing multiple save locations. But my case is rather tricky (as WilB rightly pointed out), in that it would require the second copy to have a static filename, and it would have to be saved at the start of the song. But if such a thing is possible at all, I would very much welcome it
@WilB:
Thanks so much for providing that script! I hadn't considered using a script to copy pre-existing lyrics files, as opposed to getting the loaded lyrics from the plugin itself. It still leaves the songs without saved lyrics of course, but it does take care of all regularly played songs.
I've changed the script to suit my particular case, so I've added it below in case anyone is interested. A few notes:
- It copies .txt lyrics if present, otherwise .lrc is converted. Conversion is very 'dirty', so it won't work on files that contain errors. For instance, timestamps are recognized with a few simple charAt tests instead of a proper regexp (for performance reasons).
- File operations are optimised for using a local source, and network destination. Hence, reading .lrc files is done line by line, but writing is done in one go.
- Suggestions for improvements are always welcome
//
// Script to copy current song lyrics to a static location.
//
// Copies .txt if present, otherwise .lrc is converted (quick 'n dirty).
// File operations optimised for using a local source, and network destination.
var fso = new ActiveXObject("Scripting.FileSystemObject");
var source = fb.FoobarPath + "lyrics\\";
var dest = "m:\\current_lyric.txt";
function on_playback_new_track(metadb) {
var curr, f, line, lyric, end, text, i, c;
var lines = [];
curr = source + fb.TitleFormat("%artist% - %title%").Eval();
try {
if (fso.FileExists(curr + ".txt")) {
fso.CopyFile(curr + ".txt", dest);
} else if (fso.FileExists(curr + ".lrc")) {
f = fso.OpenTextFile(curr + ".lrc", 1);
while (!f.AtEndOfStream) {
line = f.ReadLine();
lyric = line.slice(line.lastIndexOf("]") + 1);
while (line.charAt(0) === "[" && !isNaN(line.charAt(1))) {
end = line.indexOf("]", 8);
lines.push([lyric, line.slice(1, end - 1)]);
line = line.slice(end + 1);
}
}
f.Close();
lines.sort(function (a, b) {
if (a[1] < b[1]) return -1;
if (a[1] > b[1]) return 1;
return 0;
});
text = "";
for (i = 0, c = lines.length; i < c; i++) {
text += lines[i][0] + "\r\n";
}
f = fso.OpenTextFile(dest, 2, true);
f.Write(text);
f.Close();
}
} catch (e) {
if (f) f.Close();
}
}
PS: My apologies for replying so late, real life got the better of me for a while