spotify-monitor 2.1.2__tar.gz → 2.2.1__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.2
3
+ Version: 2.2.1
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
@@ -25,7 +25,7 @@ Dynamic: license-file
25
25
 
26
26
  # spotify_monitor
27
27
 
28
- spotify_monitor is a tool for real-time monitoring of Spotify friends' music activity.
28
+ Tool for real-time monitoring of Spotify friends' music activity feed.
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
 
@@ -40,6 +40,7 @@ NOTE: If you're interested in tracking changes to Spotify users' profiles includ
40
40
  - Saving all listened songs with timestamps to the CSV file
41
41
  - Clickable Spotify, Apple Music, YouTube Music and Genius Lyrics search URLs printed in the console & included in email notifications
42
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`)
43
44
  - Possibility to control the running copy of the script via signals
44
45
 
45
46
  <p align="center">
@@ -156,65 +157,66 @@ spotify_monitor --generate-config > spotify_monitor.conf
156
157
  Edit the `spotify_monitor.conf` file and change any desired configuration options (detailed comments are provided for each).
157
158
 
158
159
  <a id="spotify-access-token-source"></a>
159
- #### Spotify access token source
160
+ ### Spotify access token source
160
161
 
161
162
  The tool supports two methods for obtaining a Spotify access token.
162
163
 
163
164
  It can be configured via the `TOKEN_SOURCE` configuration option or the `--token-source` flag.
164
165
 
165
- The **recommended method** is `cookie` which uses the sp_dc cookie to retrieve a token from the Spotify web endpoint.
166
+ **Recommended: `cookie`**
166
167
 
167
- 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.
168
169
 
169
- If no method is specified, the tool defaults to the `cookie` method.
170
+ **Alternative: `client`**
170
171
 
171
- <a id="spotify-sp_dc-cookie"></a>
172
- #### 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.
173
173
 
174
- It is default method used to obtain a Spotify access token.
174
+ If no method is specified, the tool defaults to the `cookie` method.
175
175
 
176
- 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.
177
177
 
178
- Locate and copy the value of the `sp_dc` cookie.
178
+ <a id="spotify-sp_dc-cookie"></a>
179
+ #### Spotify sp_dc Cookie
179
180
 
180
- 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.
181
182
 
182
- Provide the `SP_DC_COOKIE` secret using one of the following methods:
183
- - Pass it at runtime with `-u` / `--spotify-dc-cookie`
184
- - Set it as an [environment variable](#storing-secrets) (e.g. `export SP_DC_COOKIE=...`)
185
- - 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.
186
184
 
187
- Fallback:
188
- - 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/)
189
187
 
190
- 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
191
193
 
192
- 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.
193
195
 
194
- **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).
195
197
 
196
198
  <a id="spotify-desktop-client"></a>
197
199
  #### Spotify Desktop Client
198
200
 
199
- 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.
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.
200
202
 
201
- Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
203
+ **NOTE**: Spotify appears to have changed something in client versions released after June 2025 (likely a switch to HTTP/3 and/or certificate pinning). You may need to use an older version of the Spotify desktop client for this method to work.
202
204
 
203
- Launch the Spotify desktop client and look for POST requests to `https://login{n}.spotify.com/v3/login`
205
+ - Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
204
206
 
205
- Note: The `login` part is suffixed with one or more digits (e.g. `login5`).
207
+ - Launch the Spotify desktop client and look for POST requests to `https://login{n}.spotify.com/v3/login`
208
+ - Note: The `login` part is suffixed with one or more digits (e.g. `login5`).
206
209
 
207
- If you don't see this request, log out from the client and log back in.
210
+ - If you don't see this request, log out from the Spotify desktop client and log back in.
208
211
 
209
- Export the login request body (a binary Protobuf payload) to a file.
210
-
211
- In Proxyman: ***right click the request → Export → Request Body → Save File***.
212
+ - Export the login request body (a binary Protobuf payload) to a file (e.g. ***login-request-body-file***)
213
+ - In Proxyman: **right click the request → Export → Request Body → Save File**.
212
214
 
213
215
  <p align="center">
214
216
  <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/proxyman_export_protobuf.png" alt="proxyman_export_protobuf" width="80%"/>
215
217
  </p>
216
218
 
217
- Then run the tool with `-w <path-to-login-request-body-file>`:
219
+ - Run the tool with `--token-source client -w <path-to-login-request-body-file>`:
218
220
 
219
221
  ```sh
220
222
  spotify_monitor --token-source client -w <path-to-login-request-body-file> <spotify_user_uri_id>
@@ -222,15 +224,17 @@ spotify_monitor --token-source client -w <path-to-login-request-body-file> <spot
222
224
 
223
225
  If successful, the tool will automatically extract the necessary fields and begin monitoring.
224
226
 
225
- You can also persist the Protobuf request file path using the `LOGIN_REQUEST_BODY_FILE` configuration option.
227
+ 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.
228
+
229
+ The same applies to `--token-source client` flag - you can persist it via `TOKEN_SOURCE` configuration option set to `client`.
226
230
 
227
231
  The tool will automatically refresh both the access token and client token using the intercepted refresh token.
228
232
 
229
- Advanced options are available for further customization - refer to the configuration file comments. However, default settings should work for most cases.
233
+ 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.
230
234
 
231
- You will be informed by the tool once the refresh token expires (proper message on the console and in email).
235
+ 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).
232
236
 
233
- **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.
237
+ 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.
234
238
 
235
239
  <a id="following-the-monitored-user"></a>
236
240
  ### Following the Monitored User
@@ -269,12 +273,13 @@ spotify_monitor --send-test-email
269
273
  <a id="storing-secrets"></a>
270
274
  ### Storing Secrets
271
275
 
272
- It is recommended to store secrets like `SP_DC_COOKIE` or `SMTP_PASSWORD` as either an environment variable or in a dotenv file.
276
+ 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.
273
277
 
274
- Set environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
278
+ Set the needed environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
275
279
 
276
280
  ```sh
277
281
  export SP_DC_COOKIE="your_sp_dc_cookie_value"
282
+ export REFRESH_TOKEN="your_spotify_app_refresh_token"
278
283
  export SMTP_PASSWORD="your_smtp_password"
279
284
  ```
280
285
 
@@ -284,6 +289,7 @@ Alternatively store them persistently in a dotenv file (recommended):
284
289
 
285
290
  ```ini
286
291
  SP_DC_COOKIE="your_sp_dc_cookie_value"
292
+ REFRESH_TOKEN="your_spotify_app_refresh_token"
287
293
  SMTP_PASSWORD="your_smtp_password"
288
294
  ```
289
295
 
@@ -1,6 +1,6 @@
1
1
  # spotify_monitor
2
2
 
3
- spotify_monitor is a tool for real-time monitoring of Spotify friends' music activity.
3
+ Tool for real-time monitoring of Spotify friends' music activity feed.
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
 
@@ -15,6 +15,7 @@ NOTE: If you're interested in tracking changes to Spotify users' profiles includ
15
15
  - Saving all listened songs with timestamps to the CSV file
16
16
  - Clickable Spotify, Apple Music, YouTube Music and Genius Lyrics search URLs printed in the console & included in email notifications
17
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`)
18
19
  - Possibility to control the running copy of the script via signals
19
20
 
20
21
  <p align="center">
@@ -131,65 +132,66 @@ spotify_monitor --generate-config > spotify_monitor.conf
131
132
  Edit the `spotify_monitor.conf` file and change any desired configuration options (detailed comments are provided for each).
132
133
 
133
134
  <a id="spotify-access-token-source"></a>
134
- #### Spotify access token source
135
+ ### Spotify access token source
135
136
 
136
137
  The tool supports two methods for obtaining a Spotify access token.
137
138
 
138
139
  It can be configured via the `TOKEN_SOURCE` configuration option or the `--token-source` flag.
139
140
 
140
- The **recommended method** is `cookie` which uses the sp_dc cookie to retrieve a token from the Spotify web endpoint.
141
+ **Recommended: `cookie`**
141
142
 
142
- 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.
143
144
 
144
- If no method is specified, the tool defaults to the `cookie` method.
145
+ **Alternative: `client`**
145
146
 
146
- <a id="spotify-sp_dc-cookie"></a>
147
- #### 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.
148
148
 
149
- It is default method used to obtain a Spotify access token.
149
+ If no method is specified, the tool defaults to the `cookie` method.
150
150
 
151
- 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.
152
152
 
153
- Locate and copy the value of the `sp_dc` cookie.
153
+ <a id="spotify-sp_dc-cookie"></a>
154
+ #### Spotify sp_dc Cookie
154
155
 
155
- 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.
156
157
 
157
- Provide the `SP_DC_COOKIE` secret using one of the following methods:
158
- - Pass it at runtime with `-u` / `--spotify-dc-cookie`
159
- - Set it as an [environment variable](#storing-secrets) (e.g. `export SP_DC_COOKIE=...`)
160
- - 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.
161
159
 
162
- Fallback:
163
- - 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/)
164
162
 
165
- 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
166
168
 
167
- 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.
168
170
 
169
- **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).
170
172
 
171
173
  <a id="spotify-desktop-client"></a>
172
174
  #### Spotify Desktop Client
173
175
 
174
- 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.
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.
175
177
 
176
- Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
178
+ **NOTE**: Spotify appears to have changed something in client versions released after June 2025 (likely a switch to HTTP/3 and/or certificate pinning). You may need to use an older version of the Spotify desktop client for this method to work.
177
179
 
178
- Launch the Spotify desktop client and look for POST requests to `https://login{n}.spotify.com/v3/login`
180
+ - Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
179
181
 
180
- Note: The `login` part is suffixed with one or more digits (e.g. `login5`).
182
+ - Launch the Spotify desktop client and look for POST requests to `https://login{n}.spotify.com/v3/login`
183
+ - Note: The `login` part is suffixed with one or more digits (e.g. `login5`).
181
184
 
182
- If you don't see this request, log out from the client and log back in.
185
+ - If you don't see this request, log out from the Spotify desktop client and log back in.
183
186
 
184
- Export the login request body (a binary Protobuf payload) to a file.
185
-
186
- In Proxyman: ***right click the request → Export → Request Body → Save File***.
187
+ - Export the login request body (a binary Protobuf payload) to a file (e.g. ***login-request-body-file***)
188
+ - In Proxyman: **right click the request → Export → Request Body → Save File**.
187
189
 
188
190
  <p align="center">
189
191
  <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/proxyman_export_protobuf.png" alt="proxyman_export_protobuf" width="80%"/>
190
192
  </p>
191
193
 
192
- Then run the tool with `-w <path-to-login-request-body-file>`:
194
+ - Run the tool with `--token-source client -w <path-to-login-request-body-file>`:
193
195
 
194
196
  ```sh
195
197
  spotify_monitor --token-source client -w <path-to-login-request-body-file> <spotify_user_uri_id>
@@ -197,15 +199,17 @@ spotify_monitor --token-source client -w <path-to-login-request-body-file> <spot
197
199
 
198
200
  If successful, the tool will automatically extract the necessary fields and begin monitoring.
199
201
 
200
- You can also persist the Protobuf request file path using the `LOGIN_REQUEST_BODY_FILE` configuration option.
202
+ 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.
203
+
204
+ The same applies to `--token-source client` flag - you can persist it via `TOKEN_SOURCE` configuration option set to `client`.
201
205
 
202
206
  The tool will automatically refresh both the access token and client token using the intercepted refresh token.
203
207
 
204
- Advanced options are available for further customization - refer to the configuration file comments. However, default settings should work for most cases.
208
+ 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.
205
209
 
206
- You will be informed by the tool once the refresh token expires (proper message on the console and in email).
210
+ 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).
207
211
 
208
- **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.
212
+ 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.
209
213
 
210
214
  <a id="following-the-monitored-user"></a>
211
215
  ### Following the Monitored User
@@ -244,12 +248,13 @@ spotify_monitor --send-test-email
244
248
  <a id="storing-secrets"></a>
245
249
  ### Storing Secrets
246
250
 
247
- It is recommended to store secrets like `SP_DC_COOKIE` or `SMTP_PASSWORD` as either an environment variable or in a dotenv file.
251
+ 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.
248
252
 
249
- Set environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
253
+ Set the needed environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
250
254
 
251
255
  ```sh
252
256
  export SP_DC_COOKIE="your_sp_dc_cookie_value"
257
+ export REFRESH_TOKEN="your_spotify_app_refresh_token"
253
258
  export SMTP_PASSWORD="your_smtp_password"
254
259
  ```
255
260
 
@@ -259,6 +264,7 @@ Alternatively store them persistently in a dotenv file (recommended):
259
264
 
260
265
  ```ini
261
266
  SP_DC_COOKIE="your_sp_dc_cookie_value"
267
+ REFRESH_TOKEN="your_spotify_app_refresh_token"
262
268
  SMTP_PASSWORD="your_smtp_password"
263
269
  ```
264
270
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "spotify_monitor"
7
- version = "2.1.2"
7
+ version = "2.2.1"
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.2
3
+ Version: 2.2.1
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
@@ -25,7 +25,7 @@ Dynamic: license-file
25
25
 
26
26
  # spotify_monitor
27
27
 
28
- spotify_monitor is a tool for real-time monitoring of Spotify friends' music activity.
28
+ Tool for real-time monitoring of Spotify friends' music activity feed.
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
 
@@ -40,6 +40,7 @@ NOTE: If you're interested in tracking changes to Spotify users' profiles includ
40
40
  - Saving all listened songs with timestamps to the CSV file
41
41
  - Clickable Spotify, Apple Music, YouTube Music and Genius Lyrics search URLs printed in the console & included in email notifications
42
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`)
43
44
  - Possibility to control the running copy of the script via signals
44
45
 
45
46
  <p align="center">
@@ -156,65 +157,66 @@ spotify_monitor --generate-config > spotify_monitor.conf
156
157
  Edit the `spotify_monitor.conf` file and change any desired configuration options (detailed comments are provided for each).
157
158
 
158
159
  <a id="spotify-access-token-source"></a>
159
- #### Spotify access token source
160
+ ### Spotify access token source
160
161
 
161
162
  The tool supports two methods for obtaining a Spotify access token.
162
163
 
163
164
  It can be configured via the `TOKEN_SOURCE` configuration option or the `--token-source` flag.
164
165
 
165
- The **recommended method** is `cookie` which uses the sp_dc cookie to retrieve a token from the Spotify web endpoint.
166
+ **Recommended: `cookie`**
166
167
 
167
- 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.
168
169
 
169
- If no method is specified, the tool defaults to the `cookie` method.
170
+ **Alternative: `client`**
170
171
 
171
- <a id="spotify-sp_dc-cookie"></a>
172
- #### 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.
173
173
 
174
- It is default method used to obtain a Spotify access token.
174
+ If no method is specified, the tool defaults to the `cookie` method.
175
175
 
176
- 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.
177
177
 
178
- Locate and copy the value of the `sp_dc` cookie.
178
+ <a id="spotify-sp_dc-cookie"></a>
179
+ #### Spotify sp_dc Cookie
179
180
 
180
- 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.
181
182
 
182
- Provide the `SP_DC_COOKIE` secret using one of the following methods:
183
- - Pass it at runtime with `-u` / `--spotify-dc-cookie`
184
- - Set it as an [environment variable](#storing-secrets) (e.g. `export SP_DC_COOKIE=...`)
185
- - 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.
186
184
 
187
- Fallback:
188
- - 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/)
189
187
 
190
- 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
191
193
 
192
- 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.
193
195
 
194
- **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).
195
197
 
196
198
  <a id="spotify-desktop-client"></a>
197
199
  #### Spotify Desktop Client
198
200
 
199
- 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.
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.
200
202
 
201
- Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
203
+ **NOTE**: Spotify appears to have changed something in client versions released after June 2025 (likely a switch to HTTP/3 and/or certificate pinning). You may need to use an older version of the Spotify desktop client for this method to work.
202
204
 
203
- Launch the Spotify desktop client and look for POST requests to `https://login{n}.spotify.com/v3/login`
205
+ - Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
204
206
 
205
- Note: The `login` part is suffixed with one or more digits (e.g. `login5`).
207
+ - Launch the Spotify desktop client and look for POST requests to `https://login{n}.spotify.com/v3/login`
208
+ - Note: The `login` part is suffixed with one or more digits (e.g. `login5`).
206
209
 
207
- If you don't see this request, log out from the client and log back in.
210
+ - If you don't see this request, log out from the Spotify desktop client and log back in.
208
211
 
209
- Export the login request body (a binary Protobuf payload) to a file.
210
-
211
- In Proxyman: ***right click the request → Export → Request Body → Save File***.
212
+ - Export the login request body (a binary Protobuf payload) to a file (e.g. ***login-request-body-file***)
213
+ - In Proxyman: **right click the request → Export → Request Body → Save File**.
212
214
 
213
215
  <p align="center">
214
216
  <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/proxyman_export_protobuf.png" alt="proxyman_export_protobuf" width="80%"/>
215
217
  </p>
216
218
 
217
- Then run the tool with `-w <path-to-login-request-body-file>`:
219
+ - Run the tool with `--token-source client -w <path-to-login-request-body-file>`:
218
220
 
219
221
  ```sh
220
222
  spotify_monitor --token-source client -w <path-to-login-request-body-file> <spotify_user_uri_id>
@@ -222,15 +224,17 @@ spotify_monitor --token-source client -w <path-to-login-request-body-file> <spot
222
224
 
223
225
  If successful, the tool will automatically extract the necessary fields and begin monitoring.
224
226
 
225
- You can also persist the Protobuf request file path using the `LOGIN_REQUEST_BODY_FILE` configuration option.
227
+ 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.
228
+
229
+ The same applies to `--token-source client` flag - you can persist it via `TOKEN_SOURCE` configuration option set to `client`.
226
230
 
227
231
  The tool will automatically refresh both the access token and client token using the intercepted refresh token.
228
232
 
229
- Advanced options are available for further customization - refer to the configuration file comments. However, default settings should work for most cases.
233
+ 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.
230
234
 
231
- You will be informed by the tool once the refresh token expires (proper message on the console and in email).
235
+ 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).
232
236
 
233
- **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.
237
+ 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.
234
238
 
235
239
  <a id="following-the-monitored-user"></a>
236
240
  ### Following the Monitored User
@@ -269,12 +273,13 @@ spotify_monitor --send-test-email
269
273
  <a id="storing-secrets"></a>
270
274
  ### Storing Secrets
271
275
 
272
- It is recommended to store secrets like `SP_DC_COOKIE` or `SMTP_PASSWORD` as either an environment variable or in a dotenv file.
276
+ 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.
273
277
 
274
- Set environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
278
+ Set the needed environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
275
279
 
276
280
  ```sh
277
281
  export SP_DC_COOKIE="your_sp_dc_cookie_value"
282
+ export REFRESH_TOKEN="your_spotify_app_refresh_token"
278
283
  export SMTP_PASSWORD="your_smtp_password"
279
284
  ```
280
285
 
@@ -284,6 +289,7 @@ Alternatively store them persistently in a dotenv file (recommended):
284
289
 
285
290
  ```ini
286
291
  SP_DC_COOKIE="your_sp_dc_cookie_value"
292
+ REFRESH_TOKEN="your_spotify_app_refresh_token"
287
293
  SMTP_PASSWORD="your_smtp_password"
288
294
  ```
289
295