Self-hosted music recommendations using Last.fm + Soulseek + Plex
A self-hosted alternative to Spotify's Discover Weekly. Analyzes your Last.fm listening history to find similar artists you don't already own, then downloads their top albums via Soulseek.
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
│ Last.fm │────▶│ Find New │────▶│ Soulseek │────▶│ Plex │
│ Listening │ │ Artists │ │ Download │ │ Library │
│ History │ │ │ │ │ │ │
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
- Analyze: Fetches your top artists from Last.fm (configurable period)
- Discover: Finds similar artists via Last.fm's recommendation API
- Filter: Removes artists already in your Plex/local library
- Rank: Weights recommendations by similarity score and how much you listen to related artists
- Download: Grabs top albums from new artists via Soulseek (FLAC by default)
- Last.fm account with scrobbling history
- Last.fm API key (free): https://www.last.fm/api/account/create
- slskd (Soulseek daemon): https://github.com/slskd/slskd
- Plex Media Server (optional, for library filtering)
# Clone the repo
git clone https://github.com/yourusername/discover-weekly.git
cd discover-weekly
# Install dependencies
pip install slskd-api
# Create config file
python discover_weekly.py init
# Edit config with your credentials
nano ~/.config/discover-weekly/config.jsonEdit ~/.config/discover-weekly/config.json:
{
"lastfm_api_key": "your_api_key_here",
"lastfm_user": "your_username",
"slskd_host": "http://localhost:5030",
"slskd_user": "slskd",
"slskd_pass": "slskd",
"plex_url": "http://localhost:32400",
"plex_token": "",
"plex_music_section": 1,
"music_path": "~/Music",
"target_albums": 30,
"format": "flac",
"period": "3month",
"data_dir": "~/.local/share/discover-weekly"
}| Option | Description | Default |
|---|---|---|
lastfm_api_key |
Your Last.fm API key (required) | - |
lastfm_user |
Your Last.fm username (required) | - |
slskd_host |
slskd API URL | http://localhost:5030 |
slskd_user |
slskd username | slskd |
slskd_pass |
slskd password | slskd |
plex_url |
Plex server URL (optional) | http://localhost:32400 |
plex_token |
Plex auth token (optional) | - |
plex_music_section |
Plex library section ID | 1 |
music_path |
Local music directory to check | ~/Music |
target_albums |
Number of albums to recommend | 30 |
format |
Audio format: flac, mp3, any |
flac |
period |
Last.fm period: 7day, 1month, 3month, 6month, 12month, overall |
3month |
data_dir |
Where to store history/playlists | ~/.local/share/discover-weekly |
# Option 1: From Plex Web
# Open Plex Web → F12 → Console → type: localStorage.myPlexAccessToken
# Option 2: From config file
grep -oP 'PlexOnlineToken="\K[^"]+' ~/.config/Plex\ Media\ Server/Preferences.xml# Preview what would be recommended (no downloads)
python discover_weekly.py preview
# Generate recommendations and download
python discover_weekly.py generate
# Check download progress
python discover_weekly.py status
# View past recommendations
python discover_weekly.py history$ python discover_weekly.py preview
Discover Weekly Generator
==================================================
Analyzing your listening history (3month)...
Found 50 top artists
Scanning existing library...
Found 847 artists in library
Finding similar artists you don't have...
[1/20] Deftones
[2/20] A Perfect Circle
[3/20] Tool
...
Selecting recommendations...
+ Chevelle - Wonder What's Next (score: 4.82)
+ Breaking Benjamin - Phobia (score: 4.15)
+ Sevendust - Animosity (score: 3.91)
+ Mudvayne - L.D. 50 (score: 3.67)
...
==================================================
PREVIEW - Would download these albums:
==================================================
1. Chevelle - Wonder What's Next
2. Breaking Benjamin - Phobia
3. Sevendust - Animosity
...
Total: 30 albums
Run 'discover-weekly generate' to download
Run weekly via cron or systemd timer:
# Run every Sunday at 6am
0 6 * * 0 /path/to/discover_weekly.py generate >> ~/.local/share/discover-weekly/cron.log 2>&1# ~/.config/systemd/user/discover-weekly.timer
[Unit]
Description=Run Discover Weekly every Sunday
[Timer]
OnCalendar=Sun *-*-* 06:00:00
Persistent=true
[Install]
WantedBy=timers.target# ~/.config/systemd/user/discover-weekly.service
[Unit]
Description=Discover Weekly Generator
[Service]
Type=oneshot
ExecStart=/path/to/discover_weekly.py generatesystemctl --user enable --now discover-weekly.timer- Fetch top artists from Last.fm for the configured period (default: 3 months)
- For each top artist, query Last.fm's
artist.getSimilarAPI - Filter out artists already in your Plex library or local music folder
- Weight candidates by:
- Similarity score (0.0-1.0 from Last.fm)
- How highly ranked the parent artist is in your listening
- Formula:
score = similarity × (20 - rank) / 20
- Aggregate scores across all your top artists (same artist can be recommended by multiple sources)
- Select top N unique artists with highest total scores
- Fetch top album for each selected artist
- Download via Soulseek, preferring FLAC
- Fresh recommendations: Use
period: "3month"to base recommendations on recent listening - Deep cuts: Increase
target_albumsto 50+ for more obscure recommendations - Quality: Keep
format: "flac"for best quality (Soulseek has lots of FLAC) - Plex integration: Set up a "Discover Weekly" playlist in Plex for new downloads
- Check that slskd is running and has connected peers
- Try broader searches by setting
format: "any" - Some obscure artists may not be available on Soulseek
- Verify
plex_tokenis correct - Check
plex_music_section(find via: Plex Web → Library → URL shows section ID) - Leave
plex_tokenempty to skip Plex filtering
- Make sure you're scrobbling to Last.fm regularly
- Try a longer
periodlike6monthfor more data - Check your Last.fm profile to verify listening history
MIT
- Last.fm API for music recommendations
- slskd for Soulseek integration
- Inspired by Spotify's Discover Weekly feature