Limit file name length on Windows
This commit is contained in:
parent
08046498b1
commit
2c950c6fe9
|
@ -7,3 +7,4 @@ __test__*__
|
||||||
qobuz-get
|
qobuz-get
|
||||||
*.swp
|
*.swp
|
||||||
magic.json
|
magic.json
|
||||||
|
qobuz-get.exe
|
||||||
|
|
21
source/app.d
21
source/app.d
|
@ -103,10 +103,28 @@ int main(string[] args)
|
||||||
try {
|
try {
|
||||||
auto fileName = trackName;
|
auto fileName = trackName;
|
||||||
fileName = fileName.replaceAll(regex("[\\?<>:\"/\\\\|\\*]"), "");
|
fileName = fileName.replaceAll(regex("[\\?<>:\"/\\\\|\\*]"), "");
|
||||||
|
auto relPath = discDir~"/"~num~" - "~fileName~".flac";
|
||||||
|
|
||||||
|
version (Windows) {
|
||||||
|
// making up for NTFS/Windows inadequacy
|
||||||
|
// can't really do much better than truncating, sorry.
|
||||||
|
auto totalPath = getcwd() ~ relPath;
|
||||||
|
if (totalPath.length > 255) {
|
||||||
|
totalPath = totalPath[0..(totalPath.length - 4)];
|
||||||
|
relPath = relPath[0..(relPath.length - 4)];
|
||||||
|
while (totalPath.length > 250) {
|
||||||
|
totalPath = totalPath[0..(totalPath.length - 1)];
|
||||||
|
relPath = relPath[0..(relPath.length - 1)];
|
||||||
|
}
|
||||||
|
totalPath ~= ".flac";
|
||||||
|
relPath ~= ".flac";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto pipes = pipeProcess([magic["ffmpeg"].str, "-i", "-", "-metadata", "title="~trackName, "-metadata", "artist="~trackArtist,
|
auto pipes = pipeProcess([magic["ffmpeg"].str, "-i", "-", "-metadata", "title="~trackName, "-metadata", "artist="~trackArtist,
|
||||||
"-metadata", "album="~title, "-metadata", "date="~year, "-metadata", "track="~num, "-metadata", "genre="~genre,
|
"-metadata", "album="~title, "-metadata", "date="~year, "-metadata", "track="~num, "-metadata", "genre="~genre,
|
||||||
"-metadata", "albumartist="~artist, "-metadata", "discnumber="~discNum, "-metadata", "tracktotal="~tracks.length.text,
|
"-metadata", "albumartist="~artist, "-metadata", "discnumber="~discNum, "-metadata", "tracktotal="~tracks.length.text,
|
||||||
"-metadata", "disctotal="~discs.text, discDir~"/"~num~" - "~fileName~".flac"],
|
"-metadata", "disctotal="~discs.text, relPath],
|
||||||
Redirect.stdin | Redirect.stderr | Redirect.stdout);
|
Redirect.stdin | Redirect.stderr | Redirect.stdout);
|
||||||
foreach (chunk; byChunkAsync(url, 1024)) {
|
foreach (chunk; byChunkAsync(url, 1024)) {
|
||||||
pipes.stdin.rawWrite(chunk);
|
pipes.stdin.rawWrite(chunk);
|
||||||
|
@ -116,6 +134,7 @@ int main(string[] args)
|
||||||
wait(pipes.pid);
|
wait(pipes.pid);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
writeln("Failed to download track! Check that ffmpeg is properly configured.");
|
writeln("Failed to download track! Check that ffmpeg is properly configured.");
|
||||||
|
writeln(e.msg);
|
||||||
return -8;
|
return -8;
|
||||||
}
|
}
|
||||||
writeln("Done!");
|
writeln("Done!");
|
||||||
|
|
Loading…
Reference in New Issue