spotify-monitor 2.0__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.
Potentially problematic release.
This version of spotify-monitor might be problematic. Click here for more details.
- spotify_monitor-2.0.dist-info/METADATA +503 -0
- spotify_monitor-2.0.dist-info/RECORD +7 -0
- spotify_monitor-2.0.dist-info/WHEEL +5 -0
- spotify_monitor-2.0.dist-info/entry_points.txt +2 -0
- spotify_monitor-2.0.dist-info/licenses/LICENSE +674 -0
- spotify_monitor-2.0.dist-info/top_level.txt +1 -0
- spotify_monitor.py +2481 -0
|
@@ -0,0 +1,503 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: spotify_monitor
|
|
3
|
+
Version: 2.0
|
|
4
|
+
Summary: Tool implementing real-time tracking of Spotify friends music activity
|
|
5
|
+
Author-email: Michal Szymanski <misiektoja-pypi@rm-rf.ninja>
|
|
6
|
+
License-Expression: GPL-3.0-or-later
|
|
7
|
+
Project-URL: Homepage, https://github.com/misiektoja/spotify_monitor
|
|
8
|
+
Project-URL: Source, https://github.com/misiektoja/spotify_monitor
|
|
9
|
+
Project-URL: Changelog, https://github.com/misiektoja/spotify_monitor/blob/main/RELEASE_NOTES.md
|
|
10
|
+
Keywords: spotify,monitoring,tracking,real-time,friend-activity,osint
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
15
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
16
|
+
Requires-Python: >=3.6
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: requests>=2.0
|
|
20
|
+
Requires-Dist: python-dateutil>=2.8
|
|
21
|
+
Requires-Dist: urllib3>=2.0.7
|
|
22
|
+
Requires-Dist: pyotp>=2.9.0
|
|
23
|
+
Requires-Dist: python-dotenv>=0.19
|
|
24
|
+
Dynamic: license-file
|
|
25
|
+
|
|
26
|
+
# spotify_monitor
|
|
27
|
+
|
|
28
|
+
spotify_monitor is a tool for real-time monitoring of Spotify friends' music activity.
|
|
29
|
+
|
|
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
|
+
|
|
32
|
+
<a id="features"></a>
|
|
33
|
+
## Features
|
|
34
|
+
|
|
35
|
+
- Real-time tracking of songs listened by Spotify users (including detection when user gets online & offline)
|
|
36
|
+
- Possibility to automatically play songs listened by the tracked user in your local Spotify client
|
|
37
|
+
- Information about the duration the user listened to a song and whether the song was skipped
|
|
38
|
+
- Information about the context of the listened song (playlist/artist/album) with clickable URLs
|
|
39
|
+
- Email notifications for various events (user becomes active/inactive, specific or all songs, songs on loop, errors)
|
|
40
|
+
- Saving all listened songs with timestamps to the CSV file
|
|
41
|
+
- Clickable Spotify, Apple Music, YouTube Music and Genius Lyrics search URLs printed in the console & included in email notifications
|
|
42
|
+
- Displaying basic statistics for the user's playing session (duration, time span, number of listened and skipped songs, songs on loop)
|
|
43
|
+
- Possibility to control the running copy of the script via signals
|
|
44
|
+
|
|
45
|
+
<p align="center">
|
|
46
|
+
<img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/spotify_monitor.png" alt="spotify_monitor_screenshot" width="90%"/>
|
|
47
|
+
</p>
|
|
48
|
+
|
|
49
|
+
<a id="table-of-contents"></a>
|
|
50
|
+
## Table of Contents
|
|
51
|
+
|
|
52
|
+
1. [Requirements](#requirements)
|
|
53
|
+
2. [Installation](#installation)
|
|
54
|
+
* [Install from PyPI](#install-from-pypi)
|
|
55
|
+
* [Manual Installation](#manual-installation)
|
|
56
|
+
3. [Quick Start](#quick-start)
|
|
57
|
+
4. [Configuration](#configuration)
|
|
58
|
+
* [Configuration File](#configuration-file)
|
|
59
|
+
* [Spotify sp_dc Cookie](#spotify-sp_dc-cookie)
|
|
60
|
+
* [Following the Monitored User](#following-the-monitored-user)
|
|
61
|
+
* [How to Get a Friend's User URI ID](#how-to-get-a-friends-user-uri-id)
|
|
62
|
+
* [SMTP Settings](#smtp-settings)
|
|
63
|
+
* [Storing Secrets](#storing-secrets)
|
|
64
|
+
5. [Usage](#usage)
|
|
65
|
+
* [Monitoring Mode](#monitoring-mode)
|
|
66
|
+
* [Listing Mode](#listing-mode)
|
|
67
|
+
* [Email Notifications](#email-notifications)
|
|
68
|
+
* [CSV Export](#csv-export)
|
|
69
|
+
* [Automatic Playback of Listened Tracks in the Spotify Client](#automatic-playback-of-listened-tracks-in-the-spotify-client)
|
|
70
|
+
* [Check Intervals](#check-intervals)
|
|
71
|
+
* [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix)
|
|
72
|
+
* [Coloring Log Output with GRC](#coloring-log-output-with-grc)
|
|
73
|
+
6. [Change Log](#change-log)
|
|
74
|
+
7. [License](#license)
|
|
75
|
+
|
|
76
|
+
<a id="requirements"></a>
|
|
77
|
+
## Requirements
|
|
78
|
+
|
|
79
|
+
* Python 3.6 or higher
|
|
80
|
+
* Libraries: `requests`, `python-dateutil`, `urllib3`, `pyotp`, `python-dotenv`
|
|
81
|
+
|
|
82
|
+
Tested on:
|
|
83
|
+
|
|
84
|
+
* **macOS**: Ventura, Sonoma, Sequoia
|
|
85
|
+
* **Linux**: Raspberry Pi OS (Bullseye, Bookworm), Ubuntu 24, Rocky Linux 8.x/9.x, Kali Linux 2024/2025
|
|
86
|
+
* **Windows**: 10, 11
|
|
87
|
+
|
|
88
|
+
It should work on other versions of macOS, Linux, Unix and Windows as well.
|
|
89
|
+
|
|
90
|
+
<a id="installation"></a>
|
|
91
|
+
## Installation
|
|
92
|
+
|
|
93
|
+
<a id="install-from-pypi"></a>
|
|
94
|
+
### Install from PyPI
|
|
95
|
+
|
|
96
|
+
```sh
|
|
97
|
+
pip install spotify_monitor
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
<a id="manual-installation"></a>
|
|
101
|
+
### Manual Installation
|
|
102
|
+
|
|
103
|
+
Download the *[spotify_monitor.py](https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/spotify_monitor.py)* file to the desired location.
|
|
104
|
+
|
|
105
|
+
Install dependencies via pip:
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
pip install requests python-dateutil urllib3 pyotp python-dotenv
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
Alternatively, from the downloaded *[requirements.txt](https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/requirements.txt)*:
|
|
112
|
+
|
|
113
|
+
```sh
|
|
114
|
+
pip install -r requirements.txt
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
<a id="quick-start"></a>
|
|
118
|
+
## Quick Start
|
|
119
|
+
|
|
120
|
+
- Grab your [Spotify sp_dc cookie](#spotify-sp_dc-cookie) and track the `spotify_user_uri_id` music activities:
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
spotify_monitor <spotify_user_uri_id> -u "your_sp_dc_cookie_value"
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Or if you installed [manually](#manual-installation):
|
|
128
|
+
|
|
129
|
+
```sh
|
|
130
|
+
python3 spotify_monitor.py <spotify_user_uri_id> -u "your_sp_dc_cookie_value"
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
To get the list of all supported command-line arguments / flags:
|
|
134
|
+
|
|
135
|
+
```sh
|
|
136
|
+
spotify_monitor --help
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
<a id="configuration"></a>
|
|
140
|
+
## Configuration
|
|
141
|
+
|
|
142
|
+
<a id="configuration-file"></a>
|
|
143
|
+
### Configuration File
|
|
144
|
+
|
|
145
|
+
Most settings can be configured via command-line arguments.
|
|
146
|
+
|
|
147
|
+
If you want to have it stored persistently, generate a default config template and save it to a file named `spotify_monitor.conf`:
|
|
148
|
+
|
|
149
|
+
```sh
|
|
150
|
+
spotify_monitor --generate-config > spotify_monitor.conf
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Edit the `spotify_monitor.conf` file and change any desired configuration options (detailed comments are provided for each).
|
|
155
|
+
|
|
156
|
+
<a id="spotify-sp_dc-cookie"></a>
|
|
157
|
+
### Spotify sp_dc Cookie
|
|
158
|
+
|
|
159
|
+
Log in to [https://open.spotify.com/](https://open.spotify.com/) in your web browser.
|
|
160
|
+
|
|
161
|
+
Locate and copy the value of the `sp_dc` cookie.
|
|
162
|
+
|
|
163
|
+
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
|
+
|
|
165
|
+
Provide the `SP_DC_COOKIE` secret using one of the following methods:
|
|
166
|
+
- Pass it at runtime with `-u` / `--spotify-dc-cookie`
|
|
167
|
+
- Set it as an [environment variable](#storing-secrets) (e.g. `export SP_DC_COOKIE=...`)
|
|
168
|
+
- Add it to [.env file](#storing-secrets) (`SP_DC_COOKIE=...`) for persistent use
|
|
169
|
+
|
|
170
|
+
Fallback:
|
|
171
|
+
- Hard-code it in the code or config file
|
|
172
|
+
|
|
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).
|
|
174
|
+
|
|
175
|
+
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
|
+
|
|
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).
|
|
178
|
+
|
|
179
|
+
<a id="following-the-monitored-user"></a>
|
|
180
|
+
### Following the Monitored User
|
|
181
|
+
|
|
182
|
+
To monitor a user's activity, you must follow them from the Spotify account associated with the `sp_dc` cookie.
|
|
183
|
+
|
|
184
|
+
Additionally, the user must have sharing of listening activity enabled in their Spotify client settings. Without this, no activity data will be visible.
|
|
185
|
+
|
|
186
|
+
<a id="how-to-get-a-friends-user-uri-id"></a>
|
|
187
|
+
### How to Get a Friend's User URI ID
|
|
188
|
+
|
|
189
|
+
The easiest way is via the Spotify desktop or mobile client:
|
|
190
|
+
- go to your friend's profile
|
|
191
|
+
- click the **three dots** (•••) or press the **Share** button
|
|
192
|
+
- copy the link to the profile
|
|
193
|
+
|
|
194
|
+
You'll get a URL like: [https://open.spotify.com/user/spotify_user_uri_id?si=tracking_id](https://open.spotify.com/user/spotify_user_uri_id?si=tracking_id)
|
|
195
|
+
|
|
196
|
+
Extract the part between `/user/` and `?si=` - in this case: `spotify_user_uri_id`
|
|
197
|
+
|
|
198
|
+
Use that as the user URI ID (`spotify_user_uri_id`) in the tool.
|
|
199
|
+
|
|
200
|
+
Alternatively you can list all user URI IDs of accounts you follow by using [Listing mode](#listing-mode).
|
|
201
|
+
|
|
202
|
+
<a id="smtp-settings"></a>
|
|
203
|
+
### SMTP Settings
|
|
204
|
+
|
|
205
|
+
If you want to use email notifications functionality, configure SMTP settings in the `spotify_monitor.conf` file.
|
|
206
|
+
|
|
207
|
+
Verify your SMTP settings by using `--send-test-email` flag (the tool will try to send a test email notification):
|
|
208
|
+
|
|
209
|
+
```sh
|
|
210
|
+
spotify_monitor --send-test-email
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
<a id="storing-secrets"></a>
|
|
214
|
+
### Storing Secrets
|
|
215
|
+
|
|
216
|
+
It is recommended to store secrets like `SP_DC_COOKIE` or `SMTP_PASSWORD` as either an environment variable or in a dotenv file.
|
|
217
|
+
|
|
218
|
+
Set environment variables using `export` on **Linux/Unix/macOS/WSL** systems:
|
|
219
|
+
|
|
220
|
+
```sh
|
|
221
|
+
export SP_DC_COOKIE="your_sp_dc_cookie_value"
|
|
222
|
+
export SMTP_PASSWORD="your_smtp_password"
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
On **Windows Command Prompt** use `set` instead of `export` and on **Windows PowerShell** use `$env`.
|
|
226
|
+
|
|
227
|
+
Alternatively store them persistently in a dotenv file (recommended):
|
|
228
|
+
|
|
229
|
+
```ini
|
|
230
|
+
SP_DC_COOKIE="your_sp_dc_cookie_value"
|
|
231
|
+
SMTP_PASSWORD="your_smtp_password"
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
By default the tool will auto-search for dotenv file named `.env` in current directory and then upward from it.
|
|
235
|
+
|
|
236
|
+
You can specify a custom file with `DOTENV_FILE` or `--env-file` flag:
|
|
237
|
+
|
|
238
|
+
```sh
|
|
239
|
+
spotify_monitor <spotify_user_uri_id> --env-file /path/.env-spotify_monitor
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
You can also disable `.env` auto-search with `DOTENV_FILE = "none"` or `--env-file none`:
|
|
243
|
+
|
|
244
|
+
```sh
|
|
245
|
+
spotify_monitor <spotify_user_uri_id> --env-file none
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
As a fallback, you can also store secrets in the configuration file or source code.
|
|
249
|
+
|
|
250
|
+
<a id="usage"></a>
|
|
251
|
+
## Usage
|
|
252
|
+
|
|
253
|
+
<a id="monitoring-mode"></a>
|
|
254
|
+
### Monitoring Mode
|
|
255
|
+
|
|
256
|
+
To monitor specific user activity, just type [Spotify user URI ID](#how-to-get-a-friends-user-uri-id) as a command-line argument (`spotify_user_uri_id` in the example below):
|
|
257
|
+
|
|
258
|
+
```sh
|
|
259
|
+
spotify_monitor <spotify_user_uri_id>
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
If you have not set `SP_DC_COOKIE` secret, you can use `-u` flag:
|
|
263
|
+
|
|
264
|
+
```sh
|
|
265
|
+
spotify_monitor <spotify_user_uri_id> -u "your_sp_dc_cookie_value"
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
By default, the tool looks for a configuration file named `spotify_monitor.conf` in:
|
|
269
|
+
- current directory
|
|
270
|
+
- home directory (`~`)
|
|
271
|
+
- script directory
|
|
272
|
+
|
|
273
|
+
If you generated a configuration file as described in [Configuration](#configuration), but saved it under a different name or in a different directory, you can specify its location using the `--config-file` flag:
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
```sh
|
|
277
|
+
spotify_monitor <spotify_user_uri_id> --config-file /path/spotify_monitor_new.conf
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
The tool runs until interrupted (`Ctrl+C`). Use `tmux` or `screen` for persistence.
|
|
281
|
+
|
|
282
|
+
You can monitor multiple Spotify friends by running multiple copies of the script.
|
|
283
|
+
|
|
284
|
+
The tool automatically saves its output to `spotify_monitor_<user_uri_id/file_suffix>.log` file. The log file name can be changed via `SP_LOGFILE` configuration option and its suffix via `FILE_SUFFIX` / `-y` flag. Logging can be disabled completely via `DISABLE_LOGGING` / `-d` flag.
|
|
285
|
+
|
|
286
|
+
Keep in mind that monitoring reports the listened track AFTER the user finishes listening to it. This is how activities are reported by Spotify.
|
|
287
|
+
|
|
288
|
+
<a id="listing-mode"></a>
|
|
289
|
+
### Listing Mode
|
|
290
|
+
|
|
291
|
+
There is also another mode of the tool which displays various requested information.
|
|
292
|
+
|
|
293
|
+
If you want to display a list of all the friends you follow with their recently listened tracks (`-l` flag):
|
|
294
|
+
|
|
295
|
+
```sh
|
|
296
|
+
spotify_monitor -l
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
It also displays your friend's Spotify username (often the user's first and last name) and user URI ID (often a string of random characters). The latter should be used as a tool's command-line argument to monitor the user.
|
|
300
|
+
|
|
301
|
+
<p align="center">
|
|
302
|
+
<img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/spotify_monitor_listing.png" alt="spotify_monitor_listing" width="90%"/>
|
|
303
|
+
</p>
|
|
304
|
+
|
|
305
|
+
To get basic information about the Spotify access token owner (`-v` flag):
|
|
306
|
+
|
|
307
|
+
```sh
|
|
308
|
+
spotify_monitor -v
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
<a id="email-notifications"></a>
|
|
312
|
+
### Email Notifications
|
|
313
|
+
|
|
314
|
+
To enable email notifications when a user becomes active:
|
|
315
|
+
- set `ACTIVE_NOTIFICATION` to `True`
|
|
316
|
+
- or use the `-a` flag
|
|
317
|
+
|
|
318
|
+
```sh
|
|
319
|
+
spotify_monitor <spotify_user_uri_id> -a
|
|
320
|
+
```
|
|
321
|
+
|
|
322
|
+
To be informed when a user gets inactive:
|
|
323
|
+
- set `INACTIVE_NOTIFICATION` to `True`
|
|
324
|
+
- or use the `-i` flag
|
|
325
|
+
|
|
326
|
+
```sh
|
|
327
|
+
spotify_monitor <spotify_user_uri_id> -i
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
To get email notifications when a monitored track/playlist/album plays:
|
|
331
|
+
- set `TRACK_NOTIFICATION` to `True`
|
|
332
|
+
- or use the `-t` flag
|
|
333
|
+
|
|
334
|
+
For that feature you also need to create a file with a list of songs you want to track (one track, album or playlist per line). Specify the file using the `MONITOR_LIST_FILE` or `-s` flag:
|
|
335
|
+
|
|
336
|
+
```sh
|
|
337
|
+
spotify_monitor <spotify_user_uri_id> -t -s spotify_tracks_spotify_user_uri_id
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
Example file `spotify_tracks_spotify_user_uri_id`:
|
|
341
|
+
|
|
342
|
+
```
|
|
343
|
+
we fell in love in october
|
|
344
|
+
Like a Stone
|
|
345
|
+
Half Believing
|
|
346
|
+
Something Changed
|
|
347
|
+
I Will Be There
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
You can comment out specific lines with # if needed.
|
|
351
|
+
|
|
352
|
+
To enable email notifications for every song listened by the user:
|
|
353
|
+
- set `SONG_NOTIFICATION` to `True`
|
|
354
|
+
- or use the `-j` flag
|
|
355
|
+
|
|
356
|
+
```sh
|
|
357
|
+
spotify_monitor <spotify_user_uri_id> -j
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
To be notified when a user listens to the same song on loop:
|
|
361
|
+
- set `SONG_ON_LOOP_NOTIFICATION` to `True`
|
|
362
|
+
- or use the `-x` flag
|
|
363
|
+
|
|
364
|
+
```sh
|
|
365
|
+
spotify_monitor <spotify_user_uri_id> -x
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
To disable sending an email on errors (enabled by default):
|
|
369
|
+
- set `ERROR_NOTIFICATION` to `False`
|
|
370
|
+
- or use the `-e` flag
|
|
371
|
+
|
|
372
|
+
```sh
|
|
373
|
+
spotify_monitor <spotify_user_uri_id> -e
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Make sure you defined your SMTP settings earlier (see [SMTP settings](#smtp-settings)).
|
|
377
|
+
|
|
378
|
+
Example email:
|
|
379
|
+
|
|
380
|
+
<p align="center">
|
|
381
|
+
<img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/spotify_monitor_email_notifications.png" alt="spotify_monitor_email_notifications" width="80%"/>
|
|
382
|
+
</p>
|
|
383
|
+
|
|
384
|
+
<a id="csv-export"></a>
|
|
385
|
+
### CSV Export
|
|
386
|
+
|
|
387
|
+
If you want to save all listened songs to a CSV file, set `CSV_FILE` or use `-b` flag:
|
|
388
|
+
|
|
389
|
+
```sh
|
|
390
|
+
spotify_monitor <spotify_user_uri_id> -b spotify_tracks_user_uri_id.csv
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
The file will be automatically created if it does not exist.
|
|
394
|
+
|
|
395
|
+
<a id="automatic-playback-of-listened-tracks-in-the-spotify-client"></a>
|
|
396
|
+
### Automatic Playback of Listened Tracks in the Spotify Client
|
|
397
|
+
|
|
398
|
+
If you want the tool to automatically play the tracks listened to by the user in your local Spotify client:
|
|
399
|
+
- set `TRACK_SONGS` to `True`
|
|
400
|
+
- or use the `-g` flag
|
|
401
|
+
|
|
402
|
+
```sh
|
|
403
|
+
spotify_monitor <spotify_user_uri_id> -g
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
Your Spotify client needs to be installed and running for this feature to work.
|
|
407
|
+
|
|
408
|
+
The tool fully supports automatic playback on **Linux** and **macOS**. This means it will automatically play the changed track and can also pause or play the indicated track once the user becomes inactive (see the `SP_USER_GOT_OFFLINE_TRACK_ID` configuration option).
|
|
409
|
+
|
|
410
|
+
For **Windows**, it works in a semi-automatic way: if you have the Spotify client running and you are not listening to any song, then the first track will play automatically. However, subsequent tracks will be located in the client, but you will need to press the play button manually.
|
|
411
|
+
|
|
412
|
+
You can change the playback method per platform using the corresponding configuration option.
|
|
413
|
+
|
|
414
|
+
For **macOS** set `SPOTIFY_MACOS_PLAYING_METHOD` to one of the following values:
|
|
415
|
+
- "**apple-script**" (recommended, **default**)
|
|
416
|
+
- "trigger-url"
|
|
417
|
+
|
|
418
|
+
For **Linux** set `SPOTIFY_LINUX_PLAYING_METHOD` to one of the following values:
|
|
419
|
+
- "**dbus-send**" (most common one, **default**)
|
|
420
|
+
- "qdbus" (try if dbus-send does not work)
|
|
421
|
+
- "trigger-url"
|
|
422
|
+
|
|
423
|
+
For **Windows** set `SPOTIFY_WINDOWS_PLAYING_METHOD` to one of the following values:
|
|
424
|
+
- "**start-uri**" (recommended, **default**)
|
|
425
|
+
- "spotify-cmd"
|
|
426
|
+
- "trigger-url"
|
|
427
|
+
|
|
428
|
+
The recommended defaults should work for most people.
|
|
429
|
+
|
|
430
|
+
Note: monitoring reports the listened track after the user finishes listening to it. This is how activities are reported by Spotify. It means you will be one song behind the monitored user and if the song currently listened to by the tracked user is longer than the previous one, then the previously listened song might be played in your Spotify client on repeat (and if shorter it might be changed in the middle of the currently played song).
|
|
431
|
+
|
|
432
|
+
For real-time playback tracking of a user's music activities, ask your friend to connect their Spotify account with [Last.fm](https://www.last.fm/). Then use my other tool: [lastfm_monitor](https://github.com/misiektoja/lastfm_monitor).
|
|
433
|
+
|
|
434
|
+
<a id="check-intervals"></a>
|
|
435
|
+
### Check Intervals
|
|
436
|
+
|
|
437
|
+
If you want to customize the polling interval, use `-c` flag (or `SPOTIFY_CHECK_INTERVAL` configuration option):
|
|
438
|
+
|
|
439
|
+
```sh
|
|
440
|
+
spotify_monitor <spotify_user_uri_id> -c 20
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
If you want to change the time required to mark the user as inactive (the timer starts from the last reported track), use `-o` flag (or `SPOTIFY_INACTIVITY_CHECK` configuration option):
|
|
444
|
+
|
|
445
|
+
```sh
|
|
446
|
+
spotify_monitor <spotify_user_uri_id> -o 900
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
<a id="signal-controls-macoslinuxunix"></a>
|
|
450
|
+
### Signal Controls (macOS/Linux/Unix)
|
|
451
|
+
|
|
452
|
+
The tool has several signal handlers implemented which allow to change behavior of the tool without a need to restart it with new configuration options / flags.
|
|
453
|
+
|
|
454
|
+
List of supported signals:
|
|
455
|
+
|
|
456
|
+
| Signal | Description |
|
|
457
|
+
| ----------- | ----------- |
|
|
458
|
+
| USR1 | Toggle email notifications when user gets active/inactive (-a, -i) |
|
|
459
|
+
| USR2 | Toggle email notifications for every song (-j) |
|
|
460
|
+
| CONT | Toggle email notifications for tracked songs (-t) |
|
|
461
|
+
| PIPE | Toggle email notifications when user plays song on loop (-x) |
|
|
462
|
+
| TRAP | Increase the inactivity check timer (by 30 seconds) (-o) |
|
|
463
|
+
| ABRT | Decrease the inactivity check timer (by 30 seconds) (-o) |
|
|
464
|
+
| HUP | Reload secrets from .env file |
|
|
465
|
+
|
|
466
|
+
Send signals with `kill` or `pkill`, e.g.:
|
|
467
|
+
|
|
468
|
+
```sh
|
|
469
|
+
pkill -USR1 -f "spotify_monitor <spotify_user_uri_id>"
|
|
470
|
+
```
|
|
471
|
+
|
|
472
|
+
As Windows supports limited number of signals, this functionality is available only on Linux/Unix/macOS.
|
|
473
|
+
|
|
474
|
+
<a id="coloring-log-output-with-grc"></a>
|
|
475
|
+
### Coloring Log Output with GRC
|
|
476
|
+
|
|
477
|
+
You can use [GRC](https://github.com/garabik/grc) to color logs.
|
|
478
|
+
|
|
479
|
+
Add to your GRC config (`~/.grc/grc.conf`):
|
|
480
|
+
|
|
481
|
+
```
|
|
482
|
+
# monitoring log file
|
|
483
|
+
.*_monitor_.*\.log
|
|
484
|
+
conf.monitor_logs
|
|
485
|
+
```
|
|
486
|
+
|
|
487
|
+
Now copy the [conf.monitor_logs](https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/grc/conf.monitor_logs) to your `~/.grc/` and log files should be nicely colored when using `grc` tool.
|
|
488
|
+
|
|
489
|
+
Example:
|
|
490
|
+
|
|
491
|
+
```sh
|
|
492
|
+
grc tail -F -n 100 spotify_monitor_<user_uri_id/file_suffix>.log
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
<a id="change-log"></a>
|
|
496
|
+
## Change Log
|
|
497
|
+
|
|
498
|
+
See [RELEASE_NOTES.md](https://github.com/misiektoja/spotify_monitor/blob/main/RELEASE_NOTES.md) for details.
|
|
499
|
+
|
|
500
|
+
<a id="license"></a>
|
|
501
|
+
## License
|
|
502
|
+
|
|
503
|
+
Licensed under GPLv3. See [LICENSE](https://github.com/misiektoja/spotify_monitor/blob/main/LICENSE).
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
spotify_monitor.py,sha256=Itt3Kb1izckZYhClYyjOknA3eDBA3Z6aeY4aOuWWwws,111656
|
|
2
|
+
spotify_monitor-2.0.dist-info/licenses/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
|
|
3
|
+
spotify_monitor-2.0.dist-info/METADATA,sha256=hQybfj4zEnj34Mb3fheDlbvPbgW9itczX0vU1bmNfw8,18614
|
|
4
|
+
spotify_monitor-2.0.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
5
|
+
spotify_monitor-2.0.dist-info/entry_points.txt,sha256=8HzePfUcCSXrYaXOwLbNNYO8GJcnhgCSl4wcDNECht8,57
|
|
6
|
+
spotify_monitor-2.0.dist-info/top_level.txt,sha256=EP6IPD4vHT12rLM5b_jo2i3nrfOuwk3ehhr2gWdQx9Y,16
|
|
7
|
+
spotify_monitor-2.0.dist-info/RECORD,,
|