summaryrefslogtreecommitdiffstats
path: root/modules/id3/vainfo.class.php
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-06-17 16:32:04 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-06-17 16:32:04 +0000
commite3734f063ed58356f9653a81f6dea86aa55931f4 (patch)
tree3aace945cfd5d8e988395170ff92ab75c0419819 /modules/id3/vainfo.class.php
parentc6c2320170b488f64f1c67de23a35f4ca4de59de (diff)
downloadampache-e3734f063ed58356f9653a81f6dea86aa55931f4.tar.gz
ampache-e3734f063ed58356f9653a81f6dea86aa55931f4.tar.bz2
ampache-e3734f063ed58356f9653a81f6dea86aa55931f4.zip
moved init.php improved vainfo a bit, removed checkboxes from search page
Diffstat (limited to 'modules/id3/vainfo.class.php')
-rwxr-xr-xmodules/id3/vainfo.class.php46
1 files changed, 37 insertions, 9 deletions
diff --git a/modules/id3/vainfo.class.php b/modules/id3/vainfo.class.php
index d9efe341..23f2703f 100755
--- a/modules/id3/vainfo.class.php
+++ b/modules/id3/vainfo.class.php
@@ -28,19 +28,18 @@
class vainfo {
/* Default Encoding */
- var $encoding = 'UTF-8';
+ var $encoding = '';
/* Loaded Variables */
var $filename = '';
var $type = '';
var $tags = array();
- var $info = array();
-
/* Internal Information */
var $_raw = array();
var $_getID3 = '';
var $_iconv = false;
+ var $_file_encoding = '';
var $_file_pattern = '';
var $_dir_pattern = '';
@@ -93,9 +92,15 @@ class vainfo {
/* Figure out what type of file we are dealing with */
$this->type = $this->_get_type();
+ /* This is very important, figure out th encoding of the
+ * file
+ */
+ $this->_set_encoding();
+
/* Get the general information about this file */
$info = $this->_get_info();
+
/* Gets the Tags */
$this->tags = $this->_get_tags();
$this->tags['info'] = $info;
@@ -105,6 +110,26 @@ class vainfo {
} // get_info
/**
+ * _set_encoding
+ * This function trys to figure out what the encoding
+ * is based on the file type and sets the _file_encoding
+ * var to whatever it finds, the default is UTF-8 if we
+ * can't find anything
+ */
+ function _set_encoding() {
+ /* Switch on the file type */
+ switch ($this->type) {
+ case 'mp3':
+ $this->_file_encoding = $this->_raw['encoding'];
+ break;
+ default:
+ $this->_file_encoding = 'UTF-8';
+ break;
+ } // end switch
+
+ } // _get_encoding
+
+ /**
* _get_type
* This function takes the raw information and figures out
* what type of file we are dealing with for use by the tag
@@ -285,14 +310,14 @@ class vainfo {
function _parse_id3v1($tags) {
$array = array();
-
+
/* Go through all the tags */
foreach ($tags as $tag=>$data) {
/* This is our baseline for naming
* so no translation needed
*/
- $array[$tag] = $this->_clean_tag($data['0']);
+ $array[$tag] = $this->_clean_tag($data['0'],$this->_file_encoding);
} // end foreach
@@ -316,7 +341,7 @@ class vainfo {
/* This is our baseline for naming so
* no translation is needed
*/
- $array[$tag] = $this->_clean_tag($data['0']);
+ $array[$tag] = $this->_clean_tag($data['0'],$this->_file_encoding);
} // end foreach
@@ -379,10 +404,13 @@ class vainfo {
* in the file
*/
function _clean_tag($tag,$encoding='') {
+
+ /* Guess that it's UTF-8 */
+ if (!$encoding) { $encoding = 'UTF-8'; }
-
- if ($this->_iconv) {
- $tag = iconv('UTF-8',conf('site_charset'),$tag);
+ if ($this->_iconv AND strcasecmp($encoding,$this->encoding) != 0) {
+ $charset = $this->encoding . '//TRANSLIT';
+ $tag = iconv($encoding,$charset,$tag);
}
return $tag;