spotify-monitor 2.1.1__tar.gz → 2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of spotify-monitor might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spotify_monitor
3
- Version: 2.1.1
3
+ Version: 2.2
4
4
  Summary: Tool implementing real-time tracking of Spotify friends music activity
5
5
  Author-email: Michal Szymanski <misiektoja-pypi@rm-rf.ninja>
6
6
  License-Expression: GPL-3.0-or-later
@@ -29,10 +29,6 @@ spotify_monitor is a tool for real-time monitoring of Spotify friends' music act
29
29
 
30
30
  NOTE: If you're interested in tracking changes to Spotify users' profiles including their playlists, take a look at another tool I've developed: [spotify_profile_monitor](https://github.com/misiektoja/spotify_profile_monitor).
31
31
 
32
- > Spotify made multiple changes to the web endpoint on June 10th 2025, which broke the **[sp_dc cookie](#spotify-sp_dc-cookie)** method.
33
- > 📦 The issue is under investigation to determine if it can be restored.
34
- > 👉 In the meantime, use **[desktop client](#spotify-desktop-client)** method instead.
35
-
36
32
  <a id="features"></a>
37
33
  ## Features
38
34
 
@@ -44,6 +40,7 @@ NOTE: If you're interested in tracking changes to Spotify users' profiles includ
44
40
  - Saving all listened songs with timestamps to the CSV file
45
41
  - Clickable Spotify, Apple Music, YouTube Music and Genius Lyrics search URLs printed in the console & included in email notifications
46
42
  - Displaying basic statistics for the user's playing session (duration, time span, number of listened and skipped songs, songs on loop)
43
+ - Support for two different methods to get a Spotify access token (`sp_dc cookie`, `desktop client`)
47
44
  - Possibility to control the running copy of the script via signals
48
45
 
49
46
  <p align="center">
@@ -160,65 +157,64 @@ spotify_monitor --generate-config > spotify_monitor.conf
160
157
  Edit the `spotify_monitor.conf` file and change any desired configuration options (detailed comments are provided for each).
161
158
 
162
159
  <a id="spotify-access-token-source"></a>
163
- #### Spotify access token source
160
+ ### Spotify access token source
164
161
 
165
162
  The tool supports two methods for obtaining a Spotify access token.
166
163
 
167
164
  It can be configured via the `TOKEN_SOURCE` configuration option or the `--token-source` flag.
168
165
 
169
- The **recommended method** is `cookie` which uses the sp_dc cookie to retrieve a token from the Spotify web endpoint.
166
+ **Recommended: `cookie`**
170
167
 
171
- The **alternative method** is `client` which uses captured credentials from the Spotify desktop client and a Protobuf-based login flow. This approach is intended for advanced users who want an indefinitely valid token with the widest scope.
168
+ Uses the `sp_dc` cookie to retrieve a token from the Spotify web endpoint. This method is easy to set up and recommended for most users.
172
169
 
173
- If no method is specified, the tool defaults to the `cookie` method.
170
+ **Alternative: `client`**
174
171
 
175
- <a id="spotify-sp_dc-cookie"></a>
176
- #### Spotify sp_dc Cookie
172
+ Uses captured credentials from the Spotify desktop client and a Protobuf-based login flow. It's more complex to set up and intended for advanced users who want a long-lasting token with the broadest possible access.
177
173
 
178
- It is default method used to obtain a Spotify access token.
174
+ If no method is specified, the tool defaults to the `cookie` method.
179
175
 
180
- Log in to [https://open.spotify.com/](https://open.spotify.com/) in your web browser.
176
+ **Important**: It is strongly recommended to use a separate Spotify account with this tool. It does not rely on the official Spotify Web API for core features (like fetching friend activity), as it is not supported by the public API. That said, while I've never encountered any issues on my own accounts, I can't guarantee that Spotify won't impose restrictions in the future - you've been warned.
181
177
 
182
- Locate and copy the value of the `sp_dc` cookie.
178
+ <a id="spotify-sp_dc-cookie"></a>
179
+ #### Spotify sp_dc Cookie
183
180
 
184
- Use your web browser's dev console or **Cookie-Editor** by cgagnier to extract it easily: [https://cookie-editor.com/](https://cookie-editor.com/)
181
+ This is the default method used to obtain a Spotify access token.
185
182
 
186
- Provide the `SP_DC_COOKIE` secret using one of the following methods:
187
- - Pass it at runtime with `-u` / `--spotify-dc-cookie`
188
- - Set it as an [environment variable](#storing-secrets) (e.g. `export SP_DC_COOKIE=...`)
189
- - Add it to [.env file](#storing-secrets) (`SP_DC_COOKIE=...`) for persistent use
183
+ - Log in to [https://open.spotify.com/](https://open.spotify.com/) in your web browser.
190
184
 
191
- Fallback:
192
- - Hard-code it in the code or config file
185
+ - Locate and copy the value of the `sp_dc` cookie.
186
+ - Use your web browser's dev console or **Cookie-Editor** by cgagnier to extract it easily: [https://cookie-editor.com/](https://cookie-editor.com/)
193
187
 
194
- You will be informed by the tool once the `sp_dc` cookie expires (proper message on the console and in email).
188
+ - Provide the `SP_DC_COOKIE` secret using one of the following methods:
189
+ - Pass it at runtime with `-u` / `--spotify-dc-cookie`
190
+ - Set it as an [environment variable](#storing-secrets) (e.g. `export SP_DC_COOKIE=...`)
191
+ - Add it to [.env file](#storing-secrets) (`SP_DC_COOKIE=...`) for persistent use
192
+ - Fallback: hard-code it in the code or config file
195
193
 
196
- If you store the `SP_DC_COOKIE` in a dotenv file you can update its value and send a `SIGHUP` signal to the process to reload the file with the new `sp_dc` cookie without restarting the tool. More info in [Storing Secrets](#storing-secrets) and [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix).
194
+ If your `sp_dc` cookie expires, the tool will notify you via the console and email. In that case, you'll need to grab the new `sp_dc` cookie value.
197
195
 
198
- **Important**: It is strongly recommended to use a separate Spotify account with this tool. It does not rely on the official Spotify Web API for core features (like fetching friend activity), as it is not supported by the public API.
196
+ If you store the `SP_DC_COOKIE` in a dotenv file you can update its value and send a `SIGHUP` signal to reload the file with the new `sp_dc` cookie without restarting the tool. More info in [Storing Secrets](#storing-secrets) and [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix).
199
197
 
200
198
  <a id="spotify-desktop-client"></a>
201
199
  #### Spotify Desktop Client
202
200
 
203
- To use credentials captured from the Spotify desktop client to obtain an access token, set the `TOKEN_SOURCE` configuration option to `client` or use the `--token-source client` flag.
204
-
205
- Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
201
+ This is the alternative method used to obtain a Spotify access token which simulates a login from the real Spotify desktop app using credentials intercepted from a real session.
206
202
 
207
- Launch the Spotify desktop client and look for POST requests to `https://login{n}.spotify.com/v3/login`
203
+ - Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
208
204
 
209
- Note: The `login` part is suffixed with one or more digits (e.g. `login5`).
205
+ - Launch the Spotify desktop client and look for POST requests to `https://login{n}.spotify.com/v3/login`
206
+ - Note: The `login` part is suffixed with one or more digits (e.g. `login5`).
210
207
 
211
- If you don't see this request, log out from the client and log back in.
208
+ - If you don't see this request, log out from the Spotify desktop client and log back in.
212
209
 
213
- Export the login request body (a binary Protobuf payload) to a file.
214
-
215
- In Proxyman: ***right click the request → Export → Request Body → Save File***.
210
+ - Export the login request body (a binary Protobuf payload) to a file (e.g. ***login-request-body-file***)
211
+ - In Proxyman: **right click the request → Export → Request Body → Save File**.
216
212
 
217
213
  <p align="center">
218
214
  <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/proxyman_export_protobuf.png" alt="proxyman_export_protobuf" width="80%"/>
219
215
  </p>
220
216
 
221
- Then run the tool with `-w <path-to-login-request-body-file>`:
217
+ - Run the tool with `--token-source client -w <path-to-login-request-body-file>`:
222
218
 
223
219
  ```sh
224
220
  spotify_monitor --token-source client -w <path-to-login-request-body-file> <spotify_user_uri_id>
@@ -226,15 +222,17 @@ spotify_monitor --token-source client -w <path-to-login-request-body-file> <spot
226
222
 
227
223
  If successful, the tool will automatically extract the necessary fields and begin monitoring.
228
224
 
229
- You can also persist the Protobuf request file path using the `LOGIN_REQUEST_BODY_FILE` configuration option.
225
+ Instead of using the `-w` flag each time, you can persist the Protobuf login request file path by setting the `LOGIN_REQUEST_BODY_FILE` configuration option.
226
+
227
+ The same applies to `--token-source client` flag - you can persist it via `TOKEN_SOURCE` configuration option set to `client`.
230
228
 
231
229
  The tool will automatically refresh both the access token and client token using the intercepted refresh token.
232
230
 
233
- Advanced options are available for further customization - refer to the configuration file comments. However, default settings should work for most cases.
231
+ If your refresh token expires, the tool will notify you via the console and email. In that case, you'll need to re-export the login request body.
234
232
 
235
- You will be informed by the tool once the refresh token expires (proper message on the console and in email).
233
+ If you re-export the login request body to the same file name, you can send a `SIGHUP` signal to reload the file with the new refresh token without restarting the tool. More info in [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix).
236
234
 
237
- **Important**: It is strongly recommended to use a separate Spotify account with this tool. It does not rely on the official Spotify Web API for core features (like fetching friend activity), as it is not supported by the public API.
235
+ Advanced options are available for further customization - refer to the configuration file comments. However, the default settings are suitable for most users and modifying other values is generally NOT recommended.
238
236
 
239
237
  <a id="following-the-monitored-user"></a>
240
238
  ### Following the Monitored User
@@ -273,12 +271,13 @@ spotify_monitor --send-test-email
273
271
  <a id="storing-secrets"></a>
274
272
  ### Storing Secrets
275
273
 
276
- It is recommended to store secrets like `SP_DC_COOKIE` or `SMTP_PASSWORD` as either an environment variable or in a dotenv file.
274
+ It is recommended to store secrets like `SP_DC_COOKIE`, `REFRESH_TOKEN` or `SMTP_PASSWORD` as either an environment variable or in a dotenv file.
277
275
 
278
- Set environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
276
+ Set the needed environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
279
277
 
280
278
  ```sh
281
279
  export SP_DC_COOKIE="your_sp_dc_cookie_value"
280
+ export REFRESH_TOKEN="your_spotify_app_refresh_token"
282
281
  export SMTP_PASSWORD="your_smtp_password"
283
282
  ```
284
283
 
@@ -288,6 +287,7 @@ Alternatively store them persistently in a dotenv file (recommended):
288
287
 
289
288
  ```ini
290
289
  SP_DC_COOKIE="your_sp_dc_cookie_value"
290
+ REFRESH_TOKEN="your_spotify_app_refresh_token"
291
291
  SMTP_PASSWORD="your_smtp_password"
292
292
  ```
293
293
 
@@ -4,10 +4,6 @@ spotify_monitor is a tool for real-time monitoring of Spotify friends' music act
4
4
 
5
5
  NOTE: If you're interested in tracking changes to Spotify users' profiles including their playlists, take a look at another tool I've developed: [spotify_profile_monitor](https://github.com/misiektoja/spotify_profile_monitor).
6
6
 
7
- > Spotify made multiple changes to the web endpoint on June 10th 2025, which broke the **[sp_dc cookie](#spotify-sp_dc-cookie)** method.
8
- > 📦 The issue is under investigation to determine if it can be restored.
9
- > 👉 In the meantime, use **[desktop client](#spotify-desktop-client)** method instead.
10
-
11
7
  <a id="features"></a>
12
8
  ## Features
13
9
 
@@ -19,6 +15,7 @@ NOTE: If you're interested in tracking changes to Spotify users' profiles includ
19
15
  - Saving all listened songs with timestamps to the CSV file
20
16
  - Clickable Spotify, Apple Music, YouTube Music and Genius Lyrics search URLs printed in the console & included in email notifications
21
17
  - Displaying basic statistics for the user's playing session (duration, time span, number of listened and skipped songs, songs on loop)
18
+ - Support for two different methods to get a Spotify access token (`sp_dc cookie`, `desktop client`)
22
19
  - Possibility to control the running copy of the script via signals
23
20
 
24
21
  <p align="center">
@@ -135,65 +132,64 @@ spotify_monitor --generate-config > spotify_monitor.conf
135
132
  Edit the `spotify_monitor.conf` file and change any desired configuration options (detailed comments are provided for each).
136
133
 
137
134
  <a id="spotify-access-token-source"></a>
138
- #### Spotify access token source
135
+ ### Spotify access token source
139
136
 
140
137
  The tool supports two methods for obtaining a Spotify access token.
141
138
 
142
139
  It can be configured via the `TOKEN_SOURCE` configuration option or the `--token-source` flag.
143
140
 
144
- The **recommended method** is `cookie` which uses the sp_dc cookie to retrieve a token from the Spotify web endpoint.
141
+ **Recommended: `cookie`**
145
142
 
146
- The **alternative method** is `client` which uses captured credentials from the Spotify desktop client and a Protobuf-based login flow. This approach is intended for advanced users who want an indefinitely valid token with the widest scope.
143
+ Uses the `sp_dc` cookie to retrieve a token from the Spotify web endpoint. This method is easy to set up and recommended for most users.
147
144
 
148
- If no method is specified, the tool defaults to the `cookie` method.
145
+ **Alternative: `client`**
149
146
 
150
- <a id="spotify-sp_dc-cookie"></a>
151
- #### Spotify sp_dc Cookie
147
+ Uses captured credentials from the Spotify desktop client and a Protobuf-based login flow. It's more complex to set up and intended for advanced users who want a long-lasting token with the broadest possible access.
152
148
 
153
- It is default method used to obtain a Spotify access token.
149
+ If no method is specified, the tool defaults to the `cookie` method.
154
150
 
155
- Log in to [https://open.spotify.com/](https://open.spotify.com/) in your web browser.
151
+ **Important**: It is strongly recommended to use a separate Spotify account with this tool. It does not rely on the official Spotify Web API for core features (like fetching friend activity), as it is not supported by the public API. That said, while I've never encountered any issues on my own accounts, I can't guarantee that Spotify won't impose restrictions in the future - you've been warned.
156
152
 
157
- Locate and copy the value of the `sp_dc` cookie.
153
+ <a id="spotify-sp_dc-cookie"></a>
154
+ #### Spotify sp_dc Cookie
158
155
 
159
- Use your web browser's dev console or **Cookie-Editor** by cgagnier to extract it easily: [https://cookie-editor.com/](https://cookie-editor.com/)
156
+ This is the default method used to obtain a Spotify access token.
160
157
 
161
- Provide the `SP_DC_COOKIE` secret using one of the following methods:
162
- - Pass it at runtime with `-u` / `--spotify-dc-cookie`
163
- - Set it as an [environment variable](#storing-secrets) (e.g. `export SP_DC_COOKIE=...`)
164
- - Add it to [.env file](#storing-secrets) (`SP_DC_COOKIE=...`) for persistent use
158
+ - Log in to [https://open.spotify.com/](https://open.spotify.com/) in your web browser.
165
159
 
166
- Fallback:
167
- - Hard-code it in the code or config file
160
+ - Locate and copy the value of the `sp_dc` cookie.
161
+ - Use your web browser's dev console or **Cookie-Editor** by cgagnier to extract it easily: [https://cookie-editor.com/](https://cookie-editor.com/)
168
162
 
169
- You will be informed by the tool once the `sp_dc` cookie expires (proper message on the console and in email).
163
+ - Provide the `SP_DC_COOKIE` secret using one of the following methods:
164
+ - Pass it at runtime with `-u` / `--spotify-dc-cookie`
165
+ - Set it as an [environment variable](#storing-secrets) (e.g. `export SP_DC_COOKIE=...`)
166
+ - Add it to [.env file](#storing-secrets) (`SP_DC_COOKIE=...`) for persistent use
167
+ - Fallback: hard-code it in the code or config file
170
168
 
171
- If you store the `SP_DC_COOKIE` in a dotenv file you can update its value and send a `SIGHUP` signal to the process to reload the file with the new `sp_dc` cookie without restarting the tool. More info in [Storing Secrets](#storing-secrets) and [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix).
169
+ If your `sp_dc` cookie expires, the tool will notify you via the console and email. In that case, you'll need to grab the new `sp_dc` cookie value.
172
170
 
173
- **Important**: It is strongly recommended to use a separate Spotify account with this tool. It does not rely on the official Spotify Web API for core features (like fetching friend activity), as it is not supported by the public API.
171
+ If you store the `SP_DC_COOKIE` in a dotenv file you can update its value and send a `SIGHUP` signal to reload the file with the new `sp_dc` cookie without restarting the tool. More info in [Storing Secrets](#storing-secrets) and [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix).
174
172
 
175
173
  <a id="spotify-desktop-client"></a>
176
174
  #### Spotify Desktop Client
177
175
 
178
- To use credentials captured from the Spotify desktop client to obtain an access token, set the `TOKEN_SOURCE` configuration option to `client` or use the `--token-source client` flag.
179
-
180
- Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
176
+ This is the alternative method used to obtain a Spotify access token which simulates a login from the real Spotify desktop app using credentials intercepted from a real session.
181
177
 
182
- Launch the Spotify desktop client and look for POST requests to `https://login{n}.spotify.com/v3/login`
178
+ - Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
183
179
 
184
- Note: The `login` part is suffixed with one or more digits (e.g. `login5`).
180
+ - Launch the Spotify desktop client and look for POST requests to `https://login{n}.spotify.com/v3/login`
181
+ - Note: The `login` part is suffixed with one or more digits (e.g. `login5`).
185
182
 
186
- If you don't see this request, log out from the client and log back in.
183
+ - If you don't see this request, log out from the Spotify desktop client and log back in.
187
184
 
188
- Export the login request body (a binary Protobuf payload) to a file.
189
-
190
- In Proxyman: ***right click the request → Export → Request Body → Save File***.
185
+ - Export the login request body (a binary Protobuf payload) to a file (e.g. ***login-request-body-file***)
186
+ - In Proxyman: **right click the request → Export → Request Body → Save File**.
191
187
 
192
188
  <p align="center">
193
189
  <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/proxyman_export_protobuf.png" alt="proxyman_export_protobuf" width="80%"/>
194
190
  </p>
195
191
 
196
- Then run the tool with `-w <path-to-login-request-body-file>`:
192
+ - Run the tool with `--token-source client -w <path-to-login-request-body-file>`:
197
193
 
198
194
  ```sh
199
195
  spotify_monitor --token-source client -w <path-to-login-request-body-file> <spotify_user_uri_id>
@@ -201,15 +197,17 @@ spotify_monitor --token-source client -w <path-to-login-request-body-file> <spot
201
197
 
202
198
  If successful, the tool will automatically extract the necessary fields and begin monitoring.
203
199
 
204
- You can also persist the Protobuf request file path using the `LOGIN_REQUEST_BODY_FILE` configuration option.
200
+ Instead of using the `-w` flag each time, you can persist the Protobuf login request file path by setting the `LOGIN_REQUEST_BODY_FILE` configuration option.
201
+
202
+ The same applies to `--token-source client` flag - you can persist it via `TOKEN_SOURCE` configuration option set to `client`.
205
203
 
206
204
  The tool will automatically refresh both the access token and client token using the intercepted refresh token.
207
205
 
208
- Advanced options are available for further customization - refer to the configuration file comments. However, default settings should work for most cases.
206
+ If your refresh token expires, the tool will notify you via the console and email. In that case, you'll need to re-export the login request body.
209
207
 
210
- You will be informed by the tool once the refresh token expires (proper message on the console and in email).
208
+ If you re-export the login request body to the same file name, you can send a `SIGHUP` signal to reload the file with the new refresh token without restarting the tool. More info in [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix).
211
209
 
212
- **Important**: It is strongly recommended to use a separate Spotify account with this tool. It does not rely on the official Spotify Web API for core features (like fetching friend activity), as it is not supported by the public API.
210
+ Advanced options are available for further customization - refer to the configuration file comments. However, the default settings are suitable for most users and modifying other values is generally NOT recommended.
213
211
 
214
212
  <a id="following-the-monitored-user"></a>
215
213
  ### Following the Monitored User
@@ -248,12 +246,13 @@ spotify_monitor --send-test-email
248
246
  <a id="storing-secrets"></a>
249
247
  ### Storing Secrets
250
248
 
251
- It is recommended to store secrets like `SP_DC_COOKIE` or `SMTP_PASSWORD` as either an environment variable or in a dotenv file.
249
+ It is recommended to store secrets like `SP_DC_COOKIE`, `REFRESH_TOKEN` or `SMTP_PASSWORD` as either an environment variable or in a dotenv file.
252
250
 
253
- Set environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
251
+ Set the needed environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
254
252
 
255
253
  ```sh
256
254
  export SP_DC_COOKIE="your_sp_dc_cookie_value"
255
+ export REFRESH_TOKEN="your_spotify_app_refresh_token"
257
256
  export SMTP_PASSWORD="your_smtp_password"
258
257
  ```
259
258
 
@@ -263,6 +262,7 @@ Alternatively store them persistently in a dotenv file (recommended):
263
262
 
264
263
  ```ini
265
264
  SP_DC_COOKIE="your_sp_dc_cookie_value"
265
+ REFRESH_TOKEN="your_spotify_app_refresh_token"
266
266
  SMTP_PASSWORD="your_smtp_password"
267
267
  ```
268
268
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "spotify_monitor"
7
- version = "2.1.1"
7
+ version = "2.2"
8
8
  description = "Tool implementing real-time tracking of Spotify friends music activity"
9
9
  readme = "README.md"
10
10
  license = "GPL-3.0-or-later"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spotify_monitor
3
- Version: 2.1.1
3
+ Version: 2.2
4
4
  Summary: Tool implementing real-time tracking of Spotify friends music activity
5
5
  Author-email: Michal Szymanski <misiektoja-pypi@rm-rf.ninja>
6
6
  License-Expression: GPL-3.0-or-later
@@ -29,10 +29,6 @@ spotify_monitor is a tool for real-time monitoring of Spotify friends' music act
29
29
 
30
30
  NOTE: If you're interested in tracking changes to Spotify users' profiles including their playlists, take a look at another tool I've developed: [spotify_profile_monitor](https://github.com/misiektoja/spotify_profile_monitor).
31
31
 
32
- > Spotify made multiple changes to the web endpoint on June 10th 2025, which broke the **[sp_dc cookie](#spotify-sp_dc-cookie)** method.
33
- > 📦 The issue is under investigation to determine if it can be restored.
34
- > 👉 In the meantime, use **[desktop client](#spotify-desktop-client)** method instead.
35
-
36
32
  <a id="features"></a>
37
33
  ## Features
38
34
 
@@ -44,6 +40,7 @@ NOTE: If you're interested in tracking changes to Spotify users' profiles includ
44
40
  - Saving all listened songs with timestamps to the CSV file
45
41
  - Clickable Spotify, Apple Music, YouTube Music and Genius Lyrics search URLs printed in the console & included in email notifications
46
42
  - Displaying basic statistics for the user's playing session (duration, time span, number of listened and skipped songs, songs on loop)
43
+ - Support for two different methods to get a Spotify access token (`sp_dc cookie`, `desktop client`)
47
44
  - Possibility to control the running copy of the script via signals
48
45
 
49
46
  <p align="center">
@@ -160,65 +157,64 @@ spotify_monitor --generate-config > spotify_monitor.conf
160
157
  Edit the `spotify_monitor.conf` file and change any desired configuration options (detailed comments are provided for each).
161
158
 
162
159
  <a id="spotify-access-token-source"></a>
163
- #### Spotify access token source
160
+ ### Spotify access token source
164
161
 
165
162
  The tool supports two methods for obtaining a Spotify access token.
166
163
 
167
164
  It can be configured via the `TOKEN_SOURCE` configuration option or the `--token-source` flag.
168
165
 
169
- The **recommended method** is `cookie` which uses the sp_dc cookie to retrieve a token from the Spotify web endpoint.
166
+ **Recommended: `cookie`**
170
167
 
171
- The **alternative method** is `client` which uses captured credentials from the Spotify desktop client and a Protobuf-based login flow. This approach is intended for advanced users who want an indefinitely valid token with the widest scope.
168
+ Uses the `sp_dc` cookie to retrieve a token from the Spotify web endpoint. This method is easy to set up and recommended for most users.
172
169
 
173
- If no method is specified, the tool defaults to the `cookie` method.
170
+ **Alternative: `client`**
174
171
 
175
- <a id="spotify-sp_dc-cookie"></a>
176
- #### Spotify sp_dc Cookie
172
+ Uses captured credentials from the Spotify desktop client and a Protobuf-based login flow. It's more complex to set up and intended for advanced users who want a long-lasting token with the broadest possible access.
177
173
 
178
- It is default method used to obtain a Spotify access token.
174
+ If no method is specified, the tool defaults to the `cookie` method.
179
175
 
180
- Log in to [https://open.spotify.com/](https://open.spotify.com/) in your web browser.
176
+ **Important**: It is strongly recommended to use a separate Spotify account with this tool. It does not rely on the official Spotify Web API for core features (like fetching friend activity), as it is not supported by the public API. That said, while I've never encountered any issues on my own accounts, I can't guarantee that Spotify won't impose restrictions in the future - you've been warned.
181
177
 
182
- Locate and copy the value of the `sp_dc` cookie.
178
+ <a id="spotify-sp_dc-cookie"></a>
179
+ #### Spotify sp_dc Cookie
183
180
 
184
- Use your web browser's dev console or **Cookie-Editor** by cgagnier to extract it easily: [https://cookie-editor.com/](https://cookie-editor.com/)
181
+ This is the default method used to obtain a Spotify access token.
185
182
 
186
- Provide the `SP_DC_COOKIE` secret using one of the following methods:
187
- - Pass it at runtime with `-u` / `--spotify-dc-cookie`
188
- - Set it as an [environment variable](#storing-secrets) (e.g. `export SP_DC_COOKIE=...`)
189
- - Add it to [.env file](#storing-secrets) (`SP_DC_COOKIE=...`) for persistent use
183
+ - Log in to [https://open.spotify.com/](https://open.spotify.com/) in your web browser.
190
184
 
191
- Fallback:
192
- - Hard-code it in the code or config file
185
+ - Locate and copy the value of the `sp_dc` cookie.
186
+ - Use your web browser's dev console or **Cookie-Editor** by cgagnier to extract it easily: [https://cookie-editor.com/](https://cookie-editor.com/)
193
187
 
194
- You will be informed by the tool once the `sp_dc` cookie expires (proper message on the console and in email).
188
+ - Provide the `SP_DC_COOKIE` secret using one of the following methods:
189
+ - Pass it at runtime with `-u` / `--spotify-dc-cookie`
190
+ - Set it as an [environment variable](#storing-secrets) (e.g. `export SP_DC_COOKIE=...`)
191
+ - Add it to [.env file](#storing-secrets) (`SP_DC_COOKIE=...`) for persistent use
192
+ - Fallback: hard-code it in the code or config file
195
193
 
196
- If you store the `SP_DC_COOKIE` in a dotenv file you can update its value and send a `SIGHUP` signal to the process to reload the file with the new `sp_dc` cookie without restarting the tool. More info in [Storing Secrets](#storing-secrets) and [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix).
194
+ If your `sp_dc` cookie expires, the tool will notify you via the console and email. In that case, you'll need to grab the new `sp_dc` cookie value.
197
195
 
198
- **Important**: It is strongly recommended to use a separate Spotify account with this tool. It does not rely on the official Spotify Web API for core features (like fetching friend activity), as it is not supported by the public API.
196
+ If you store the `SP_DC_COOKIE` in a dotenv file you can update its value and send a `SIGHUP` signal to reload the file with the new `sp_dc` cookie without restarting the tool. More info in [Storing Secrets](#storing-secrets) and [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix).
199
197
 
200
198
  <a id="spotify-desktop-client"></a>
201
199
  #### Spotify Desktop Client
202
200
 
203
- To use credentials captured from the Spotify desktop client to obtain an access token, set the `TOKEN_SOURCE` configuration option to `client` or use the `--token-source client` flag.
204
-
205
- Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
201
+ This is the alternative method used to obtain a Spotify access token which simulates a login from the real Spotify desktop app using credentials intercepted from a real session.
206
202
 
207
- Launch the Spotify desktop client and look for POST requests to `https://login{n}.spotify.com/v3/login`
203
+ - Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
208
204
 
209
- Note: The `login` part is suffixed with one or more digits (e.g. `login5`).
205
+ - Launch the Spotify desktop client and look for POST requests to `https://login{n}.spotify.com/v3/login`
206
+ - Note: The `login` part is suffixed with one or more digits (e.g. `login5`).
210
207
 
211
- If you don't see this request, log out from the client and log back in.
208
+ - If you don't see this request, log out from the Spotify desktop client and log back in.
212
209
 
213
- Export the login request body (a binary Protobuf payload) to a file.
214
-
215
- In Proxyman: ***right click the request → Export → Request Body → Save File***.
210
+ - Export the login request body (a binary Protobuf payload) to a file (e.g. ***login-request-body-file***)
211
+ - In Proxyman: **right click the request → Export → Request Body → Save File**.
216
212
 
217
213
  <p align="center">
218
214
  <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/proxyman_export_protobuf.png" alt="proxyman_export_protobuf" width="80%"/>
219
215
  </p>
220
216
 
221
- Then run the tool with `-w <path-to-login-request-body-file>`:
217
+ - Run the tool with `--token-source client -w <path-to-login-request-body-file>`:
222
218
 
223
219
  ```sh
224
220
  spotify_monitor --token-source client -w <path-to-login-request-body-file> <spotify_user_uri_id>
@@ -226,15 +222,17 @@ spotify_monitor --token-source client -w <path-to-login-request-body-file> <spot
226
222
 
227
223
  If successful, the tool will automatically extract the necessary fields and begin monitoring.
228
224
 
229
- You can also persist the Protobuf request file path using the `LOGIN_REQUEST_BODY_FILE` configuration option.
225
+ Instead of using the `-w` flag each time, you can persist the Protobuf login request file path by setting the `LOGIN_REQUEST_BODY_FILE` configuration option.
226
+
227
+ The same applies to `--token-source client` flag - you can persist it via `TOKEN_SOURCE` configuration option set to `client`.
230
228
 
231
229
  The tool will automatically refresh both the access token and client token using the intercepted refresh token.
232
230
 
233
- Advanced options are available for further customization - refer to the configuration file comments. However, default settings should work for most cases.
231
+ If your refresh token expires, the tool will notify you via the console and email. In that case, you'll need to re-export the login request body.
234
232
 
235
- You will be informed by the tool once the refresh token expires (proper message on the console and in email).
233
+ If you re-export the login request body to the same file name, you can send a `SIGHUP` signal to reload the file with the new refresh token without restarting the tool. More info in [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix).
236
234
 
237
- **Important**: It is strongly recommended to use a separate Spotify account with this tool. It does not rely on the official Spotify Web API for core features (like fetching friend activity), as it is not supported by the public API.
235
+ Advanced options are available for further customization - refer to the configuration file comments. However, the default settings are suitable for most users and modifying other values is generally NOT recommended.
238
236
 
239
237
  <a id="following-the-monitored-user"></a>
240
238
  ### Following the Monitored User
@@ -273,12 +271,13 @@ spotify_monitor --send-test-email
273
271
  <a id="storing-secrets"></a>
274
272
  ### Storing Secrets
275
273
 
276
- It is recommended to store secrets like `SP_DC_COOKIE` or `SMTP_PASSWORD` as either an environment variable or in a dotenv file.
274
+ It is recommended to store secrets like `SP_DC_COOKIE`, `REFRESH_TOKEN` or `SMTP_PASSWORD` as either an environment variable or in a dotenv file.
277
275
 
278
- Set environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
276
+ Set the needed environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
279
277
 
280
278
  ```sh
281
279
  export SP_DC_COOKIE="your_sp_dc_cookie_value"
280
+ export REFRESH_TOKEN="your_spotify_app_refresh_token"
282
281
  export SMTP_PASSWORD="your_smtp_password"
283
282
  ```
284
283
 
@@ -288,6 +287,7 @@ Alternatively store them persistently in a dotenv file (recommended):
288
287
 
289
288
  ```ini
290
289
  SP_DC_COOKIE="your_sp_dc_cookie_value"
290
+ REFRESH_TOKEN="your_spotify_app_refresh_token"
291
291
  SMTP_PASSWORD="your_smtp_password"
292
292
  ```
293
293