//static CoverArt CoverArtUtils::guessCoverArt(TrackPointer pTrack) { CoverArt art; art.info.source = CoverInfo::GUESSED; if (pTrack.isNull()) { return art; } const QFileInfo fileInfo(pTrack->getFileInfo()); art.image = extractEmbeddedCover(fileInfo, pTrack->getSecurityToken()); if (!art.image.isNull()) { // TODO() here we my introduce a duplicate hash code art.info.hash = calculateHash(art.image); art.info.coverLocation = QString(); art.info.type = CoverInfo::METADATA; qDebug() << "CoverArtUtils::guessCoverArt found metadata art" << art; return art; } QLinkedList<QFileInfo> possibleCovers = findPossibleCoversInFolder( fileInfo.absolutePath()); art = selectCoverArtForTrack(pTrack.data(), possibleCovers); if (art.info.type == CoverInfo::FILE) { qDebug() << "CoverArtUtils::guessCoverArt found file art" << art; } else { qDebug() << "CoverArtUtils::guessCoverArt didn't find art" << art; } return art; }
//static CoverInfo CoverArtUtils::guessCoverInfo(const Track& track) { CoverInfo coverInfo; coverInfo.trackLocation = track.getLocation(); coverInfo.source = CoverInfo::GUESSED; const QFileInfo fileInfo(track.getFileInfo()); QImage image = extractEmbeddedCover(fileInfo, track.getSecurityToken()); if (!image.isNull()) { // TODO() here we my introduce a duplicate hash code coverInfo.hash = calculateHash(image); coverInfo.coverLocation = QString(); coverInfo.type = CoverInfo::METADATA; qDebug() << "CoverArtUtils::guessCover found metadata art" << coverInfo; return coverInfo; } QLinkedList<QFileInfo> possibleCovers = findPossibleCoversInFolder( fileInfo.absolutePath()); coverInfo = selectCoverArtForTrack(track, possibleCovers); if (coverInfo.type == CoverInfo::FILE) { qDebug() << "CoverArtUtils::guessCover found file art" << coverInfo; } else { qDebug() << "CoverArtUtils::guessCover didn't find art" << coverInfo; } return coverInfo; }
//static CoverInfo CoverArtUtils::selectCoverArtForTrack( const Track& track, const QLinkedList<QFileInfo>& covers) { const QString trackBaseName = track.getFileInfo().baseName(); const QString albumName = track.getAlbum(); const QString trackLocation = track.getLocation(); CoverInfoRelative coverInfoRelative = selectCoverArtForTrack(trackBaseName, albumName, covers); return CoverInfo(coverInfoRelative, trackLocation); }
//static CoverArt CoverArtUtils::selectCoverArtForTrack( Track* pTrack, const QLinkedList<QFileInfo>& covers) { if (pTrack == NULL || covers.isEmpty()) { CoverArt art; art.info.source = CoverInfo::GUESSED; return art; } const QString trackBaseName = pTrack->getFileInfo().baseName(); const QString albumName = pTrack->getAlbum(); return selectCoverArtForTrack(trackBaseName, albumName, covers); }