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.
- {spotify_monitor-2.1.1 → spotify_monitor-2.2}/PKG-INFO +40 -40
- {spotify_monitor-2.1.1 → spotify_monitor-2.2}/README.md +39 -39
- {spotify_monitor-2.1.1 → spotify_monitor-2.2}/pyproject.toml +1 -1
- {spotify_monitor-2.1.1 → spotify_monitor-2.2}/spotify_monitor.egg-info/PKG-INFO +40 -40
- {spotify_monitor-2.1.1 → spotify_monitor-2.2}/spotify_monitor.py +393 -240
- {spotify_monitor-2.1.1 → spotify_monitor-2.2}/LICENSE +0 -0
- {spotify_monitor-2.1.1 → spotify_monitor-2.2}/setup.cfg +0 -0
- {spotify_monitor-2.1.1 → spotify_monitor-2.2}/spotify_monitor.egg-info/SOURCES.txt +0 -0
- {spotify_monitor-2.1.1 → spotify_monitor-2.2}/spotify_monitor.egg-info/dependency_links.txt +0 -0
- {spotify_monitor-2.1.1 → spotify_monitor-2.2}/spotify_monitor.egg-info/entry_points.txt +0 -0
- {spotify_monitor-2.1.1 → spotify_monitor-2.2}/spotify_monitor.egg-info/requires.txt +0 -0
- {spotify_monitor-2.1.1 → spotify_monitor-2.2}/spotify_monitor.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spotify_monitor
|
|
3
|
-
Version: 2.
|
|
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
|
-
|
|
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
|
-
|
|
166
|
+
**Recommended: `cookie`**
|
|
170
167
|
|
|
171
|
-
|
|
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
|
-
|
|
170
|
+
**Alternative: `client`**
|
|
174
171
|
|
|
175
|
-
|
|
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
|
-
|
|
174
|
+
If no method is specified, the tool defaults to the `cookie` method.
|
|
179
175
|
|
|
180
|
-
|
|
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
|
-
|
|
178
|
+
<a id="spotify-sp_dc-cookie"></a>
|
|
179
|
+
#### Spotify sp_dc Cookie
|
|
183
180
|
|
|
184
|
-
|
|
181
|
+
This is the default method used to obtain a Spotify access token.
|
|
185
182
|
|
|
186
|
-
|
|
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
|
-
|
|
192
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
203
|
+
- Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
|
|
208
204
|
|
|
209
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
141
|
+
**Recommended: `cookie`**
|
|
145
142
|
|
|
146
|
-
|
|
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
|
-
|
|
145
|
+
**Alternative: `client`**
|
|
149
146
|
|
|
150
|
-
|
|
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
|
-
|
|
149
|
+
If no method is specified, the tool defaults to the `cookie` method.
|
|
154
150
|
|
|
155
|
-
|
|
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
|
-
|
|
153
|
+
<a id="spotify-sp_dc-cookie"></a>
|
|
154
|
+
#### Spotify sp_dc Cookie
|
|
158
155
|
|
|
159
|
-
|
|
156
|
+
This is the default method used to obtain a Spotify access token.
|
|
160
157
|
|
|
161
|
-
|
|
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
|
-
|
|
167
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
178
|
+
- Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
|
|
183
179
|
|
|
184
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: spotify_monitor
|
|
3
|
-
Version: 2.
|
|
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
|
-
|
|
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
|
-
|
|
166
|
+
**Recommended: `cookie`**
|
|
170
167
|
|
|
171
|
-
|
|
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
|
-
|
|
170
|
+
**Alternative: `client`**
|
|
174
171
|
|
|
175
|
-
|
|
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
|
-
|
|
174
|
+
If no method is specified, the tool defaults to the `cookie` method.
|
|
179
175
|
|
|
180
|
-
|
|
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
|
-
|
|
178
|
+
<a id="spotify-sp_dc-cookie"></a>
|
|
179
|
+
#### Spotify sp_dc Cookie
|
|
183
180
|
|
|
184
|
-
|
|
181
|
+
This is the default method used to obtain a Spotify access token.
|
|
185
182
|
|
|
186
|
-
|
|
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
|
-
|
|
192
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
203
|
+
- Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
|
|
208
204
|
|
|
209
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|