Пример #1
0
 public function downloadVideo($videoLink, $fileName)
 {
     require 'youtube-dl.class.php';
     $downloadDir = realpath(sprintf('%s/../data/downloads/', APPLICATION_PATH));
     $ffmpegLogsDir = realpath(sprintf('%s/../data/logs/', APPLICATION_PATH));
     $youtubeDownloader = new yt_downloader($videoLink['video_link']);
     $youtubeDownloader->set_downloads_dir($downloadDir . DIRECTORY_SEPARATOR);
     $youtubeDownloader->set_ffmpegLogs_dir($ffmpegLogsDir . DIRECTORY_SEPARATOR);
     $youtubeDownloader->set_download_thumbnail(false);
     $youtubeDownloader->set_video_title($fileName);
     //        $youtubeDownloader->download_video(); exit;
     $youtubeDownloader->download_audio();
     $audioFileName = $youtubeDownloader->get_video_title();
     return sprintf('%s.mp3', $audioFileName);
 }