misc fixes, album art
This commit is contained in:
parent
c6362020c1
commit
c8507c3c8a
19
source/app.d
19
source/app.d
|
@ -3,6 +3,8 @@ import qobuz.api;
|
||||||
|
|
||||||
int main(string[] args)
|
int main(string[] args)
|
||||||
{
|
{
|
||||||
|
string VERSION = "1.0";
|
||||||
|
|
||||||
if (args.length != 2) {
|
if (args.length != 2) {
|
||||||
writefln("Usage: %s <album id or url>", args[0]);
|
writefln("Usage: %s <album id or url>", args[0]);
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -49,7 +51,12 @@ int main(string[] args)
|
||||||
}
|
}
|
||||||
|
|
||||||
string dirName = artist~" - "~title~" ("~year~") [WEB FLAC]";
|
string dirName = artist~" - "~title~" ("~year~") [WEB FLAC]";
|
||||||
mkdir(dirName);
|
try {
|
||||||
|
mkdir(dirName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
writeln("Could not create directory: `"~dirName~"`. Does it exist already?");
|
||||||
|
return -9;
|
||||||
|
}
|
||||||
|
|
||||||
foreach (i, track; tracks) {
|
foreach (i, track; tracks) {
|
||||||
auto num = (i+1).text;
|
auto num = (i+1).text;
|
||||||
|
@ -67,9 +74,9 @@ int main(string[] args)
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto pipes = pipeProcess([magic["ffmpeg"].str, "-i", "-", "-metadata", "title="~trackName, "-metadata", "author="~artist,
|
auto pipes = pipeProcess([magic["ffmpeg"].str, "-i", "-", "-metadata", "title="~trackName, "-metadata", "artist="~artist,
|
||||||
"-metadata", "album="~title, "-metadata", "year="~year, "-metadata", "track="~num, "-metadata", "genre="~genre,
|
"-metadata", "album="~title, "-metadata", "year="~year, "-metadata", "track="~num, "-metadata", "genre="~genre,
|
||||||
dirName~"/"~num~" "~trackName~".flac"], Redirect.stdin | Redirect.stderr | Redirect.stdout);
|
"-metadata", "comment=qobuz-get "~VERSION, dirName~"/"~num~" "~trackName~".flac"], Redirect.stdin | Redirect.stderr | Redirect.stdout);
|
||||||
foreach (chunk; byChunkAsync(url, 1024)) {
|
foreach (chunk; byChunkAsync(url, 1024)) {
|
||||||
pipes.stdin.rawWrite(chunk);
|
pipes.stdin.rawWrite(chunk);
|
||||||
pipes.stdin.flush;
|
pipes.stdin.flush;
|
||||||
|
@ -83,5 +90,11 @@ int main(string[] args)
|
||||||
writeln("Done!");
|
writeln("Done!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get album art
|
||||||
|
write("Getting album art... ");
|
||||||
|
stdout.flush;
|
||||||
|
download(id.getArtUrl, dirName~"/cover.jpg");
|
||||||
|
writeln("Done!");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,3 +80,14 @@ string getDownloadUrl(JSONValue magic, string id) {
|
||||||
|
|
||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string getArtUrl(string id) {
|
||||||
|
if (id.length != 13) {
|
||||||
|
writeln("Album ID of invalid length given!");
|
||||||
|
exit(-10);
|
||||||
|
}
|
||||||
|
|
||||||
|
string a = id[11..13];
|
||||||
|
string b = id[9..11];
|
||||||
|
return "http://static.qobuz.com/images/covers/"~a~"/"~b~"/"~id~"_max.jpg";
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue