public function run() { // first of all - try to guess if this dir should be // treated as an album or as a bunch of loose tracks // further this method is adding score to several attributes which will be migrated to production db-table $this->setHandleAsAlbum(); #print_r($this->r); cliLog("handleAsAlbumScore " . $this->handleAsAlbumScore, 3, 'purple'); #die(); #if($this->tracks[0]['relativePath'] == 'newroot/crse002cd--Calibre-Musique_Concrete-2CD-CRSE002CD-2001-sour/101-calibre-deep_everytime.mp3') { #print_r($this->r); die(); #} // extract some attributes from tracks // those will be used for album stuff $mergedFromTracks = array('artist' => array(), 'genre' => array(), 'label' => array(), 'catalogNr' => array()); foreach (array_keys($mergedFromTracks) as $what) { foreach ($this->tracks as $idx => $rawTagData) { $mergedFromTracks[$what][] = $this->getMostScored($idx, $what); } $mergedFromTracks[$what][] = $this->getMostScored('album', $what); $mergedFromTracks[$what] = join(',', array_unique($mergedFromTracks[$what])); } $albumArtists = count(trimExplode(",", $mergedFromTracks['artist'])) > 3 ? 'Various Artists' : $mergedFromTracks['artist']; $a = new Album(); $a->setArtistId(join(",", Artist::getIdsByString($albumArtists))); $a->setGenreId(join(",", Genre::getIdsByString($mergedFromTracks['genre']))); #$a->setLabelId(join(",", Label::getIdsByString($mergedFromTracks['label']))); $a->setCatalogNr($this->mostScored['album']['catalogNr']); $a->setRelativePath($this->getRelativeDirectoryPath()); $a->setRelativePathHash($this->getRelativeDirectoryPathHash()); $a->setAdded($this->getDirectoryMtime()); $a->setFilemtime($this->getDirectoryMtime()); $a->setTitle($this->mostScored['album']['title']); $a->setYear($this->mostScored['album']['year']); $a->setIsJumble($this->handleAsAlbum === TRUE ? 0 : 1); $a->setTrackCount(count($this->tracks)); #print_r($a); die(); $a->update(); $albumId = $a->getId(); // add the whole bunch of valid and indvalid attributes to albumindex table $this->updateAlbumIndex($albumId); foreach ($this->tracks as $idx => $rawTagData) { $t = $this->migrateNonGuessableData($rawTagData); $t->setArtistId($this->mostScored[$idx]['artist']); // currently the string insted of an artistId $t->setTitle($this->mostScored[$idx]['title']); $t->setFeaturedArtistsAndRemixers(); # setFeaturedArtistsAndRemixers() is processing: # $t->setArtistId(); # $t->setFeaturingId(); # $t->setRemixerId(); $t->setGenreId(join(",", Genre::getIdsByString($this->getMostScored($idx, 'genre')))); $t->setLabelId(join(",", Label::getIdsByString($this->getMostScored($idx, 'label')))); $t->setCatalogNr($this->mostScored[$idx]['catalogNr']); $t->setDisc($this->mostScored[$idx]['disc']); $t->setNumber($this->mostScored[$idx]['number']); $t->setComment($this->mostScored[$idx]['comment']); $t->setYear($this->mostScored[$idx]['year']); $t->setAlbumId($albumId); // make sure to use identical ids in table:rawtagdata and table:track \Slimpd\Track::ensureRecordIdExists($t->getId()); $t->update(); // make sure extracted images will be referenced to an album \Slimpd\Bitmap::addAlbumIdToTrackId($t->getId(), $albumId); # // add the whole bunch of valid and indvalid attributes to trackindex table $this->updateTrackIndex($t->getId(), $idx); } unset($this->r['album']); if ($this->handleAsAlbum === TRUE) { // try to guess if all tracks of this album has obviously invalid fixable attributes } return; print_r($this->r); #die(); }