Changed import script and the HTML UI to use the same metadata import mechanism. This should fix .

This commit is contained in:
paul 2006-10-25 20:56:42 +00:00
parent 620cc4d93d
commit 593e499a96
3 changed files with 289 additions and 208 deletions
campcaster/src/modules
htmlUI/var
storageAdmin/var
storageServer/var

View File

@ -35,9 +35,9 @@ class uiHandler extends uiBase {
#$this->_cleanArray($_SESSION);
if (!$this->_validateForm($formdata, $mask)) {
$_SESSION['retransferFormData']['login'] = $formdata['login'];
$_SESSION['retransferFormData']['login'] = $formdata['login'];
$_SESSION['retransferFormData']['langid'] = $formdata['langid'];
$_SESSION['retransferFormData']['pass'] = "\n";
$_SESSION['retransferFormData']['pass'] = "\n";
$this->redirUrl = UI_BROWSER.'?popup[]=login';
return FALSE;
}
@ -46,9 +46,9 @@ class uiHandler extends uiBase {
if (!$sessid || PEAR::isError($sessid)){
$this->_retMsg('Login failed.');
$_SESSION['retransferFormData']['login'] = $formdata['login'];
$_SESSION['retransferFormData']['login'] = $formdata['login'];
$_SESSION['retransferFormData']['langid'] = $formdata['langid'];
$_SESSION['retransferFormData']['pass'] = "\n";
$_SESSION['retransferFormData']['pass'] = "\n";
$this->redirUrl = UI_BROWSER.'?popup[]=login';
return FALSE;
}
@ -61,7 +61,7 @@ class uiHandler extends uiBase {
if (PEAR::isError($id)) {
$this->_retMsg('Access to home directory failed.');
$_SESSION['retransferFormData']['login']=$formdata['login'];
$_SESSION['retransferFormData']['login'] = $formdata['login'];
$this->redirUrl = UI_BROWSER.'?popup[]=login';
return FALSE;
}
@ -127,15 +127,26 @@ class uiHandler extends uiBase {
return FALSE;
}
$metadata = camp_get_audio_metadata($formdata['mediafile']['tmp_name']);
if (PEAR::isError($metadata)) {
$this->_retMsg($metadata->getMessage());
$this->redirUrl = UI_BROWSER."?act=addFileData&folderId=".$formdata['folderId'];
return FALSE;
}
$tmpgunid = md5(microtime().$_SERVER['SERVER_ADDR'].rand()."org.mdlf.campcaster");
$ntmp = $this->gb->bufferDir.'/'.$tmpgunid;
move_uploaded_file($formdata['mediafile']['tmp_name'], $ntmp);
chmod($ntmp, 0664);
// echo "buffer dir: ".$this->gb->bufferDir."<BR>";
// echo "$ntmp <br>";
// print_r($formdata);
// exit;
$r = $this->gb->putFile($folderId, $formdata['mediafile']['name'], $ntmp, NULL, $this->sessid, $replace);
@unlink($ntmp);
if(PEAR::isError($r)) {
if (PEAR::isError($r)) {
$this->_retMsg($r->getMessage());
$this->redirUrl = UI_BROWSER."?act=editFile&id=".$id;
return FALSE;
@ -177,37 +188,38 @@ class uiHandler extends uiBase {
*/
function transMData($id, $langid=UI_DEFAULT_LANGID)
{
include dirname(__FILE__).'/formmask/metadata.inc.php';
include(dirname(__FILE__).'/formmask/metadata.inc.php');
$ia = $this->gb->analyzeFile($id, $this->sessid);
if (PEAR::isError($ia)) {
$this->_retMsg($ia->getMessage());
return;
}
$this->_setMdataValue($id, UI_MDATA_KEY_DURATION, $this->gb->_secsToPlTime($ia['playtime_seconds']));
$this->_setMDataValue($id, UI_MDATA_KEY_FORMAT, UI_MDATA_VALUE_FORMAT_FILE);
// some data from raw audio
if ($ia['audio']['channels']) {
$this->_setMDataValue($id, UI_MDATA_KEY_CHANNELS, $ia['audio']['channels']);
if (isset($ia['audio']['channels'])) {
$this->_setMDataValue($id, UI_MDATA_KEY_CHANNELS, $ia['audio']['channels']);
}
if ($ia['audio']['sample_rate']) {
if (isset($ia['audio']['sample_rate'])) {
$this->_setMDataValue($id, UI_MDATA_KEY_SAMPLERATE, $ia['audio']['sample_rate']);
}
if ($ia['audio']['bitrate']) {
$this->_setMDataValue($id, UI_MDATA_KEY_BITRATE, $ia['audio']['bitrate']);
if (isset($ia['audio']['bitrate'])) {
$this->_setMDataValue($id, UI_MDATA_KEY_BITRATE, $ia['audio']['bitrate']);
}
if ($ia['audio']['codec']) {
$this->_setMDataValue($id, UI_MDATA_KEY_ENCODER, $ia['audio']['codec']);
if (isset($ia['audio']['codec'])) {
$this->_setMDataValue($id, UI_MDATA_KEY_ENCODER, $ia['audio']['codec']);
}
// from id3 Tags
foreach ($mask['pages'] as $key=>$val) { ## loop main, music, talk
foreach ($mask['pages'][$key] as $k=>$v) { ## loop throught elements
if (is_array($v['id3'])) {
foreach ($v['id3'] as $name) { ## loop throught list of equivalent id3-tags
$key = strtolower($name);
if ($ia['comments'][$key][0]) {
$this->_setMdataValue($id, $v['element'], str_replace("'", "\\'", utf8_encode($ia['comments'][$key][0])), $langid);
}
}
}
// loop main, music, talk
foreach ($mask['pages'] as $key => $val) {
// loop through elements
foreach ($mask['pages'][$key] as $k => $v) {
if (isset($v['element']) && isset($ia[$v['element']])) {
$this->_setMdataValue($id, $v['element'], $ia[$v['element']], $langid);
}
}
}
}

View File

@ -4,6 +4,7 @@
* @version $Revision$
*/
ini_set('memory_limit', '64M');
set_time_limit(30);
header("Content-type: text/plain");
echo "\n#StorageServer import script:\n";
//echo date('H:i:s')."\n";
@ -23,93 +24,32 @@ if (PEAR::isError($dbc)) {
exit(1);
}
$dbc->setFetchMode(DB_FETCHMODE_ASSOC);
$gb = &new GreenBox($dbc, $config);
$gb =& new GreenBox($dbc, $config);
$testonly = (isset($argv[1]) && $argv[1] == '-t');
$errors = 0;
$g_errors = 0;
$filecount = 0;
function _err($r, $fn, $txt='')
/**
* Print error to the screen and keep a count of number of errors.
*
* @param PEAR_Error $pearErrorObj
* @param string $txt
*/
function import_err($p_pearErrorObj, $txt='')
{
global $errors;
if (PEAR::isError($r)) {
$msg = $r->getMessage()." ".$r->getUserInfo();
} else {
$msg = $txt;
global $g_errors;
if (PEAR::isError($p_pearErrorObj)) {
$msg = $p_pearErrorObj->getMessage()." ".$p_pearErrorObj->getUserInfo();
}
echo "ERROR\n $msg\n";
$errors++;
echo "\nERROR: $msg\n";
if (!empty($txt)) {
echo "ERROR: $txt\n";
}
$g_errors++;
}
$flds = array(
'dc:format' => array(
array('path'=>"['mime_type']", 'ignoreEnc'=>TRUE),
),
'ls:bitrate' => array(
array('path'=>"['bitrate']", 'ignoreEnc'=>TRUE),
),
'dcterms:extent'=> array(
array('path'=>"['playtime_seconds']", 'ignoreEnc'=>TRUE),
),
'dc:title' => array(
array('path'=>"['id3v2']['TIT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v1']", 'dataPath'=>"['title']", 'encPath'=>"['encoding']"),
array('path'=>"['ogg']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['tags']['vorbiscomment']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
),
'dc:creator' => array(
array('path'=>"['id3v2']['TPE1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TP1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v1']", 'dataPath'=>"['artist']", 'encPath'=>"['encoding']"),
array('path'=>"['ogg']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['tags']['vorbiscomment']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
),
'dc:source' => array(
array('path'=>"['id3v2']['TALB'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TAL'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
),
'ls:encoded_by' => array(
array('path'=>"['id3v2']['TENC'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TEN'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['ogg']['comments']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['tags']['vorbiscomment']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
),
'ls:track_num' => array(
array('path'=>"['id3v2']['TRCK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TRK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['ogg']['comments']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['tags']['vorbiscomment']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
),
'ls:genre' => array(
array('path'=>"['id3v1']", 'dataPath'=>"['genre']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TCON'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['comments']['content_type']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
array('path'=>"['ogg']['comments']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['tags']['vorbiscomment']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
),
'ls:channels' => array(
array('path'=>"['audio']['channels']", 'ignoreEnc'=>TRUE),
),
'ls:year' => array(
array('path'=>"['comments']['date']"),
array('path'=>"['ogg']['comments']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['tags']['vorbiscomment']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
),
//'dc:publisher' => array(array('path'=>"['comments']['label']")),
'ls:filename' => array(
array('path'=>"['filename']"),
),
/*
'xx:fileformat' => array(array('path'=>"['fileformat']")),
'xx:filesize' => array(array('path'=>"['filesize']")),
'xx:dataformat' => array(array('path'=>"['audio']['dataformat']")),
'xx:sample_rate'=> array(array('path'=>"['audio']['sample_rate']")),
*/
);
$titleKey = 'dc:title';
$r = $gb->getObjId('import', $gb->storId);
if (PEAR::isError($r)) {
@ -125,26 +65,6 @@ if (is_null($r)) {
}
$parid = $r;
function addMdata($key, $val, $iEnc='iso-8859-1')
{
global $mdata, $titleHaveSet, $titleKey;
#echo "$key($iEnc): $val\n";
if (!is_null($val)) {
$data = $val;
$oEnc = 'UTF-8';
if (function_exists('iconv') && $iEnc != $oEnc) {
$data = $r = @iconv($iEnc, $oEnc, $data);
if ($r === FALSE) {
echo "Warning: convert $key data to unicode failed\n";
$data = $val; // fallback
}
}
if ($key == $titleKey) {
$titleHaveSet = TRUE;
}
$mdata[$key] = trim($data);
}
}
$stdin = fopen('php://stdin', 'r');
while ($filename = fgets($stdin, 2048)) {
@ -154,81 +74,19 @@ while ($filename = fgets($stdin, 2048)) {
continue;
}
echo "$filename: ";
set_time_limit(30);
//$infoFromFile = GetAllFileInfo("$filename", 'mp3');
//prepared for getid3 upgrade:
$getID3 = new getID3;
$infoFromFile = $getID3->analyze("$filename");
//echo "\n".var_export($infoFromFile)."\n"; exit;
if (PEAR::isError($infoFromFile)) {
_err($infoFromFile, $filename);
continue;
}
if (isset($infoFromFile['error'])) {
_err(NULL, $filename, $infoFromFile['error']);
continue;
}
#if(!$infoFromFile['fileformat']){ echo "???\n"; continue; }
if (!$infoFromFile['bitrate']) {
echo "not audio?\n";
continue;
}
$mdata = array();
$titleHaveSet = FALSE;
foreach ($flds as $key => $getid3keys) {
if ($testonly) {
echo "$key\n";
}
foreach ($getid3keys as $getid3key) {
// defaults:
$ignoreEnc = FALSE;
$dataPath = "";
$encPath = "";
$enc = "UTF-8";
extract($getid3key);
$vn = "\$infoFromFile$path$dataPath";
if ($testonly) {
echo " $vn -> ";
}
eval("\$vnFl = isset($vn);");
if ($vnFl) {
eval("\$data = $vn;");
if ($testonly) {
echo "$data\n";
}
if (!$ignoreEnc && $encPath != "") {
$encVn = "\$infoFromFile$path$encPath";
eval("\$encVnFl = isset($encVn);");
if ($encVnFl) {
eval("\$enc = $encVn;");
}
}
if ($testonly) {
echo " ENC=$enc\n";
}
//addMdata($key, $data);
addMdata($key, $data, $enc);
break;
} else {
if ($testonly) {
echo "\n";
}
}
}
}
if ($testonly) {
var_dump($mdata);
}
if (!$titleHaveSet || trim($mdata[$titleKey]) == '') {
addMdata($titleKey, basename($filename));
$mdata = camp_get_audio_metadata($filename, $testonly);
if (PEAR::isError($mdata)) {
import_err($mdata);
continue;
}
unset($mdata['audio']);
unset($mdata['playtime_seconds']);
if (!$testonly) {
$r = $gb->bsPutFile($parid, $mdata['ls:filename'], "$filename", "$storageServerPath/var/emptyMdata.xml", NULL, 'audioclip');
if (PEAR::isError($r)) {
_err($r, $filename);
import_err($r, "Error in bsPutFile()");
echo var_export($mdata)."\n";
continue;
}
@ -236,15 +94,15 @@ while ($filename = fgets($stdin, 2048)) {
$r = $gb->bsSetMetadataBatch($id, $mdata);
if (PEAR::isError($r)) {
_err($r, $filename);
import_err($r, "Error in bsSetMetadataBatch()");
echo var_export($mdata)."\n";
continue;
}
} else {
var_dump($infoFromFile);
echo"======================= ";
echo "======================= ";
var_dump($mdata);
echo"======================= ";
echo "======================= ";
}
echo "OK\n";
@ -256,9 +114,9 @@ $end = intval(date('U'));
//echo date('H:i:s')."\n";
$time = $end - $start;
if ($time > 0) {
$speed = round(($filecount+$errors)/$time, 1);
$speed = round(($filecount+$g_errors)/$time, 1);
} else {
$speed = "N/A";
}
echo " Files ".($testonly ? "analyzed" : "imported").": $filecount, in $time s, $speed files/s, errors: $errors\n";
echo " Files ".($testonly ? "analyzed" : "imported").": $filecount, in $time s, $speed files/s, errors: $g_errors\n";
?>

View File

@ -1,9 +1,219 @@
<?php
/**
* Add data to the global array $mdata, also sets global variables
* $titleHaveSet and $titleKey.
*
* Converts the given string ($val) into UTF-8.
*
* @param array $p_mdata
* The array to add the metadata to.
* @param string $p_key
* Metadata key.
* @param string $p_val
* Metadata value.
* @param string $p_inputEncoding
* Encoding type of the input value.
*/
function camp_add_metadata(&$p_mdata, $p_key, $p_val, $p_inputEncoding='iso-8859-1')
{
#echo "$key($iEnc): $val\n";
if (!is_null($p_val)) {
$data = $p_val;
$outputEncoding = 'UTF-8';
if (function_exists('iconv') && ($p_inputEncoding != $outputEncoding) ) {
$data = @iconv($p_inputEncoding, $outputEncoding, $data);
if ($data === FALSE) {
echo "Warning: convert $key data to unicode failed\n";
$data = $p_val; // fallback
}
}
$p_mdata[$p_key] = trim($data);
}
}
/**
* Return an array with the given audio file's ID3 tags. The keys in the
* array can be:
* <pre>
* dc:format
* ls:bitrate
* dcterms:extent
* dc:title
* dc:creator
* dc:source
* ls:encoded_by
* ls:track_num
* ls:genre
* ls:channels
* ls:year
* ls:filename
* </pre>
*
* @param string $p_filename
* @param boolean $p_testonly
* For diagnostic and debugging purposes - setting this to TRUE
* will print out the values found in the file and the ones assigned
* to the return array.
* @return array/PEAR_Error
*/
function camp_get_audio_metadata($p_filename, $p_testonly = false)
{
$getID3 = new getID3();
$infoFromFile = $getID3->analyze($p_filename);
//echo "\n".var_export($infoFromFile)."\n"; exit;
if (PEAR::isError($infoFromFile)) {
return $infoFromFile;
}
if (isset($infoFromFile['error'])) {
return new PEAR_Error(array_pop($infoFromFile['error']));
}
#if(!$infoFromFile['fileformat']){ echo "???\n"; continue; }
if (!$infoFromFile['bitrate']) {
return new PEAR_Error("File given is not an audio file.");
}
if ($p_testonly) {
print_r($infoFromFile);
}
$titleKey = 'dc:title';
$flds = array(
'dc:format' => array(
array('path'=>"['mime_type']", 'ignoreEnc'=>TRUE),
),
'ls:bitrate' => array(
array('path'=>"['bitrate']", 'ignoreEnc'=>TRUE),
),
'dcterms:extent'=> array(
array('path'=>"['playtime_seconds']", 'ignoreEnc'=>TRUE),
),
'dc:title' => array(
array('path'=>"['id3v2']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TIT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TT2'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v1']", 'dataPath'=>"['title']", 'encPath'=>"['encoding']"),
array('path'=>"['ogg']['comments']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['tags']['vorbiscomment']['title']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
),
'dc:creator' => array(
array('path'=>"['id3v2']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TPE1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TP1'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v1']", 'dataPath'=>"['artist']", 'encPath'=>"['encoding']"),
array('path'=>"['ogg']['comments']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['tags']['vorbiscomment']['artist']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
),
'dc:source' => array(
array('path'=>"['id3v2']['comments']['album']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TALB'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TAL'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
),
'ls:encoded_by' => array(
array('path'=>"['id3v2']['TENC'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TEN'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['ogg']['comments']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['tags']['vorbiscomment']['encoded-by']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
),
'ls:track_num' => array(
array('path'=>"['id3v2']['TRCK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TRK'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['ogg']['comments']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['tags']['vorbiscomment']['tracknumber']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
),
'ls:genre' => array(
array('path'=>"['id3v1']", 'dataPath'=>"['genre']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['TCON'][0]", 'dataPath'=>"['data']", 'encPath'=>"['encoding']"),
array('path'=>"['id3v2']['comments']['content_type']", 'dataPath'=>"[0]", 'ignoreEnc'=>TRUE),
array('path'=>"['ogg']['comments']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['tags']['vorbiscomment']['genre']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
),
'ls:channels' => array(
array('path'=>"['audio']['channels']", 'ignoreEnc'=>TRUE),
),
'ls:year' => array(
array('path'=>"['comments']['date']"),
array('path'=>"['ogg']['comments']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
array('path'=>"['tags']['vorbiscomment']['date']", 'dataPath'=>"[0]", 'encPath'=>"['encoding']"),
),
//'dc:publisher' => array(array('path'=>"['comments']['label']")),
'ls:filename' => array(
array('path'=>"['filename']"),
),
/*
'xx:fileformat' => array(array('path'=>"['fileformat']")),
'xx:filesize' => array(array('path'=>"['filesize']")),
'xx:dataformat' => array(array('path'=>"['audio']['dataformat']")),
'xx:sample_rate'=> array(array('path'=>"['audio']['sample_rate']")),
*/
);
$mdata = array();
if (isset($infoFromFile['audio'])) {
$mdata['audio'] = $infoFromFile['audio'];
}
if (isset($infoFromFile['playtime_seconds'])) {
$mdata['playtime_seconds'] = $infoFromFile['playtime_seconds'];
}
$titleHaveSet = FALSE;
foreach ($flds as $key => $getid3keys) {
if ($p_testonly) {
echo "$key\n";
}
foreach ($getid3keys as $getid3key) {
$path = $getid3key["path"];
$ignoreEnc = isset($getid3key["ignoreEnc"])?$getid3key["ignoreEnc"]:FALSE;
$dataPath = isset($getid3key["dataPath"])?$getid3key["dataPath"]:"";
$encPath = isset($getid3key["encPath"])?$getid3key["encPath"]:"";
$enc = "UTF-8";
$vn = "\$infoFromFile$path$dataPath";
if ($p_testonly) {
echo " $vn -> ";
}
eval("\$vnFl = isset($vn);");
if ($vnFl) {
eval("\$data = $vn;");
if ($p_testonly) {
echo "$data\n";
}
if (!$ignoreEnc && $encPath != "") {
$encVn = "\$infoFromFile$path$encPath";
eval("\$encVnFl = isset($encVn);");
if ($encVnFl) {
eval("\$enc = $encVn;");
}
}
if ($p_testonly) {
echo " ENC=$enc\n";
}
camp_add_metadata($mdata, $key, $data, $enc);
if ($key == $titleKey) {
$titleHaveSet = TRUE;
}
break;
} else {
if ($p_testonly) {
echo "\n";
}
}
}
}
if ($p_testonly) {
var_dump($mdata);
}
if (!$titleHaveSet || trim($mdata[$titleKey]) == '') {
camp_add_metadata($mdata, $titleKey, basename($p_filename));
}
return $mdata;
}
/**
* RawMediaData class
*
* File storage support class
* Store media files in real filesystem and handle access to them.<br>
* Store media files in real filesystem and handle access to them.
*
* @author $Author$
* @version $Revision$
@ -11,10 +221,10 @@
* @subpackage StorageServer
* @see StoredFile
*/
class RawMediaData{
class RawMediaData {
/**
* Constructor
* Constructor
*
* @param string $gunid
* global unique id
@ -34,7 +244,7 @@ class RawMediaData{
/**
* Insert media file to filesystem
* Insert media file to filesystem
*
* @param string $mediaFileLP
* local path
@ -67,7 +277,7 @@ class RawMediaData{
/**
* Delete and insert media file
* Delete and insert media file
*
* @param string $mediaFileLP, local path
* @return mixed
@ -144,10 +354,11 @@ class RawMediaData{
if (!$this->exists) {
return FALSE;
}
//$ia = @GetAllFileinfo($this->fname, 'mp3');
//prepared for getid3 upgrade:
$getID3 = new getID3;
$ia = $getID3->analyze($this->fname);
$ia = camp_get_audio_metadata($this->fname);
// echo "<pre>";
// $ia = camp_get_audio_metadata($this->fname, true);
// print_r($ia);
// exit;
return $ia;
}
@ -160,11 +371,11 @@ class RawMediaData{
function getMime()
{
$a = $this->analyze();
if ($a === FALSE) {
if (PEAR::isError($a)) {
return $a;
}
if (isset($a['mime_type'])) {
return $a['mime_type'];
if (isset($a['dc:format'])) {
return $a['dc:format'];
}
return '';
}