View Single Post
Old 12-25-2011, 05:05 AM   PM User | #116
chump2877
Senior Coder

 
chump2877's Avatar
 
Join Date: Dec 2004
Location: the U.S. of freakin' A.
Posts: 2,530
Thanks: 15
Thanked 128 Times in 121 Posts
chump2877 is on a distinguished road
Quote:
Originally Posted by jibreel View Post
Basicly i need a link after the conversion finished like "DOWNLOAD NOW" that is linked to the mp3 that they just converted, If this helps i'm hosting the website on a shared host.
I've gotten several requests for this feature, so I have modified the code as follows:

1) Added download link after successful conversion
2) Added conversion process progress bar
3) Some general refactoring of code

Download the revised files below. ...And please let me know if you experience any issues with the code....

Happy Holidays!

Quote:
Edit: The progress bar feature will only work for PHP versions 5.3 and above. To disable the progress bar, you need only comment out the following lines of code in YouTubeToMp3Converter.class.php:

PHP Code:
        private function SaveVideo($url)
        {
            
$this->_percentVidDownloaded 0;
            
$this->SetTempVidFileName(time());
            
$file fopen($this->GetTempVidFileName(), 'w');
            
$ch curl_init();
            
curl_setopt($chCURLOPT_FILE$file);
            
curl_setopt($chCURLOPT_HEADER0);
            
curl_setopt($chCURLOPT_URL$url);
            
curl_setopt($chCURLOPT_FOLLOWLOCATION1);
            
//curl_setopt($ch, CURLOPT_NOPROGRESS, false);
            //curl_setopt($ch, CURLOPT_PROGRESSFUNCTION, array($this, 'UpdateVideoDownloadProgress'));
            //curl_setopt($ch, CURLOPT_BUFFERSIZE, 4096000);
            
curl_exec($ch);
            
curl_close($ch);
            
fclose($file);
            return 
is_file($this->GetTempVidFileName());
        } 
...and change the following line of code in index.php:
PHP Code:
echo '<div id="progress-bar"><div id="progress">0%</div></div></div>'
...to:
PHP Code:
echo '</div>'
Attached Files
File Type: zip 12-25-11.zip (3.4 KB, 244 views)
__________________
Regards, R.J.

Last edited by chump2877; 12-26-2011 at 06:05 AM..
chump2877 is offline   Reply With Quote
Users who have thanked chump2877 for this post:
jibreel (12-25-2011)