PHP – Convert youtu.be URLs to youtube.com

Youtube has introduced a new URL shorthand – youtu.be

For example youtu.be/DIArJjU8HjE takes you to

youtube.com/watch?v=DIArJjU8HjE&feature=youtu.be

Annoyingly this means that any users pasting a youtu.be URL into your video parsing scripts will be told it doesn’t work, so we’d best get updating those scripts!

Pop this in before you start processing the url, where $url is, not surprisingly, the url to be parsed.

[update 20110720-1657]While implementing this and similar for grabbing youtube thumbnails today I suddenly though, what if youtube ever starts using https? Well, the odds may be slim, but the costs of allowing for it are negligible, so why take the risk?

[/update]

That particular link is the fantastic new video from my friends Six Toes – currently featured on the front of the Depeche Mode website.

6 thoughts on “PHP – Convert youtu.be URLs to youtube.com”

  1. Dunno if it’s useful for you but you can also say -mtime +1 day which searches for anything with a modification time of 1 day or more. Check the man page though because it is a little weird iirc, 1 day in your mind I think means 2 in finds opinion! Still useful though.

  2. Hey Robin. Posterous seems to be posting comments to the wrong topics – am looking into this!On that topic, yeah, finding within a fixed period is nice and simple. I had need to check for an absolute time, for which I found the syntax poorly explained, so thought it was worth noting for future reference…

Leave a Reply

Your e-mail address will not be published. Required fields are marked *