GoFuckYourself.com - Adult Webmaster Forum

GoFuckYourself.com - Adult Webmaster Forum (https://gfy.com/index.php)
-   Fucking Around & Business Discussion (https://gfy.com/forumdisplay.php?f=26)
-   -   is it possible to use php to extract a youtube video? (https://gfy.com/showthread.php?t=1007241)

d-null 01-23-2011 01:00 PM

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?

fris 01-23-2011 01:08 PM

do you have access to the shell?

theirs a good python script called youtube_dl

Vendzilla 01-23-2011 01:58 PM

Use Firefox, right click, view page info, click on media and then click on the swf file and save

fris 01-23-2011 02:55 PM

Quote:

Originally Posted by Vendzilla (Post 17864344)
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 https://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


fuzebox 01-23-2011 03:03 PM

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.

Vendzilla 01-23-2011 03:57 PM

Quote:

Originally Posted by fris (Post 17864410)
i think he wants it to his server, not desktop.

here is youtube_dl in action

Code:

[chris@jumbo ~]$ youtube-dl https://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

d-null 01-23-2011 05:04 PM

Quote:

Originally Posted by fris (Post 17864410)
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

fris 01-23-2011 06:45 PM

Quote:

Originally Posted by Vendzilla (Post 17864474)
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 ;)

fris 01-23-2011 07:11 PM

Quote:

Originally Posted by d-null (Post 17864615)
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 = "https://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 = "https://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/>";
 
?>

:)

Angry Jew Cat - Banned for Life 01-24-2011 12:29 AM

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

cherrylula 01-24-2011 06:18 AM

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

Fletch XXX 01-24-2011 06:26 AM

5+ years ago this woulda be a 6 page thread of shit flinging :1orglaugh

fris 01-24-2011 07:02 AM

Quote:

Originally Posted by cherrylula (Post 17865489)
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.

cherrylula 01-24-2011 07:08 AM

Quote:

Originally Posted by fris (Post 17865540)
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.... :1orglaugh

and :1orglaugh :1orglaugh :1orglaugh some more!

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

d-null 01-24-2011 10:26 PM

Quote:

Originally Posted by fris (Post 17864761)
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 = "https://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 = "https://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 :1orglaugh


All times are GMT -7. The time now is 04:32 AM.

Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123