Created
November 20, 2020 13:42
-
-
Save silver-mixer/43009c048a5e7e60f2182198ad0a105b to your computer and use it in GitHub Desktop.
Export YouTube playlist in JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(() => { | |
const VERSION = "v1"; | |
let id = location.href.match(/\?list=([a-zA-Z0-9-_]+)($|&)/)[1]; | |
let title = document.getElementById('text-displayed').innerText; | |
let created_at = Date.now(); | |
let videos = []; | |
document.querySelectorAll('ytd-playlist-video-renderer').forEach(e => { | |
videos.push({ | |
title: e.querySelector('#video-title').innerText, | |
id: e.querySelector('a').href.match(/\?v=([a-zA-Z0-9-_]+)($|&)/)[1], | |
channel: e.querySelector('#channel-name').innerText | |
}); | |
}); | |
let data = { | |
version: VERSION, | |
title: title, | |
id: id, | |
created_at: created_at, | |
videos: videos | |
}; | |
let a = document.createElement('a'); | |
a.href = URL.createObjectURL(new Blob([JSON.stringify(data)], {type: 'text/plain'})); | |
a.download = 'playlist_' + id + '.json'; | |
a.click(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment