spotify-monitor 2.0rc1__py3-none-any.whl → 2.1__py3-none-any.whl

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spotify_monitor
3
- Version: 2.0rc1
3
+ Version: 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
@@ -56,7 +56,9 @@ NOTE: If you're interested in tracking changes to Spotify users' profiles includ
56
56
  3. [Quick Start](#quick-start)
57
57
  4. [Configuration](#configuration)
58
58
  * [Configuration File](#configuration-file)
59
- * [Spotify sp_dc Cookie](#spotify-sp_dc-cookie)
59
+ * [Spotify access token source](#spotify-access-token-source)
60
+ * [Spotify sp_dc Cookie](#spotify-sp_dc-cookie)
61
+ * [Spotify Desktop Client](#spotify-desktop-client)
60
62
  * [Following the Monitored User](#following-the-monitored-user)
61
63
  * [How to Get a Friend's User URI ID](#how-to-get-a-friends-user-uri-id)
62
64
  * [SMTP Settings](#smtp-settings)
@@ -153,8 +155,23 @@ spotify_monitor --generate-config > spotify_monitor.conf
153
155
 
154
156
  Edit the `spotify_monitor.conf` file and change any desired configuration options (detailed comments are provided for each).
155
157
 
158
+ <a id="spotify-access-token-source"></a>
159
+ #### Spotify access token source
160
+
161
+ The tool supports two methods for obtaining a Spotify access token.
162
+
163
+ It can be configured via the `TOKEN_SOURCE` configuration option or the `--token-source` flag.
164
+
165
+ The **recommended method** is `cookie` which uses the sp_dc cookie to retrieve a token from the Spotify web endpoint.
166
+
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
+
169
+ If no method is specified, the tool defaults to the `cookie` method.
170
+
156
171
  <a id="spotify-sp_dc-cookie"></a>
157
- ### Spotify sp_dc Cookie
172
+ #### Spotify sp_dc Cookie
173
+
174
+ It is default method used to obtain a Spotify access token.
158
175
 
159
176
  Log in to [https://open.spotify.com/](https://open.spotify.com/) in your web browser.
160
177
 
@@ -170,11 +187,50 @@ Provide the `SP_DC_COOKIE` secret using one of the following methods:
170
187
  Fallback:
171
188
  - Hard-code it in the code or config file
172
189
 
173
- The `sp_dc` cookie is typically valid for up to 2 weeks. You will be informed by the tool once the cookie expires (proper message on the console and in email).
190
+ You will be informed by the tool once the `sp_dc` cookie expires (proper message on the console and in email).
174
191
 
175
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).
176
193
 
177
- It is recommended to create a new Spotify account for use with the tool since we are not using the official Spotify Web API most of the time (as it does not support fetching friend activity).
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.
195
+
196
+ <a id="spotify-desktop-client"></a>
197
+ #### Spotify Desktop Client
198
+
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.
200
+
201
+ Run an intercepting proxy of your choice (like [Proxyman](https://proxyman.com)).
202
+
203
+ Launch the Spotify desktop client and look for requests to `https://login{n}.spotify.com/v3/login`
204
+
205
+ Note: The `login` part is suffixed with one or more digits (e.g. `login5.spotify.com`).
206
+
207
+ If you don't see this request, log out from the client and log back in.
208
+
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
+
213
+ <p align="center">
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
+ </p>
216
+
217
+ Then run the tool with `-w <path-to-login-request-body-file>`:
218
+
219
+ ```sh
220
+ spotify_monitor --token-source client -w <path-to-login-request-body-file> <spotify_user_uri_id>
221
+ ```
222
+
223
+ If successful, the tool will automatically extract the necessary fields and begin monitoring.
224
+
225
+ You can also persist the Protobuf request file path using the `LOGIN_REQUEST_BODY_FILE` configuration option.
226
+
227
+ The tool will automatically refresh both the access token and client token using the intercepted refresh token.
228
+
229
+ Advanced options are available for further customization - refer to the configuration file comments. However, default settings should work for most cases.
230
+
231
+ You will be informed by the tool once the refresh token expires (proper message on the console and in email).
232
+
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.
178
234
 
179
235
  <a id="following-the-monitored-user"></a>
180
236
  ### Following the Monitored User
@@ -259,7 +315,7 @@ To monitor specific user activity, just type [Spotify user URI ID](#how-to-get-a
259
315
  spotify_monitor <spotify_user_uri_id>
260
316
  ```
261
317
 
262
- If you have not set `SP_DC_COOKIE` secret, you can use `-u` flag:
318
+ If you use the default method to obtain a Spotify access token (`cookie`) and have not set `SP_DC_COOKIE` secret, you can use `-u` flag:
263
319
 
264
320
  ```sh
265
321
  spotify_monitor <spotify_user_uri_id> -u "your_sp_dc_cookie_value"
@@ -461,7 +517,7 @@ List of supported signals:
461
517
  | PIPE | Toggle email notifications when user plays song on loop (-x) |
462
518
  | TRAP | Increase the inactivity check timer (by 30 seconds) (-o) |
463
519
  | ABRT | Decrease the inactivity check timer (by 30 seconds) (-o) |
464
- | HUP | Reload secrets from .env file |
520
+ | HUP | Reload secrets from .env file and token source credentials from Protobuf files |
465
521
 
466
522
  Send signals with `kill` or `pkill`, e.g.:
467
523
 
@@ -0,0 +1,7 @@
1
+ spotify_monitor.py,sha256=g_kitqHOJr-708PeGjrosvMG3Om6AzH6d0xE8VdPbDc,145830
2
+ spotify_monitor-2.1.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
3
+ spotify_monitor-2.1.dist-info/METADATA,sha256=4OdX74oC29gletoUAq0amLvMkKcq-GqOxXVt1E_ATTQ,21529
4
+ spotify_monitor-2.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
5
+ spotify_monitor-2.1.dist-info/entry_points.txt,sha256=8HzePfUcCSXrYaXOwLbNNYO8GJcnhgCSl4wcDNECht8,57
6
+ spotify_monitor-2.1.dist-info/top_level.txt,sha256=EP6IPD4vHT12rLM5b_jo2i3nrfOuwk3ehhr2gWdQx9Y,16
7
+ spotify_monitor-2.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.8.0)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5