View Single Post
Old 01-23-2011, 07:11 PM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,513
Quote:
Originally Posted by d-null View Post
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/>";
  
?>
__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


My Cam Feeds Script / Free Templates / Gallery Scraper
fris is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote