YT annotation downloader

Program to download YouTube annotations, before YouTube deletes them on Jan 15 2019. Made primarily for my own use (so not very polished); provided as is with no guarantees about anything.

The file format seems fairly self-explanatory; I may in the future try to make a program to convert annotations to subtitles or somehow otherwise have a way to view them. Watch this space. (Might be a few weeks, if at all.)

Annotations URLs are of the form if you want to download them manually or write your own downloader.

1. Generate a file listing the videos

Easiest way is to go to the channel's page, go to the Videos tab, scroll until all relevant videos are loaded (I prefer to sort oldest first, but that depends on which videos you care about), then open the browser console for that window and copy the following:

+function() {var v = document.querySelectorAll('ytd-item-section-renderer a.ytd-video-renderer'); var r = ''; for(var i = 0; i < v.length; i++) {var h = v[i].href.match(/[?&]v=([^&]+)/)[1]; r += h+' '+i+'-'+h+'.xml #'+v[i].innerHTML.replace(/\n/,'').trim()+"\n";} console.log(r);}()

Copy the output to a text file.

If you want to create or edit it manually, the format is

video ID (space) filename

Lines that start with # are ignored; space followed by # causes the rest of the line to be ignored. Filename can't contain / (this was a safeguard to prevent me from accidentally overwriting the wrong file).

2. Download the annotations

Download downloader (View source)

In a terminal window, change to the directory you want to put the output and type

perl list.txt
where is the path to the file linked above, and list.txt is the file you created in step 1.

Only so far been tested on Mac OS X.

The program will wait 10 seconds between requests because I'm worried about YouTube trying to block bots. (I haven't been blocked yet; I make no guarantees.)

The number shown is the line number of the text file.

You can stop it at any time by pressing ctrl-C (ideally when the check mark is visible). If you start it again in the same directory, it'll start where it left off (it skips anything it's already downloaded). The program stops if it encounters any error, including deleted videos. If a video isn't available, you'll have to manually remove it from the text file (or add # to the beginning of the line).