spotify-monitor 2.1.2__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.2 → spotify_monitor-2.2}/PKG-INFO +40 -36
- {spotify_monitor-2.1.2 → spotify_monitor-2.2}/README.md +39 -35
- {spotify_monitor-2.1.2 → spotify_monitor-2.2}/pyproject.toml +1 -1
- {spotify_monitor-2.1.2 → spotify_monitor-2.2}/spotify_monitor.egg-info/PKG-INFO +40 -36
- {spotify_monitor-2.1.2 → spotify_monitor-2.2}/spotify_monitor.py +358 -202
- {spotify_monitor-2.1.2 → spotify_monitor-2.2}/LICENSE +0 -0
- {spotify_monitor-2.1.2 → spotify_monitor-2.2}/setup.cfg +0 -0
- {spotify_monitor-2.1.2 → spotify_monitor-2.2}/spotify_monitor.egg-info/SOURCES.txt +0 -0
- {spotify_monitor-2.1.2 → spotify_monitor-2.2}/spotify_monitor.egg-info/dependency_links.txt +0 -0
- {spotify_monitor-2.1.2 → spotify_monitor-2.2}/spotify_monitor.egg-info/entry_points.txt +0 -0
- {spotify_monitor-2.1.2 → spotify_monitor-2.2}/spotify_monitor.egg-info/requires.txt +0 -0
- {spotify_monitor-2.1.2 → 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
|
|
@@ -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,64 @@ 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
|
-
|
|
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
|
-
|
|
166
|
+
**Recommended: `cookie`**
|
|
166
167
|
|
|
167
|
-
|
|
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
|
-
|
|
170
|
+
**Alternative: `client`**
|
|
170
171
|
|
|
171
|
-
|
|
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
|
-
|
|
174
|
+
If no method is specified, the tool defaults to the `cookie` method.
|
|
175
175
|
|
|
176
|
-
|
|
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
|
-
|
|
178
|
+
<a id="spotify-sp_dc-cookie"></a>
|
|
179
|
+
#### Spotify sp_dc Cookie
|
|
179
180
|
|
|
180
|
-
|
|
181
|
+
This is the default method used to obtain a Spotify access token.
|
|
181
182
|
|
|
182
|
-
|
|
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
|
-
|
|
188
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
200
|
-
|
|
201
|
-
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.
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
- Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
|
|
204
204
|
|
|
205
|
-
|
|
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`).
|
|
206
207
|
|
|
207
|
-
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.
|
|
208
209
|
|
|
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***.
|
|
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**.
|
|
212
212
|
|
|
213
213
|
<p align="center">
|
|
214
214
|
<img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/proxyman_export_protobuf.png" alt="proxyman_export_protobuf" width="80%"/>
|
|
215
215
|
</p>
|
|
216
216
|
|
|
217
|
-
|
|
217
|
+
- Run the tool with `--token-source client -w <path-to-login-request-body-file>`:
|
|
218
218
|
|
|
219
219
|
```sh
|
|
220
220
|
spotify_monitor --token-source client -w <path-to-login-request-body-file> <spotify_user_uri_id>
|
|
@@ -222,15 +222,17 @@ spotify_monitor --token-source client -w <path-to-login-request-body-file> <spot
|
|
|
222
222
|
|
|
223
223
|
If successful, the tool will automatically extract the necessary fields and begin monitoring.
|
|
224
224
|
|
|
225
|
-
|
|
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`.
|
|
226
228
|
|
|
227
229
|
The tool will automatically refresh both the access token and client token using the intercepted refresh token.
|
|
228
230
|
|
|
229
|
-
|
|
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.
|
|
230
232
|
|
|
231
|
-
|
|
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).
|
|
232
234
|
|
|
233
|
-
|
|
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.
|
|
234
236
|
|
|
235
237
|
<a id="following-the-monitored-user"></a>
|
|
236
238
|
### Following the Monitored User
|
|
@@ -269,12 +271,13 @@ spotify_monitor --send-test-email
|
|
|
269
271
|
<a id="storing-secrets"></a>
|
|
270
272
|
### Storing Secrets
|
|
271
273
|
|
|
272
|
-
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.
|
|
273
275
|
|
|
274
|
-
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:
|
|
275
277
|
|
|
276
278
|
```sh
|
|
277
279
|
export SP_DC_COOKIE="your_sp_dc_cookie_value"
|
|
280
|
+
export REFRESH_TOKEN="your_spotify_app_refresh_token"
|
|
278
281
|
export SMTP_PASSWORD="your_smtp_password"
|
|
279
282
|
```
|
|
280
283
|
|
|
@@ -284,6 +287,7 @@ Alternatively store them persistently in a dotenv file (recommended):
|
|
|
284
287
|
|
|
285
288
|
```ini
|
|
286
289
|
SP_DC_COOKIE="your_sp_dc_cookie_value"
|
|
290
|
+
REFRESH_TOKEN="your_spotify_app_refresh_token"
|
|
287
291
|
SMTP_PASSWORD="your_smtp_password"
|
|
288
292
|
```
|
|
289
293
|
|
|
@@ -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,64 @@ 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
|
-
|
|
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
|
-
|
|
141
|
+
**Recommended: `cookie`**
|
|
141
142
|
|
|
142
|
-
|
|
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
|
-
|
|
145
|
+
**Alternative: `client`**
|
|
145
146
|
|
|
146
|
-
|
|
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
|
-
|
|
149
|
+
If no method is specified, the tool defaults to the `cookie` method.
|
|
150
150
|
|
|
151
|
-
|
|
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
|
-
|
|
153
|
+
<a id="spotify-sp_dc-cookie"></a>
|
|
154
|
+
#### Spotify sp_dc Cookie
|
|
154
155
|
|
|
155
|
-
|
|
156
|
+
This is the default method used to obtain a Spotify access token.
|
|
156
157
|
|
|
157
|
-
|
|
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
|
-
|
|
163
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
175
|
-
|
|
176
|
-
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.
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
- Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
|
|
179
179
|
|
|
180
|
-
|
|
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`).
|
|
181
182
|
|
|
182
|
-
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.
|
|
183
184
|
|
|
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***.
|
|
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**.
|
|
187
187
|
|
|
188
188
|
<p align="center">
|
|
189
189
|
<img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/proxyman_export_protobuf.png" alt="proxyman_export_protobuf" width="80%"/>
|
|
190
190
|
</p>
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
- Run the tool with `--token-source client -w <path-to-login-request-body-file>`:
|
|
193
193
|
|
|
194
194
|
```sh
|
|
195
195
|
spotify_monitor --token-source client -w <path-to-login-request-body-file> <spotify_user_uri_id>
|
|
@@ -197,15 +197,17 @@ spotify_monitor --token-source client -w <path-to-login-request-body-file> <spot
|
|
|
197
197
|
|
|
198
198
|
If successful, the tool will automatically extract the necessary fields and begin monitoring.
|
|
199
199
|
|
|
200
|
-
|
|
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`.
|
|
201
203
|
|
|
202
204
|
The tool will automatically refresh both the access token and client token using the intercepted refresh token.
|
|
203
205
|
|
|
204
|
-
|
|
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.
|
|
205
207
|
|
|
206
|
-
|
|
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).
|
|
207
209
|
|
|
208
|
-
|
|
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.
|
|
209
211
|
|
|
210
212
|
<a id="following-the-monitored-user"></a>
|
|
211
213
|
### Following the Monitored User
|
|
@@ -244,12 +246,13 @@ spotify_monitor --send-test-email
|
|
|
244
246
|
<a id="storing-secrets"></a>
|
|
245
247
|
### Storing Secrets
|
|
246
248
|
|
|
247
|
-
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.
|
|
248
250
|
|
|
249
|
-
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:
|
|
250
252
|
|
|
251
253
|
```sh
|
|
252
254
|
export SP_DC_COOKIE="your_sp_dc_cookie_value"
|
|
255
|
+
export REFRESH_TOKEN="your_spotify_app_refresh_token"
|
|
253
256
|
export SMTP_PASSWORD="your_smtp_password"
|
|
254
257
|
```
|
|
255
258
|
|
|
@@ -259,6 +262,7 @@ Alternatively store them persistently in a dotenv file (recommended):
|
|
|
259
262
|
|
|
260
263
|
```ini
|
|
261
264
|
SP_DC_COOKIE="your_sp_dc_cookie_value"
|
|
265
|
+
REFRESH_TOKEN="your_spotify_app_refresh_token"
|
|
262
266
|
SMTP_PASSWORD="your_smtp_password"
|
|
263
267
|
```
|
|
264
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
|
|
@@ -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,64 @@ 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
|
-
|
|
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
|
-
|
|
166
|
+
**Recommended: `cookie`**
|
|
166
167
|
|
|
167
|
-
|
|
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
|
-
|
|
170
|
+
**Alternative: `client`**
|
|
170
171
|
|
|
171
|
-
|
|
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
|
-
|
|
174
|
+
If no method is specified, the tool defaults to the `cookie` method.
|
|
175
175
|
|
|
176
|
-
|
|
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
|
-
|
|
178
|
+
<a id="spotify-sp_dc-cookie"></a>
|
|
179
|
+
#### Spotify sp_dc Cookie
|
|
179
180
|
|
|
180
|
-
|
|
181
|
+
This is the default method used to obtain a Spotify access token.
|
|
181
182
|
|
|
182
|
-
|
|
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
|
-
|
|
188
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
200
|
-
|
|
201
|
-
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.
|
|
202
202
|
|
|
203
|
-
|
|
203
|
+
- Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
|
|
204
204
|
|
|
205
|
-
|
|
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`).
|
|
206
207
|
|
|
207
|
-
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.
|
|
208
209
|
|
|
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***.
|
|
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**.
|
|
212
212
|
|
|
213
213
|
<p align="center">
|
|
214
214
|
<img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/proxyman_export_protobuf.png" alt="proxyman_export_protobuf" width="80%"/>
|
|
215
215
|
</p>
|
|
216
216
|
|
|
217
|
-
|
|
217
|
+
- Run the tool with `--token-source client -w <path-to-login-request-body-file>`:
|
|
218
218
|
|
|
219
219
|
```sh
|
|
220
220
|
spotify_monitor --token-source client -w <path-to-login-request-body-file> <spotify_user_uri_id>
|
|
@@ -222,15 +222,17 @@ spotify_monitor --token-source client -w <path-to-login-request-body-file> <spot
|
|
|
222
222
|
|
|
223
223
|
If successful, the tool will automatically extract the necessary fields and begin monitoring.
|
|
224
224
|
|
|
225
|
-
|
|
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`.
|
|
226
228
|
|
|
227
229
|
The tool will automatically refresh both the access token and client token using the intercepted refresh token.
|
|
228
230
|
|
|
229
|
-
|
|
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.
|
|
230
232
|
|
|
231
|
-
|
|
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).
|
|
232
234
|
|
|
233
|
-
|
|
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.
|
|
234
236
|
|
|
235
237
|
<a id="following-the-monitored-user"></a>
|
|
236
238
|
### Following the Monitored User
|
|
@@ -269,12 +271,13 @@ spotify_monitor --send-test-email
|
|
|
269
271
|
<a id="storing-secrets"></a>
|
|
270
272
|
### Storing Secrets
|
|
271
273
|
|
|
272
|
-
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.
|
|
273
275
|
|
|
274
|
-
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:
|
|
275
277
|
|
|
276
278
|
```sh
|
|
277
279
|
export SP_DC_COOKIE="your_sp_dc_cookie_value"
|
|
280
|
+
export REFRESH_TOKEN="your_spotify_app_refresh_token"
|
|
278
281
|
export SMTP_PASSWORD="your_smtp_password"
|
|
279
282
|
```
|
|
280
283
|
|
|
@@ -284,6 +287,7 @@ Alternatively store them persistently in a dotenv file (recommended):
|
|
|
284
287
|
|
|
285
288
|
```ini
|
|
286
289
|
SP_DC_COOKIE="your_sp_dc_cookie_value"
|
|
290
|
+
REFRESH_TOKEN="your_spotify_app_refresh_token"
|
|
287
291
|
SMTP_PASSWORD="your_smtp_password"
|
|
288
292
|
```
|
|
289
293
|
|