Skip to content

Repository files navigation

Tidal Backup Script

Export Tidal data, using Google Apps Script.

This script can be used to automatically export a user's data, particularly playlists, from Tidal. They are stored in a specified Google Drive directory, where they can be easily downloaded or shared.

Usage

This script is designed to be run on-demand via the GAS interface, or periodically via GAS triggers. For more info on setting up GAS triggers, see this Google Apps Script guide.

The script includes a backupLibrary() function to export library data, such as saved tracks and followed artists, as well as backupPlaylists() to export all playlists, both of which can be run directly. To export all data at once, simply run the main() function.

Setup

There are four steps necessary to run this script.

  1. Register a Tidal API app
  2. Customize your config file
  3. Load the script into a new Google Apps Script project
  4. Authorise the script with the Tidal API

1. Register a Tidal API app

To access the Tidal API, each application needs to be registered with Tidal. This can be done from the 'Tidal Developer Dashboard'.

To register an app, you only need to specify an app name. Once registered, you will need navigate to the app settings on the app page, to specify the 'scopes' that the app will use: TBD!!! - collection.read - playlists.read - user.read Once that done, the client ID & client secret can be collected from the app page, for the config file.

For more information, see Tidal's Development Guide.

2. Customize your config file

config.js should contain a single JavaScript object, used to specify all necessary configuration information. Here's where you specify the user, the Tidal client ID & client secret for accessing the API, as well as the Google Drive directory to save the exported files to.

An example version is provided, named example.config.js, which can be renamed or copied to config.js before loading into the GAS project.

The basic structure can be seen below.

const config = {
    "clientId": "<Tidal client ID>",
    "clientSecret": "<Tidal client secret>",
    "outputFormat":  ["raw", "csv", "xspf"],
    "backupDir": "<Google Drive directory ID>",
    "removeMissingPlaylists": <true/false>
};
  • clientId & clientSecret: An identifier & key for accessing the Tidal API. They can be found on the page for the app you created in step 1.
  • outputFormat: An array indicating the desired output format(s). Valid values are:
    • raw - Raw, (mostly) unedited JSON file, direct from the API. This is useful if you want to capture some details that are not preserved by the other formats.
    • csv - A comma-separate text file, containing a minimal set of details for each category of backup.
    • xspf - An XML/XSPF playlist file, containing details about each track, as well as the overall playlist. Only relevant for playlist backup.
  • backupDir: The ID of the Google Drive directory, where exported data should be stored. This can be found by navigating to the folder, and grabbing the ID from the tail of the URL.
  • removeMissingPlaylists: This option will remove backed up playlist files if they do not match a current playlist, e.g. name changed, or deleted.
  • downloadPlaylistCover: This option will also download cover art for each playlist.

3. Load the script into a new Google Apps Script project

You can manually load the script into a new GAS project, by simply copying and pasting each of the files into the editor.

Or you can use a tool like clasp to upload it directly. For more information on using clasp, here is a guide I found useful.

4. Authorise the script with the Tidal API

For the script to be able to access your data, it first needs to be authorised. This should only need to be done once, unless the user or Tidal details in the config file change. This involves logging into Tidal as the desired user, via a URL generated by the script.

The script can be authorised by deploying it as a web app, and navigating to the deployed URL. For more information on how to do this, see this Google Apps Script guide.

On the page, you will find instructions on adding the web app's address as a redirect_uri to the Tidal app, and authorising the script with Tidal.

Once this is done, the script can be un-deployed (if desired), and all data retrieval functions should work. If the script is run and cannot detect usable credentials, it will throw an error.

About

Export Tidal data, using Google Apps Script

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Contributors

Languages