OxyTube.com - Blog

YouTube download ability added!

Posted in OxyTube by oxytube on March 8th, 2008

I’ve added the ability to download YouTube videos from OxyTube directly. Just click on the download input button on the far right of a video result and wait for a second or two.

Just in case you’re wondering how it’s done:

<?php
$engineName = $_POST['engine'];
$id = $_POST['id'];


switch ($engineName) {
case “youtube”:
$txt = file_get_contents(”http://youtube.com/watch?v=” . $id);
$t = substr($txt, strpos($txt, ‘”t”:’) + 6, 32);
$url = “http://www.youtube.com/get_video?video_id=” . $id . “&t=” . $t;
break;
case “myspace”:
// myspace: short urls?, long id case is specific case of general bitwise operations?
$lastFour = strrev(substr($id, strlen($id) - 4));
$firstChars = substr($id, 0, strlen($id) - 5);
while (strlen($firstChars) < 7) $firstChars = “0″ . $firstChars;
$url = “http://content.movies.myspace.com/” . $firstChars . “/” . substr($lastFour, 0, 2) . “/” . substr($lastFour, 2) . “/” . $id . “.flv”;
break;
}

echo $url;
?>

The code should be pretty self explanatory.

For YouTube, within a video’s page source, there lies an SWF argument ambiguously named “t”. Find the value of the 32 characters string “t” and the download URL is merely:
http://www.youtube.com/get_video?video_id=<id>&t=<t>

where <id> refers to a video’s id and <t> refers to the SWF arg “t”. The above could also be accomplished with regular expressions, however I think substr and strpos are easier to understand.

I’ve also figured out how to generate MySpace download URL’s for videos with ID’s of length 10. Unfortunately some older videos have ID’s of less than 10 characters. In the near future I’ll add the ability to download from other sites such as Vimeo and MySpace.

alpha released

Posted in OxyTube by oxytube on March 7th, 2008

Clicking the image below will result in a 30% chance of happiness.

oxytube1.png

To my knowledge, only some minor CSS/HTML issues still exist, so do enjoy!

Features to come:
Veoh support, ability to view Featured videos from all sites, and anything anyone else can think of.