Compare commits

...

7 Commits
1.3 ... master

Author SHA1 Message Date
Al Beano 7df418a447 Updated download link 2018-01-07 00:11:55 +00:00
Al Beano 35b0e9f525 Update README for finding auth token 2018-01-04 20:28:21 +00:00
Al Beano 169dcd9897 (experimental) Download tracks using curl
std.net.curl seems to cause various issues in this case, and it is probably easier to interface with curl directly.
2018-01-04 13:25:53 +00:00
Al Beano 84d5fe939f Revert to byChunkAsync as byChunk causes memory problems 2018-01-04 00:15:33 +00:00
Al Beano fab4c19ad9 Use byChunk to download files, there is no reason to use byChunkAsync 2018-01-03 18:29:21 +00:00
Al Beano 2c950c6fe9 Limit file name length on Windows 2017-12-08 18:04:46 +00:00
Al Beano 08046498b1 Use 'date' as field for the year of recording, as this is more widely recognised 2017-12-06 22:58:27 +00:00
3 changed files with 46 additions and 8 deletions

1
.gitignore vendored
View File

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

View File

@ -4,6 +4,8 @@ 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.
@ -36,6 +38,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)
* 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.
* Open the page for any album.
* In the Network window, you should see a `GET` request beginning with `get?album_id`. 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,9 +1,10 @@
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.2";
string VERSION = "1.4";
if (args.length != 2) {
writefln("Usage: %s <album id or url>", args[0]);
@ -103,19 +104,53 @@ 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", "year="~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", "disctotal="~discs.text, discDir~"/"~num~" - "~fileName~".flac"],
"-metadata", "disctotal="~discs.text, relPath],
Redirect.stdin | Redirect.stderr | Redirect.stdout);
foreach (chunk; byChunkAsync(url, 1024)) {
pipes.stdin.rawWrite(chunk);
pipes.stdin.flush;
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;
}
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!");