Skip to content

DiamondEyesFox/discover-weekly

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Discover Weekly

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.

How It Works

┌─────────────┐     ┌─────────────┐     ┌─────────────┐     ┌─────────────┐
│   Last.fm   │────▶│  Find New   │────▶│  Soulseek   │────▶│    Plex     │
│  Listening  │     │   Artists   │     │  Download   │     │  Library    │
│   History   │     │             │     │             │     │             │
└─────────────┘     └─────────────┘     └─────────────┘     └─────────────┘
  1. Analyze: Fetches your top artists from Last.fm (configurable period)
  2. Discover: Finds similar artists via Last.fm's recommendation API
  3. Filter: Removes artists already in your Plex/local library
  4. Rank: Weights recommendations by similarity score and how much you listen to related artists
  5. Download: Grabs top albums from new artists via Soulseek (FLAC by default)

Requirements

Installation

# 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.json

Configuration

Edit ~/.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"
}

Config Options

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

Getting Your Plex Token

# 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

Usage

# 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

Example Output

$ 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

Automation

Run weekly via cron or systemd timer:

Cron

# Run every Sunday at 6am
0 6 * * 0 /path/to/discover_weekly.py generate >> ~/.local/share/discover-weekly/cron.log 2>&1

Systemd Timer

# ~/.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 generate
systemctl --user enable --now discover-weekly.timer

How the Algorithm Works

  1. Fetch top artists from Last.fm for the configured period (default: 3 months)
  2. For each top artist, query Last.fm's artist.getSimilar API
  3. Filter out artists already in your Plex library or local music folder
  4. 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
  5. Aggregate scores across all your top artists (same artist can be recommended by multiple sources)
  6. Select top N unique artists with highest total scores
  7. Fetch top album for each selected artist
  8. Download via Soulseek, preferring FLAC

Tips

  • Fresh recommendations: Use period: "3month" to base recommendations on recent listening
  • Deep cuts: Increase target_albums to 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

Troubleshooting

"No results found" for searches

  • 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

Can't connect to Plex

  • Verify plex_token is correct
  • Check plex_music_section (find via: Plex Web → Library → URL shows section ID)
  • Leave plex_token empty to skip Plex filtering

Recommendations seem wrong

  • Make sure you're scrobbling to Last.fm regularly
  • Try a longer period like 6month for more data
  • Check your Last.fm profile to verify listening history

License

MIT

Credits

  • Last.fm API for music recommendations
  • slskd for Soulseek integration
  • Inspired by Spotify's Discover Weekly feature

About

Self-hosted Discover Weekly: Music recommendations using Last.fm + Soulseek + Plex

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages