spotify-monitor 2.3.1__tar.gz → 2.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of spotify-monitor might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: spotify_monitor
3
- Version: 2.3.1
3
+ Version: 2.6
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
@@ -26,7 +26,7 @@ Dynamic: license-file
26
26
 
27
27
  # spotify_monitor
28
28
 
29
- Tool for real-time monitoring of Spotify friends' music activity feed.
29
+ Tool for real-time monitoring of **Spotify friends' music activity feed**.
30
30
 
31
31
  ✨ 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).
32
32
 
@@ -38,13 +38,15 @@ Tool for real-time monitoring of Spotify friends' music activity feed.
38
38
  - Real-time tracking of songs listened by Spotify users (including detection when user gets online & offline)
39
39
  - Possibility to automatically play songs listened by the tracked user in your local Spotify client
40
40
  - Information about the duration the user listened to a song and whether the song was skipped
41
+ - Detection and annotation for crossfaded songs during playback with configurable thresholds
41
42
  - Information about the context of the listened song (playlist/artist/album) with clickable URLs
42
43
  - Email notifications for various events (user becomes active/inactive, specific or all songs, songs on loop, errors)
43
44
  - Saving all listened songs with timestamps to the CSV file
44
- - Clickable Spotify, Apple Music, YouTube Music and Genius Lyrics search URLs printed in the console & included in email notifications
45
+ - Clickable Spotify, Apple Music, YouTube Music, Amazon Music, Deezer, Tidal, Genius Lyrics, AZLyrics, Tekstowo.pl, Musixmatch and Lyrics.com search URLs printed in the console and included in email notifications (configurable per service)
45
46
  - Displaying basic statistics for the user's playing session (duration, time span, number of listened and skipped songs, songs on loop)
46
47
  - Support for two different methods to get a Spotify access token (`sp_dc cookie`, `desktop client`)
47
48
  - Possibility to control the running copy of the script via signals
49
+ - Functional, procedural Python (minimal OOP)
48
50
 
49
51
  <p align="center">
50
52
  <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/spotify_monitor.png" alt="spotify_monitor_screenshot" width="90%"/>
@@ -57,6 +59,7 @@ Tool for real-time monitoring of Spotify friends' music activity feed.
57
59
  2. [Installation](#installation)
58
60
  * [Install from PyPI](#install-from-pypi)
59
61
  * [Manual Installation](#manual-installation)
62
+ * [Upgrading](#upgrading)
60
63
  3. [Quick Start](#quick-start)
61
64
  4. [Configuration](#configuration)
62
65
  * [Configuration File](#configuration-file)
@@ -77,8 +80,11 @@ Tool for real-time monitoring of Spotify friends' music activity feed.
77
80
  * [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix)
78
81
  * [Coloring Log Output with GRC](#coloring-log-output-with-grc)
79
82
  6. [Debugging Tools](#debugging-tools)
83
+ * [Access Token Retrieval via sp_dc Cookie and TOTP](#access-token-retrieval-via-sp_dc-cookie-and-totp)
84
+ * [Secret Key Extraction from Spotify Web Player Bundles](#secret-key-extraction-from-spotify-web-player-bundles)
80
85
  7. [Change Log](#change-log)
81
- 8. [License](#license)
86
+ 8. [Maintainers](#maintainers)
87
+ 9. [License](#license)
82
88
 
83
89
  <a id="requirements"></a>
84
90
  ## Requirements
@@ -88,8 +94,8 @@ Tool for real-time monitoring of Spotify friends' music activity feed.
88
94
 
89
95
  Tested on:
90
96
 
91
- * **macOS**: Ventura, Sonoma, Sequoia
92
- * **Linux**: Raspberry Pi OS (Bullseye, Bookworm), Ubuntu 24, Rocky Linux 8.x/9.x, Kali Linux 2024/2025
97
+ * **macOS**: Ventura, Sonoma, Sequoia, Tahoe
98
+ * **Linux**: Raspberry Pi OS (Bullseye, Bookworm, Trixie), Ubuntu 24/25, Rocky Linux 8.x/9.x, Kali Linux 2024/2025
93
99
  * **Windows**: 10, 11
94
100
 
95
101
  It should work on other versions of macOS, Linux, Unix and Windows as well.
@@ -112,7 +118,7 @@ Download the *[spotify_monitor.py](https://raw.githubusercontent.com/misiektoja/
112
118
  Install dependencies via pip:
113
119
 
114
120
  ```sh
115
- pip install requests python-dateutil urllib3 pyotp python-dotenv
121
+ pip install requests python-dateutil urllib3 pyotp python-dotenv wcwidth
116
122
  ```
117
123
 
118
124
  Alternatively, from the downloaded *[requirements.txt](https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/requirements.txt)*:
@@ -121,6 +127,17 @@ Alternatively, from the downloaded *[requirements.txt](https://raw.githubusercon
121
127
  pip install -r requirements.txt
122
128
  ```
123
129
 
130
+ <a id="upgrading"></a>
131
+ ### Upgrading
132
+
133
+ To upgrade to the latest version when installed from PyPI:
134
+
135
+ ```sh
136
+ pip install spotify_monitor -U
137
+ ```
138
+
139
+ If you installed manually, download the newest *[spotify_monitor.py](https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/spotify_monitor.py)* file to replace your existing installation.
140
+
124
141
  <a id="quick-start"></a>
125
142
  ## Quick Start
126
143
 
@@ -143,6 +160,10 @@ To get the list of all supported command-line arguments / flags:
143
160
  spotify_monitor --help
144
161
  ```
145
162
 
163
+ <p align="center">
164
+ <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/spotify_monitor_skipped.png" alt="spotify_monitor_skipped" width="90%"/>
165
+ </p>
166
+
146
167
  <a id="configuration"></a>
147
168
  ## Configuration
148
169
 
@@ -160,6 +181,8 @@ spotify_monitor --generate-config > spotify_monitor.conf
160
181
 
161
182
  Edit the `spotify_monitor.conf` file and change any desired configuration options (detailed comments are provided for each).
162
183
 
184
+ **New in v2.6:** The configuration file includes options to enable/disable music service URLs (Apple Music, YouTube Music, Amazon Music, Deezer, Tidal) and lyrics service URLs (Genius, AZLyrics, Tekstowo.pl, Musixmatch, Lyrics.com) in console and email outputs. You can also configure crossfade detection thresholds and the number of recent songs to include in inactivity emails.
185
+
163
186
  <a id="spotify-access-token-source"></a>
164
187
  ### Spotify access token source
165
188
 
@@ -199,7 +222,7 @@ If your `sp_dc` cookie expires, the tool will notify you via the console and ema
199
222
 
200
223
  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).
201
224
 
202
- `Note`: encrypted byte sequences used for TOTP secret generation tend to expire every now and then; you can either check the [issues](https://github.com/misiektoja/spotify_monitor/issues) section of the project to see if there are any new secrets published or you can run the [spotify_monitor_secret_grabber.py](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber.py) and extract it by yourself (see [Debugging Tools](https://github.com/misiektoja/spotify_monitor#debugging-tools) for more info).
225
+ > **NOTE:** secrets used for TOTP generation (`SECRET_CIPHER_DICT`) expire every two days, that's why since v2.4 the tool fetches it from remote URL (see `SECRET_CIPHER_DICT_URL`); you can also run the [spotify_monitor_secret_grabber](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber.py) and extract it by yourself (see [Secret Key Extraction from Spotify Web Player Bundles](#secret-key-extraction-from-spotify-web-player-bundles) for more info).
203
226
 
204
227
  <a id="spotify-desktop-client"></a>
205
228
  #### Spotify Desktop Client
@@ -404,6 +427,8 @@ To be informed when a user gets inactive:
404
427
  spotify_monitor <spotify_user_uri_id> -i
405
428
  ```
406
429
 
430
+ Inactivity emails include recent songs from the session with skipped track status. Configure the number of recent songs to include via the `INACTIVE_EMAIL_RECENT_SONGS_COUNT` configuration option.
431
+
407
432
  To get email notifications when a monitored track/playlist/album plays:
408
433
  - set `TRACK_NOTIFICATION` to `True`
409
434
  - or use the `-t` flag
@@ -572,32 +597,165 @@ grc tail -F -n 100 spotify_monitor_<user_uri_id/file_suffix>.log
572
597
  <a id="debugging-tools"></a>
573
598
  ## Debugging Tools
574
599
 
575
- To help with troubleshooting and development, two debug utilities are available in the `debug` directory:
600
+ To help with troubleshooting and development, two debug utilities are available in the [debug](https://github.com/misiektoja/spotify_monitor/tree/dev/debug) directory.
576
601
 
577
- - [spotify_monitor_totp_test.py](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_totp_test.py): fetching of Spotify access token based on a Spotify Web Player `sp_dc` cookie value:
602
+ <a id="access-token-retrieval-via-sp_dc-cookie-and-totp"></a>
603
+ ### Access Token Retrieval via sp_dc Cookie and TOTP
604
+
605
+ The [spotify_monitor_totp_test](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_totp_test.py) tool retrieves a Spotify access token using a Web Player `sp_dc` cookie and TOTP parameters.
606
+
607
+ Download from [here](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_totp_test.py) or:
608
+
609
+ ```sh
610
+ wget https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/dev/debug/spotify_monitor_totp_test.py
611
+ ```
612
+
613
+ Install requirements:
578
614
 
579
615
  ```sh
580
616
  pip install requests python-dateutil pyotp
617
+ ```
618
+
619
+ Run:
620
+
621
+ ```sh
581
622
  python3 spotify_monitor_totp_test.py --sp-dc "your_sp_dc_cookie_value"
582
623
  ```
583
624
 
584
- - [spotify_monitor_secret_grabber.py](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber.py): automatic extractor for secret keys used for TOTP generation in Spotify Web Player JavaScript bundles:
625
+ You should get a valid Spotify access token, example output:
626
+
627
+ <p align="center">
628
+ <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/spotify_monitor_totp_test.png" alt="spotify_monitor_totp_test" width="100%"/>
629
+ </p>
630
+
631
+ > **NOTE:** secrets used for TOTP generation (`SECRET_CIPHER_DICT`) expire every two days; you can either run the [spotify_monitor_secret_grabber](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber.py) and extract it by yourself (see [here](#secret-key-extraction-from-spotify-web-player-bundles) for more info) or you can pass `--fetch-secrets` flag in `spotify_monitor_totp_test` (available since v1.6). There is also a [xyloflake/spot-secrets-go/](https://github.com/xyloflake/spot-secrets-go/) repo which offers JSON files that are automatically updated with current secrets (you can pass `--download-secrets` flag in `spotify_monitor_totp_test` to get it automatically from remote URL, available since v1.8).
632
+
633
+ <a id="secret-key-extraction-from-spotify-web-player-bundles"></a>
634
+ ### Secret Key Extraction from Spotify Web Player Bundles
635
+
636
+ The [spotify_monitor_secret_grabber](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber.py) tool automatically extracts secret keys used for TOTP generation in Spotify Web Player JavaScript bundles.
637
+
638
+ > 💡 **Quick tip:** The easiest and recommended way to run this tool is via Docker. Jump directly to the [Docker usage section below](#-secret-key-extraction-via-docker-recommended-easiest-way).
639
+
640
+ Download from [here](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber.py) or:
641
+
642
+ ```sh
643
+ wget https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/dev/debug/spotify_monitor_secret_grabber.py
644
+ ```
645
+
646
+ Install requirements:
585
647
 
586
648
  ```sh
587
649
  pip install playwright
588
650
  playwright install
651
+ ```
652
+
653
+ Run interactively (default output mode):
654
+
655
+ ```sh
589
656
  python3 spotify_monitor_secret_grabber.py
590
657
  ```
591
658
 
659
+ You should get output similar to below:
660
+
592
661
  <p align="center">
593
662
  <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/spotify_monitor_secret_grabber.png" alt="spotify_monitor_secret_grabber" width="100%"/>
594
663
  </p>
595
664
 
665
+ Show help:
666
+ ```sh
667
+ python3 spotify_monitor_secret_grabber.py -h
668
+ ```
669
+
670
+ ---
671
+
672
+ <a id="cli-output-modes"></a>
673
+ ### CLI Output Modes
674
+
675
+ The script supports several output modes for different use cases:
676
+
677
+ | Flag | Description | Output |
678
+ |------|--------------|--------|
679
+ | `--secret` | Prints plain JSON array of extracted secrets | `[{"version": X, "secret": "..."}, ...]` |
680
+ | `--secretbytes` | Prints JSON array with ASCII byte values | `[{"version": X, "secret": [..]}, ...]` |
681
+ | `--secretdict` | Prints JSON object/dict mapping version → byte list | `{"X": [..], "Y": [..]}` |
682
+ | `--all` | Extracts secrets and **writes all three outputs** to local files | `secrets.json`, `secretBytes.json`, `secretDict.json` |
683
+
684
+ Print extracted secrets in specific format, for example Python-friendly secret bytes (JSON object/dict) and save to indicated file:
685
+
686
+ ```sh
687
+ python3 spotify_monitor_secret_grabber.py --secretdict > secretDict.json
688
+ ```
689
+
690
+ Or, to generate and save all secret formats to files (`secrets.json`, `secretBytes.json`, `secretDict.json`) at once:
691
+
692
+ ```sh
693
+ python3 spotify_monitor_secret_grabber.py --all
694
+ ```
695
+
696
+ Default file paths and names can be configured directly in the `OUTPUT_FILES` dictionary at the top of the script.
697
+
698
+ ---
699
+
700
+ <a id="-secret-key-extraction-via-docker-recommended-easiest-way"></a>
701
+ ### 🐳 Secret Key Extraction via Docker (Recommended Easiest Way)
702
+
703
+ A prebuilt multi-architecture image is available on Docker Hub: [`misiektoja/spotify-secrets-grabber`](https://hub.docker.com/r/misiektoja/spotify-secrets-grabber)
704
+
705
+ This image works on:
706
+ - macOS (Intel & Apple Silicon)
707
+ - Linux (x86_64 and ARM64)
708
+ - Windows (Docker Desktop / WSL2)
709
+ - Raspberry Pi 4/5 (64-bit OS)
710
+
711
+ Run interactively (default output mode):
712
+
713
+ ```sh
714
+ docker run --rm misiektoja/spotify-secrets-grabber
715
+ ```
716
+
717
+ Show help:
718
+ ```sh
719
+ docker run --rm misiektoja/spotify-secrets-grabber -h
720
+ ```
721
+
722
+ Print extracted secrets in specific format, for example Python-friendly secret bytes (JSON object/dict) and save to indicated file:
723
+ ```sh
724
+ docker run --rm misiektoja/spotify-secrets-grabber --secretdict > secretDict.json
725
+ ```
726
+
727
+ Or, to generate and save all secret formats to files (`secrets.json`, `secretBytes.json`, `secretDict.json`) at once:
728
+
729
+ ```sh
730
+ docker run --rm -v .:/work -w /work misiektoja/spotify-secrets-grabber --all
731
+ ```
732
+
733
+ *For SELinux hosts (Fedora/RHEL), use `-v .:/work:Z`.*
734
+
735
+ <a id="optional-use-docker-compose-one-command-for-all-oss"></a>
736
+ Or optionally use Docker Compose (a preconfigured [compose.yaml](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber_docker/compose.yaml) file is included in the repo):
737
+
738
+ ```sh
739
+ docker compose run --rm spotify-secrets-grabber --all
740
+ ```
741
+
742
+ This will save all files into your current directory on any system (macOS, Linux or Windows).
743
+
744
+ ---
745
+
746
+ You can now update the secrets used for TOTP generation (for example `SECRET_CIPHER_DICT` in `spotify_monitor_totp_test`, `spotify_monitor` and `spotify_profile_monitor`) either manually or by referencing an external `secretDict.json` file, which can be hosted in another repo or stored locally. See the description of `SECRET_CIPHER_DICT_URL` in those files for details.
747
+
596
748
  <a id="change-log"></a>
597
749
  ## Change Log
598
750
 
599
751
  See [RELEASE_NOTES.md](https://github.com/misiektoja/spotify_monitor/blob/main/RELEASE_NOTES.md) for details.
600
752
 
753
+ <a id="maintainers"></a>
754
+ ## Maintainers
755
+
756
+ [![Maintainer: misiektoja](https://img.shields.io/badge/maintainer-misiektoja-blue)](https://github.com/misiektoja)
757
+ [![Maintainer: tomballgithub](https://img.shields.io/badge/maintainer-tomballgithub-blue)](https://github.com/tomballgithub)
758
+
601
759
  <a id="license"></a>
602
760
  ## License
603
761
 
@@ -1,6 +1,6 @@
1
1
  # spotify_monitor
2
2
 
3
- Tool for real-time monitoring of Spotify friends' music activity feed.
3
+ Tool for real-time monitoring of **Spotify friends' music activity feed**.
4
4
 
5
5
  ✨ 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
 
@@ -12,13 +12,15 @@ Tool for real-time monitoring of Spotify friends' music activity feed.
12
12
  - Real-time tracking of songs listened by Spotify users (including detection when user gets online & offline)
13
13
  - Possibility to automatically play songs listened by the tracked user in your local Spotify client
14
14
  - Information about the duration the user listened to a song and whether the song was skipped
15
+ - Detection and annotation for crossfaded songs during playback with configurable thresholds
15
16
  - Information about the context of the listened song (playlist/artist/album) with clickable URLs
16
17
  - Email notifications for various events (user becomes active/inactive, specific or all songs, songs on loop, errors)
17
18
  - Saving all listened songs with timestamps to the CSV file
18
- - Clickable Spotify, Apple Music, YouTube Music and Genius Lyrics search URLs printed in the console & included in email notifications
19
+ - Clickable Spotify, Apple Music, YouTube Music, Amazon Music, Deezer, Tidal, Genius Lyrics, AZLyrics, Tekstowo.pl, Musixmatch and Lyrics.com search URLs printed in the console and included in email notifications (configurable per service)
19
20
  - Displaying basic statistics for the user's playing session (duration, time span, number of listened and skipped songs, songs on loop)
20
21
  - Support for two different methods to get a Spotify access token (`sp_dc cookie`, `desktop client`)
21
22
  - Possibility to control the running copy of the script via signals
23
+ - Functional, procedural Python (minimal OOP)
22
24
 
23
25
  <p align="center">
24
26
  <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/spotify_monitor.png" alt="spotify_monitor_screenshot" width="90%"/>
@@ -31,6 +33,7 @@ Tool for real-time monitoring of Spotify friends' music activity feed.
31
33
  2. [Installation](#installation)
32
34
  * [Install from PyPI](#install-from-pypi)
33
35
  * [Manual Installation](#manual-installation)
36
+ * [Upgrading](#upgrading)
34
37
  3. [Quick Start](#quick-start)
35
38
  4. [Configuration](#configuration)
36
39
  * [Configuration File](#configuration-file)
@@ -51,8 +54,11 @@ Tool for real-time monitoring of Spotify friends' music activity feed.
51
54
  * [Signal Controls (macOS/Linux/Unix)](#signal-controls-macoslinuxunix)
52
55
  * [Coloring Log Output with GRC](#coloring-log-output-with-grc)
53
56
  6. [Debugging Tools](#debugging-tools)
57
+ * [Access Token Retrieval via sp_dc Cookie and TOTP](#access-token-retrieval-via-sp_dc-cookie-and-totp)
58
+ * [Secret Key Extraction from Spotify Web Player Bundles](#secret-key-extraction-from-spotify-web-player-bundles)
54
59
  7. [Change Log](#change-log)
55
- 8. [License](#license)
60
+ 8. [Maintainers](#maintainers)
61
+ 9. [License](#license)
56
62
 
57
63
  <a id="requirements"></a>
58
64
  ## Requirements
@@ -62,8 +68,8 @@ Tool for real-time monitoring of Spotify friends' music activity feed.
62
68
 
63
69
  Tested on:
64
70
 
65
- * **macOS**: Ventura, Sonoma, Sequoia
66
- * **Linux**: Raspberry Pi OS (Bullseye, Bookworm), Ubuntu 24, Rocky Linux 8.x/9.x, Kali Linux 2024/2025
71
+ * **macOS**: Ventura, Sonoma, Sequoia, Tahoe
72
+ * **Linux**: Raspberry Pi OS (Bullseye, Bookworm, Trixie), Ubuntu 24/25, Rocky Linux 8.x/9.x, Kali Linux 2024/2025
67
73
  * **Windows**: 10, 11
68
74
 
69
75
  It should work on other versions of macOS, Linux, Unix and Windows as well.
@@ -86,7 +92,7 @@ Download the *[spotify_monitor.py](https://raw.githubusercontent.com/misiektoja/
86
92
  Install dependencies via pip:
87
93
 
88
94
  ```sh
89
- pip install requests python-dateutil urllib3 pyotp python-dotenv
95
+ pip install requests python-dateutil urllib3 pyotp python-dotenv wcwidth
90
96
  ```
91
97
 
92
98
  Alternatively, from the downloaded *[requirements.txt](https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/requirements.txt)*:
@@ -95,6 +101,17 @@ Alternatively, from the downloaded *[requirements.txt](https://raw.githubusercon
95
101
  pip install -r requirements.txt
96
102
  ```
97
103
 
104
+ <a id="upgrading"></a>
105
+ ### Upgrading
106
+
107
+ To upgrade to the latest version when installed from PyPI:
108
+
109
+ ```sh
110
+ pip install spotify_monitor -U
111
+ ```
112
+
113
+ If you installed manually, download the newest *[spotify_monitor.py](https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/spotify_monitor.py)* file to replace your existing installation.
114
+
98
115
  <a id="quick-start"></a>
99
116
  ## Quick Start
100
117
 
@@ -117,6 +134,10 @@ To get the list of all supported command-line arguments / flags:
117
134
  spotify_monitor --help
118
135
  ```
119
136
 
137
+ <p align="center">
138
+ <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/spotify_monitor_skipped.png" alt="spotify_monitor_skipped" width="90%"/>
139
+ </p>
140
+
120
141
  <a id="configuration"></a>
121
142
  ## Configuration
122
143
 
@@ -134,6 +155,8 @@ spotify_monitor --generate-config > spotify_monitor.conf
134
155
 
135
156
  Edit the `spotify_monitor.conf` file and change any desired configuration options (detailed comments are provided for each).
136
157
 
158
+ **New in v2.6:** The configuration file includes options to enable/disable music service URLs (Apple Music, YouTube Music, Amazon Music, Deezer, Tidal) and lyrics service URLs (Genius, AZLyrics, Tekstowo.pl, Musixmatch, Lyrics.com) in console and email outputs. You can also configure crossfade detection thresholds and the number of recent songs to include in inactivity emails.
159
+
137
160
  <a id="spotify-access-token-source"></a>
138
161
  ### Spotify access token source
139
162
 
@@ -173,7 +196,7 @@ If your `sp_dc` cookie expires, the tool will notify you via the console and ema
173
196
 
174
197
  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).
175
198
 
176
- `Note`: encrypted byte sequences used for TOTP secret generation tend to expire every now and then; you can either check the [issues](https://github.com/misiektoja/spotify_monitor/issues) section of the project to see if there are any new secrets published or you can run the [spotify_monitor_secret_grabber.py](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber.py) and extract it by yourself (see [Debugging Tools](https://github.com/misiektoja/spotify_monitor#debugging-tools) for more info).
199
+ > **NOTE:** secrets used for TOTP generation (`SECRET_CIPHER_DICT`) expire every two days, that's why since v2.4 the tool fetches it from remote URL (see `SECRET_CIPHER_DICT_URL`); you can also run the [spotify_monitor_secret_grabber](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber.py) and extract it by yourself (see [Secret Key Extraction from Spotify Web Player Bundles](#secret-key-extraction-from-spotify-web-player-bundles) for more info).
177
200
 
178
201
  <a id="spotify-desktop-client"></a>
179
202
  #### Spotify Desktop Client
@@ -378,6 +401,8 @@ To be informed when a user gets inactive:
378
401
  spotify_monitor <spotify_user_uri_id> -i
379
402
  ```
380
403
 
404
+ Inactivity emails include recent songs from the session with skipped track status. Configure the number of recent songs to include via the `INACTIVE_EMAIL_RECENT_SONGS_COUNT` configuration option.
405
+
381
406
  To get email notifications when a monitored track/playlist/album plays:
382
407
  - set `TRACK_NOTIFICATION` to `True`
383
408
  - or use the `-t` flag
@@ -546,32 +571,165 @@ grc tail -F -n 100 spotify_monitor_<user_uri_id/file_suffix>.log
546
571
  <a id="debugging-tools"></a>
547
572
  ## Debugging Tools
548
573
 
549
- To help with troubleshooting and development, two debug utilities are available in the `debug` directory:
574
+ To help with troubleshooting and development, two debug utilities are available in the [debug](https://github.com/misiektoja/spotify_monitor/tree/dev/debug) directory.
550
575
 
551
- - [spotify_monitor_totp_test.py](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_totp_test.py): fetching of Spotify access token based on a Spotify Web Player `sp_dc` cookie value:
576
+ <a id="access-token-retrieval-via-sp_dc-cookie-and-totp"></a>
577
+ ### Access Token Retrieval via sp_dc Cookie and TOTP
578
+
579
+ The [spotify_monitor_totp_test](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_totp_test.py) tool retrieves a Spotify access token using a Web Player `sp_dc` cookie and TOTP parameters.
580
+
581
+ Download from [here](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_totp_test.py) or:
582
+
583
+ ```sh
584
+ wget https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/dev/debug/spotify_monitor_totp_test.py
585
+ ```
586
+
587
+ Install requirements:
552
588
 
553
589
  ```sh
554
590
  pip install requests python-dateutil pyotp
591
+ ```
592
+
593
+ Run:
594
+
595
+ ```sh
555
596
  python3 spotify_monitor_totp_test.py --sp-dc "your_sp_dc_cookie_value"
556
597
  ```
557
598
 
558
- - [spotify_monitor_secret_grabber.py](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber.py): automatic extractor for secret keys used for TOTP generation in Spotify Web Player JavaScript bundles:
599
+ You should get a valid Spotify access token, example output:
600
+
601
+ <p align="center">
602
+ <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/spotify_monitor_totp_test.png" alt="spotify_monitor_totp_test" width="100%"/>
603
+ </p>
604
+
605
+ > **NOTE:** secrets used for TOTP generation (`SECRET_CIPHER_DICT`) expire every two days; you can either run the [spotify_monitor_secret_grabber](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber.py) and extract it by yourself (see [here](#secret-key-extraction-from-spotify-web-player-bundles) for more info) or you can pass `--fetch-secrets` flag in `spotify_monitor_totp_test` (available since v1.6). There is also a [xyloflake/spot-secrets-go/](https://github.com/xyloflake/spot-secrets-go/) repo which offers JSON files that are automatically updated with current secrets (you can pass `--download-secrets` flag in `spotify_monitor_totp_test` to get it automatically from remote URL, available since v1.8).
606
+
607
+ <a id="secret-key-extraction-from-spotify-web-player-bundles"></a>
608
+ ### Secret Key Extraction from Spotify Web Player Bundles
609
+
610
+ The [spotify_monitor_secret_grabber](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber.py) tool automatically extracts secret keys used for TOTP generation in Spotify Web Player JavaScript bundles.
611
+
612
+ > 💡 **Quick tip:** The easiest and recommended way to run this tool is via Docker. Jump directly to the [Docker usage section below](#-secret-key-extraction-via-docker-recommended-easiest-way).
613
+
614
+ Download from [here](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber.py) or:
615
+
616
+ ```sh
617
+ wget https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/dev/debug/spotify_monitor_secret_grabber.py
618
+ ```
619
+
620
+ Install requirements:
559
621
 
560
622
  ```sh
561
623
  pip install playwright
562
624
  playwright install
625
+ ```
626
+
627
+ Run interactively (default output mode):
628
+
629
+ ```sh
563
630
  python3 spotify_monitor_secret_grabber.py
564
631
  ```
565
632
 
633
+ You should get output similar to below:
634
+
566
635
  <p align="center">
567
636
  <img src="https://raw.githubusercontent.com/misiektoja/spotify_monitor/refs/heads/main/assets/spotify_monitor_secret_grabber.png" alt="spotify_monitor_secret_grabber" width="100%"/>
568
637
  </p>
569
638
 
639
+ Show help:
640
+ ```sh
641
+ python3 spotify_monitor_secret_grabber.py -h
642
+ ```
643
+
644
+ ---
645
+
646
+ <a id="cli-output-modes"></a>
647
+ ### CLI Output Modes
648
+
649
+ The script supports several output modes for different use cases:
650
+
651
+ | Flag | Description | Output |
652
+ |------|--------------|--------|
653
+ | `--secret` | Prints plain JSON array of extracted secrets | `[{"version": X, "secret": "..."}, ...]` |
654
+ | `--secretbytes` | Prints JSON array with ASCII byte values | `[{"version": X, "secret": [..]}, ...]` |
655
+ | `--secretdict` | Prints JSON object/dict mapping version → byte list | `{"X": [..], "Y": [..]}` |
656
+ | `--all` | Extracts secrets and **writes all three outputs** to local files | `secrets.json`, `secretBytes.json`, `secretDict.json` |
657
+
658
+ Print extracted secrets in specific format, for example Python-friendly secret bytes (JSON object/dict) and save to indicated file:
659
+
660
+ ```sh
661
+ python3 spotify_monitor_secret_grabber.py --secretdict > secretDict.json
662
+ ```
663
+
664
+ Or, to generate and save all secret formats to files (`secrets.json`, `secretBytes.json`, `secretDict.json`) at once:
665
+
666
+ ```sh
667
+ python3 spotify_monitor_secret_grabber.py --all
668
+ ```
669
+
670
+ Default file paths and names can be configured directly in the `OUTPUT_FILES` dictionary at the top of the script.
671
+
672
+ ---
673
+
674
+ <a id="-secret-key-extraction-via-docker-recommended-easiest-way"></a>
675
+ ### 🐳 Secret Key Extraction via Docker (Recommended Easiest Way)
676
+
677
+ A prebuilt multi-architecture image is available on Docker Hub: [`misiektoja/spotify-secrets-grabber`](https://hub.docker.com/r/misiektoja/spotify-secrets-grabber)
678
+
679
+ This image works on:
680
+ - macOS (Intel & Apple Silicon)
681
+ - Linux (x86_64 and ARM64)
682
+ - Windows (Docker Desktop / WSL2)
683
+ - Raspberry Pi 4/5 (64-bit OS)
684
+
685
+ Run interactively (default output mode):
686
+
687
+ ```sh
688
+ docker run --rm misiektoja/spotify-secrets-grabber
689
+ ```
690
+
691
+ Show help:
692
+ ```sh
693
+ docker run --rm misiektoja/spotify-secrets-grabber -h
694
+ ```
695
+
696
+ Print extracted secrets in specific format, for example Python-friendly secret bytes (JSON object/dict) and save to indicated file:
697
+ ```sh
698
+ docker run --rm misiektoja/spotify-secrets-grabber --secretdict > secretDict.json
699
+ ```
700
+
701
+ Or, to generate and save all secret formats to files (`secrets.json`, `secretBytes.json`, `secretDict.json`) at once:
702
+
703
+ ```sh
704
+ docker run --rm -v .:/work -w /work misiektoja/spotify-secrets-grabber --all
705
+ ```
706
+
707
+ *For SELinux hosts (Fedora/RHEL), use `-v .:/work:Z`.*
708
+
709
+ <a id="optional-use-docker-compose-one-command-for-all-oss"></a>
710
+ Or optionally use Docker Compose (a preconfigured [compose.yaml](https://github.com/misiektoja/spotify_monitor/blob/dev/debug/spotify_monitor_secret_grabber_docker/compose.yaml) file is included in the repo):
711
+
712
+ ```sh
713
+ docker compose run --rm spotify-secrets-grabber --all
714
+ ```
715
+
716
+ This will save all files into your current directory on any system (macOS, Linux or Windows).
717
+
718
+ ---
719
+
720
+ You can now update the secrets used for TOTP generation (for example `SECRET_CIPHER_DICT` in `spotify_monitor_totp_test`, `spotify_monitor` and `spotify_profile_monitor`) either manually or by referencing an external `secretDict.json` file, which can be hosted in another repo or stored locally. See the description of `SECRET_CIPHER_DICT_URL` in those files for details.
721
+
570
722
  <a id="change-log"></a>
571
723
  ## Change Log
572
724
 
573
725
  See [RELEASE_NOTES.md](https://github.com/misiektoja/spotify_monitor/blob/main/RELEASE_NOTES.md) for details.
574
726
 
727
+ <a id="maintainers"></a>
728
+ ## Maintainers
729
+
730
+ [![Maintainer: misiektoja](https://img.shields.io/badge/maintainer-misiektoja-blue)](https://github.com/misiektoja)
731
+ [![Maintainer: tomballgithub](https://img.shields.io/badge/maintainer-tomballgithub-blue)](https://github.com/tomballgithub)
732
+
575
733
  <a id="license"></a>
576
734
  ## License
577
735
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "spotify_monitor"
7
- version = "2.3.1"
7
+ version = "2.6"
8
8
  description = "Tool implementing real-time tracking of Spotify friends music activity"
9
9
  readme = "README.md"
10
10
  license = "GPL-3.0-or-later"