Created
March 29, 2020 13:18
-
-
Save evsasse/4e3019b0bdc6377f40b731cbffa81644 to your computer and use it in GitHub Desktop.
Load youtube playlist into csv
This file contains 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
var jq = document.createElement('script'); | |
jq.src = "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
// WAIT! | |
// WAIT! | |
// WAIT! | |
jQuery.noConflict(); | |
$ = jQuery; | |
var videos = []; | |
// SCROLL TILL THE END, MAKE SURE ALL TIMES LOADED | |
// SCROLL TILL THE END, MAKE SURE ALL TIMES LOADED | |
// SCROLL TILL THE END, MAKE SURE ALL TIMES LOADED | |
$('ytd-playlist-video-renderer').map(function () { | |
try { | |
$this = $(this); | |
$time = $this.find('.ytd-thumbnail-overlay-time-status-renderer'); | |
time = $time.text().replace(/[\x00-\x1F\x7F-\x9F\ ]/g, ""); | |
$title = $this.find('#video-title'); | |
title = $title.text().replace(/[\x00-\x1F\x7F-\x9F]/g, "").trim(); | |
$channel = $this.find('.ytd-channel-name'); | |
channel = $channel.first().text().replace(/[\x00-\x1F\x7F-\x9F]/g, "").trim(); | |
$thumbWrapper = $this.find('#thumbnail'); | |
link = $thumbWrapper[1].href; | |
$img = $thumbWrapper.find('img.yt-img-shadow'); | |
img = $img.prop('src'); | |
videos.push([time, title, channel, link, img]) | |
return 1; | |
} catch (e) { | |
console.error(e); | |
return 0; | |
} | |
}); | |
var csv = videos.map(function(d){ | |
return JSON.stringify(d); | |
}).join('\n').replace(/(^\[)|(\]$)/mg, ''); | |
$textarea = $('<textarea></textarea>'); | |
$('#owner-container').after($textarea); | |
$textarea.val(csv); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment