Ticket #285: autotagconvert.patch

File autotagconvert.patch, 3.1 kB (added by momo-i, 5 months ago)
  • catalog.class.php

     
    10741074                /* Record the reading of these tags */ 
    10751075                debug_event('tag-read',"Reading Tags from $song->file",'5','ampache-catalog'); 
    10761076                 
    1077                 $vainfo = new vainfo($song->file,'',$sort_pattern,$rename_pattern); 
     1077                $vainfo = new vainfo($song->file,'','','',$sort_pattern,$rename_pattern); 
    10781078                $vainfo->get_info(); 
    10791079 
    10801080                /* Find the correct key */ 
     
    20002000        public function insert_local_song($file,$file_info) { 
    20012001 
    20022002                /* Create the vainfo object and get info */ 
    2003                 $vainfo         = new vainfo($file,'',$this->sort_pattern,$this->rename_pattern); 
     2003                $vainfo         = new vainfo($file,'','','',$this->sort_pattern,$this->rename_pattern); 
    20042004                $vainfo->get_info(); 
    20052005 
    20062006                $key = get_tag_type($vainfo->tags); 
  • vainfo.class.php

     
    2727class vainfo {  
    2828 
    2929        /* Default Encoding */ 
    30         var $encoding = ''; 
     30        var $encoding = 'UTF-8'; 
     31        var $encoding_id3v1 = ''; 
     32        var $encoding_id3v2 = ''; 
    3133         
    3234        /* Loaded Variables */ 
    3335        var $filename = ''; 
     
    3638 
    3739        /* Internal Information */ 
    3840        var $_raw               = array(); 
     41        var $_raw2              = array(); 
    3942        var $_getID3            = ''; 
    4043        var $_iconv             = false;  
    4144        var $_file_encoding     = ''; 
     
    4750         * This function just sets up the class, it doesn't 
    4851         * actually pull the information 
    4952         */ 
    50         function vainfo($file,$encoding='',$dir_pattern,$file_pattern) {  
     53        function vainfo($file,$encoding='UTF-8',$encoding_id3v1='',$encoding_id3v2='',$dir_pattern,$file_pattern) {  
    5154 
    5255                $this->filename = $file; 
    5356                if ($encoding) {  
     
    6366 
    6467                // Initialize getID3 engine 
    6568                $this->_getID3 = new getID3(); 
     69 
     70                // get id3tag encodings 
     71                $this->_raw2 = $this->_getID3->analyze($file); 
     72                if(function_exsits('mb_detect_encoding')) { 
     73                        if(mb_detect_encoding($this->_raw2['tags']['id3v1']['title']['0'])) { 
     74                                $this->encoding_id3v1 = mb_detect_encoding($this->_raw2['tags']['id3v1']['title']['0']); 
     75                        } 
     76                        else { 
     77                                $this->encoding_id3v1 = $encoding_id3v1; 
     78                        } 
     79                        if(mb_detect_encoding($this->_raw2['tags']['id3v2']['title']['0'])) { 
     80                                $this->encoding_id3v2 = mb_detect_encoding($this->_raw2['tags']['id3v2']['title']['0']); 
     81                        } 
     82                        else { 
     83                                $this->encoding_id3v2 = $encoding_id3v2; 
     84                        } 
     85                } 
     86                else { 
     87                        $this->encoding_id3v1 = $encoding_id3v1; 
     88                        $this->encoding_id3v2 = $encoding_id3v2; 
     89                } 
     90 
    6691                $this->_getID3->option_md5_data         = false; 
    6792                $this->_getID3->option_md5_data_source  = false; 
    6893                $this->_getID3->option_tags_html        = false; 
    6994                $this->_getID3->option_extra_info       = false; 
    7095                $this->_getID3->option_tag_lyrics3      = false; 
    7196                $this->_getID3->encoding                = $this->encoding;  
     97                $this->_getID3->encoding_id3v1          = $this->encoding_id3v1; 
     98                $this->_getID3->encoding_id3v2          = $this->encoding_id3v2; 
    7299                $this->_getID3->option_tags_process    = true;  
    73100 
    74101                /* Check for ICONV */