FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


HOW TO: Build you own YouTube file downloader





gidevelop
Do you ever want to have your own youtube downloader well here is an ideea that works i've tested. One problem though if your host is not supporting CURL this script will not work. Here is the code than copy+paste+name the page to whatever you want+upload+grab and download

Code:
<?php
// Being submitted...
if($_GET['youtube']) {
   // It has so run function "youtube_t" and redirect to that.
   $download = youtube_t($_GET['youtube']);
   header("Location: $download");
}
// Find the matches in the result
function youtube_t ($url) {
   $page = g_page($url);
   if ($page === false) {
      // YouTube won't load...
      die("No connection to Youtube could be established.");
   }
   preg_match('/watch_fullscreen\?video_id=(.*?)&l=(.*?)+&t=(.*?)&/', $page, $match);
   $match1 = "http://www.youtube.com/get_video?video_id=";
   if(!$match[1]) {
      // Video doesn't exist...
      die("The specifyed video does not exist on YouTube.");
   }
   $match1 .= $match[1];
   $match1 .= "&t=";
   $match1 .= $match[3];
   return $match1;
}
// Grab the YouTube page
function g_page ($url) {
   $curl = curl_init($url);
   curl_setopt($curl, CURLOPT_HEADER, false);
   curl_setopt($curl, CURLOPT_VERBOSE, false);
   curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
   $output = curl_exec($curl);
   // Check for errors
   if (curl_errno($curl)) {
      trigger_error('CURL error: "' . curl_error($curl) . '"', E_USER_WARNING);
      $output = false;
   }
   curl_close($curl);
   return $output;
} ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-gb" lang="en-gb">
   <head profile="http://gmpg.org/xfn/11">
      <title>Snatchr - YouTube Download FLV Movie</title>
      <link rel="icon" href="image/favicon.ico" type="image/x-icon" />
      <link rel="stylesheet" href="style.css" media="all" type="text/css" />
      <meta http-equiv="cache-control" content="no-cache" />
      <meta http-equiv="content-language" content="en-gb" />
      <meta http-equiv="content-type" content="text/html; charset=utf-8" />
      <meta http-equiv="imagetoolbar" content="false" />
      <meta http-equiv="pragma" content="no-cache" />
      <meta name="author" content="Your name" />
      <meta name="copyright" content="Copyright (c) your name - <?php echo date('Y'); ?>" />
      <meta name="description" content="description goes here." />
      <meta name="distribution" content="global" />
      <meta name="last-modified" content="<?php echo date('l, dS F Y H:i:s T'); ?>" />
      <meta name="mssmarttagspreventparsing" content="true" />
      <meta name="robots" content="index, follow, noarchive" />
      <meta name="revisit-after" content="7 days" />
      <script type="text/javascript" src="http://www.google-analytics.com/urchin.js"></script>
      <script type="text/javascript">_uacct = "UA-534469-5"; urchinTracker();</script>
   </head>
   
   <body>
      <form action="<?php $_SERVER['PHP_SELF'] ?>" method="get">
         YouTube Video: <input name="youtube" type="text" /> e.g. <em>http://youtube.com/watch?v=nojWJ6-XmeQ</em> <input type="submit" value="Grab and Download!" />
      </form>
      
   </body>
</html>


These code is free for takeing. But please if you have a tested ideea of how to avoid the CURL usage please let me now.

Hope you like it !

PS. If you get this error
Quote:
Fatal error: Call to undefined function curl_init() in C:\Programme\xampp\htdocs\index.php on line 92
it meens that CURL is not supported
AOP Web Development
Thanks' for sharing this. one. Smile
roboguyspacedude
Wow. I never even thought that something like that could be written in php. I was always using the Firefox extension video downloader.
PseudoKnight
That's really cool, though I'd really prefer just leaving the video on youtube's servers. I can think of a few niche uses, but still really cool.
phpc0d3r
that's pretty cool but I usually just use videodownloader.
I don't download alot of videos either.
Usually just ones I want to put on my myspace.
kiran_n444
Thnx Dude this is realli helpful!
billgertz
what a neat code! whoa!

you can use this code not only for youtube but to related sites as well.
gidevelop
Thank you .... Thank you very much.
asim
good one buddy,

thanks for sharing this..... can u please say which version supports curl... so that i cant upgrade.......
emem
This really is a good script, except that not all servers have curl...
sambhav
Hey. This is great. I will just try out and make my own youtube downloader.
manav
but y do u wanna turn curl off...

i mean every host these days supports it... including frih...
TheForgottenArts
That's awesome, dude, thanks so much.
gidevelop
i would like very much to bypass the curl or use an alternative but.. i do not have any ideas for now.zile
zile i'll look into it for an easy approach and to remove the usage of curl. Thank you very much for the support !!!
cr3ativ3
It's quite simple to write a script to download a video off youtube but what I want to do is find a flv to avi converter that works in php and then merge them then have it grab+convert then download that would be awesome. When I want to download the video it is simply a means of going to my cache and finding the get_vid or whatever flash file.
gidevelop
@ cr3ativ3

i don't quite get it. You want to download the already avi or what ???
I yhink you want something like this(if i get the idea correct):

1] INSERT LINK INTO TEXT BOX >[http://www.youtube.com/watch?v=xxxxxxxxxx&feature=dir]
2] ON SUBMIT PROCESSES [get video -> convert to avi -> ask user "Save target as.."]

I have tried this... it's an awsome idea but.. a don't think is so easy.. If you get an inspiration let me know. BYE
cr3ativ3
gidevelop wrote:
@ cr3ativ3

i don't quite get it. You want to download the already avi or what ???
I yhink you want something like this(if i get the idea correct):

1] INSERT LINK INTO TEXT BOX >[http://www.youtube.com/watch?v=xxxxxxxxxx&feature=dir]
2] ON SUBMIT PROCESSES [get video -> convert to avi -> ask user "Save target as.."]

I have tried this... it's an awsome idea but.. a don't think is so easy.. If you get an inspiration let me know. BYE


Ya sorry I am not very good at explaining things but essential that is what I was wanting to do, like I know how to do the first part and third (get video then allow the user to save it), but converting it is hard if I could find a guide to converting flv to avi I would build a conversion script, or if I could find one already written I could use it but I can't seem to find anything. I was able to find an open source vb application that converts perfectly, but I can't seem to find it anymore, if I could I would try and convert the code over to php.

I can't find any sites that download and convert then allow you to download the video as avi, like I have found some but non of them work.
gidevelop
cr3ativ3 wrote:
gidevelop wrote:
@ cr3ativ3

i don't quite get it. You want to download the already avi or what ???
I yhink you want something like this(if i get the idea correct):

1] INSERT LINK INTO TEXT BOX >[http://www.youtube.com/watch?v=xxxxxxxxxx&feature=dir]
2] ON SUBMIT PROCESSES [get video -> convert to avi -> ask user "Save target as.."]

I have tried this... it's an awsome idea but.. a don't think is so easy.. If you get an inspiration let me know. BYE


Ya sorry ...


This is very challenging indeed . I will try to find something... but not even the standalone software aren't so good. 80% of them are crap, 10 % do not work, and the other 10% are having astronomical prices ..so .... decisions decisions !!!
Fire Boar
There's probably a perl script somewhere. Just take that and either convert it to PHP or run it from the cgi-bin.
gidevelop
Holly $#37. I found a site witch does what you want. Check it out here >>http://vixy.net/
simplyw00x
Quote:
flv to avi

Why? All decent media players play flv, and flv to avi encoding is hideously taxing on the processor.
[FuN]goku
simplyw00x wrote:
Quote:
flv to avi

Why? All decent media players play flv, and flv to avi encoding is hideously taxing on the processor.
You mean like VLC Very Happy
Fire Boar
simplyw00x wrote:
Quote:
flv to avi

Why? All decent media players play flv, and flv to avi encoding is hideously taxing on the processor.


Ah, but ALL media players play AVI. And by "all decent" you mean "most decent" because there are some damn good ones out there which won't play FLV.
simplyw00x
Quote:
there are some damn good ones out there which won't play FLV.

A contradiction in terms, surely? Flv is just a container for H.263 [0] and AAC, and any media player that can't handle those isn't really 'damn good' in my book.

Quote:
You mean like VLC

VLC, mPlayer, Windows Media Player with FFshow, totem, etc. etc. --- any player whose programmers care more about decent video playback than a flashy interface.
Related topics
.rm files
Dynamic User Customizable Sites. CSS + PHP = Awesome!
CSS templates
JavaScript (Menu)
JAva HELP
solved
Server Site...
Can l get a CSS document to...
[PHP] Server Load
Securing website software
Game Maker
Youtube Clone?
LG To Release YouTube Phone with Direct Upload
how to unlock a zip or rar file
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.