Note that there are some explanatory texts on larger screens.

plurals
  1. POyoutube video downloaded successfully on local, but on server(online) only 0 byte flv is downloading
    primarykey
    data
    text
    <p>I'm using php tube class to download youtube video. Video is automatically downloaded in a folder by submitting youtube video url.</p> <p>everything is working fine on local (XAMPP), but when I upload this to server(online), THEN ONLY 0 byte flv file is saved.</p> <p>I also debug the code both side( local and global ).</p> <p>I get the url like this( on <strong>local</strong>)</p> <p><code>http://www.youtube.com/get_video?video_id=1jNWCFwqPvM&amp;=vjVQa1PpcFMyYCECyfmYENWklpwXGyhVgJpSFPgNAEc%3D</code></p> <p>whereas on <strong>server</strong> I got link like this</p> <p><code>http://www.youtube.com/ get_video?video_id=1jNWCFwqPvM&amp;t=vjVQa1PpcFNS3SPxIXi8hy-NF4qZFFrScDXCjGLLrLc%3D</code></p> <p>when I copy the link getting from <strong>local</strong> and paste on browser then a download box appear on browser, whereas when I copy the link getting from <strong>server</strong> and paste on browser then only a blank page appears</p> <ol> <li>please solve my problem, where is the error? </li> <li>how to know that pear is installed or not on server?</li> <li><p>on server side sometimes I get link like</p> <p><code>http://www.youtube.com/get_video?video_id=1jNWCFwqPvM&amp;t=vjVQa1PpcFNS3SPxIXi8hy-NF4qZFFrScDXCjGLLrLc%3D</code> </p></li> </ol> <p>but sometimes I get only</p> <p><code>http://www.youtube.com/get_video?video_id=&amp;t=</code></p> <p>How to solve these?</p> <p><strong>UPDATE:</strong></p> <p>I debug all the code and found that <code>file_get_contents()</code> return string(0) on server whereas on local it return some integer value. <code>allow_url_fopen</code> is onmy server</p> <p>this is <code>index.php</code></p> <pre><code>include_once('functions.php'); $url = $_POST['url']; // here is url of youtube video $pattern = getPatternFromUrl($url); $flv_path = GrabFlvFromYoutube($pattern ); echo "File Successfully Downloaded at:".$flv_path."&lt;br/&gt;"; </code></pre> <hr> <p>these functions are in <code>functions.php</code></p> <pre><code>function getPatternFromUrl($url) { $url = $url.'&amp;'; $pattern = '/v=(.+?)&amp;+/'; preg_match($pattern, $url, $matches); //echo $matches[1]; die; return ($matches[1]); } </code></pre> <p>and </p> <pre><code>function GrabFlvFromYoutube( $pattern ) { require_once ("phptube.php"); $tube = new PHPTube (); $flv_http_path = $tube-&gt;download($pattern) ; echo "&lt;br/&gt;Complete URL:".$flv_http_path; set_time_limit(0); $data = file_get_contents($flv_http_path); //var_dump(file_get_contents($flv_http_path)); $new_flv_path = dirname(_FILE_).'/flvs/'.$pattern.'-'.time().'.flv' ; echo "&lt;br /&gt;File uploaed:"; file_put_contents($new_flv_path, $data); return $new_flv_path ; } </code></pre> <hr> <p>below function in <code>phptube.php</code></p> <pre><code>class PHPTube { var $cookies; var $mgr; var $req; var $debug = true; var $auth = false; function PHPTube () {} function download ($video_id) { $url = "http://www.youtube.com/watch?v=".$video_id; $this-&gt;req =&amp; new HTTP_Request($url); $response = $this-&gt;req-&gt;sendRequest(); if (PEAR::isError($response)) { $response-&gt;getMessage()."\n"; } else { $page = $this-&gt;req-&gt;getResponseBody(); $vpattern = '/v=(.*?)&amp;/'; //$vpattern ='/video_id:(.*?)/'; preg_match($vpattern,$page,$mv); //preg_match('&amp;"video_id": "(.*?)"&amp;', $page, $mv); echo "&lt;br /&gt;Video ID:".$v_id = $mv[1]; //$tpattern='/"t": "(.*?)"/'; $tpattern = '/&amp;t=(.*?)&amp;/'; preg_match($tpattern,$page,$tickets); echo "&lt;br /&gt;Token ID:".$token = $tickets[1]; $curl = "video_id="; $curl .= $v_id; $curl .= "&amp;t="; $curl.= $token; //echo "&lt;br /&gt;Query String:".$curl; die; $url = "http://www.youtube.com/get_video?".$curl; if ($this-&gt;debug) return $url; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload