CopyTagsToComments not working for first of series (win)

The place for "I can't figure out how to..." questions.
Post Reply
jxn
User
Posts: 7
Joined: Thu Feb 23, 2006 4:14 pm

CopyTagsToComments not working for first of series (win)

Post by jxn » Wed Feb 21, 2007 1:15 am

Hi there... I'm having problems getting copytagstocomments to copy tags to comments for the first in a series of analyzed files. Unless I'm quite incompetent (always possible), I wonder if this might be a bug in getid3. My code works fine on linux machines, but refuses to copy tags on windows machines for the first file fetched by my code... here's the part I feel is relevant:

Code: Select all

// getTrkId3() function
//
// Description: 
// This function uses getId3_lib::CopyTagsToComments(), specifically the returned comments_html array 
// to retrieve tags information from files in a semi-stable manner 
// 
// inputs:
// 1. string filename of file from which to retrieve tags 
//
// outputs:
// 1. an array with file information/metadata
//    Array Structure:
//    $array[category] (id of the file's main category)
//          [artist]
//          [album]
//          [num] (track number)
//          [title] (track title)
//          [virtue] requred to sort outside of UNSORTED dir 
//          [status] required to save outside of UNSORTED dir
//          [bitrate]
//          [ext] (filename extension)
//          [filesize]
//          [status]
//          [genre]
//          [playtime]
//          [filepath]
//          [filename]
// 3. destination directory 
//
// Outputs:
// an array with the file name and directory on success; false on failure.

function getTrkId3 ($file) {
   include_once('./includes/getid3-1.7.8b1/getid3/getid3.php');
   $fileTypes = array('mp3','ogg','wmv','asf','flac','wma','wav','aac','m4a'); // for now, m4a doesn't seem to work... 
   $fileInfo = pathinfo($file); // grab path and file names for the file; returns an array with 'dirname','basename','extension', and 'filename'
   $ext = strtolower($fileInfo[extension]);
   if(in_array($ext,$fileTypes)) {
      
      // initialize a new getID3 object
      $getID3 = new getID3;
      
      // use getid3's analyze function to examine the incoming file 
      $trackInfo = $getID3->analyze($incomingDir.$file);
      
      // getid3's CopyTagsToComments function can take the snagged metadata and put it into an array marked as 'comments_html'
      getid3_lib::CopyTagsToComments($trackInfo);
      
      // put the relevant comments_html array data into a simpler array called $trkFile, which we'll use throughout the program 
      $trk['title'] = (isset($trackInfo['comments_html']['title'][0]) ? $trackInfo['comments_html']['title'][0] : "");
      
      // make a few attempts at getting the track artist name 
//      $trk['artist'] = (isset($trackInfo['comments_html']['artist'][0]) ? $trackInfo['comments_html']['artist'][0] : "");
      if ( isset($trackInfo['comments_html']['artist'][0]) ) {
         $trk['artist'] = $trackInfo['comments_html']['artist'][0];
      } else if ( isset($trackInfo['comments_html']['TPE1'][0]) ) {
         $trk['artist'] = $trackInfo['comments_html']['TPE1'][0];
      } else if ( isset($trackInfo['comments_html']['

jxn
User
Posts: 7
Joined: Thu Feb 23, 2006 4:14 pm

Post by jxn » Mon Aug 20, 2007 2:17 pm

...as a workaround, I've found that scanning a dummy track (ie. scanning the first file in a series once, then rescanning each file after that) works alright. I expect it's a slightly unnecessary overhead, though.

Allan Hansen
getID3() v2 developer
Posts: 445
Joined: Sun May 04, 2003 2:22 pm
Location: Holmegaard, Denmark

Post by Allan Hansen » Mon Aug 20, 2007 5:25 pm

Maybe it is an issue with PHP?

We have done no testing with versions > 5.1.6.

jxn
User
Posts: 7
Joined: Thu Feb 23, 2006 4:14 pm

Post by jxn » Mon Aug 20, 2007 6:22 pm

Allan Hansen wrote:Maybe it is an issue with PHP?

We have done no testing with versions > 5.1.6.
possibly: I'm using 5.2.3

Post Reply