How to Index, Scape, Build a Spreadsheet, and Download an Entire YouTube Channel in 2022
Step 1: Get the List of YouTube Video Links from the Channel
Extract All YouTube Links from a Web Page: Go to the Chrome Developer Console (F12), click in Console and paste in:
var urls = document.getElementsByTagName('a');
for (url in urls) {
console.log ( urls[url].href );
}
Select All (Ctrl-A), Copy, and Paste (Ctrl-V) into a text editor to sort out the list. I've used EditPlus for over 20 years because it allows me to use regular expressions when doing a search-and-replace... use the ^ (hat character or shift-6) to place text at the beginning of every line and $ (dollar sign or shift-4) to place text at the end of each line.
Step 2: Get the "Metadata" (Title, Number of Views, etc.) for Each Video Link
Start with just ONE YouTube video before building a "batch file." I use YT-DLP (a command-line tool).
yt-dlp -o "%%(id)s %%(upload_date)s %%(title)s %%(view_count)s %%(duration)s" --get-filename https://www.youtube.com/watch?v=Rl1wkoG-os0 >> list.txt
This will dump the video ID, upload date, title, view count, duration (in seconds) into a new line in the file "list.txt."
Here's a really important nuance: if you were to run this command (perhaps as a test) in the command line, you would only have one percent % sign. But when you enter this into a batch (.bat) file, you must enter two percent signs %%.
I use a "search-and-replace" regular expression in EditPlus to add the special command to the left and right of each YouTube video, then save the file as "batch1.bat" (with the quotes), and then I can let it run and fill up the text file containing the list.
Because I separated the "columns" with a "tab" character, it pastes right into any Excel or Google Sheets spreadsheet.
Step 3: Download Every YouTube Video in the Channel
You could almost figure this out on your own, without me having to tell you. Build a batch file with the list of YouTube videos, a search-and-replace regular expression in EditPlus:
yt-dlp -S res,ext:mp4:m4a --recode mp4 --output "%%(id)s %%(title)s.%%(ext)s" https://www.youtube.com/watch?v=Rl1wkoG-os0
Filed in: Archive 4: 2020-2023 • Uncategorized