function do_track_by_track($trackobject) { // The difference between this and the above function is that this one takes tracks as they come in direct // from the backend - without being collectionised. This is faster and uses less RAM but does rely on the tags // being correct - they're filtered before being sent here. // Tracks must have disc and albumartist tags to be handled by this method. // The collectionizer was designed to sort tracks without those tags so if those tags exist they don't need // to be collectionized. global $mysqlc, $find_track, $update_track, $prefs; static $current_albumartist = null; static $current_album = null; static $current_domain = null; static $current_albumlink = null; static $albumobj = null; static $albumindex = null; static $albumartistindex = null; $artistname = $trackobject->get_sort_artist(); if ($current_albumartist != $artistname) { $albumartistindex = check_artist($artistname, false); } if ($albumartistindex == null) { debuglog("ERROR! Checked artist " . $artistname . " and index is still null!", "MYSQL_TBT", 1); return false; } if ($current_albumartist != $artistname || $current_album != $trackobject->tags['Album'] || $current_domain != $trackobject->tags['domain'] || $trackobject->tags['X-AlbumUri'] != null && $trackobject->tags['X-AlbumUri'] != $current_albumlink) { $albumobj = new album($trackobject->tags['Album'], $artistname, $trackobject->tags['domain']); $albumobj->newTrack($trackobject); $albumindex = check_album($albumobj->name, $albumartistindex, $albumobj->uri, $albumobj->getImage('small'), $albumobj->getDate(), "0", $albumobj->getKey(), $albumobj->musicbrainz_albumid, $albumobj->domain, false); if ($albumindex == null) { debuglog("ERROR! Album index for " . $albumobj->name . " is still null!", "MYSQL_TBT", 1); return false; } } else { $albumobj->newTrack($trackobject, true); } $current_albumartist = $artistname; $current_album = $albumobj->name; $current_domain = $albumobj->domain; $current_albumlink = $albumobj->uri; foreach ($albumobj->tracks as $trackobj) { // The album we've just created must only have one track, but this makes sure we use the track object // that is part of the album. This MAY be important due to various assumptions and the fact that PHP // insists on copying variables rather than passing by reference. check_and_update_track($trackobj, $albumindex, $albumartistindex, $artistname); } }