diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-06-14 23:57:21 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-06-14 23:57:21 +0000 |
commit | 7db599b70d03cc288fcf499bebd9afb2485c930d (patch) | |
tree | 556e85f9baf10f2b1e845eec9cc098f22d2115cd /lib | |
parent | fed2041c7b15e30fd126d6b1290ba255d3ec5d1d (diff) | |
download | ampache-7db599b70d03cc288fcf499bebd9afb2485c930d.tar.gz ampache-7db599b70d03cc288fcf499bebd9afb2485c930d.tar.bz2 ampache-7db599b70d03cc288fcf499bebd9afb2485c930d.zip |
new vainfo which should solve the ogg with id3 tags issue and potentially break other things yeah!
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/catalog.class.php | 31 | ||||
-rw-r--r-- | lib/general.lib.php | 101 | ||||
-rw-r--r-- | lib/log.lib.php | 7 |
3 files changed, 62 insertions, 77 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php index aec7432b..e4262ddb 100644 --- a/lib/class/catalog.class.php +++ b/lib/class/catalog.class.php @@ -871,20 +871,17 @@ class Catalog { */ function update_song_from_tags($song) { - + /* Record the reading of these tags */ debug_event('tag-read',"Reading Tags from $song->file",'5','ampache-catalog'); - $info = new Audioinfo(); - $results = $info->Info($song->file); + $vainfo = new vainfo($song->file,'',$this->sort_pattern,$this->rename_pattern); + $vainfo->get_info(); /* Find the correct key */ - $key = get_tag_type($results); - - /* Fill Missing Information */ - $results = $song->fill_info($results,$this->sort_pattern . "/" . $this->rename_pattern, $this->id, $key); + $key = get_tag_type($vainfo->tags); /* Clean up the tags */ - $results = clean_tag_info($results,$key,$song->file); + $results = clean_tag_info($vainfo->tags,$key,$song->file); /* Setup the vars */ $new_song = new Song(); @@ -903,7 +900,7 @@ class Catalog { $genre = $results['genre']; /* Clean up Old Vars */ - unset($results,$key,$info); + unset($vainfo,$key); /* * We have the artist/genre/album name need to check it in the tables @@ -1977,19 +1974,15 @@ class Catalog { */ function insert_local_song($file,$file_info) { - /* Create the Audioinfo object and get info */ - $audio_info = new Audioinfo(); + /* Create the vainfo object and get info */ + $vainfo = new vainfo($file,'',$this->sort_pattern,$this->rename_pattern); + $vainfo->get_info(); $song_obj = new Song(); - $results = $audio_info->Info($file); - $results['file'] = $file; - - $key = get_tag_type($results); - /* Fill Empty info from filename/path */ - $results = $song_obj->fill_info($results,$this->sort_pattern . "/" . $this->rename_pattern,$this->id,$key); + $key = get_tag_type($vainfo->tags); /* Clean Up the tags */ - $results = clean_tag_info($results,$key,$file); + $results = clean_tag_info($vainfo->tags,$key,$file); /* Set the vars here... so we don't have to do the '" . $blah['asd'] . "' */ $title = sql_escape($results['title']); @@ -2023,7 +2016,7 @@ class Catalog { if (!$db_results) { debug_event('insert',"Unable to insert $file -- $sql",'5','ampache-catalog'); - echo "<span style=\"color: #F00;\">Error Adding $file </span><br />$sql<br />"; + echo "<span style=\"color: #F00;\">Error Adding $file </span><hr />$sql<hr />"; flush(); } diff --git a/lib/general.lib.php b/lib/general.lib.php index 1ad4a908..085f33af 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -335,70 +335,54 @@ function extend_session($sid) { } // extend_session -/*! - @function get_tag_type - @discussion finds out what tag the audioinfo - results returned -*/ +/** + * get_tag_type + * This takes the result set, and the the tag_order + * As defined by your config file and trys to figure out + * which tag type it should use, if your tag_order + * doesn't match anything then it just takes the first one + * it finds in the results. + */ function get_tag_type($results) { - // Check and see if we are dealing with an ogg - // If so order will be a little different - if ($results['ogg']) { - $order[0] = 'ogg'; - } // end if ogg - elseif ($results['rm'] OR $results['format_name'] == 'Real') { - $order[0] = 'real'; - } - elseif ($results['flac']) { - $order[0] = 'flac'; - } - elseif ($results['asf']) { - $order[0] = 'asf'; - } - elseif ($results['m4a']) { - $order[0] = 'm4a'; - } - elseif ($results['mpc']) { - $order[0] = 'mpc'; - } - else { - $order = conf('id3tag_order'); - } // end else - - if (!is_array($order)) { - $order = array($order); - } - - // set the $key to the first found tag style (according to their prefs) + /* Pull In the config option */ + $order = conf('tag_order'); + + if (!is_array($order)) { + $order = array($order); + } + + /* Foreach through the defined key order + * the first one we find is the first one we use + */ foreach($order as $key) { if ($results[$key]) { + $returned_key = $key; break; } } - return $key; + /* If we didn't find anything then default it to the + * first in the results set + */ + if (!isset($returned_key)) { + $keys = array_keys($results); + $returned_key = $keys['0']; + } + + return $returned_key; } // get_tag_type -/*! - @function clean_tag_info - @discussion cleans up the tag information -*/ +/** + * 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 + * sanatized format that ampache can actually use + */ function clean_tag_info($results,$key,$filename) { - if ($key == 'real') { - $results['real'] = $results['tags']['real']; - } - - /* Flatten any arrayed results */ - foreach ($results[$key] as $field=>$data) { - if (is_array($data)) { - $results[$key][$field] = array_pop($data); - } - } - $info = array(); $clean_array = array("\n","\t","\r","\0"); @@ -407,13 +391,18 @@ function clean_tag_info($results,$key,$filename) { $info['file'] = $filename; $info['title'] = stripslashes(trim($results[$key]['title'])); $info['year'] = intval($results[$key]['year']); - $info['comment'] = sql_escape(str_replace($clean_array,$wipe_array,$results[$key]['comment'])); - $info['bitrate'] = intval($results['avg_bit_rate']); - $info['rate'] = intval($results['sample_rate']); - $info['mode'] = $results['bitrate_mode']; - $info['size'] = filesize($filename); - $info['time'] = intval($results['playing_time']); $info['track'] = intval($results[$key]['track']); + $info['comment'] = sql_escape(str_replace($clean_array,$wipe_array,$results[$key]['comment'])); + + /* This are pulled from the info array */ + $info['bitrate'] = intval($results['info']['bitrate']); + $info['rate'] = intval($results['info']['sample_rate']); + $info['mode'] = $results['info']['bitrate_mode']; + $info['size'] = $results['info']['filesize']; + $info['mime'] = $results['info']['mime']; + $into['encoding'] = $results['info']['encoding']; + $info['time'] = intval($results['info']['playing_time']); + $info['channels'] = intval($results['info']['channels']); /* These are used to generate the correct ID's later */ $info['artist'] = trim($results[$key]['artist']); diff --git a/lib/log.lib.php b/lib/log.lib.php index a82338f0..ed19984c 100644 --- a/lib/log.lib.php +++ b/lib/log.lib.php @@ -81,8 +81,11 @@ function ampache_error_handler($errno, $errstr, $errfile, $errline) { break; } // end switch - /* Don't log var: Deprecated we know shutup! */ - if (strstr($errstr,"var: Deprecated. Please use the public/private/protected modifiers")) { + /* Don't log var: Deprecated we know shutup! + * Yea now getid3() spews errors I love it :( + */ + if (strstr($errstr,"var: Deprecated. Please use the public/private/protected modifiers") OR + strstr($errstr,"getimagesize() [")) { return false; } |