Skip to content

Instantly share code, notes, and snippets.

@specious
Created November 22, 2015 03:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save specious/77a22811bb1bef93b289 to your computer and use it in GitHub Desktop.
Save specious/77a22811bb1bef93b289 to your computer and use it in GitHub Desktop.
Shortens a YouTube URL
#!/usr/bin/env node
if( process.argv.length > 2 ) {
var video_id = /(youtu\.be\/|youtube\.com\/(watch\?(.*&)?v=|(embed|v)\/))([^\?&"'>]+)/.exec( process.argv[2] )[5]
console.log( "http://youtu.be/" + video_id )
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment