diff --git a/README.md b/README.md index a3a581e..997e635 100644 --- a/README.md +++ b/README.md @@ -404,6 +404,27 @@ content_url = JSON.parse(client.post("/1.0/content/B002V0QUOC/licenserequest", b ``` +**Note**: `content_url` is now provided in `.aaxc` format, which ffmpeg does **not** currently support, see [mkb79/Audible#3](https://github.com/mkb79/Audible/issues/3). For now you can use the following to get files in `.aax` format: + +```crystal +require "audible" + +asin = "some_asin" +codec = "some_codec" # Desired quality from /1.0/library/{asin}?response_groups=product_attrs,relationships + +client = Audible::Client.from_json(File.read("session.json")) + +request = HTTP::Request.new("GET", "/FionaCDEServiceEngine/FSDownloadContent?type=AUDI¤tTransportMethod=WIFI&key=#{asin}&codec=#{codec}") +request = client.sign_request(request) + +tld = Audible::LOCALES[client.locale]["AUDIBLE_API"].to_s.split("api.audible.")[1] +content_url = HTTP::Client.new(URI.parse("https://cde-ta-g7g.amazon.com")).exec(request) + .headers["Location"].gsub("https://cds.audible.com", "https://cds.audible.#{tld}") # => https://cds.audible.com/download... + +# `content_url` can then be downloaded using any tool + +``` + Assuming you have your activation bytes, you can convert .aax into another format with the following: ``` diff --git a/src/audible.cr b/src/audible.cr index 7915f2d..739a9f2 100644 --- a/src/audible.cr +++ b/src/audible.cr @@ -42,7 +42,7 @@ module Audible def self.from_json(body : Hash(String, JSON::Any)) client = new - client.login_cookies = Hash.zip(body["login_cookies"].as_h.keys, body["login_cookies"].as_h.values.map { |value| value.as_s }) + client.login_cookies = body["login_cookies"].as_h.transform_values { |value| value.as_s } client.adp_token = body["adp_token"].as_s client.access_token = body["access_token"].as_s client.refresh_token = body["refresh_token"].as_s