1. This website uses cookies. By continuing to use this website you are giving consent to cookies being used.
    For information on cookies and how you can disable them visit our Cookie Usage page.
    Dismiss Notice

PHP Video Downloader

Discussion in 'Web Development' started by vareside, May 23, 2008.

  1. vareside

    vareside New Member

    Hi folks,
    I need a free script that enables my users to download videos from sites like Metacafe, Youtube, Blip, Revver, iFilm, Vareside etc.
     
  2. pezboy45

    pezboy45 Mod/Design & Coder [Pro]

  3. vareside

    vareside New Member

  4. vareside

    vareside New Member

    Well, can someone actually tell me how to run this PHP code propperly? Because I just found it on the web:

    function get_content_of_url($url){
    $ohyeah = curl_init();
    curl_setopt($ohyeah, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ohyeah, CURLOPT_URL, $url);
    $data = curl_exec($ohyeah);
    curl_close($ohyeah);
    return $data;
    }

    function get_flv_link($string) {
    if (eregi("watch_fullscreen\?video_id=(.*)&title=", $string, $out)) {
    $outdata = $out[1];
    }
    return 'http://youtube.com/get_video.php?video_id='.$outdata;
    }

    function get_http_header($url){
    $uh = curl_init();
    curl_setopt($uh, CURLOPT_URL, $url);
    curl_setopt($uh, CURLOPT_HEADER, 1);
    curl_setopt($uh, CURLOPT_RETURNTRANSFER, 1);
    $res = curl_exec($uh);
    curl_close($uh);
    return $res;
    }

    function show_url($http_header){
    $arai = explode("\n",$http_header);
    foreach($arai as $ini){
    if(eregi("location",$ini)) $url = $ini;
    }
    list($sampah,$hasil) = explode("Location:",$url);
    return str_replace("\n","",trim($hasil));
    }

    function download_youtube($url){
    $data = get_content_of_url($url);
    $next_url = get_flv_link($data);
    $data = get_http_header($next_url);
    return show_url($data);
    }

    $url = "http://youtube.com/watch?v=SAQZ0BDXn48";
    echo download_youtube($url);
     
  5. pezboy45

    pezboy45 Mod/Design & Coder [Pro]

    Yea, your supposed to do this:

    PHP:
    <?php 
    function get_content_of_url($url){
    $ohyeah curl_init();
    curl_setopt($ohyeahCURLOPT_RETURNTRANSFER1);
    curl_setopt($ohyeahCURLOPT_URL$url);
    $data curl_exec($ohyeah);
    curl_close($ohyeah);
    return 
    $data;
    }

    function 
    get_flv_link($string) {
    if (
    eregi("watch_fullscreen\?video_id=(.*)&title="$string$out)) {
    $outdata $out[1];
    }
    return 
    'http://youtube.com/get_video.php?video_id='.$outdata;
    }

    function 
    get_http_header($url){
    $uh curl_init();
    curl_setopt($uhCURLOPT_URL$url);
    curl_setopt($uhCURLOPT_HEADER1);
    curl_setopt($uhCURLOPT_RETURNTRANSFER1);
    $res curl_exec($uh);
    curl_close($uh);
    return 
    $res;
    }

    function 
    show_url($http_header){
    $arai explode("\n",$http_header);
    foreach(
    $arai as $ini){
    if(
    eregi("location",$ini)) $url $ini;
    }
    list(
    $sampah,$hasil) = explode("Location:",$url);
    return 
    str_replace("\n","",trim($hasil));
    }

    function 
    download_youtube($url){
    $data get_content_of_url($url);
    $next_url get_flv_link($data);
    $data get_http_header($next_url);
    return 
    show_url($data);
    }

    $url "http://youtube.com/watch?v=SAQZ0BDXn48";
    echo 
    download_youtube($url);
    ?>
    But, I tried it, and it didn't work...
     
  6. vareside

    vareside New Member

    Ok, does anyone else have a working code then?
     
  7. Jaybirddesigns

    Jaybirddesigns New Member

    Don't know if this helps or not but maybe you could implement it with your current site, open source: http://phpmotion.com/