main
Kyle Bergstedt Publish 0.3.0 6ecd974

name: spotify-ytmusic-bridge description: "Drive Spotify and YouTube Music on the user's Mac through the Spotify + YouTube Music bridge (music_* verbs on Adom Bridge): list Spotify playlists and their songs from the signed-in Spotify desktop app (read-only), search YouTube Music and list its playlists in the user's real signed-in Chrome, and copy Spotify playlists into new YouTube Music playlists with song matching. Nothing is ever deleted. Trigger words: spotify, youtube music, yt music, my spotify playlists, what's in my playlist, search youtube music, import spotify playlists to youtube music, move my playlists to youtube music, switch from spotify, music_transfer, music_spotify_playlists, music_ytmusic_search." user-invocable: true

Spotify + YouTube Music bridge

This bridge runs on the user's Mac under Adom Bridge. Drive it from the container with adom-bridge music_<verb> '<json>'.

It works through the apps the user is already signed in to, so there are no API keys or developer accounts:

  • Spotify: the Spotify desktop app, read-only. The bridge reads the app's own session through its local debugging port.
  • YouTube Music: the user's real Chrome profile that has YouTube Music, through the Adom Native Browser Extension (nbrowser_*). Cookies never leave Chrome.

⛔ Never delete anything

The bridge has no delete code; don't work around that with other tools. Spotify is read-only. On YouTube Music the bridge only creates new playlists and adds songs to playlists it created. Never delete, rename, reorder or remove songs from the user's playlists on either service. If something the bridge made needs to go, tell the user and let them remove it.

Cold start: read this before you panic

Response Meaning What you do
errorCode: spotify_restart_needed Spotify is open without its local debugging port Ask the user, then music_spotify_connect {"restart":true}. Spotify quits and reopens, and playback stops for a few seconds
errorCode: spotify_not_installed No Spotify desktop app Offer to install it (brew install --cask spotify); the user signs in
errorCode: nb_missing_in_profile The Adom browser extension isn't loaded in the Chrome profile that has YouTube Music Load it there: chrome://extensions → Developer mode → Load unpacked → the nb extension folder
errorCode: ytmusic_signed_out YouTube Music is signed out in that profile The user signs in
errorCode: ytmusic_profile_unknown The bridge couldn't tell which Chrome profile has YouTube Music Pass ytProfile:"chrome:<email>" (nbrowser_profiles lists them)

Always start with music_readiness. It's read-only, and its nextSteps say exactly what's missing.

Verbs

Verb What it does Key args
music_readiness Read-only check of Spotify, the YouTube Music Chrome profile and the extension ytProfile?
music_spotify_connect Connect to the signed-in Spotify app restart? (ask first)
music_spotify_playlists The Spotify library: name, track count, folder, kind (mine, collaborative, followed, spotify-made) refresh?
music_spotify_tracks The songs in a Spotify playlist or album (title, artists, album, length, ISRC). Takes a saved playlist's name, or any Spotify link, saved or not playlist (name, id, or open.spotify.com/playlist/… / /album/… link), limit?
music_ytmusic_playlists The YouTube Music library playlists ytProfile?
music_ytmusic_search Search YouTube Music songs (or videos) query or queries[], videos?
music_transfer Background job that copies Spotify playlists into new YouTube Music playlists see below
music_status / music_report / music_cancel Follow, review and stop the job jobId?, full?
music_describe The full catalog

Copying playlists from Spotify to YouTube Music

  1. music_readiness, then music_spotify_connect.
  2. music_spotify_playlists: show the user the summary and ask which set to copy. The default is the user's own and collaborative playlists. includeFollowed and includeSpotifyMade add the other kinds, and playlists:[...] picks specific ones. Entries can be saved-playlist names or ids, or any Spotify playlist or album link: the user doesn't have to save it first. Public playlists, ones shared with the user, and albums all work.
  3. For a big library, run music_transfer {"dryRun":true} and then music_report first. That shows the match quality and writes nothing.
  4. music_transfer {...} returns a jobId. It runs at about 30 songs per 15 s. New playlists are private unless privacy says otherwise.
  5. Poll music_status every ~20 s, and tell the user which playlist it's on.
  6. music_report: give the user each new playlist's link, the unsure songs (added, worth a listen) and the missing ones (not added; they can add them by hand).

Matching uses title, artists and length. It prefers the official song over lyric videos, covers, remixes and live versions, and it won't treat "Song 2" or "Song (Instrumental)" as the same track as "Song".

Things to know

  • Resumable. Rerunning music_transfer skips finished playlists and continues a half-done one. The state lives in ~/.adom/spotify-ytmusic/ on the Mac.
  • Background, one window. The bridge keeps a single minimized YouTube Music window in the user's Chrome, reuses it, and closes it after 2 minutes idle (or when a transfer ends). Don't raise it, and don't open your own.
  • Links. A link someone pastes (https://open.spotify.com/playlist/…?si=…) can go straight into music_spotify_tracks or music_transfer. spotify:album:… URIs and bare ids work too.
  • Testing. Use testPrefix:"[test] " and trackLimit, so test playlists are obvious and the user can delete them.
  • Not songs. Podcast episodes are skipped. Local files are searched by their tags. Liked Songs isn't supported yet.
  • ok:true isn't the finish line. Check that music_status.state is "done", and read the report, before telling the user it worked.
  • Relay any _hint that asks the user to do something, unchanged.