From 67693c6ad0843d5cd882204f556d00b7dcf6d0cf Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 26 Jan 2018 17:30:28 +0100 Subject: [PATCH] input/qobuz: add setting "format_id" --- doc/user.xml | 14 ++++++++++++++ src/input/plugins/QobuzClient.cxx | 4 +++- src/input/plugins/QobuzClient.hxx | 8 +++++++- src/input/plugins/QobuzInputPlugin.cxx | 5 ++++- src/input/plugins/QobuzTrackRequest.cxx | 2 +- 5 files changed, 29 insertions(+), 4 deletions(-) diff --git a/doc/user.xml b/doc/user.xml index 70466984f..103f5f6c3 100644 --- a/doc/user.xml +++ b/doc/user.xml @@ -2429,6 +2429,20 @@ run The Qobuz password. + + + + format_id + N + + + The Qobuz + format identifier, i.e. a number which + chooses the format and quality to be requested from + Qobuz. The default is "5" (320 kbit/s MP3). + + diff --git a/src/input/plugins/QobuzClient.cxx b/src/input/plugins/QobuzClient.cxx index b31aa05af..693afaf11 100644 --- a/src/input/plugins/QobuzClient.cxx +++ b/src/input/plugins/QobuzClient.cxx @@ -52,10 +52,12 @@ QobuzClient::QobuzClient(EventLoop &event_loop, const char *_app_id, const char *_app_secret, const char *_device_manufacturer_id, const char *_username, const char *_email, - const char *_password) + const char *_password, + const char *_format_id) :base_url(_base_url), app_id(_app_id), app_secret(_app_secret), device_manufacturer_id(_device_manufacturer_id), username(_username), email(_email), password(_password), + format_id(_format_id), curl(event_loop), defer_invoke_handlers(event_loop, BIND_THIS_METHOD(InvokeHandlers)) { diff --git a/src/input/plugins/QobuzClient.hxx b/src/input/plugins/QobuzClient.hxx index f2ebce493..5999adb00 100644 --- a/src/input/plugins/QobuzClient.hxx +++ b/src/input/plugins/QobuzClient.hxx @@ -45,6 +45,7 @@ class QobuzClient final : QobuzLoginHandler { const char *const app_id, *const app_secret; const char *const device_manufacturer_id; const char *const username, *const email, *const password; + const char *const format_id; CurlInit curl; @@ -72,7 +73,12 @@ public: const char *_app_id, const char *_app_secret, const char *_device_manufacturer_id, const char *_username, const char *_email, - const char *_password); + const char *_password, + const char *_format_id); + + const char *GetFormatId() const noexcept { + return format_id; + } gcc_pure CurlGlobal &GetCurl() noexcept; diff --git a/src/input/plugins/QobuzInputPlugin.cxx b/src/input/plugins/QobuzInputPlugin.cxx index 8111fb025..bf1c89bf3 100644 --- a/src/input/plugins/QobuzInputPlugin.cxx +++ b/src/input/plugins/QobuzInputPlugin.cxx @@ -148,10 +148,13 @@ InitQobuzInput(EventLoop &event_loop, const ConfigBlock &block) if (password == nullptr) throw PluginUnavailable("No Qobuz password configured"); + const char *format_id = block.GetBlockValue("format_id", "5"); + qobuz_client = new QobuzClient(event_loop, base_url, app_id, app_secret, device_manufacturer_id, - username, email, password); + username, email, password, + format_id); } static void diff --git a/src/input/plugins/QobuzTrackRequest.cxx b/src/input/plugins/QobuzTrackRequest.cxx index ba9a07258..3c83297d2 100644 --- a/src/input/plugins/QobuzTrackRequest.cxx +++ b/src/input/plugins/QobuzTrackRequest.cxx @@ -70,7 +70,7 @@ MakeTrackUrl(QobuzClient &client, const char *track_id) return client.MakeSignedUrl("track", "getFileUrl", { {"track_id", track_id}, - {"format_id", "5"}, + {"format_id", client.GetFormatId()}, }); }