diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-06-12 23:12:53 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-06-12 23:12:53 +0000 |
commit | fed2041c7b15e30fd126d6b1290ba255d3ec5d1d (patch) | |
tree | ca02f48777e05b8e85b932a809d96fb4123cf12a | |
parent | 26553fbefc9ec307e050b31a5f052011478d9d7d (diff) | |
download | ampache-fed2041c7b15e30fd126d6b1290ba255d3ec5d1d.tar.gz ampache-fed2041c7b15e30fd126d6b1290ba255d3ec5d1d.tar.bz2 ampache-fed2041c7b15e30fd126d6b1290ba255d3ec5d1d.zip |
updated vainfo class that now reads flac files.. just gotta fix everything else
-rwxr-xr-x | docs/CHANGELOG | 2 | ||||
-rwxr-xr-x | modules/id3/vainfo.class.php | 257 |
2 files changed, 253 insertions, 6 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 80cc1302..c4f0b5f6 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -4,6 +4,8 @@ -------------------------------------------------------------------------- v.3.3.2-Beta3 + - Fixed Transcoding logic issue and added preset line for + transcoding flac files in .dist file (Defaulted to Off) - Upgraded to Getid3() 1.7.6 - Fixed an issue where the new song->get_url() wasn't respecting the force_http_play, this also fixes a long outstanding diff --git a/modules/id3/vainfo.class.php b/modules/id3/vainfo.class.php index 629c9af5..46cc8943 100755 --- a/modules/id3/vainfo.class.php +++ b/modules/id3/vainfo.class.php @@ -15,16 +15,17 @@ class vainfo { /* Default Encoding */ var $encoding = 'UTF-8'; - /* Loaded Variables */ var $filename = ''; - var $_getID3 = ''; var $type = ''; var $tags = array(); var $info = array(); - /* Returned Variables */ - var $_info = array(); + + /* Internal Information */ + var $_raw = array(); + var $_getID3 = ''; + var $_iconv = false; /** * Constructor @@ -42,8 +43,15 @@ class vainfo { $this->_getID3 = new getID3(); $this->_getID3->option_md5_data = false; $this->_getID3->option_md5_data_source = false; + $this->_getID3->option_tags_html = false; + $this->_getID3->option_extra_info = false; $this->_getID3->encoding = $this->encoding; + /* Check for ICONV */ + if (function_exists('iconv')) { + $this->_iconv = true; + } + } // vainfo @@ -56,13 +64,250 @@ class vainfo { function get_info() { /* Get the Raw file information */ - $raw_array = $this->_getID3->analyze($this->filename); + $this->_raw = $this->_getID3->analyze($this->filename); /* Figure out what type of file we are dealing with */ - + $this->type = $this->_get_type(); + + /* Get the general information about this file */ + $this->info = $this->_get_info(); + + /* Gets the Tags */ + $this->tags = $this->_get_tags(); + unset($this->_raw); +print_r($this); } // get_info + /** + * _get_type + * This function takes the raw information and figures out + * what type of file we are dealing with for use by the tag + * function + */ + function _get_type() { + + /* There are a few places that the file type can + * come from, in the end we trust the encoding + * type + */ + if ($type = $this->_raw['audio']['streams']['0']['dataformat']) { + $this->_clean_type($type); + return $type; + } + if ($type = $this->_raw['audio']['dataformat']) { + $this->_clean_type($type); + return $type; + } + if ($type = $this->_raw['fileformat']) { + $this->_clean_type($type); + return $type; + } + + return false; + + } // _get_type + + + /** + * _get_tags + * This function takes the raw information and the type and + * attempts to gather the tags and then normalize them into + * ['tag_name']['var'] = value + */ + function _get_tags() { + + $results = array(); + + /* 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) { + case 'vorbiscomment': + $results[$key] = $this->_parse_vorbiscomment($tag_array); + break; + case 'id3v1': + $results[$key] = $this->_parse_id3v1($tag_array); + break; + case 'id3v2': + $results[$key] = $this->_parse_id3v2($tag_array); + break; + case 'ape': + $results[$key] = $this->_parse_ape($tag_array); + break; + default: + debug_event('vainfo','Error: Unable to determine tag type of ' . $key . ' for file ' . $this->filename,'5'); + break; + } // end switch + + } // end foreach + + return $results; + + } // _get_tags + + /** + * _get_info + * This function gathers and returns the general information + * about a song, vbr/cbr sample rate channels etc + */ + function _get_info() { + + $array = array(); + + /* Try to pull the information directly from + * the audio array + */ + if ($this->_raw['audio']['bitrate_mode']) { + $array['bitrate_mode'] = $this->_raw['audio']['bitrate_mode']; + } + if ($this->_raw['audio']['bitrate']) { + $array['bitrate'] = $this->_raw['audio']['bitrate']; + } + if ($this->_raw['audio']['channels']) { + $array['channels'] = intval($this->_raw['audio']['channels']); + } + if ($this->_raw['audio']['sample_rate']) { + $array['sample_rate'] = intval($this->_raw['audio']['sample_rate']); + } + if ($this->_raw['filesize']) { + $array['filesize'] = intval($this->_raw['filesize']); + } + if ($this->_raw['encoding']) { + $array['encoding'] = $this->_raw['encoding']; + } + if ($this->_raw['mime_type']) { + $array['mime'] = $this->_raw['mime_type']; + } + if ($this->_raw['playtime_seconds']) { + $array['playing_time'] = $this->_raw['playtime_seconds']; + } + + return $array; + + } // _get_info + + /** + * _clean_type + * This standardizes the type that we are given into a reconized + * type + */ + function _clean_type($type) { + + switch ($type) { + case 'mp3': + case 'mpeg3': + return 'mp3'; + break; + case 'flac': + return 'flac'; + break; + 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 'unknown'; + break; + } // end switch on type + + } // _clean_type + + /** + * _parse_vorbiscomment + * This function takes a vorbiscomment from getid3() and then + * returns the elements translated using iconv if needed in a + * pretty little format + */ + function _parse_vorbiscomment($tags) { + + /* Results array */ + $array = array(); + + /* go through them all! */ + foreach ($tags as $tag=>$data) { + + /* We need to translate a few of these tags */ + switch ($tag) { + case 'tracknumber': + $array['track'] = $this->_clean_tag($data['0']); + break; + } // end switch + + $array[$tag] = $this->_clean_tag($data['0']); + + } // end foreach + + return $array; + + } // _parse_vorbiscomment + + /** + * _parse_id3v1 + * This function takes a id3v1 tag set from getid3() and then + * returns the elements translated using iconv if needed in a + * pretty little format + */ + function _parse_id3v1($tags) { + + + + } // _parse_id3v1 + + /** + * _parse_id3v2 + * This function takes a id3v2 tag set from getid3() and then + * returns the lelements translated using iconv if needed in a + * pretty little format + */ + function _parse_id3v2($tags) { + + + + + } // _parse_id3v2 + + /** + * _parse_ape + * This function takes ape tags set by getid3() and then + * returns the elements translated using iconv if needed in a + * pretty little format + */ + function _parse_ape($tags) { + + + } // _parse_ape + + /** + * _parse_quicktime + * this function takes the quicktime tags set by getid3() and then + * returns the elements translated using iconv if needed in a + * pretty little format + */ + function _parse_quicktime($tags) { + + + + + } // _parse_quicktime + + /** + * _clean_tag + * This function cleans up the tag that it's passed using Iconv + * if we've got it + */ + function _clean_tag($tag) { + + if ($this->_iconv) { + + } + + return $tag; + + + + } // _clean_tag + } // end class vainfo ?> |