function add($item) { global $config; if ($item['url']) { // this is a remote file if ($config['httpStreaming']) { $lines = file($item['url']); foreach ($lines as $line) { if (!empty($line)) { $this->audioFiles[] = array('url' => $line); } } } else { // nothing to do // not tested for Tamburine } } else { // this is a local file // CHANGED BY BUDDHAFLY 06-02-20 if (!in_array(sotf_File::getExtension($item['path']), $config['skipGetID3FileTypes'])) { $getID3 = new getID3(); $mp3info = $getID3->analyze($item['path']); getid3_lib::CopyTagsToComments($mp3info); } else { $fileinfo['video'] = true; } //$mp3info = GetAllFileInfo($item['path']); //debug('mp3info', $mp3info); // CHANGED BY BUDDHAFLY 06-02-20 $bitrate = (string) $mp3info['bitrate']; if (!$bitrate) { raiseError("Could not determine bitrate, maybe this audio is temporarily unavailable"); } $item['bitrate'] = $bitrate; if ($config['httpStreaming']) { //$tmpFileName = 'au_' . $item['id'] . '_' . ($item['name'] ? $item['name'] : basename($item['path'])); $tmpFileName = 'au_' . $item['id'] . '_' . basename($item['path']); $tmpFile = $config['tmpDir'] . "/{$tmpFileName}"; $file = @readlink($tmpFile); if ($file) { if (!is_readable($file)) { logError("Bad symlink: {$tmpFile} to {$file}"); unlink($tmpFile); $file = false; } } if (!$file) { if (!symlink($item['path'], $tmpFile)) { raiseError("symlink failed in tmp dir"); } } $item['url'] = $config['tmpUrl'] . "/{$tmpFileName}"; } $this->totalLength += $mp3info["playtime_seconds"]; $this->audioFiles[] = $item; } }
/** * Adds a file to the list. * * @param string $path Path of the file to add to the list * @return boolean If the file was successfully added to the list return true, else false */ function add($path) { global $config; $path = realpath(trim($path)); if (is_file($path)) { if (!$this->pathExist($path)) { $oggaudio = false; $getid3_skipped = false; if (sotf_File::getExtension($path) == 'ogg') { $getID3 = new getID3(); $fileinfo = $getID3->analyze($path); getid3_lib::CopyTagsToComments($fileinfo); if (isset($fileinfo['audio']) && !isset($fileinfo['video'])) { $oggaudio = true; } else { $getid3_skipped = true; } } else { if (!in_array(sotf_File::getExtension($path), $config['skipGetID3FileTypes'])) { // CHANGED BY BUDDHAFLY 06-02-14 $getID3 = new getID3(); $fileinfo = $getID3->analyze($path); getid3_lib::CopyTagsToComments($fileinfo); //$fileinfo = GetAllFileInfo($this->path); } else { $getid3_skipped = true; } } if (!$oggaudio && $getid3_skipped) { $fileinfo['video'] = true; } //$audioinfo = GetAllFileInfo($path); if (isset($fileinfo["video"])) { $this->list[] =& new sotf_VideoFile($path, $fileinfo); } else { if (isset($fileinfo["audio"])) { $this->list[] =& new sotf_AudioFile($path, $fileinfo); } else { $this->list[] =& new sotf_File($path); } } // if-elseif-else } //if } //if return false; }
function fileOK($file) { global $config; if (!in_array(sotf_File::getExtension($file), $config['skipGetID3FileTypes'])) { $getID3 = new getID3(); $fileinfo = $getID3->analyze($file); getid3_lib::CopyTagsToComments($fileinfo); } else { $fileinfo['video'] = true; } if (!is_readable($file) || filesize($file) == 0 || !isset($fileinfo['audio'])) { return false; } return true; }
function saveID3($file) { global $config; if (!in_array(sotf_File::getExtension($this->path), $config['skipGetID3FileTypes'])) { return; } $fileInfo = $file->allInfo; //----------------- CHANGED BY BUDDHAFLY 06-02-19 $id3 = $fileInfo['id3v1']; require_once $config['getid3dir'] . "/write.php"; $tagwriter = new getid3_writetags(); $tagwriter->filename = $file; $TagData['comment'][] = "id: " . $this->id; debug("writing ID3V1", $id3); // write tags if ($tagwriter->WriteTags()) { //echo 'Successfully wrote tags<br>'; if (!empty($tagwriter->warnings)) { logError('Wrtiting ID3V1 Tags: There were some warnings:<br>' . implode('<br><br>', $tagwriter->warnings)); } } else { logError("Could not change ID3V1 tags in file " . $file->path); } //--------------------------------------------------- /* //$id3['comment'] = substr(substr($config['rootUrl'], 7), 0, 30); $id3['comment'] = "id: " . $this->id; //$id3['album'] = "id: " . $this->id; //if(!$id3['title']) // $id3['title'] = substr($this->get('title'), 0, 30); //if(!$id3['artist']) // $id3['artist'] = substr($this->getCreatorNames(), 0, 30); debug("writing ID3V1", $id3); //$succ = WriteID3v1($file->path, $id3['title'], $id3['artist'], $id3['album'], $id3['year'], $id3['comment'], $id3['genre'], NULL /*track*/ /*); $succ = WriteID3v1($file->path, $id3['comment'], NULL /*track*/ /*); if(!$succ) logError("Could not change ID3V1 tags in file ". $file->path); */ }
function getTotalFrames($source, $index) { global $config; if (!in_array(sotf_File::getExtension($source), $config['skipGetID3FileTypes'])) { $getID3 = new getID3(); $fileinfo = $getID3->analyze($source); getid3_lib::CopyTagsToComments($fileinfo); $totalframes = round($fileinfo["playtime_seconds"] * $config['videoFormats'][$index]['framerate']); return $totalframes; } else { return -1; } }
/** * Sets up sotf_AudioFile object * * @constructor sotf_AudioFile * @param string $path Path of the file */ function sotf_VideoFile($path, $fileinfo = '') { global $config; $parent = get_parent_class($this); parent::$parent($path); // Call the constructor of the parent class. lk. super() if (!in_array(sotf_File::getExtension($path), $config['skipGetID3FileTypes'])) { // CHANGED BY BUDDHAFLY 06-02-14 $getID3 = new getID3(); $fileinfo = $getID3->analyze($path); getid3_lib::CopyTagsToComments($fileinfo); //print_r_html($fileinfo); //$fileinfo = GetAllFileInfo($this->path); } else { $fileinfo['video'] = true; } if ($fileinfo) { $this->allInfo = $fileinfo; } //was $fileInfo //if ($audioinfo["fileformat"] == 'mp3' || $audioinfo["fileformat"] == 'ogg') { //debug("finfo", $fileinfo); if (!in_array(sotf_File::getExtension($path), $config['skipGetID3FileTypes'])) { $videoinfo = $fileinfo['video']; $this->type = "video"; //$this->format = $fileinfo["fileformat"]; $this->format = $videoinfo["dataformat"]; if ($this->format == "quicktime") { $this->format = "mov"; } if ($fileinfo['quicktime']['ftyp']['signature'] == "3gp4") { $this->format = "3gp"; } else { if ($this->format == "mpeg4") { $this->format = "mp4"; } } if ($this->format == "asf") { $this->format = "wmv"; } if ($this->format == "mpeg") { $this->format = "mpg"; } if ($videoinfo["bitrate_mode"] == 'vbr') { $this->bitrate = "VBR"; } $this->bitrate = round($fileinfo["bitrate"] / 1000); $this->average_bitrate = round($fileinfo["bitrate"] / 1000); $this->duration = round($fileinfo["playtime_seconds"]); $this->mimetype = $this->determineMimeType($this->format); $this->codec = $videoinfo["codec"]; $this->frame_rate = round($videoinfo["frame_rate"]); $this->resolution_x = $videoinfo["resolution_x"]; $this->resolution_y = $videoinfo["resolution_y"]; $this->lossless = $videoinfo["lossless"]; $this->pixel_aspect_ratio = $videoinfo["pixel_aspect_ratio"]; if (isset($fileinfo['audio'])) { $audioinfo = $fileinfo['audio']; if ($audioinfo["sample_rate"]) { $this->samplerate = $audioinfo["sample_rate"]; } else { $this->samplerate = 0; } if ($audioinfo["channels"]) { $this->channels = $audioinfo["channels"]; } else { $this->channels = 0; } } else { $this->samplerate = 0; $this->channels = 0; } } else { if (isset($fileinfo['video'])) { $this->type = "video"; $this->format = sotf_File::getExtension($path); $this->mimetype = $config['mimetypes']['format']; $this->bitrate = 0; $this->samplerate = 0; $this->channels = 0; } } }
} $page->forceLogin(); $okURL = sotf_Utils::getParameter('okURL'); // delete topic $delTopic = sotf_Utils::getParameter('deltopic'); if ($delTopic) { $vocabularies->delFromTopic($delTopic); $page->redirect("editMeta.php?id={$prgId}#topics"); exit; } $prg =& new sotf_Programme($prgId); // ---- changed by wolfgang csacsinovits and martin schmidt GET ID3 TAGS and write into Metadata - Fields $audioFiles = $prg->listAudioFiles('true'); $file = $prg->getAudioDir() . '/' . $audioFiles[0]['filename']; if ($new) { if (!in_array(sotf_File::getExtension($file), $config['skipGetID3FileTypes'])) { $getID3 = new getID3(); $ThisFileInfo = $getID3->analyze($file); getid3_lib::CopyTagsToComments($ThisFileInfo); } else { $fileinfo['video'] = true; } //$ThisFileInfo = GetAllFileInfo($file, 'mp3', false, false, false) ; if ($ThisFileInfo['comments']['title'] != '') { $title = implode(', ', $ThisFileInfo['comments']['title']); } if ($ThisFileInfo['comments']['artist'] != '') { $artist = implode(', ', $ThisFileInfo['comments']['artist']); } if ($ThisFileInfo['comments']['genre'] != '') { $genre = implode(', ', $ThisFileInfo['comments']['genre']);
/** * Sets up sotf_AudioFile object * * @constructor sotf_AudioFile * @param string $path Path of the file */ function sotf_AudioFile($path, $fileinfo = '') { global $config; $parent = get_parent_class($this); parent::$parent($path); // Call the constructor of the parent class. lk. super() $oggaudio = false; $getid3_skipped = false; if (sotf_File::getExtension($this->path) == 'ogg') { $getID3 = new getID3(); $fileinfo = $getID3->analyze($this->path); getid3_lib::CopyTagsToComments($fileinfo); if (isset($fileinfo['audio']) && !isset($fileinfo['video'])) { $oggaudio = true; } else { $getid3_skipped = true; } } else { if (!in_array(sotf_File::getExtension($this->path), $config['skipGetID3FileTypes'])) { // CHANGED BY BUDDHAFLY 06-02-14 $getID3 = new getID3(); $fileinfo = $getID3->analyze($this->path); getid3_lib::CopyTagsToComments($fileinfo); //$fileinfo = GetAllFileInfo($this->path); } else { $getid3_skipped = true; } } if (!$oggaudio && $getid3_skipped) { $fileinfo['video'] = true; } if ($fileinfo) { $this->allInfo = $fileinfo; } //was $fileInfo //if ($audioinfo["fileformat"] == 'mp3' || $audioinfo["fileformat"] == 'ogg') { //debug("finfo", $fileinfo); //print_r($fileinfo); // ADDED BY BUDDHAFLY 06-02-20 if (isset($fileinfo['video']) && $fileinfo['video']['dataformat'] != "jpg") { $this->type = "video"; } else { if (isset($fileinfo['audio'])) { $this->type = "audio"; } } if (isset($fileinfo['audio'])) { $audioinfo = $fileinfo['audio']; // ADDED BY BUDDHAFLY 06-02-20 if (isset($fileinfo['video'])) { $this->type = "video"; } else { // ADDED BY BUDDHAFLY 06-02-20 $this->type = "audio"; } //$this->format = $fileinfo["fileformat"]; $this->format = $fileinfo["fileformat"]; if ($audioinfo["bitrate_mode"] == 'vbr') { $this->bitrate = "VBR"; } $this->bitrate = round($audioinfo["bitrate"] / 1000); $this->average_bitrate = round($audioinfo["bitrate"] / 1000); $this->samplerate = $audioinfo["sample_rate"]; $this->channels = $audioinfo["channels"]; $this->duration = round($fileinfo["playtime_seconds"]); $this->mimetype = $this->determineMimeType($this->format); } }
exit; } // delete prog if (sotf_Utils::getParameter('delprog')) { $prgid = sotf_Utils::getParameter('prgid'); $prg = new sotf_Programme($prgid); $prg->delete(); $page->redirect("editor.php"); exit; } if (sotf_Utils::getParameter('addprog')) { $fname = sotf_Utils::getParameter('fname'); $station = sotf_Utils::getParameter('station'); checkPerm($station, 'create'); //ADDED BY BUDDHAFLY if (!in_array(sotf_File::getExtension($user->getUserDir() . '/' . $fname), $config['skipGetID3FileTypes'])) { $getID3 = new getID3(); $fileinfo = $getID3->analyze($user->getUserDir() . '/' . $fname); getid3_lib::CopyTagsToComments($fileinfo); } else { $fileinfo['video'] = true; } if (isset($fileinfo['video'])) { $is_video = true; } //-------------------------------------------- //logError(print_r($fileinfo, true)); $newPrg = new sotf_Programme(); $track = preg_replace('/\\.[^.]*$/', '', $fname); debug("create with track", $track); $newPrg->create($station, $track, $is_video);