Created
September 16, 2015 22:14
-
-
Save jffry/d4a52c3997e4e3061683 to your computer and use it in GitHub Desktop.
Revisions
-
jffry created this gist
Sep 16, 2015 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,45 @@ ng-conf [tweeted](https://twitter.com/ngconf/status/643915619415388160) that they had some easter eggs. YouTube annotations seemed like a good place to hide one, so I scraped the annotations from their videos. First, can we programmatically get annotations? Yes! Googling around reveals URLs like `https://www.youtube.com/annotations_invideo?features=1&legacy=1&video_id=QHulaj5ZxbI` Second, how to get a list of all their video IDs? Quick and dirty! I opened their channel's video list at https://www.youtube.com/user/ngconfvideos/videos and used my browser console to scrape out the video IDs: ```js //open browser devtools on https://www.youtube.com/user/ngconfvideos/videos var ids = Array.prototype.slice.call(document.querySelectorAll('a[href]')) .map(function(a){ var m = /watch\?v=([^&]+)/i.exec(a.href); if (m) return m[1]}) .filter(function(id){ return id; }); console.log(ids.join('\n')); /* => Re7jY4pRY_Y Re7jY4pRY_Y yh4ExTTrScQ yh4ExTTrScQ z0-dkOavwsg z0-dkOavwsg XQM0K6YG18s XQM0K6YG18s jzkQXlvpvHU jzkQXlvpvHU ... */ ``` Third, to search. We'll use `curl` to download all these annotations, and `grep` to look at the output. Paste the output from the dev console into a text editor, sort unique, and then bodge into something like this and run it in your shell: ```sh curl \ "https://www.youtube.com/annotations_invideo?features=1&legacy=1&video_id=Re7jY4pRY_Y" \ "https://www.youtube.com/annotations_invideo?features=1&legacy=1&video_id=yh4ExTTrScQ" \ "https://www.youtube.com/annotations_invideo?features=1&legacy=1&video_id=z0-dkOavwsg" \ "https://www.youtube.com/annotations_invideo?features=1&legacy=1&video_id=XQM0K6YG18s" \ "https://www.youtube.com/annotations_invideo?features=1&legacy=1&video_id=jzkQXlvpvHU" \ | grep ti.to ``` ...and out pops the registration link!