public function getData($filename)
 {
     $this->filename = $filename;
     $getId3 = new GetId3();
     $audio = $getId3->setOptionMD5Data(true)->setOptionMD5DataSource(true)->setEncoding('UTF-8')->analyze($filename);
     if (isset($audio['error'])) {
         throw new NotFoundHttpException(sprintf('Error at reading audio properties from "%s" with GetId3: %s.', $filename, $audio['error']));
     }
     return $audio;
 }
Example #2
0
 public function getData($filename)
 {
     $this->filename = $filename;
     $getId3 = new GetId3();
     $audio = $getId3->setOptionMD5Data(true)->setOptionMD5DataSource(true)->setEncoding('UTF-8')->analyze($filename);
     if (isset($audio['error'])) {
         $error = is_array($audio['error']) ? implode(';', $audio['error']) : $audio['error'];
         throw new \InvalidArgumentException(sprintf('Error at reading audio properties from "%s" with GetId3: %s.', $filename, $error));
     }
     return $audio;
 }
 public function getMetadata(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return;
     }
     $format = 'reference';
     $getId3 = new GetId3();
     $audio = $getId3->setOptionMD5Data(true)->setOptionMD5DataSource(true)->setEncoding('UTF-8')->analyze($media->getBinaryContent()->getPathname());
     /*echo "<pre>";
       print_r($audio);
       echo "</pre>";
       exit();*/
     $metadata = array('image_src' => $this->getMetadataImage($audio), 'image_mime' => $this->getMetadataImageMimeTypes($audio), 'encoding' => $audio['encoding'], 'filesize' => $audio['filesize'], 'mime_type' => $audio['mime_type'], 'fileformat' => $audio['fileformat'], 'playtime_seconds' => $audio['playtime_seconds'], 'playtime_string' => $audio['playtime_string'], 'dataformat' => $audio['audio']['dataformat'], 'channels' => $audio['audio']['channels'], 'sample_rate' => $audio['audio']['sample_rate'], 'bitrate' => $audio['audio']['bitrate'], 'channelmode ' => $audio['audio']['channelmode'], 'bitrate_mode' => $audio['audio']['bitrate_mode'], 'title' => $this->getMetadataTitle($audio), 'comment' => $this->getMetadataComment($audio), 'artist' => $this->getMetadataArtist($audio), 'album' => $this->getMetadataAlbum($audio), 'year' => $this->getMetadataAlbumYear($audio), 'track_number' => $this->getMetadataTrackNumber($audio), 'genre' => $this->getMetadataGenre($audio));
     return $metadata;
 }
Example #4
0
 public function getMetadata(MediaInterface $media)
 {
     if (!$media->getBinaryContent()) {
         return;
     }
     $format = 'reference';
     $getId3 = new GetId3();
     $fileinfo = $getId3->setOptionMD5Data(true)->setOptionMD5DataSource(true)->setEncoding('UTF-8')->analyze($media->getBinaryContent()->getPathname());
     $metadata = array('src' => $this->generatePublicUrl($media, $format), 'filesize' => $fileinfo['filesize'], 'fileformat' => $fileinfo['fileformat'], 'encoding' => $fileinfo['encoding'], 'mime_type' => $fileinfo['mime_type'], 'playtime_seconds' => $fileinfo['playtime_seconds'], 'playtime_string' => $fileinfo['playtime_string'], 'bitrate' => $fileinfo['bitrate'], 'audio_dataformat' => $fileinfo['audio']['dataformat'], 'audio_codec' => isset($fileinfo['audio']['codec']) ? $fileinfo['audio']['codec'] : '', 'audio_sample_rate' => $fileinfo['audio']['sample_rate'], 'audio_channels' => $fileinfo['audio']['channels'], 'audio_bits_per_sample' => isset($fileinfo['audio']['bits_per_sample']) ? $fileinfo['audio']['bits_per_sample'] : '', 'audio_lossless' => isset($fileinfo['audio']['lossless']) ? $fileinfo['audio']['lossless'] : '', 'audio_channelmode' => isset($fileinfo['audio']['channelmode']) ? $fileinfo['audio']['channelmode'] : '', 'video_dataformat' => $fileinfo['video']['dataformat'], 'video_resolution_x' => $fileinfo['video']['resolution_x'], 'video_resolution_y' => $fileinfo['video']['resolution_y'], 'video_fourcc' => isset($fileinfo['video']['fourcc']) ? $fileinfo['video']['fourcc'] : '', 'video_frame_rate' => $fileinfo['video']['frame_rate'], 'video_codec' => isset($fileinfo['video']['codec']) ? $fileinfo['video']['codec'] : '');
     /*echo "<pre>";
       print_r($metadata);
       print_r($fileinfo);
       echo "</pre>";
       exit();*/
     return $metadata;
 }
Example #5
0
 /**
  * @return GetId3
  */
 protected function getId3()
 {
     if ($this->id3 === null) {
         $this->id3 = new GetId3();
         $this->id3->setOptionMD5Data(true)->setOptionMD5DataSource(true)->setEncoding('UTF-8');
     }
     return $this->id3;
 }
 private function analyzeAudioFile($path)
 {
     $id3Analyzer = new GetId3();
     $id3data = $id3Analyzer->analyze($path);
     $metadata = [];
     if (array_key_exists('tags', $id3data)) {
         $tags = $id3data['tags'];
         $flat = function (array $arr) {
             $newArr = [];
             foreach ($arr as $k => $v) {
                 $newArr[$k] = is_array($v) ? $v[0] : $v;
             }
             return $newArr;
         };
         $metadata = array_key_exists('id3v2', $tags) ? $flat($tags['id3v2']) : (array_key_exists('id3v1', $tags) ? $flat($tags['id3v1']) : []);
     }
     return $metadata;
 }
 private function createAnalyzer()
 {
     $analyzer = new MediaAnalyzer();
     $analyzer->setOptionMD5Data(true)->setOptionMD5DataSource(true)->setEncoding('UTF-8');
     return $analyzer;
 }
 protected function retrieveId3Info($file)
 {
     $object = array();
     if (file_exists($file)) {
         // Getting ID3 of media
         $getID3 = new GetId3();
         $ThisFileInfo = $getID3->analyze($file);
         $len = @$ThisFileInfo['playtime_string'];
         if ($len != null) {
             $object['duration'] = $len;
         }
     }
     return $object;
 }
Example #9
0
 function fileInfo(FileModel $file, $suffix = false)
 {
     if ($suffix) {
         $_filename = explode('.', $file->filename);
         $file->filename = implode('.', [$_filename[0], $suffix, $_filename[1]]);
     }
     $path = storage_path('app/' . $file->filename);
     $_file = File::get($path);
     $type = File::mimeType($path);
     $getId3 = new GetId3();
     $mimeType = $getId3->analyze($path)['mime_type'];
     return ['file' => $_file, 'type' => $mimeType, 'path' => $path];
 }
 public function download()
 {
     $input = Input::get('item');
     Kint::dump($input);
     $item = Item::find($input);
     /*
      * Notes:
      * 12/19/2010 and before (Session IDs 1 - 386):  On Dot 5 Hosting site at 128kbps.
      * After 12/19/2010 - 04/17/2011 (Session IDs 387 - 430):  On Dot 5 Hosting site at 64kbps.
      * After 04/17/2011 (Session IDs 431 and greater):  On Dreamhost site at 64kbps.
      */
     if ($item->id < 387) {
         $dl_url = 'http://www.workshopmultimedia.com/memorial_drive/' . str_ireplace('.mp3', '', $item->filename_base) . '_128kbps.mp3';
     } elseif ($item->id < 431) {
         $dl_url = 'http://www.workshopmultimedia.com/memorial_drive/' . str_ireplace('.mp3', '', $item->filename_base) . '_64kbps.mp3';
     } else {
         $dl_url = 'http://www.workshopmultimedia.net/memorial_drive/' . str_ireplace('.mp3', '', $item->filename_base) . '_64kbps.mp3';
     }
     // Update the download count
     $item->num_downloads += 1;
     $item->save();
     $id3 = new GetId3();
     $audio = $id3->setOptionMD5Data(TRUE)->setOptionMD5DataSource(TRUE)->setEncoding('UTF-8')->analyze($dl_url);
     Kint::dump($audio);
     //if ( !isset($audio['error']) )
     return Response::download($dl_url, urlencode($item->session_title . ' - ' . $item->speaker_name . ' - ' . $item->session_date . '.mp3'));
 }
Example #11
0
 public function songconfirmAction()
 {
     // Handle files submitted directly to page.
     $ignore_files = (int) $this->getParam('ignore_files');
     $request = $this->di->get('request');
     if ($request->hasFiles() && !$ignore_files) {
         $this->_processSongUpload();
     }
     // Validate song identifier token.
     $token = $this->_getSongHashToken();
     if (!$this->_validateSongHash($token)) {
         return $this->redirectFromHere(array('action' => 'song'));
     }
     // Check that any stations were selected
     if (!$this->hasParam('stations')) {
         throw new \DF\Exception\DisplayOnly('You did not specify any stations!');
     }
     // Check for uploaded songs.
     $temp_dir_name = 'song_uploads';
     $temp_dir = DF_INCLUDE_TEMP . DIRECTORY_SEPARATOR . $temp_dir_name;
     $all_files = glob($temp_dir . DIRECTORY_SEPARATOR . $token . '*.mp3');
     if (empty($all_files)) {
         throw new \DF\Exception\DisplayOnly('No files were uploaded!');
     }
     $songs = array();
     $getId3 = new GetId3();
     $getId3->encoding = 'UTF-8';
     foreach ($all_files as $song_file_base) {
         $song_file_path = $temp_dir . DIRECTORY_SEPARATOR . basename($song_file_base);
         // Attempt to analyze the MP3.
         $audio = $getId3->analyze($song_file_path);
         if (isset($audio['error'])) {
             @unlink($song_file_path);
             throw new \DF\Exception\DisplayOnly(sprintf('Error at reading audio properties with GetId3: %s.', $audio['error'][0]));
         }
         if (isset($audio['tags']['id3v1']['title'])) {
             $song_data = array('title' => $audio['tags']['id3v1']['title'][0], 'artist' => $audio['tags']['id3v1']['artist'][0]);
         } elseif (isset($audio['tags']['id3v2']['title'])) {
             $song_data = array('title' => $audio['tags']['id3v2']['title'][0], 'artist' => $audio['tags']['id3v2']['artist'][0]);
         } else {
             @unlink($song_file_path);
             continue;
         }
         // Check if existing submission exists.
         $song = Song::getOrCreate($song_data);
         $existing_submission = SongSubmission::getRepository()->findOneBy(array('hash' => $song->id));
         if ($existing_submission instanceof SongSubmission) {
             @unlink($song_file_path);
             continue;
         }
         // Create record in database.
         $metadata = array('File Format' => strtoupper($audio['fileformat']), 'Play Time' => $audio['playtime_string'], 'Bitrate' => round($audio['audio']['bitrate'] / 1024) . 'kbps', 'Bitrate Mode' => strtoupper($audio['audio']['bitrate_mode']), 'Channels' => $audio['audio']['channels'], 'Sample Rate' => $audio['audio']['sample_rate']);
         $record = new SongSubmission();
         $record->song = $song;
         $auth = $this->di->get('auth');
         $record->user = $auth->getLoggedInUser();
         $record->title = $song_data['title'];
         $record->artist = $song_data['artist'];
         $record->song_metadata = $metadata;
         $record->stations = $this->getParam('stations');
         $song_download_url = $record->uploadSong($song_file_path);
         $record->save();
         // Append information to e-mail to stations.
         $song_row = array('Download URL' => '<a href="' . $song_download_url . '" target="_blank">' . $song_download_url . '</a>', 'Title' => $song_data['title'], 'Artist' => $song_data['artist']) + $metadata;
         $songs[] = $song_row;
     }
     if (!empty($songs)) {
         // Notify all existing managers.
         $network_administrators = Action::getUsersWithAction('administer all');
         $email_to = Utilities::ipull($network_administrators, 'email');
         // Pull list of station managers for the specified stations.
         $station_managers = array();
         $short_names = Station::getShortNameLookup();
         foreach ($this->getParam('stations') as $station_key) {
             if (isset($short_names[$station_key])) {
                 $station_id = $short_names[$station_key]['id'];
                 $station = Station::find($station_id);
                 foreach ($station->managers as $manager) {
                     $station_managers[] = $manager->email;
                 }
             }
         }
         $email_to = array_merge($email_to, $station_managers);
         // Trigger e-mail notice.
         if (!empty($email_to)) {
             \DF\Messenger::send(array('to' => $email_to, 'subject' => 'New Song(s) Submitted to Station', 'template' => 'newsong', 'vars' => array('songs' => $songs)));
         }
     }
     // Have to manually call view because a view was already rendered (e-mail was sent).
     // TODO: Fix this. It's dumb.
     $this->view->songs = $songs;
     return $this->view->render('submit', 'songconfirm');
 }