is it possible to use php to extract a youtube video?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • d-null
    . . .
    • Apr 2007
    • 13724

    #1

    is it possible to use php to extract a youtube video?

    I am wondering if it is possible to use a very short php script to download the flv of a youtube video straight to my server. Just want to do one video, so I can hardcode the youtube url in the short script, doesn't have to be any fancy interface or anything

    anyone have any ideas on this?

    __________________

    Looking for a custom TUBE SCRIPT that supports massive traffic, load balancing, billing support, and h264 encoding? Hit up Konrad!
    Looking for designs for your websites or custom tubesite design? Hit up Zuzana Designs
    Check out the #1 WordPress SEO Plugin: CyberSEO Suite
  • fris
    I have to go potty
    • Aug 2002
    • 55785

    #2
    do you have access to the shell?

    theirs a good python script called youtube_dl
    Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


    Totally Free Templates

    Comment

    • Vendzilla
      Biker Gnome
      • Mar 2004
      • 23200

      #3
      Use Firefox, right click, view page info, click on media and then click on the swf file and save
      Carbon is not the problem, it makes up 0.041% of our atmosphere , 95% of that is from Volcanos and decomposing plants and stuff. So people in the US are responsible for 13% of the carbon in the atmosphere which 95% is not from Humans, like cars and trucks and stuff and they want to spend trillions to fix it while Solar Panel plants are powered by coal plants
      think about that

      Comment

      • fris
        I have to go potty
        • Aug 2002
        • 55785

        #4
        Originally posted by Vendzilla
        Use Firefox, right click, view page info, click on media and then click on the swf file and save
        i think he wants it to his server, not desktop.

        here is youtube_dl in action

        Code:
        [chris@jumbo ~]$ youtube-dl http://www.youtube.com/watch?v=SbasOIcGjqs
        [youtube] Setting language
        [youtube] SbasOIcGjqs: Downloading video webpage
        [youtube] SbasOIcGjqs: Downloading video info webpage
        [youtube] SbasOIcGjqs: Extracting video information
        [download] Destination: SbasOIcGjqs.mp4
        [download] 100.0% of 3.61M at  559.66k/s ETA 00:00
        Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


        Totally Free Templates

        Comment

        • fuzebox
          making it rain
          • Oct 2003
          • 22363

          #5
          Sites like clipnabber.com require you to paste the source code in... Makes me believe there must be an easy formula to pull the mp4 url from the code.

          Comment

          • Vendzilla
            Biker Gnome
            • Mar 2004
            • 23200

            #6
            Originally posted by fris
            i think he wants it to his server, not desktop.

            here is youtube_dl in action

            Code:
            [chris@jumbo ~]$ youtube-dl http://www.youtube.com/watch?v=SbasOIcGjqs
            [youtube] Setting language
            [youtube] SbasOIcGjqs: Downloading video webpage
            [youtube] SbasOIcGjqs: Downloading video info webpage
            [youtube] SbasOIcGjqs: Extracting video information
            [download] Destination: SbasOIcGjqs.mp4
            [download] 100.0% of 3.61M at  559.66k/s ETA 00:00
            He said one video, why get s script for one video?
            Put it on your desktop, upload to your server, nothing complicated
            Carbon is not the problem, it makes up 0.041% of our atmosphere , 95% of that is from Volcanos and decomposing plants and stuff. So people in the US are responsible for 13% of the carbon in the atmosphere which 95% is not from Humans, like cars and trucks and stuff and they want to spend trillions to fix it while Solar Panel plants are powered by coal plants
            think about that

            Comment

            • d-null
              . . .
              • Apr 2007
              • 13724

              #7
              Originally posted by fris
              i think he wants it to his server, not desktop.
              correct

              no shell access

              hoping to figure out a way to do it with php

              __________________

              Looking for a custom TUBE SCRIPT that supports massive traffic, load balancing, billing support, and h264 encoding? Hit up Konrad!
              Looking for designs for your websites or custom tubesite design? Hit up Zuzana Designs
              Check out the #1 WordPress SEO Plugin: CyberSEO Suite

              Comment

              • fris
                I have to go potty
                • Aug 2002
                • 55785

                #8
                Originally posted by Vendzilla
                He said one video, why get s script for one video?
                Put it on your desktop, upload to your server, nothing complicated
                ya of course its simple, but he still wants to do it via php ;)
                Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                Totally Free Templates

                Comment

                • fris
                  I have to go potty
                  • Aug 2002
                  • 55785

                  #9
                  Originally posted by d-null
                  correct

                  no shell access

                  hoping to figure out a way to do it with php
                  try this.

                  Code:
                  <?php
                  
                    class youtube
                    {
                        var $cookies;
                        var $mgr;
                        var $req;
                        var $debug = true;
                        var $auth = false;
                        
                        function youtube()
                        {
                        }
                        function download($video_id)
                        {
                            $url = "http://www.youtube.com/watch?v=" . $video_id;
                            $this->req =& new HTTP_Request($url);
                            $response = $this->req->sendRequest();
                            if (PEAR::isError($response)) {
                                $response->getMessage() . "\n";
                            } else {
                                $page = $this->req->getResponseBody();
                                $vpattern = '/v=(.*?)&/';
                                preg_match($vpattern, $page, $mv);
                                echo "<br />Video ID:" . $v_id = $mv[1];
                                $tpattern = '/&t=(.*?)&/';
                                preg_match($tpattern, $page, $tickets);
                                echo "<br />Token ID:" . $token = $tickets[1];
                                $curl = "video_id=";
                                $curl .= $v_id;
                                $curl .= "&t=";
                                $curl .= $token;
                                $url = "http://www.youtube.com/get_video?" . $curl;
                                if ($this->debug)
                                    return $url;
                            }
                        }
                    }
                    
                    function getPatternFromUrl($url)
                    {
                        $url = $url . '&';
                        $pattern = '/v=(.+?)&+/';
                        preg_match($pattern, $url, $matches);
                        return($matches[1]);
                    }
                    
                    function GrabFlvFromYoutube($pattern)
                    {
                        $tube = new youtube();
                        $flv_http_path = $tube->download($pattern);
                        echo "<br/>Complete URL:" . $flv_http_path;
                        set_time_limit(0);
                        
                        $data = file_get_contents($flv_http_path);
                        $new_flv_path = dirname(_FILE_) . '/flvs/' . $pattern . '-' . time() . '.flv';
                        echo "<br />File uploaed:";
                        file_put_contents($new_flv_path, $data);
                        return $new_flv_path;
                    }
                    
                    // here is url of youtube video
                    $url = $_POST['url'];
                    $pattern = getPatternFromUrl($url);
                    $flv_path = GrabFlvFromYoutube($pattern);
                    echo "File Successfully Downloaded at:" . $flv_path . "<br/>";
                    
                  ?>
                  Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                  Totally Free Templates

                  Comment

                  • Angry Jew Cat - Banned for Life
                    (felis madjewicus)
                    • Jul 2006
                    • 20368

                    #10
                    Try scraping the youtube URL for the appropriate data and dropping it into this URL structure, then downloading. http://www.ehow.com/how_4685059_youtube-mp-video.html

                    Comment

                    • cherrylula
                      lol
                      • Jan 2002
                      • 15969

                      #11
                      Where's all the heros bitching about stealing content? lol @ this thread

                      Comment

                      • Fletch XXX
                        GFY HALL OF FAME DAMMIT!!!
                        • Jan 2002
                        • 60840

                        #12
                        5+ years ago this woulda be a 6 page thread of shit flinging

                        Want an Android App for your tube, membership, or free site?

                        Need banners or promo material? Hit us up (ICQ Fletch: 148841377) or email me fletchxxx at gmail.com - recent work - About me

                        Comment

                        • fris
                          I have to go potty
                          • Aug 2002
                          • 55785

                          #13
                          Originally posted by cherrylula
                          Where's all the heros bitching about stealing content? lol @ this thread
                          well as long as you dont use the videos dl'd from youtube for profit, i dont see any reason why you cant download them for offline viewing, i use an app called mxtube on my ipod which lets me grab yt vids for offline viewing.
                          Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


                          Totally Free Templates

                          Comment

                          • cherrylula
                            lol
                            • Jan 2002
                            • 15969

                            #14
                            Originally posted by fris
                            well as long as you dont use the videos dl'd from youtube for profit, i dont see any reason why you cant download them for offline viewing, i use an app called mxtube on my ipod which lets me grab yt vids for offline viewing.
                            oh, not for profit. yeah this board is for technical hobbyists, I forgot....

                            and some more!

                            ... but it's ok, I clicked this thread to learn too! thanks everyone.

                            Comment

                            • d-null
                              . . .
                              • Apr 2007
                              • 13724

                              #15
                              Originally posted by fris
                              try this.

                              Code:
                              <?php
                              
                                class youtube
                                {
                                    var $cookies;
                                    var $mgr;
                                    var $req;
                                    var $debug = true;
                                    var $auth = false;
                                    
                                    function youtube()
                                    {
                                    }
                                    function download($video_id)
                                    {
                                        $url = "http://www.youtube.com/watch?v=" . $video_id;
                                        $this->req =& new HTTP_Request($url);
                                        $response = $this->req->sendRequest();
                                        if (PEAR::isError($response)) {
                                            $response->getMessage() . "\n";
                                        } else {
                                            $page = $this->req->getResponseBody();
                                            $vpattern = '/v=(.*?)&/';
                                            preg_match($vpattern, $page, $mv);
                                            echo "<br />Video ID:" . $v_id = $mv[1];
                                            $tpattern = '/&t=(.*?)&/';
                                            preg_match($tpattern, $page, $tickets);
                                            echo "<br />Token ID:" . $token = $tickets[1];
                                            $curl = "video_id=";
                                            $curl .= $v_id;
                                            $curl .= "&t=";
                                            $curl .= $token;
                                            $url = "http://www.youtube.com/get_video?" . $curl;
                                            if ($this->debug)
                                                return $url;
                                        }
                                    }
                                }
                                
                                function getPatternFromUrl($url)
                                {
                                    $url = $url . '&';
                                    $pattern = '/v=(.+?)&+/';
                                    preg_match($pattern, $url, $matches);
                                    return($matches[1]);
                                }
                                
                                function GrabFlvFromYoutube($pattern)
                                {
                                    $tube = new youtube();
                                    $flv_http_path = $tube->download($pattern);
                                    echo "<br/>Complete URL:" . $flv_http_path;
                                    set_time_limit(0);
                                    
                                    $data = file_get_contents($flv_http_path);
                                    $new_flv_path = dirname(_FILE_) . '/flvs/' . $pattern . '-' . time() . '.flv';
                                    echo "<br />File uploaed:";
                                    file_put_contents($new_flv_path, $data);
                                    return $new_flv_path;
                                }
                                
                                // here is url of youtube video
                                $url = $_POST['url'];
                                $pattern = getPatternFromUrl($url);
                                $flv_path = GrabFlvFromYoutube($pattern);
                                echo "File Successfully Downloaded at:" . $flv_path . "<br/>";
                                
                              ?>
                              thanks for this fris

                              I'm playing with it but still getting 500 errors, is there something I am missing if trying to run the above as it is?


                              and I'm not doing this to "steal" any content for those that voiced concern

                              __________________

                              Looking for a custom TUBE SCRIPT that supports massive traffic, load balancing, billing support, and h264 encoding? Hit up Konrad!
                              Looking for designs for your websites or custom tubesite design? Hit up Zuzana Designs
                              Check out the #1 WordPress SEO Plugin: CyberSEO Suite

                              Comment

                              Working...