Local Music Integration¶
SecondBrain includes a local-first music preference subsystem currently backing Spotify. It operates exclusively in the local runtime database and does not sync your Spotify OAuth tokens to the plaintext Obsidian vault.
Capabilities¶
The local music integration pulls down: - Your top 50 recent artists (short, medium, and long term) - Your top 50 recent tracks (short, medium, and long term) - Your 50 most recently played listening events - Your currently playing track - Your saved podcast shows (up to 50) - Your saved podcast episodes (up to 50) - A derived profile snapshot capturing your vibe, top genres, and podcast subscriptions.
This data is used contextually across SecondBrain:
- Automatically appended to the shared v2 ContextPack as concise preference lines (which provides passive awareness of your mood/listening style to chat, kernel, Data Agent, and UI context-pack consumers).
- Explicit music_recommend tool used by conversational agents so they can recommend tracks deterministically grounded in your history.
- Optional people-graph linking through sb music sync --person-id <id> or sb music link-person <id>.
Configuration & OAuth¶
1. Set Up Spotify App¶
You need a Spotify Developer app.
- Go to the Spotify Developer Dashboard.
- Create a new App.
- When asked "Which API/SDKs are you planning to use?", select Web API.
- Edit the settings and add a Redirect URI of http://127.0.0.1:8080/callback.
- Note down your Client ID and Client Secret.
2. Connect the Provider Locally¶
Run the connective flow from the sb CLI:
You will be interactively prompted for your Client ID and Client Secret.
The CLI will generate an authorization URL for you to visit. Open the link, log in, and then paste the redirect URL's code parameter back into the CLI.
Privacy Notice: Success means your tokens are now stored inside the encrypted/sandboxed SQLite
runtime.dbresiding in your configuredstate_dir. The tokens will seamlessly refresh silently. They are intentionally kept out of your.mdVault.
Managing the Integration¶
You can manage the integration and trigger data ingestion entirely via the command pipeline.
sb music sync runs the pull loop against Spotify right now. You can run this whenever you want updated context.
sb music status reveals how many objects your local runtime DB is managing, including event history tracking.
sb music recommend <mood> runs the internal recommendation heuristic against your derived profile based on matching recent history clusters.
sb music podcasts shows your saved podcast shows and recent episodes.
sb music debug-profile outputs the raw JSON MusicProfileSnapshot that the orchestration pipeline injects into LLM capabilities.
sb music purge spotify erases all synced local music tables without dropping the tables entirely. Use this if you want to reset.
Note: If you had previously connected Spotify before the podcast feature was added, you will need to re-authorize (
sb music connect spotify) so the newuser-library-readscope is granted.