summaryrefslogtreecommitdiffstats
path: root/lib/class/vainfo.class.php
diff options
context:
space:
mode:
authorPaul 'flowerysong' Arthur <flowerysong00@yahoo.com>2010-03-14 20:14:52 +0000
committerPaul 'flowerysong' Arthur <flowerysong00@yahoo.com>2010-03-14 20:14:52 +0000
commit1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc (patch)
tree54655ff3e692a71a17f1d37cd97374b263557ca1 /lib/class/vainfo.class.php
parentef48bf3fbdca2a4d25f5d025f4c6ad23905e5369 (diff)
downloadampache-1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc.tar.gz
ampache-1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc.tar.bz2
ampache-1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc.zip
Cosmetics: remove trailing whitespace
Diffstat (limited to 'lib/class/vainfo.class.php')
-rw-r--r--lib/class/vainfo.class.php482
1 files changed, 241 insertions, 241 deletions
diff --git a/lib/class/vainfo.class.php b/lib/class/vainfo.class.php
index 692d0229..152cc67d 100644
--- a/lib/class/vainfo.class.php
+++ b/lib/class/vainfo.class.php
@@ -23,15 +23,15 @@
/**
* vainfo
* This class takes the information pulled from getID3 and returns it in a
- * Ampache friendly way.
+ * Ampache friendly way.
*/
-class vainfo {
+class vainfo {
/* Default Encoding */
public $encoding = '';
public $encoding_id3v1 = 'ISO-8859-1';
public $encoding_id3v2 = 'ISO-8859-1';
-
+
/* Loaded Variables */
public $filename = '';
public $type = '';
@@ -41,33 +41,33 @@ class vainfo {
public $_raw = array();
public $_raw2 = array();
public $_getID3 = '';
- public $_iconv = false;
+ public $_iconv = false;
public $_file_encoding = '';
public $_file_pattern = '';
public $_dir_pattern = '';
/* Internal Private */
- private $_binary_parse = array();
- private $_pathinfo;
- private $_broken=false;
+ private $_binary_parse = array();
+ private $_pathinfo;
+ private $_broken=false;
/**
* Constructor
* This function just sets up the class, it doesn't
* actually pull the information
*/
- public function __construct($file,$encoding='',$encoding_id3v1='',$encoding_id3v2='',$dir_pattern,$file_pattern) {
+ public function __construct($file,$encoding='',$encoding_id3v1='',$encoding_id3v2='',$dir_pattern,$file_pattern) {
/* Check for ICONV */
- if (function_exists('iconv')) {
+ if (function_exists('iconv')) {
$this->_iconv = true;
}
$this->filename = $file;
- if ($encoding) {
+ if ($encoding) {
$this->encoding = $encoding;
}
- else {
+ else {
$this->encoding = Config::get('site_charset');
}
@@ -82,20 +82,20 @@ class vainfo {
else {
$this->_pathinfo = pathinfo(str_replace('%2F', '/', urlencode($this->filename)));
}
- $this->_pathinfo['extension'] = strtolower($this->_pathinfo['extension']);
+ $this->_pathinfo['extension'] = strtolower($this->_pathinfo['extension']);
// Before we roll the _getID3 route let's see about using exec + a binary
/*
- if (!isset($this->_binary_parse[$this->_pathinfo['extension']])) {
+ if (!isset($this->_binary_parse[$this->_pathinfo['extension']])) {
// Figure out if we've got binary parse ninja-skills here
- $this->_binary_parse[$this->_pathinfo['extension']] = $this->can_binary_parse();
- debug_event('BinaryParse','Binary Parse for ' . $this->_pathinfo['extension'] . ' set to ' . make_bool($this->_binary_parse[$this->_pathinfo['extension']]),'5');
- }
+ $this->_binary_parse[$this->_pathinfo['extension']] = $this->can_binary_parse();
+ debug_event('BinaryParse','Binary Parse for ' . $this->_pathinfo['extension'] . ' set to ' . make_bool($this->_binary_parse[$this->_pathinfo['extension']]),'5');
+ }
*/
// Initialize getID3 engine
$this->_getID3 = new getID3();
-// if ($this->_binary_parse[$this->_pathinfo['extension']]) { return true; }
+// if ($this->_binary_parse[$this->_pathinfo['extension']]) { return true; }
// get id3tag encodings
// we have to run this right here because we don't know what we have in the files
@@ -105,9 +105,9 @@ class vainfo {
}
catch (Exception $error) {
debug_event('Getid3()',"Broken file detected $file - " . $error->message,'1');
- $this->_broken = true;
- return false;
- }
+ $this->_broken = true;
+ return false;
+ }
if(function_exists('mb_detect_encoding')) {
$this->encoding_id3v1 = array();
@@ -122,7 +122,7 @@ class vainfo {
} else {
$this->encoding_id3v1 = "ISO-8859-1";
}
-
+
$this->encoding_id3v2 = array();
$this->encoding_id3v2[] = mb_detect_encoding($this->_raw2['tags']['id3v2']['artist']['0']);
@@ -147,10 +147,10 @@ class vainfo {
$this->_getID3->option_tags_html = false;
$this->_getID3->option_extra_info = true;
$this->_getID3->option_tag_lyrics3 = true;
- $this->_getID3->encoding = $this->encoding;
+ $this->_getID3->encoding = $this->encoding;
$this->_getID3->encoding_id3v1 = $this->encoding_id3v1;
$this->_getID3->encoding_id3v2 = $this->encoding_id3v2;
- $this->_getID3->option_tags_process = true;
+ $this->_getID3->option_tags_process = true;
} // vainfo
@@ -164,41 +164,41 @@ class vainfo {
*/
public function get_info() {
- // If this is broken, don't waste time figuring it out a second time, just return
+ // If this is broken, don't waste time figuring it out a second time, just return
// their rotting carcass of a media file back on the pile
- if ($this->_broken) {
- $this->tags = $this->set_broken();
- return true;
- }
+ if ($this->_broken) {
+ $this->tags = $this->set_broken();
+ return true;
+ }
// If we've got a green light try out the binary
-// if ($this->_binary_parse[$this->_pathinfo['extension']]) {
-// $this->run_binary_parse();
-// }
-
-// else {
+// if ($this->_binary_parse[$this->_pathinfo['extension']]) {
+// $this->run_binary_parse();
+// }
+
+// else {
/* Get the Raw file information */
- try {
+ try {
$this->_raw = $this->_getID3->analyze($this->filename);
- }
- catch (Exception $error) {
+ }
+ catch (Exception $error) {
debug_event('Getid3()',"Unable to catalog file:" . $error->message,'1');
- }
+ }
/* Figure out what type of file we are dealing with */
$this->type = $this->_get_type();
/* Get the general information about this file */
$info = $this->_get_info();
-// }
+// }
/* Gets the Tags */
$this->tags = $this->_get_tags();
$this->tags['info'] = $info;
unset($this->_raw);
-
+
} // get_info
/**
@@ -207,7 +207,7 @@ class vainfo {
* As defined by your config file and trys to figure out
* which tag type(s) it should use, if your tag_order
* doesn't match anything then it just takes the first one
- * it finds in the results.
+ * it finds in the results.
*/
public static function get_tag_type($results) {
@@ -217,7 +217,7 @@ class vainfo {
if (!is_array($order)) {
$order = array($order);
}
-
+
/* Foreach through the defined key order
* adding them to an ordered array as we go
*/
@@ -244,8 +244,8 @@ class vainfo {
/**
* clean_tag_info
- * This function takes the array from vainfo along with the
- * key we've decided on and the filename and returns it in a
+ * This function takes the array from vainfo along with the
+ * key we've decided on and the filename and returns it in a
* sanatized format that ampache can actually use
*/
public static function clean_tag_info($results,$keys,$filename) {
@@ -275,11 +275,11 @@ class vainfo {
// Specific Audio Flags
foreach ($keys as $key) {
- if (!$results[$key]['video_codec']) {
- $slash_point = strpos($results[$key]['disk'],'/');
- if ($slash_point !== FALSE) {
- $results[$key]['disk'] = substr($results[$key]['disk'],0,$slash_point);
- }
+ if (!$results[$key]['video_codec']) {
+ $slash_point = strpos($results[$key]['disk'],'/');
+ if ($slash_point !== FALSE) {
+ $results[$key]['disk'] = substr($results[$key]['disk'],0,$slash_point);
+ }
/* These are used to generate the correct ID's later */
$info['title'] = $info['title']
? $info['title']
@@ -331,16 +331,16 @@ class vainfo {
$info['language'] = $info['language']
? $info['language']
: Dba::escape($results[$key]['language']);
-
+
$info['lyrics'] = $info['lyrics']
? $info['lyrics']
: str_replace(array("\r\n","\r","\n"), '<br />',strip_tags($results[$key]['unsynchronised lyric']));
- $info['track'] = $info['track']
+ $info['track'] = $info['track']
? $info['track']
: intval($results[$key]['track']);
}
- else {
+ else {
$info['resolution_x'] = $info['resolution_x']
? $info['resolution_x']
: intval($results[$key]['resolution_x']);
@@ -355,7 +355,7 @@ class vainfo {
$info['video_codec'] = $info['video_codec']
? $info['video_codec']
- : Dba::escape($results[$key]['video_codec']);
+ : Dba::escape($results[$key]['video_codec']);
}
}
// Lyrics3 v2.0
@@ -370,23 +370,23 @@ class vainfo {
/**
* _get_type
* This function takes the raw information and figures out
- * what type of file we are dealing with for use by the tag
+ * what type of file we are dealing with for use by the tag
* function
*/
- public function _get_type() {
+ public function _get_type() {
/* There are a few places that the file type can
- * come from, in the end we trust the encoding
+ * come from, in the end we trust the encoding
* type
*/
- if ($type = $this->_raw['video']['dataformat']) {
+ if ($type = $this->_raw['video']['dataformat']) {
// Manually set the tag information
- if ($type == 'flv') {
- $this->_raw['tags']['flv'] = array();
- }
- if ($type == 'quicktime') {
- $this->_raw['tags']['quicktime'] = array();
- }
+ if ($type == 'flv') {
+ $this->_raw['tags']['flv'] = array();
+ }
+ if ($type == 'quicktime') {
+ $this->_raw['tags']['quicktime'] = array();
+ }
if($type == 'mpeg' OR $type == 'mpg') {
$this->_raw['tags']['mpeg'] = array();
}
@@ -396,21 +396,21 @@ class vainfo {
if($type == 'wmv') {
$this->_raw['tags']['wmv'] = array();
}
- else {
- $this->_raw['tags']['avi'] = array();
- }
- $type = $this->_clean_type($type);
- return $type;
- }
- if ($type = $this->_raw['audio']['streams']['0']['dataformat']) {
+ else {
+ $this->_raw['tags']['avi'] = array();
+ }
+ $type = $this->_clean_type($type);
+ return $type;
+ }
+ if ($type = $this->_raw['audio']['streams']['0']['dataformat']) {
$type = $this->_clean_type($type);
return $type;
}
- if ($type = $this->_raw['audio']['dataformat']) {
+ if ($type = $this->_raw['audio']['dataformat']) {
$type = $this->_clean_type($type);
return $type;
}
- if ($type = $this->_raw['fileformat']) {
+ if ($type = $this->_raw['fileformat']) {
$type = $this->_clean_type($type);
return $type;
}
@@ -426,26 +426,26 @@ class vainfo {
* attempts to gather the tags and then normalize them into
* ['tag_name']['var'] = value
*/
- public function _get_tags() {
+ public function _get_tags() {
$results = array();
/* Gather Tag information from the filenames */
$results['file'] = $this->_parse_filename($this->filename);
- /* Return false if we don't have
- * any tags to look at
+ /* Return false if we don't have
+ * any tags to look at
*/
- if (!is_array($this->_raw['tags'])) {
- return $results;
+ if (!is_array($this->_raw['tags'])) {
+ return $results;
}
- /* The tags can come in many different shapes and colors
+ /* The tags can come in many different shapes and colors
* depending on the encoding time of day and phase of the
* moon
*/
- foreach ($this->_raw['tags'] as $key=>$tag_array) {
- switch ($key) {
+ foreach ($this->_raw['tags'] as $key=>$tag_array) {
+ switch ($key) {
case 'vorbiscomment':
debug_event('_get_tags', 'Parsing vorbis', '5');
$results[$key] = $this->_parse_vorbiscomment($tag_array);
@@ -468,14 +468,14 @@ class vainfo {
break;
case 'riff':
debug_event('_get_tags', 'Parsing riff', '5');
- $results[$key] = $this->_parse_riff($tag_array);
+ $results[$key] = $this->_parse_riff($tag_array);
break;
- case 'flv':
+ case 'flv':
debug_event('_get_tags', 'Parsing flv', '5');
- $results[$key] = $this->_parse_flv($this->_raw2);
- break;
+ $results[$key] = $this->_parse_flv($this->_raw2);
+ break;
case 'mpg':
- case 'mpeg':
+ case 'mpeg':
debug_event('_get_tags', 'Parsing MPEG', '5');
$results[$key] = $this->_parse_mpg($this->_raw2);
break;
@@ -484,15 +484,15 @@ class vainfo {
debug_event('_get_tags', 'Parsing WMV/WMA/ASF', '5');
$results[$key] = $this->_parse_wmv($this->_raw2);
break;
- case 'avi':
+ case 'avi':
debug_event('_get_tags', 'Parsing avi', '5');
- $results[$key] = $this->_parse_avi($this->_raw2);
- break;
+ $results[$key] = $this->_parse_avi($this->_raw2);
+ break;
case 'lyrics3':
debug_event('_get_tags', 'Parsing lyrics3', '5');
$results[$key] = $this->_parse_lyrics($tag_array);
break;
- default:
+ default:
debug_event('vainfo','Error: Unable to determine tag type of ' . $key . ' for file ' . $this->filename . ' Assuming id3v2','5');
$results[$key] = $this->_parse_id3v2($this->_raw['id3v2']['comments']);
break;
@@ -509,35 +509,35 @@ class vainfo {
* This function gathers and returns the general information
* about a song, vbr/cbr sample rate channels etc
*/
- private function _get_info() {
+ private function _get_info() {
$array = array();
/* Try to pull the information directly from
- * the audio array
+ * the audio array
*/
- if ($this->_raw['audio']['bitrate_mode']) {
+ if ($this->_raw['audio']['bitrate_mode']) {
$array['bitrate_mode'] = $this->_raw['audio']['bitrate_mode'];
}
- if ($this->_raw['audio']['bitrate']) {
+ if ($this->_raw['audio']['bitrate']) {
$array['bitrate'] = $this->_raw['audio']['bitrate'];
}
- if ($this->_raw['audio']['channels']) {
+ if ($this->_raw['audio']['channels']) {
$array['channels'] = intval($this->_raw['audio']['channels']);
}
- if ($this->_raw['audio']['sample_rate']) {
+ if ($this->_raw['audio']['sample_rate']) {
$array['sample_rate'] = intval($this->_raw['audio']['sample_rate']);
}
- if ($this->_raw['filesize']) {
+ if ($this->_raw['filesize']) {
$array['filesize'] = intval($this->_raw['filesize']);
}
- if ($this->_raw['encoding']) {
+ if ($this->_raw['encoding']) {
$array['encoding'] = $this->_raw['encoding'];
}
- if ($this->_raw['mime_type']) {
+ if ($this->_raw['mime_type']) {
$array['mime'] = $this->_raw['mime_type'];
}
- if ($this->_raw['playtime_seconds']) {
+ if ($this->_raw['playtime_seconds']) {
$array['playing_time'] = $this->_raw['playtime_seconds'];
}
if ($this->_raw['lyrics3']) {
@@ -545,17 +545,17 @@ class vainfo {
}
return $array;
-
+
} // _get_info
/**
* _clean_type
- * This standardizes the type that we are given into a reconized
+ * This standardizes the type that we are given into a reconized
* type
*/
- private function _clean_type($type) {
+ private function _clean_type($type) {
- switch ($type) {
+ switch ($type) {
case 'mp3':
case 'mp2':
case 'mpeg3':
@@ -564,16 +564,16 @@ class vainfo {
case 'vorbis':
return 'ogg';
break;
- case 'flac':
+ case 'flac':
case 'flv':
case 'mpg':
case 'mpeg':
case 'asf':
case 'wmv':
- case 'avi':
- case 'quicktime':
- return $type;
- default:
+ case 'avi':
+ case 'quicktime':
+ return $type;
+ default:
/* Log the fact that we couldn't figure it out */
debug_event('vainfo','Unable to determine file type from ' . $type . ' on file ' . $this->filename,'5');
return $type;
@@ -609,16 +609,16 @@ class vainfo {
* returns the elements translated using iconv if needed in a
* pretty little format
*/
- private function _parse_vorbiscomment($tags) {
+ private function _parse_vorbiscomment($tags) {
/* Results array */
$array = array();
/* go through them all! */
- foreach ($tags as $tag=>$data) {
-
+ foreach ($tags as $tag=>$data) {
+
/* We need to translate a few of these tags */
- switch ($tag) {
+ switch ($tag) {
case 'genre':
// multiple genre support
@@ -629,8 +629,8 @@ class vainfo {
case 'tracknumber':
$array['track'] = $this->_clean_tag($data['0']);
break;
- case 'discnumber':
- $array['disk'] = $this->_clean_tag($data['0']);
+ case 'discnumber':
+ $array['disk'] = $this->_clean_tag($data['0']);
break;
case 'date':
$array['year'] = $this->_clean_tag($data['0']);
@@ -649,23 +649,23 @@ class vainfo {
/**
* _parse_id3v1
* This function takes a id3v1 tag set from getid3() and then
- * returns the elements translated using iconv if needed in a
+ * returns the elements translated using iconv if needed in a
* pretty little format
*/
- private function _parse_id3v1($tags) {
+ private function _parse_id3v1($tags) {
$array = array();
$encoding = $this->_raw['id3v1']['encoding'];
-
+
/* Go through all the tags */
- foreach ($tags as $tag=>$data) {
+ foreach ($tags as $tag=>$data) {
- /* This is our baseline for naming
- * so no translation needed
+ /* This is our baseline for naming
+ * so no translation needed
*/
$array[$tag] = $this->_clean_tag($data['0'],$encoding);
-
+
} // end foreach
return $array;
@@ -678,18 +678,18 @@ class vainfo {
* returns the lelements translated using iconv if needed in a
* pretty little format
*/
- private function _parse_id3v2($tags) {
+ private function _parse_id3v2($tags) {
$array = array();
/* Go through the tags */
- foreach ($tags as $tag=>$data) {
+ foreach ($tags as $tag=>$data) {
/**
- * the new getid3 handles this differently
+ * the new getid3 handles this differently
* so we now need to account for it :(
*/
- switch ($tag) {
+ switch ($tag) {
case 'genre':
// multiple genre support
foreach($data as $genre) {
@@ -706,16 +706,16 @@ class vainfo {
case 'comments':
$array['comment'] = $this->_clean_tag($data['0'],'');
break;
- case 'title':
- $array['title'] = $this->_clean_tag($data['0'],'');
- break;
- default:
+ case 'title':
+ $array['title'] = $this->_clean_tag($data['0'],'');
+ break;
+ default:
$array[$tag] = $this->_clean_tag($data['0'],'');
break;
} // end switch on tag
-
+
} // end foreach
-
+
$id3v2 = $this->_raw['id3v2'];
if(!empty($id3v2['UFID'])) {
@@ -745,9 +745,9 @@ class vainfo {
* returns the elements translated using iconv if needed in a
* pretty little format
*/
- private function _parse_ape($tags) {
+ private function _parse_ape($tags) {
- foreach ($tags as $tag=>$data) {
+ foreach ($tags as $tag=>$data) {
switch ($tag) {
case 'genre':
@@ -762,7 +762,7 @@ class vainfo {
break;
} // end switch on tag
- } // end foreach tags
+ } // end foreach tags
return $array;
@@ -770,35 +770,35 @@ class vainfo {
/**
* _parse_riff
- * this function takes the riff take information passed by getid3() and
+ * this function takes the riff take information passed by getid3() and
* then reformats it so that it matches the other formats. May require iconv
*/
- private function _parse_riff($tags) {
-
- foreach ($tags as $tag=>$data) {
+ private function _parse_riff($tags) {
+
+ foreach ($tags as $tag=>$data) {
- switch ($tag) {
+ switch ($tag) {
case 'product':
- $array['album'] = $this->_clean_tag($data['0'],$this->_file_encoding);
+ $array['album'] = $this->_clean_tag($data['0'],$this->_file_encoding);
break;
- default:
- $array[$tag] = $this->_clean_tag($data['0'],$this->_file_encoding);
+ default:
+ $array[$tag] = $this->_clean_tag($data['0'],$this->_file_encoding);
break;
} // end switch on tag
} // foreach tags
- return $array;
+ return $array;
} // _parse_riff
/**
* _parse_quicktime
* this function takes the quicktime tags set by getid3() and then
- * returns the elements translated using iconv if needed in a
+ * returns the elements translated using iconv if needed in a
* pretty little format
*/
- private function _parse_quicktime($tags) {
+ private function _parse_quicktime($tags) {
/* Results array */
$array = array();
@@ -809,7 +809,7 @@ class vainfo {
/* We need to translate a few of these tags */
switch ($tag) {
case 'creation_date':
- if (strlen($data['0']) > 4) {
+ if (strlen($data['0']) > 4) {
/* Weird Date format, attempt to normalize */
$data['0'] = date("Y",strtotime($data['0']));
}
@@ -820,36 +820,36 @@ class vainfo {
$array[$tag] = $this->_clean_tag($data['0']);
} // end foreach
-
+
// Also add in any video related stuff we might find
- if (strpos($this->_raw2['mime_type'],'video') !== false) {
- $info = $this->_parse_avi($this->_raw2);
- $info['video_codec'] = $this->_raw2['quicktime']['ftyp']['fourcc'];
- $array = array_merge($info,$array);
- }
+ if (strpos($this->_raw2['mime_type'],'video') !== false) {
+ $info = $this->_parse_avi($this->_raw2);
+ $info['video_codec'] = $this->_raw2['quicktime']['ftyp']['fourcc'];
+ $array = array_merge($info,$array);
+ }
return $array;
} // _parse_quicktime
/**
- * _parse_avi
+ * _parse_avi
* This attempts to parse our the information on an avi file and present it in some
* kind of sane format, this is a little hard as these files don't have tags
*/
- private function _parse_avi($tags) {
+ private function _parse_avi($tags) {
- $array = array();
+ $array = array();
$array['title'] = urldecode($this->_pathinfo['filename']);
- $array['video_codec'] = $tags['video']['fourcc'];
- $array['audio_codec'] = $tags['audio']['dataformat'];
- $array['resolution_x'] = $tags['video']['resolution_x'];
- $array['resolution_y'] = $tags['video']['resolution_y'];
- $array['mime'] = $tags['mime_type'];
- $array['comment'] = $tags['video']['codec'];
+ $array['video_codec'] = $tags['video']['fourcc'];
+ $array['audio_codec'] = $tags['audio']['dataformat'];
+ $array['resolution_x'] = $tags['video']['resolution_x'];
+ $array['resolution_y'] = $tags['video']['resolution_y'];
+ $array['mime'] = $tags['mime_type'];
+ $array['comment'] = $tags['video']['codec'];
- return $array;
+ return $array;
} // _parse_avi
@@ -890,7 +890,7 @@ class vainfo {
case 'video/x-ms-wmv':
if(isset($tags['tags']['asf']['title']['0'])) {
$array['title'] = $tags['tags']['asf']['title']['0'];
- }
+ }
else {
$array['title'] = urldecode($this->_pathinfo['filename']);
}
@@ -911,17 +911,17 @@ class vainfo {
* This attempts to parse our the information on an flv file and present it in some
* kind of sane format, this is a little hard as these files don't have tags
*/
- private function _parse_flv($tags) {
+ private function _parse_flv($tags) {
- $array = array();
+ $array = array();
$array['title'] = urldecode($this->_pathinfo['filename']);
- $array['video_codec'] = $tags['video']['codec'];
- $array['audio_codec'] = $tags['audio']['dataformat'];
- $array['resolution_x'] = $tags['video']['resolution_x'];
- $array['resolution_y'] = $tags['video']['resolution_y'];
- $array['mime'] = $tags['mime_type'];
- $array['comment'] = $tags['video']['codec'];
+ $array['video_codec'] = $tags['video']['codec'];
+ $array['audio_codec'] = $tags['audio']['dataformat'];
+ $array['resolution_x'] = $tags['video']['resolution_x'];
+ $array['resolution_y'] = $tags['video']['resolution_y'];
+ $array['mime'] = $tags['mime_type'];
+ $array['comment'] = $tags['video']['codec'];
return $array;
@@ -930,10 +930,10 @@ class vainfo {
/**
* _parse_filename
* This function uses the passed file and dir patterns
- * To pull out extra tag information and populate it into
+ * To pull out extra tag information and populate it into
* it's own array
*/
- private function _parse_filename($filename) {
+ private function _parse_filename($filename) {
$results = array();
@@ -945,11 +945,11 @@ class vainfo {
$slash_type = '\\';
}
- $pattern = preg_quote($this->_dir_pattern) . $slash_type . preg_quote($this->_file_pattern);
+ $pattern = preg_quote($this->_dir_pattern) . $slash_type . preg_quote($this->_file_pattern);
preg_match_all("/\%\w/",$pattern,$elements);
-
+
$preg_pattern = preg_quote($pattern);
- $preg_pattern = preg_replace("/\%[Ty]/","([0-9]+?)",$preg_pattern);
+ $preg_pattern = preg_replace("/\%[Ty]/","([0-9]+?)",$preg_pattern);
$preg_pattern = preg_replace("/\%\w/","(.+?)",$preg_pattern);
$preg_pattern = str_replace("/","\/",$preg_pattern);
$preg_pattern = str_replace(" ","\s",$preg_pattern);
@@ -959,12 +959,12 @@ class vainfo {
array_shift($matches);
/* Foreach through what we've found */
- foreach ($matches as $key=>$value) {
+ foreach ($matches as $key=>$value) {
$new_key = translate_pattern_code($elements['0'][$key]);
- if ($new_key) {
+ if ($new_key) {
$results[$new_key] = $value;
}
- } // end foreach matches
+ } // end foreach matches
return $results;
@@ -975,7 +975,7 @@ class vainfo {
* This translates the tag name to a frame, if there a many it returns the first
* one if finds that exists in the raw
*/
- private function _id3v2_tag_to_frame($tag_name) {
+ private function _id3v2_tag_to_frame($tag_name) {
static $map = array(
'comment'=>array('COM','COMM'),
@@ -986,15 +986,15 @@ class vainfo {
'artist'=>array('TPE1'),
'year'=>array('TDRC'));
- foreach ($map[$tag_name] as $frame) {
- if (isset($this->_raw['id3v2'][$frame])) {
- return $frame;
- }
- }
+ foreach ($map[$tag_name] as $frame) {
+ if (isset($this->_raw['id3v2'][$frame])) {
+ return $frame;
+ }
+ }
- return false;
+ return false;
- } // _id3v2_tag_to_frame
+ } // _id3v2_tag_to_frame
/**
* _clean_tag
@@ -1004,10 +1004,10 @@ class vainfo {
* is, and or if it's different then the encoding recorded
* in the file
*/
- private function _clean_tag($tag,$encoding='') {
+ private function _clean_tag($tag,$encoding='') {
- // If we've got iconv then go ahead and clear her up
- if ($this->_iconv) {
+ // If we've got iconv then go ahead and clear her up
+ if ($this->_iconv) {
/* Guess that it's UTF-8 */
/* Try GNU iconv //TRANSLIT extension first */
if (!$encoding) { $encoding = $this->_getID3->encoding; }
@@ -1027,27 +1027,27 @@ class vainfo {
* This returns true/false if we can do a binary parse of the file in question
* only the extension is passed so this can be inaccurate
*/
- public function can_binary_parse() {
+ public function can_binary_parse() {
// We're going to need exec for this
- if (!is_callable('exec')) {
- return false;
- }
+ if (!is_callable('exec')) {
+ return false;
+ }
// For now I'm going to use an approved list of apps, later we should allow user config
- switch ($this->_pathinfo['extension']) {
- case 'mp3':
+ switch ($this->_pathinfo['extension']) {
+ case 'mp3':
// Verify the application is there and callable
- exec('id3v2 -v',$results,$retval);
- if ($retval == 0) { return true; }
- break;
+ exec('id3v2 -v',$results,$retval);
+ if ($retval == 0) { return true; }
+ break;
default:
//FAILURE
- break;
+ break;
}
- return false;
+ return false;
} // can_binary_parse
@@ -1056,16 +1056,16 @@ class vainfo {
* This runs the binary parse operations here down in Ampache land
* it is passed the filename, and only called if can_binary_parse passes
*/
- public function run_binary_parse() {
+ public function run_binary_parse() {
// Switch on the extension
- switch ($this->_pathinfo['extension']) {
- case 'mp3':
+ switch ($this->_pathinfo['extension']) {
+ case 'mp3':
$this->_raw['tags'] = $this->mp3_binary_parse();
- break;
+ break;
default:
- $this->_raw['tags'] = array();
- break;
+ $this->_raw['tags'] = array();
+ break;
} // switch on extension
} // run_binary_parse
@@ -1075,56 +1075,56 @@ class vainfo {
* This tries to read the tag information from mp3s using a binary and the exec() command
* This will not work on a lot of systems... but it should be faster
*/
- public function mp3_binary_parse() {
+ public function mp3_binary_parse() {
- require_once(Config::get('prefix') . '/modules/getid3/module.tag.id3v2.php');
+ require_once(Config::get('prefix') . '/modules/getid3/module.tag.id3v2.php');
- $filename = escapeshellarg($this->filename);
+ $filename = escapeshellarg($this->filename);
- exec('id3v2 -l ' . $filename,$info,$retval);
+ exec('id3v2 -l ' . $filename,$info,$retval);
- if ($retval != 0) { return array(); }
+ if ($retval != 0) { return array(); }
- $position=0;
- $results = array();
+ $position=0;
+ $results = array();
// If we've got Id3v1 tag information
- if (substr($info[$position],0,5) == 'id3v1') {
- $position++;
- $v1['title'][] = trim(substr($info[$position],8,30));
+ if (substr($info[$position],0,5) == 'id3v1') {
+ $position++;
+ $v1['title'][] = trim(substr($info[$position],8,30));
$v1['artist'][] = trim(substr($info[$position],49,79));
- $position++;
- $v1['album'][] = trim(substr($info[$position],8,30));
- $v1['year'][] = trim(substr($info[$position],47,53));
- $v1['genre'][] = trim(preg_replace("/\(\d+\)/","",substr($info[$position],60,strlen($info[$position]))));
- $position++;
- $v1['comment'][]= trim(substr($info[$position],8,30));
- $v1['track'][] = trim(substr($info[$position],48,3));
- $results['id3v1'] = $v1;
- $position++;
+ $position++;
+ $v1['album'][] = trim(substr($info[$position],8,30));
+ $v1['year'][] = trim(substr($info[$position],47,53));
+ $v1['genre'][] = trim(preg_replace("/\(\d+\)/","",substr($info[$position],60,strlen($info[$position]))));
+ $position++;
+ $v1['comment'][]= trim(substr($info[$position],8,30));
+ $v1['track'][] = trim(substr($info[$position],48,3));
+ $results['id3v1'] = $v1;
+ $position++;
}
- if (substr($info[$position],0,5) == 'id3v2') {
- $position++;
+ if (substr($info[$position],0,5) == 'id3v2') {
+ $position++;
$element_count = count($info);
- while ($position < $element_count) {
+ while ($position < $element_count) {
$position++;
$element = getid3_id3v2::FrameNameShortLookup(substr($info[$position],0,4));
- if (!$element) { continue; }
- $data = explode(":",$info[$position],2);
- $value = array_pop($data);
- $results['id3v2'][$element][] = $value;
- }
+ if (!$element) { continue; }
+ $data = explode(":",$info[$position],2);
+ $value = array_pop($data);
+ $results['id3v2'][$element][] = $value;
+ }
} // end if id3v2
- return $results;
+ return $results;
} // mp3_binary_parse
/**
* set_broken
- * This fills all tag types with Unknown (Broken)
+ * This fills all tag types with Unknown (Broken)
*/
- public function set_broken() {
+ public function set_broken() {
/* Pull In the config option */
$order = Config::get('tag_order');
@@ -1133,13 +1133,13 @@ class vainfo {
$order = array($order);
}
- $key = array_shift($order);
+ $key = array_shift($order);
- $broken[$key]['title'] = '**BROKEN** ' . $this->filename;
- $broken[$key]['album'] = 'Unknown (Broken)';
- $broken[$key]['artist'] = 'Unknown (Broken)';
+ $broken[$key]['title'] = '**BROKEN** ' . $this->filename;
+ $broken[$key]['album'] = 'Unknown (Broken)';
+ $broken[$key]['artist'] = 'Unknown (Broken)';
- return $broken;
+ return $broken;
} // set_broken