Compare commits

..

No commits in common. "master" and "1.2" have entirely different histories.
master ... 1.2

4 changed files with 22 additions and 63 deletions

1
.gitignore vendored
View File

@ -7,4 +7,3 @@ __test__*__
qobuz-get
*.swp
magic.json
qobuz-get.exe

View File

@ -4,8 +4,6 @@ Tool to download FLACs from qobuz.com.
## Setup
**If git.fuwafuwa.moe is down, click [here](https://github.com/whiteisthenewblack/qobuz-get/files/1599102/qobuz-get-win32-1.3.zip) for the latest Windows binary.**
Statically linked 64-bit Linux and Windows binaries are available in the [Releases](https://git.fuwafuwa.moe/albino/qobuz-get/releases) tab. On Linux, you should install sox, ffmpeg and mktorrent with your package manager, and insert the paths to the binaries (found using `which sox`, `which ffmpeg`, etc...) into magic.json.
There are three other values which must be inserted into magic.json. `app_id` and `app_secret` are listed on [this page](http://shell.cyberia.is/~albino/qobuz-creds.html). `user_auth_token` is specific to your qobuz account. See the bottom of this README for instructions on finding it. These values could change from time to time, so if qobuz-get stops working suddenly, you probably need to get new ones.
@ -38,6 +36,6 @@ Check that the values in magic.json are correct, then ask for help on IRC. Conne
* Open http://play.qobuz.com in your browser and log in with your credentials.
* Open the 'Network' tab of your browser's developer tools. (In Firefox, right click on page -> inspect element -> select the 'Network' tab)
* Open the page for any album.
* In the Network window, you should see a `GET` request beginning with `get?album_id`. Select it.
* Type any letter into the "Search" box at the top right of the page.
* In the Network window, you should see a `GET` request beginning with `search`. Select it.
* You should see a list of headers on the right hand side (in Chrome, you need to click the "Headers" tab). Scroll down to the one which says `x-user-auth-token`. Select the content, and copy and paste it into magic.json. Done!

View File

@ -1,10 +1,9 @@
import std.stdio, std.regex, std.json, std.file, std.datetime, std.conv, std.process, std.net.curl, std.string;
import qobuz.api;
import etc.c.curl;
int main(string[] args)
{
string VERSION = "1.4";
string VERSION = "1.2";
if (args.length != 2) {
writefln("Usage: %s <album id or url>", args[0]);
@ -52,7 +51,10 @@ int main(string[] args)
}
string dirName = artist~" - "~title~" ("~year~") [WEB FLAC]";
dirName = dirName.replaceAll(regex("[\\?<>:\"/\\\\|\\*]"), "");
version (Windows) {
dirName = dirName.replaceAll(regex("[\\?<>:\"/\\\\|\\*]"), "");
}
try {
mkdir(dirName);
@ -69,13 +71,7 @@ int main(string[] args)
num = track["track_number"].integer.text;
discNum = track["media_number"].integer.text;
trackName = track["title"].str;
try {
trackArtist = track["performer"]["name"].str;
} catch (Exception e) {
// Qobuz doesn't return a "performer" for all albums, and I'm not sure about
// the best way to deal with this. Leaving blank for now.A
trackArtist = "";
}
trackArtist = track["performer"]["name"].str;
if (num.length < 2)
num = "0"~num;
writef(" [%s/%s] %s... ", discNum, num, trackName);
@ -103,54 +99,22 @@ int main(string[] args)
try {
auto fileName = trackName;
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,
"-metadata", "album="~title, "-metadata", "date="~year, "-metadata", "track="~num, "-metadata", "genre="~genre,
"-metadata", "albumartist="~artist, "-metadata", "discnumber="~discNum, "-metadata", "tracktotal="~tracks.length.text,
"-metadata", "disctotal="~discs.text, relPath],
Redirect.stdin | Redirect.stderr | Redirect.stdout);
extern(C) static size_t writefunc(const ubyte* data, size_t size, size_t nmemb, void* p) {
auto pp = *(cast(ProcessPipes*) p);
pp.stdin.rawWrite(data[0..size*nmemb]);
pp.stdin.flush();
return size*nmemb;
version (Windows) {
fileName = fileName.replaceAll(regex("[\\?<>:\"/\\\\|\\*]"), "");
}
auto pipes = pipeProcess([magic["ffmpeg"].str, "-i", "-", "-metadata", "title="~trackName, "-metadata", "artist="~trackArtist,
"-metadata", "album="~title, "-metadata", "year="~year, "-metadata", "track="~num, "-metadata", "genre="~genre,
"-metadata", "albumartist="~artist, "-metadata", "discnumber="~discNum, "-metadata", "tracktotal="~tracks.length.text,
"-metadata", "disctotal="~discs.text, discDir~"/"~num~" - "~fileName~".flac"],
Redirect.stdin | Redirect.stderr | Redirect.stdout);
foreach (chunk; byChunkAsync(url, 1024)) {
pipes.stdin.rawWrite(chunk);
pipes.stdin.flush;
}
CURL* curl;
CURLcode res;
curl = curl_easy_init();
curl_easy_setopt(curl, CurlOption.url, toStringz(url));
curl_easy_setopt(curl, CurlOption.followlocation, 1L);
curl_easy_setopt(curl, CurlOption.writefunction, cast(void*) &writefunc);
curl_easy_setopt(curl, CurlOption.writedata, cast(void*) &pipes);
res = curl_easy_perform(curl);
assert(res == CurlError.ok);
curl_easy_cleanup(curl);
pipes.stdin.close;
wait(pipes.pid);
} catch (Exception e) {
writeln("Failed to download track! Check that ffmpeg is properly configured.");
writeln(e.msg);
return -8;
}
writeln("Done!");
@ -180,7 +144,9 @@ int main(string[] args)
if (choice == "y") {
try {
auto trackName = tracks[0]["title"].str;
trackName = trackName.replaceAll(regex("[\\?<>:\"/\\\\|\\*]"), "");
version (Windows) {
trackName = trackName.replaceAll(regex("[\\?<>:\"/\\\\|\\*]"), "");
}
auto full = execute([magic["sox"].str, firstDisc~"/01 - "~trackName~".flac", "-n", "remix", "1", "spectrogram",
"-x", "3000", "-y", "513", "-z", "120", "-w", "Kaiser", "-o", "SpecFull.png"]);
@ -219,5 +185,3 @@ int main(string[] args)
return 0;
}
// ex: set tabstop=2 expandtab:

View File

@ -91,5 +91,3 @@ string getArtUrl(string id) {
string b = id[9..11];
return "http://static.qobuz.com/images/covers/"~a~"/"~b~"/"~id~"_max.jpg";
}
// ex: set tabstop=2 expandtab: