Skip to content

Instantly share code, notes, and snippets.

@evdokimovm
Last active January 19, 2025 02:22
Show Gist options
  • Save evdokimovm/cd46cf17b00c044efb3a0c2c1e5d93a7 to your computer and use it in GitHub Desktop.
Save evdokimovm/cd46cf17b00c044efb3a0c2c1e5d93a7 to your computer and use it in GitHub Desktop.
Save the whole list of your saved youtube playlists to text file. Open youtube.com/feed/library or youtube.com/feed/you press "show more" in playlists section. scroll page down to load all playlists list and run the following script in console

Export all your saved YouTube playlists

Since Google Takeout for YouTube doesn't export playlists you've saved, but only those you've created, I've written this script that will automatically export the list of saved playlists to a text file

How to use that:

  1. Open youtube.com/feed/library or youtube.com/feed/you
  2. At the bottom of the "Playlists" section, click the "Show more" button
  3. Scroll down the page to the bottom to ensure that all playlists are loaded and displayed
  4. Open JS console
  5. Paste and run the script

Also, you can export the contents of a specific playlist to a text file. To do this:

  1. Replace the first line of the script with the following:
var all_contents = document.querySelectorAll('div#contents > ytd-playlist-video-renderer > div#content > div#container > div#meta > h3 > a')
  1. Open playlist you want to export. Your likes for example: https://www.youtube.com/playlist?list=LL
  2. Scroll down the page to the bottom to ensure that all contents are loaded and displayed
  3. Open JS console
  4. Run the changed script
var all_contents = document.querySelectorAll('div#contents > ytd-item-section-renderer:nth-of-type(3) > div#contents > ytd-shelf-renderer > div#dismissible > div#contents > ytd-grid-renderer > div#items > ytd-grid-playlist-renderer > div#details > yt-formatted-string > a')
async function getFullTitle(item) {
var double_parent_node = item.parentNode.parentNode
var channel_name_container = double_parent_node.querySelector('ytd-video-meta-block > div#metadata > div#byline-container > ytd-channel-name > div#container > div#text-container > yt-formatted-string')
var playlist_title = double_parent_node.querySelector('h3 > a')
var _a = channel_name_container.querySelector('a')
if (_a) {
return playlist_title.title + ' | -> ' + _a.text + ' | -> ' + _a.href + '\n'
} else {
return playlist_title.title + ' | -> ' + channel_name_container.title + '\n'
}
}
async function getHREF(item) {
return item.href + '\n'
}
async function putThingsTogether() {
var list = ''
for (var i = 0; i < all_contents.length; i++) {
list += await getFullTitle(all_contents[i])
list += await getHREF(all_contents[i])
list += '\n'
}
return list
}
var _list = await putThingsTogether()
function download(filename, text) {
var blob = new Blob([text], { type: 'text/plain' })
var url = URL.createObjectURL(blob)
var link = document.createElement('a')
link.href = url
link.download = filename
link.click()
URL.revokeObjectURL(url)
}
download('my_youtube_saved_playlists.txt', _list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment