Originally posted by chump2877
View Post
Announcement
Collapse
No announcement yet.
YouTube-to-MP3 conversion - PHP class and script
Collapse
X
-
-
Java script text box open for radio selection
I want to open a text box on radio selection ,i.e 5 radio selection for 5 text box,
after selecting second radio, previous text box should not close and new text box should open for second selections
Please help me on this
sample code:
Code:<html> <head> <script type="text/javascript"> function show() { document.getElementById('area').style.display = 'block'; } function hide() { document.getElementById('area').style.display = 'none'; } function show() { document.getElementById('area1').style.display = 'block'; } function hide() { document.getElementById('area1').style.display = 'none'; } </script> </head> <body> <form name="radios"> <table> <tr> <td> <INPUT TYPE=RADIO NAME="X" VALUE="H" onclick="hide();"/>A </td> <td> <INPUT TYPE=RADIO NAME="X" VALUE="L" onclick="show();"/>B </td> <td> <TEXTAREA id="area" style="display: none;" NAME="data" ROWS=5 COLS=50></TEXTAREA> </td> </tr> <tr> <INPUT TYPE=RADIO NAME="X" VALUE="H" onclick="hide();"/>C <INPUT TYPE=RADIO NAME="X" VALUE="L" onclick="show();"/>B <TEXTAREA id="area1" style="display: none;" NAME="data" ROWS=5 COLS=50></TEXTAREA> </tr> </table> </form> </body> </html>
Comment
-
-
Originally posted by rbisconti97 View PostHi, thanks for the update. I can convert most videos, but cannot convert the following:
http://www.youtube.com/watch?v=U64bongHqYU
"This video contains content from SME, Music Services, Inc. and Sony ATV Publishing, one or more of whom have blocked it in your country on copyright grounds.
Sorry about that."Regards, R.J.
---------------------------------------------------------
Help spread the word! Like our YouTube-to-Mp3 Conversion Script on Facebook !! :-)
[Instructional videos and tutorials are also available on YouTube, Dailymotion, and Vimeo]
Explore all products and services, view demos, review documentation, check prices, and more!
♪♪ …Need Web Hosting For Our YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪
Comment
-
-
Originally posted by chump2877 View PostWhen I visit that video in my browser, I get the following message:
Please see this post for information regarding videos that are blocked by the videos' uploaders on a per-country basis.
Comment
-
-
Originally posted by suresh.dhanapal View PostI want to open a text box on radio selection ,i.e 5 radio selection for 5 text box,
after selecting second radio, previous text box should not close and new text box should open for second selections
Please help me on this
sample code:
Code:<html> <head> <script type="text/javascript"> function show() { document.getElementById('area').style.display = 'block'; } function hide() { document.getElementById('area').style.display = 'none'; } function show() { document.getElementById('area1').style.display = 'block'; } function hide() { document.getElementById('area1').style.display = 'none'; } </script> </head> <body> <form name="radios"> <table> <tr> <td> <INPUT TYPE=RADIO NAME="X" VALUE="H" onclick="hide();"/>A </td> <td> <INPUT TYPE=RADIO NAME="X" VALUE="L" onclick="show();"/>B </td> <td> <TEXTAREA id="area" style="display: none;" NAME="data" ROWS=5 COLS=50></TEXTAREA> </td> </tr> <tr> <INPUT TYPE=RADIO NAME="X" VALUE="H" onclick="hide();"/>C <INPUT TYPE=RADIO NAME="X" VALUE="L" onclick="show();"/>B <TEXTAREA id="area1" style="display: none;" NAME="data" ROWS=5 COLS=50></TEXTAREA> </tr> </table> </form> </body> </html>
Regards, R.J.
---------------------------------------------------------
Help spread the word! Like our YouTube-to-Mp3 Conversion Script on Facebook !! :-)
[Instructional videos and tutorials are also available on YouTube, Dailymotion, and Vimeo]
Explore all products and services, view demos, review documentation, check prices, and more!
♪♪ …Need Web Hosting For Our YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪
Comment
-
-
Originally posted by Luckyplaya View PostHi chump,
can you Update that you can convert Facebook videos?
would be niceRegards, R.J.
---------------------------------------------------------
Help spread the word! Like our YouTube-to-Mp3 Conversion Script on Facebook !! :-)
[Instructional videos and tutorials are also available on YouTube, Dailymotion, and Vimeo]
Explore all products and services, view demos, review documentation, check prices, and more!
♪♪ …Need Web Hosting For Our YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪
Comment
-
-
Originally posted by farhaty View PostHello, is there any why to set the cache the MP3 files?
(Note: Log files and downloaded video files are deleted automatically after EVERY conversion.)
That said, in the past, I have programmed mp3 cache functionality as a custom enhancement to the software, on a per-client basis. If you are interested, I am available to program such a thing for you, but clearly I would have to charge you extra for the service.Regards, R.J.
---------------------------------------------------------
Help spread the word! Like our YouTube-to-Mp3 Conversion Script on Facebook !! :-)
[Instructional videos and tutorials are also available on YouTube, Dailymotion, and Vimeo]
Explore all products and services, view demos, review documentation, check prices, and more!
♪♪ …Need Web Hosting For Our YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪
Comment
-
-
Looks like Vevo videos can no longer be download again
I was able to convert these same videos not more than a day ago!!
[Note: You will notice that all the major YouTube-to-Mp3 sites can no longer convert the newest/latest Vevo videos. At least, this is what I have noticed! For example: http://www.youtube-mp3.org/#v=IDAqAgbM07g]
I don't know what YouTube is up to, but I vow to persevere and continue to look for a way around this issue!
My software still converts all other videos, but it appears Vevo (and its ilk) are getting special treatment from YouTube. Let's hope this is not the end for converting videos from these channels. Stay tuned, and please be patient, as I search for a solution.
Thanks!Last edited by chump2877; Jun 21, 2013, 03:07 AM.Regards, R.J.
---------------------------------------------------------
Help spread the word! Like our YouTube-to-Mp3 Conversion Script on Facebook !! :-)
[Instructional videos and tutorials are also available on YouTube, Dailymotion, and Vimeo]
Explore all products and services, view demos, review documentation, check prices, and more!
♪♪ …Need Web Hosting For Our YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪
Comment
-
-
Here is the preliminary fix for the latest Vevo video problem. The following code is meant to be a drop-in replacement for the YouTubeToMp3Converter.class.php file for the free version only. If this solution continues to work after further testing, then I will release a similar fix for the paid-for version of my software at that time.
Please let me know if this code works for you. I appreciate your help in testing this code.
[Note: The only code to change is in the existing SetFlvUrls() method and the new DecryptYouTubeCypher() method. (I'm assuming that you are using the most recent release of the free version!)]
YouTubeToMp3Converter.class.php
PHP Code:<?php
// Conversion Class
include 'config.class.php';
class YouTubeToMp3Converter extends Config
{
// Private Fields
private $_songFileName = '';
private $_flvUrls = array();
private $_tempVidFileName;
private $_uniqueID = '';
private $_vidSrcTypes = array('source_code', 'url');
private $_percentVidDownloaded = 0;
#region Public Methods
function __construct()
{
$this->_uniqueID = time() . "_" . uniqid('', true);
}
function DownloadVideo($youTubeUrl)
{
$file_contents = file_get_contents($youTubeUrl);
if ($file_contents !== false)
{
$this->SetSongFileName($file_contents);
$this->SetFlvUrls($file_contents, $youTubeUrl);
if ($this->GetSongFileName() != '' && count($this->GetFlvUrls()) > 0)
{
return $this->SaveVideo($this->GetFlvUrls());
}
}
return false;
}
function GenerateMP3($audioQuality)
{
$qualities = $this->GetAudioQualities();
$quality = (in_array($audioQuality, $qualities)) ? $audioQuality : $qualities[1];
$exec_string = parent::_FFMPEG.' -i '.$this->GetTempVidFileName().' -vol '.parent::_VOLUME.' -y -acodec libmp3lame -ab '.$quality.'k '.$this->GetSongFileName() . ' 2> logs/' . $this->_uniqueID . '.txt';
$ffmpegExecUrl = preg_replace('/(([^\/]+?)(\.php))$/', "exec_ffmpeg.php", "http://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']);
$postData = "cmd=".urlencode($exec_string);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $ffmpegExecUrl);
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_exec($ch);
curl_close($ch);
}
function DownloadMP3($file)
{
$filepath = parent::_SONGFILEDIR . urldecode($file);
$filename = urldecode($file);
if (parent::_ENABLE_CONCURRENCY_CONTROL)
{
$filename = preg_replace('/((_uuid-)(\w{13})(\.mp3))$/', "$4", $filename);
}
if (is_file($filepath))
{
header('Content-Type: audio/mpeg3');
header('Content-Length: ' . filesize($filepath));
header('Content-Disposition: attachment; filename="'.$filename.'"');
ob_clean();
flush();
readfile($filepath);
die();
}
else
{
$redirect = explode("?", $_SERVER['REQUEST_URI']);
header('Location: ' . $redirect[0]);
}
}
function ExtractSongTrackName($vidSrc, $srcType)
{
$name = '';
$vidSrcTypes = $this->GetVidSrcTypes();
if (in_array($srcType, $vidSrcTypes))
{
$vidSrc = ($srcType == $vidSrcTypes[1]) ? file_get_contents($vidSrc) : $vidSrc;
if ($vidSrc !== false)
{
if (preg_match('/(<title>)(.+?)( - YouTube)(<\/title>)/', $vidSrc, $matches) == 1)
{
$name = trim($matches[2]);
$name = iconv("UTF-8", "ISO-8859-1//TRANSLIT", $name);
$name = (!empty($name)) ? html_entity_decode($name) : 'unknown_'.time();
}
}
}
return $name;
}
function ExtractVideoId($youTubeUrl)
{
$v = '';
$urlQueryStr = parse_url(trim($youTubeUrl), PHP_URL_QUERY);
if ($urlQueryStr !== false && !empty($urlQueryStr))
{
parse_str($urlQueryStr);
}
return $v;
}
function UpdateVideoDownloadProgress($downloadSize, $downloaded, $uploadSize, $uploaded)
{
$percent = round($downloaded/$downloadSize, 2) * 100;
if ($percent > $this->_percentVidDownloaded)
{
$this->_percentVidDownloaded++;
echo '<script type="text/javascript">updateVideoDownloadProgress("'. $percent .'");</script>';
ob_end_flush();
ob_flush();
flush();
}
}
#endregion
#region Private "Helper" Methods
private function SaveVideo(array $urls)
{
$success = false;
$vidCount = -1;
while (!$success && ++$vidCount < count($urls))
{
$this->_percentVidDownloaded = 0;
$this->SetTempVidFileName();
$file = fopen($this->GetTempVidFileName(), 'w');
$ch = curl_init();
curl_setopt($ch, CURLOPT_FILE, $file);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_URL, $urls[$vidCount]);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
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);
if (is_file($this->GetTempVidFileName()))
{
if (!filesize($this->GetTempVidFileName()) || filesize($this->GetTempVidFileName()) < 10000)
{
unlink($this->GetTempVidFileName());
}
else
{
$success = true;
}
}
}
return $success;
}
private function DecryptYouTubeCypher($signature)
{
$sigParts = explode('.', $signature);
if (count($sigParts) == 2)
{
$sigParts[1] = substr(substr($sigParts[1], 0, 8) . substr($sigParts[0], 0, 1) . substr($sigParts[1], 9, 9) . substr($sigParts[1], -4, 1) . substr($sigParts[1], 19, 20) . substr($sigParts[1], 18, 1), 0, 40);
$sigParts[0] = substr($sigParts[0], -40);
$signature = strrev($sigParts[0] . '.' . $sigParts[1]);
}
return $signature;
}
#endregion
#region Properties
public function GetSongFileName()
{
return $this->_songFileName;
}
private function SetSongFileName($file_contents)
{
$vidSrcTypes = $this->GetVidSrcTypes();
$trackName = $this->ExtractSongTrackName($file_contents, $vidSrcTypes[0]);
if (!empty($trackName))
{
$fname = parent::_SONGFILEDIR . preg_replace('/_{2,}/','_',preg_replace('/ /','_',preg_replace('/[^A-Za-z0-9 _-]/','',$trackName)));
$fname .= (parent::_ENABLE_CONCURRENCY_CONTROL) ? uniqid('_uuid-') : '';
$this->_songFileName = $fname . '.mp3';
}
}
public function GetFlvUrls()
{
return $this->_flvUrls;
}
private function SetFlvUrls($file_contents, $youTubeUrl)
{
$vidUrls = array();
$vidSrcTypes = $this->GetVidSrcTypes();
$cypherUsed = false;
$vidInfoTypes = array('&el=embedded', '&el=detailpage', '&el=vevo', '');
$vidId = $this->ExtractVideoId($youTubeUrl);
foreach ($vidInfoTypes as $infotype)
{
$content = file_get_contents('https://www.youtube.com/get_video_info?&video_id='.$vidId.$infotype.'&ps=default&eurl=&gl=US&hl=en');
parse_str($content, $output);
//@print_r($output);
//echo "\n\n";
if (isset($output['status']) && $output['status'] == 'ok')
{
//die(print_r($output));
$cypherUsed = isset($output['use_cipher_signature']) && $output['use_cipher_signature'] == 'True';
break;
}
}
if (preg_match('/(ytplayer\.config = )([^\r\n]+?)(;<\/script>)/', $file_contents, $matches) == 1)
{
$jsonObj = json_decode(trim($matches[2], ';'));
if (isset($jsonObj->args->url_encoded_fmt_stream_map))
{
$urls = urldecode(urldecode($jsonObj->args->url_encoded_fmt_stream_map));
//$urls = urldecode(urldecode($jsonObj->args->adaptive_fmts));
//die($urls);
if (preg_match('/^((.+?)(=))/', $urls, $matches) == 1)
{
$urlsArr = preg_split('/,'.preg_quote($matches[0], '/').'/', $urls, -1, PREG_SPLIT_NO_EMPTY);
foreach ($urlsArr as $url)
{
if ($matches[0] != 'url=')
{
$url = ($url != $urlsArr[0]) ? $matches[0].$url : $url;
$urlBase = preg_replace('/(.+?)(url=)(.+?)(\?)(.+)/', "$3$4", $url);
$urlParams = preg_replace('/(.+?)(url=)(.+?)(\?)(.+)/', "$1$5", $url);
$url = $urlBase . "&" . $urlParams;
}
else
{
$url = preg_replace('/^(url=)/', "", $url);
}
$url = preg_replace('/(.*)(itag=\d+&)(.*?)/', '$1$3', $url, 1);
if (preg_match('/quality=small/', $url) != 1)
{
$url = preg_replace('/&sig=|&s=/', "&signature=", $url);
$url = trim($url, ',');
$url .= '&title=' . urlencode($this->ExtractSongTrackName($file_contents, $vidSrcTypes[0]));
$url = preg_replace_callback('/(&type=)(.+?)(&)/', function($match){return $match[1].urlencode($match[2]).$match[3];}, $url);
if ($cypherUsed)
{
$urlParts = parse_url($url);
parse_str($urlParts['query'], $vars);
//echo $vars['signature'] . "\n\n";
$vars['signature'] = $this->DecryptYouTubeCypher($vars['signature']);
//die($vars['signature'] . "\n\n");
$queryStr = http_build_query($vars, '', '&');
$url = $urlParts['scheme'] . '://' . $urlParts['host'] . $urlParts['path'] . '?' . $queryStr;
}
$vidUrls[] = $url;
}
}
$vidUrls = array_reverse($vidUrls);
//die(print_r($vidUrls));
}
}
}
$this->_flvUrls = $vidUrls;
}
public function GetAudioQualities()
{
return $this->_audioQualities;
}
private function GetTempVidFileName()
{
return $this->_tempVidFileName;
}
private function SetTempVidFileName()
{
$this->_tempVidFileName = parent::_TEMPVIDDIR . $this->_uniqueID .'.flv';
}
public function GetVidSrcTypes()
{
return $this->_vidSrcTypes;
}
public function GetUniqueID()
{
return $this->_uniqueID;
}
#endregion
}
?>Last edited by chump2877; Jun 21, 2013, 07:25 PM.Regards, R.J.
---------------------------------------------------------
Help spread the word! Like our YouTube-to-Mp3 Conversion Script on Facebook !! :-)
[Instructional videos and tutorials are also available on YouTube, Dailymotion, and Vimeo]
Explore all products and services, view demos, review documentation, check prices, and more!
♪♪ …Need Web Hosting For Our YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪
Comment
-
-
The new (updated and hopefully stable) distribution of files is located at the bottom of this post.
PLEASE SEE THIS POST FOR IMPORTANT INFO REGARDING THE USE AND INSTALLATION OF THIS SCRIPT.
DO NOT USE THE ZIP DISTRIBUTION LOCATED AT THE ABOVE LINKED PAGE. USE ONLY THE ZIP FILE ATTACHED TO THE BOTTOM OF THIS POST.
1) This fix addresses another problem with the conversion of Vevo videos.
Only YouTubeToMp3Converter.class.php was modified, and (since the last update) only code in the existing SetFlvUrls() method and the new DecryptYouTubeCypher() method was updated.
I will soon be updating the paid-for version of the app as well, and I will email an updated (free) copy to all those who have already purchased the script. (Updates will be sent to your Tradebit email addresses only.)
As always, please let me know if you have any questions/concerns regarding the above and/or the code.Attached FilesRegards, R.J.
---------------------------------------------------------
Help spread the word! Like our YouTube-to-Mp3 Conversion Script on Facebook !! :-)
[Instructional videos and tutorials are also available on YouTube, Dailymotion, and Vimeo]
Explore all products and services, view demos, review documentation, check prices, and more!
♪♪ …Need Web Hosting For Our YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪
Comment
-
-
new version works!
very nice, thanks for updating!
Comment
-
-
Hello everyone,
I have just finished updating the paid-for version of my software. New in this version:
- Fix to address another problem with the conversion of Vevo videos.
The following files/directories were changed/added:- VideoConverter.class.php updated
Only VideoConverter.class.php was updated, and (since the last update) only code in the SetVidSourceUrls(), DecryptYouTubeCypher(), and PrepareYouTubeDownloadLink() methods was changed/added.
All previous customers who have purchased the paid-for version of my app are receiving this new, updated version via the e-mail addresses that you provided at Tradebit.com.
Please report any issues with either the paid-for version or the free version in this forum thread. Your feedback is encouraged. Donations are welcome!
Thanks!Regards, R.J.
---------------------------------------------------------
Help spread the word! Like our YouTube-to-Mp3 Conversion Script on Facebook !! :-)
[Instructional videos and tutorials are also available on YouTube, Dailymotion, and Vimeo]
Explore all products and services, view demos, review documentation, check prices, and more!
♪♪ …Need Web Hosting For Our YouTube-To-Mp3 Conversion Software? Check Here !!… ♪♪
Comment
Comment