Skip to content

Instantly share code, notes, and snippets.

@nqthqn
Created March 28, 2020 05:49
Show Gist options
  • Save nqthqn/1cf0fb6393c578b34c85ec42654c7165 to your computer and use it in GitHub Desktop.
Save nqthqn/1cf0fb6393c578b34c85ec42654c7165 to your computer and use it in GitHub Desktop.
Spotify to YouTube Music
// Open dev tools on a spotify playlist and run this script
// You will get a list of links that will take you to searches for the songs
let tracks = [...document.querySelectorAll(".track-name-wrapper")]
.map(t => ({
name: t.querySelector(".tracklist-name").innerText,
artist: t.querySelector(".TrackListRow__artists").innerText,
album: t.querySelector(".TrackListRow__album").innerText
}))
.map(({ name, artist, album }) => {
const q = encodeURIComponent(`${name} ${artist} ${album}`);
return `https://music.youtube.com/search?q=${q} (${name})`;
})
.join("\n");
console.log(tracks);
@nqthqn
Copy link
Author

nqthqn commented Mar 28, 2020

As a CSV for copying into google sheets

let tracks = [...document.querySelectorAll(".track-name-wrapper")]
  .map(t => ({
    name: t.querySelector(".tracklist-name")?.innerText || "",
    artist: t.querySelector(".TrackListRow__artists")?.innerText || t.querySelector(".tracklist-row__artist-name-link")?.innerText || "",
    album: t.querySelector(".TrackListRow__album")?.innerText || ""
  })).map(({ name, artist, album }) => {
    const q = encodeURIComponent(`${name} ${artist} ${album}`);
    const youtube = `https://www.youtube.com/results?search_query=${q}`;
    return `${name}\t${artist}\t${album}\t${youtube}`
}).join('\n');

console.log(`name\tartist\talbum\tyoutube\n`+tracks);

What if we had a bookmarklet "copy from spotify playlist" and "paste to youtube music playlist"?

@nqthqn
Copy link
Author

nqthqn commented Mar 28, 2020

from a bookmarklet you can do this, the document must be in focus

navigator.clipboard.writeText(`name\tartist\talbum\tyoutube\n`+tracksAsCsv)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment