freesound: update to API v2

Multimedia / Ardour - Colin Fletcher [googlemail.com] - 20 May 2022 13:33 UTC

Add a new client id & token for Ardour 7, and update to Freesound's API
v2.

Implement OAuth authentication for Freesound downloads, as described at: https://freesound.org/docs/api/authentication.html#oauth-authentication

Open the Freesound login page in the default browser, so that the user can log in and get an authorization code, to copy-&-paste from the browser. Exchange this authorization code for an access token, and use it in a custom 'Authorization: Bearer $TOKEN' http header.

If logging in to Freesound to download a file fails or is cancelled, clear the 'downloading' flag for that file in the list so that a subsequent click on it will try to log in again.

Show login progress in download progress bar, and disable preview if file hasn't yet been downloaded.

If a download fails for any reason (except the user cancelling it), report an error in the Log window.

Use curl_free() for pointers returned by curl_easy_escape(), as per the curl documentation, rather than plain free().

Also, don't use the www. sub-domain of freesound.org: although it appears to work for most things, it returns an empty document from https://freesound.org/apiv2/oauth2/access_token/

Remove default empty token value from Mootcher constructor, to make it explicit when we construct a Mootcher that doesn't require authorisation, by requiring an empty token parameter in that case.

9fe0a4f4dd freesound: update to API v2
gtk2_ardour/sfdb_freesound_mootcher.cc | 277 ++++++++++++++++++++++++++-------
gtk2_ardour/sfdb_freesound_mootcher.h | 32 ++--
gtk2_ardour/sfdb_ui.cc | 133 +++++++++-------
gtk2_ardour/sfdb_ui.h | 5 +-
4 files changed, 318 insertions(+), 129 deletions(-)

  • Share