| 1 |
Spotify Plugin |
| 2 |
============== |
| 3 |
|
| 4 |
The ``spotify`` plugin generates Spotify_ playlists from tracks in your library |
| 5 |
with the ``beet spotify`` command using the `Spotify Search API`_. |
| 6 |
|
| 7 |
Also, the plugin can use the Spotify Album_ and Track_ APIs to provide metadata |
| 8 |
matches for the importer. |
| 9 |
|
| 10 |
.. _album: https://developer.spotify.com/documentation/web-api/reference/get-an-album |
| 11 |
|
| 12 |
.. _spotify: https://open.spotify.com/ |
| 13 |
|
| 14 |
.. _spotify search api: https://developer.spotify.com/documentation/web-api/reference/search |
| 15 |
|
| 16 |
.. _track: https://developer.spotify.com/documentation/web-api/reference/get-track |
| 17 |
|
| 18 |
Why Use This Plugin? |
| 19 |
-------------------- |
| 20 |
|
| 21 |
- You're a Beets user and Spotify user already. |
| 22 |
- You have playlists or albums you'd like to make available in Spotify from |
| 23 |
Beets without having to search for each artist/album/track. |
| 24 |
- You want to check which tracks in your library are available on Spotify. |
| 25 |
- You want to autotag music with metadata from the Spotify API. |
| 26 |
- You want to obtain track popularity and audio features (e.g., danceability) |
| 27 |
|
| 28 |
Basic Usage |
| 29 |
----------- |
| 30 |
|
| 31 |
First, enable the ``spotify`` plugin (see :ref:`using-plugins`). Then, use the |
| 32 |
``spotify`` command with a beets query: |
| 33 |
|
| 34 |
:: |
| 35 |
|
| 36 |
beet spotify [OPTIONS...] QUERY |
| 37 |
|
| 38 |
Here's an example: |
| 39 |
|
| 40 |
:: |
| 41 |
|
| 42 |
$ beet spotify "In The Lonely Hour" |
| 43 |
Processing 14 tracks... |
| 44 |
https://open.spotify.com/track/19w0OHr8SiZzRhjpnjctJ4 |
| 45 |
https://open.spotify.com/track/3PRLM4FzhplXfySa4B7bxS |
| 46 |
[...] |
| 47 |
|
| 48 |
Command-line options include: |
| 49 |
|
| 50 |
- ``-m MODE`` or ``--mode=MODE`` where ``MODE`` is either "list" or "open" |
| 51 |
controls whether to print out the playlist (for copying and pasting) or open |
| 52 |
it in the Spotify app. (See below.) |
| 53 |
- ``--show-failures`` or ``-f``: List the tracks that did not match a Spotify |
| 54 |
ID. |
| 55 |
|
| 56 |
You can enter the URL for an album or song on Spotify at the ``enter Id`` prompt |
| 57 |
during import: |
| 58 |
|
| 59 |
:: |
| 60 |
|
| 61 |
Enter search, enter Id, aBort, eDit, edit Candidates, plaY? i |
| 62 |
Enter release ID: https://open.spotify.com/album/2rFYTHFBLQN3AYlrymBPPA |
| 63 |
|
| 64 |
Configuration |
| 65 |
------------- |
| 66 |
|
| 67 |
This plugin can be configured like other metadata source plugins as described in |
| 68 |
:ref:`metadata-source-plugin-configuration`. |
| 69 |
|
| 70 |
Default |
| 71 |
~~~~~~~ |
| 72 |
|
| 73 |
.. code-block:: yaml |
| 74 |
|
| 75 |
spotify: |
| 76 |
mode: list |
| 77 |
region_filter: |
| 78 |
show_failures: no |
| 79 |
tiebreak: popularity |
| 80 |
regex: [] |
| 81 |
search_query_ascii: no |
| 82 |
client_id: REDACTED |
| 83 |
client_secret: REDACTED |
| 84 |
tokenfile: spotify_token.json |
| 85 |
data_source_mismatch_penalty: 0.5 |
| 86 |
search_limit: 5 |
| 87 |
|
| 88 |
.. conf:: mode |
| 89 |
:default: list |
| 90 |
|
| 91 |
Controls how the playlist is output: |
| 92 |
|
| 93 |
- ``list``: Print out the playlist as a list of links. This list can then |
| 94 |
be pasted in to a new or existing Spotify playlist. |
| 95 |
- ``open``: This mode actually sends a link to your default browser with |
| 96 |
instructions to open Spotify with the playlist you created. Until this |
| 97 |
has been tested on all platforms, it will remain optional. |
| 98 |
|
| 99 |
.. conf:: region_filter |
| 100 |
:default: |
| 101 |
|
| 102 |
A two-character country abbreviation, to limit results to that market. |
| 103 |
|
| 104 |
.. conf:: show_failures |
| 105 |
:default: no |
| 106 |
|
| 107 |
List each lookup that does not return a Spotify ID (and therefore cannot be |
| 108 |
added to a playlist). |
| 109 |
|
| 110 |
.. conf:: tiebreak |
| 111 |
:default: popularity |
| 112 |
|
| 113 |
How to choose the candidate if there is more than one identical result. For |
| 114 |
example, there might be multiple releases of the same album. |
| 115 |
|
| 116 |
- ``popularity``: pick the more popular candidate |
| 117 |
- ``first``: pick the first candidate |
| 118 |
|
| 119 |
.. conf:: regex |
| 120 |
:default: [] |
| 121 |
|
| 122 |
An array of regex transformations to perform on the track/album/artist fields |
| 123 |
before sending them to Spotify. Can be useful for changing certain |
| 124 |
abbreviations, like ft. -> feat. For example: |
| 125 |
|
| 126 |
.. code-block:: yaml |
| 127 |
|
| 128 |
regex: |
| 129 |
- field: albumartist |
| 130 |
search: Something |
| 131 |
replace: Replaced |
| 132 |
- field: title |
| 133 |
search: Something Else |
| 134 |
replace: AlsoReplaced |
| 135 |
|
| 136 |
.. conf:: search_query_ascii |
| 137 |
:default: no |
| 138 |
|
| 139 |
If enabled, the search query will be converted to ASCII before being sent to |
| 140 |
Spotify. Converting searches to ASCII can enhance search results in some |
| 141 |
cases, but in general, it is not recommended. For instance, |
| 142 |
``artist:deadmau5 album:4×4`` will be converted to ``artist:deadmau5 |
| 143 |
album:4x4`` (notice ``×!=x``). |
| 144 |
|
| 145 |
.. include:: ./shared_metadata_source_config.rst |
| 146 |
|
| 147 |
Obtaining Track Popularity and Audio Features from Spotify |
| 148 |
---------------------------------------------------------- |
| 149 |
|
| 150 |
Spotify provides information on track popularity_ and audio features_ that can |
| 151 |
be used for music discovery. |
| 152 |
|
| 153 |
.. _features: https://developer.spotify.com/documentation/web-api/reference/get-audio-features |
| 154 |
|
| 155 |
.. _popularity: https://developer.spotify.com/documentation/web-api/reference/get-track |
| 156 |
|
| 157 |
The ``spotify`` plugin provides an additional command ``spotifysync`` to obtain |
| 158 |
these track attributes from Spotify: |
| 159 |
|
| 160 |
- ``beet spotifysync [-f]``: obtain popularity and audio features information |
| 161 |
for every track in the library. By default, ``spotifysync`` will skip tracks |
| 162 |
that already have this information populated. Using the ``-f`` or ``-force`` |
| 163 |
option will download the data even for tracks that already have it. Please |
| 164 |
note that ``spotifysync`` works on tracks that have the Spotify track |
| 165 |
identifiers. So run ``spotifysync`` only after importing your music, during |
| 166 |
which Spotify identifiers will be added for tracks where Spotify is chosen as |
| 167 |
the tag source. |
| 168 |
|
| 169 |
In addition to ``popularity``, the command currently sets these audio features |
| 170 |
for all tracks with a Spotify track ID: |
| 171 |
|
| 172 |
- ``acousticness`` |
| 173 |
- ``danceability`` |
| 174 |
- ``energy`` |
| 175 |
- ``instrumentalness`` |
| 176 |
- ``key`` |
| 177 |
- ``liveness`` |
| 178 |
- ``loudness`` |
| 179 |
- ``mode`` |
| 180 |
- ``speechiness`` |
| 181 |
- ``tempo`` |
| 182 |
- ``time_signature`` |
| 183 |
- ``valence`` |