YouTube Freedom Version 3

by Stephen Fluin 2010.10.11

HTML5 Beta YouTube Video Download

The battle for YouTube continues. I love to download videos from YouTube. If you are using the HTML5 beta, I had previously written a bookmarklet that unblocks the videos and lets you download them directly with HTML5. It appears that either a recent update to Chrome or to YouTube has rendered the existing bookmarklet ineffective. Some javascript investigation has revealed that the event listener for oncontextmenu is now anonymous (or at least I don't have it in scope), and setting it to false no longer clears the listener (as it shouldn't according to DOM). This means that in order to continue using the YouTube Unlocker Bookmarklet, I had to update it to clone the node, and replace the old one. Cloning a node in DOM does not copy event listeners, and this is the only way to clear them.

javascript:(function(){ vb=document.getElementsByClassName('video-blocker')[0]; if(vb) vb.style['display'] = 'none'; o = document.getElementsByClassName('video-content')[0]; o.oncontextmenu = false; p = o.parentElement; n = o.cloneNode(true); p.replaceChild(n,o); })();

Or just drag the YouTube Unlocker Bookmarklet onto your bookmarks bar and you should be good to go. This has only been tested in chrome.

Flash YouTube Video Download

If you still use the old Flash way of viewing videos, they have also improved their algorithm so that videos are deleted as soon as they are opened in /tmp/. This means that you can no longer trivially copy them out. Fortunatly the file still exists on linux systems, and it's not impossible to copy them out of the tmp folder. Check out the following command line (which I pasted into a button on my panel) that opens the video in VLC. Similar could be used to copy the file to your home folder, or whatever you wanted to do with it.

lsof -p `pgrep -f flashplayer` | grep '/tmp/Flash[^ ]*' | awk '{ print "/proc/" $2 "/fd/" $4 }' | sed 's/[rwu]$//' | xargs vlc

On a technical level, this command looks up the flashplayer executable and finds open file handles (including deleted files) to Flash files in your tmp folder. The string is then rewritten into something that can be passed into VLC. If you run this script (or hit the button on your panel with this script in it), VLC will open with any currently open videos, making watching the video easy and nice again.


permalink