ChaoscripT
Active Member
Hi,
I have youtubetomp3 site, www.YoutubeToMP3.me,
Now I have problem with videos that contain unusual chars, like
etc.
Here is the 2 functions that Saved the name from youtube:
Regards.
I have youtubetomp3 site, www.YoutubeToMP3.me,
Now I have problem with videos that contain unusual chars, like
PHP:
";,/
Here is the 2 functions that Saved the name from youtube:
PHP:
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 && eregi('eow-title',$vidSrc))
{
$name = end(explode('eow-title',$vidSrc));
$name = current(explode('">',$name));
$name = end(explode('title="',$name));
}
}
return $name;
}
PHP:
private function SetSongFileName($file_contents)
{
$vidSrcTypes = $this->GetVidSrcTypes();
$trackName = $this->ExtractSongTrackName($file_contents, $vidSrcTypes[0]);
return $this->_songFileName = (!empty($trackName)) ? self::_SONGFILEDIR . preg_replace('/_{2,}/','_',preg_replace('/ /','_',preg_replace('/^[A-Za-z0-9]+$/','',$trackName))) . '.mp3' : '';
}
Regards.