/*! * \brief Check a list of files against images already in the database * * \param music_files MusicLoadedMap * * \returns Nothing. */ void MusicFileScanner::ScanArtwork(MusicLoadedMap &music_files) { MusicLoadedMap::Iterator iter; MSqlQuery query(MSqlQuery::InitCon()); query.prepare("SELECT CONCAT_WS('/', path, filename) " "FROM music_albumart " "LEFT JOIN music_directories ON music_albumart.directory_id=music_directories.directory_id " "WHERE music_albumart.embedded = 0 " "AND music_albumart.hostname = :HOSTNAME"); query.bindValue(":HOSTNAME", gCoreContext->GetHostName()); if (!query.exec()) MythDB::DBError("MusicFileScanner::ScanArtwork", query); LOG(VB_GENERAL, LOG_INFO, "Checking artwork"); QString name; if (query.isActive() && query.size() > 0) { while (query.next()) { for (int x = 0; x < m_startDirs.count(); x++) { name = m_startDirs[x] + query.value(0).toString(); if ((iter = music_files.find(name)) != music_files.end()) break; } if (iter != music_files.end()) { if (music_files[name].location == MusicFileScanner::kDatabase) continue; else { ++m_coverartUnchanged; music_files.erase(iter); } } else { music_files[name].location = MusicFileScanner::kDatabase; } } } }
/*! * \brief Check a list of files against musics files already in the database * * \param music_files MusicLoadedMap * * \returns Nothing. */ void MusicFileScanner::ScanMusic(MusicLoadedMap &music_files) { MusicLoadedMap::Iterator iter; MSqlQuery query(MSqlQuery::InitCon()); query.prepare("SELECT CONCAT_WS('/', path, filename), date_modified " "FROM music_songs LEFT JOIN music_directories ON " "music_songs.directory_id=music_directories.directory_id " "WHERE filename NOT LIKE ('%://%') " "AND hostname = :HOSTNAME"); query.bindValue(":HOSTNAME", gCoreContext->GetHostName()); if (!query.exec()) MythDB::DBError("MusicFileScanner::ScanMusic", query); LOG(VB_GENERAL, LOG_INFO, "Checking tracks"); QString name; if (query.isActive() && query.size() > 0) { while (query.next()) { for (int x = 0; x < m_startDirs.count(); x++) { name = m_startDirs[x] + query.value(0).toString(); if ((iter = music_files.find(name)) != music_files.end()) break; } if (iter != music_files.end()) { if (music_files[name].location == MusicFileScanner::kDatabase) continue; else if (HasFileChanged(name, query.value(1).toString())) music_files[name].location = MusicFileScanner::kNeedUpdate; else { ++m_tracksUnchanged; music_files.erase(iter); } } else music_files[name].location = MusicFileScanner::kDatabase; } } }
/*! * \brief Check a list of files against images already in the database * * \param music_files MusicLoadedMap * * \returns Nothing. */ void FileScanner::ScanArtwork(MusicLoadedMap &music_files) { MusicLoadedMap::Iterator iter; MSqlQuery query(MSqlQuery::InitCon()); if (!query.exec("SELECT CONCAT_WS('/', path, filename) " "FROM music_albumart LEFT JOIN music_directories ON " "music_albumart.directory_id=music_directories.directory_id" " WHERE music_albumart.embedded=0")) MythDB::DBError("FileScanner::ScanArtwork", query); uint counter = 0; MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); QString message = QObject::tr("Scanning Album Artwork"); MythUIProgressDialog *file_checking = new MythUIProgressDialog(message, popupStack, "albumprogressdialog"); if (file_checking->Create()) { popupStack->AddScreen(file_checking, false); file_checking->SetTotal(query.size()); } else { delete file_checking; file_checking = NULL; } if (query.isActive() && query.size() > 0) { while (query.next()) { QString name; name = m_startdir + query.value(0).toString(); if (name != QString::null) { if ((iter = music_files.find(name)) != music_files.end()) { if (music_files[name] == kDatabase) { if (file_checking) { file_checking->SetProgress(++counter); qApp->processEvents(); } continue; } else music_files.erase(iter); } else { music_files[name] = kDatabase; } } if (file_checking) { file_checking->SetProgress(++counter); qApp->processEvents(); } } } if (file_checking) file_checking->Close(); }
/*! * \brief Check a list of files against musics files already in the database * * \param music_files MusicLoadedMap * * \returns Nothing. */ void FileScanner::ScanMusic(MusicLoadedMap &music_files) { MusicLoadedMap::Iterator iter; MSqlQuery query(MSqlQuery::InitCon()); if (!query.exec("SELECT CONCAT_WS('/', path, filename), date_modified " "FROM music_songs LEFT JOIN music_directories ON " "music_songs.directory_id=music_directories.directory_id " "WHERE filename NOT LIKE ('%://%')")) MythDB::DBError("FileScanner::ScanMusic", query); uint counter = 0; MythScreenStack *popupStack = GetMythMainWindow()->GetStack("popup stack"); QString message = QObject::tr("Scanning music files"); MythUIProgressDialog *file_checking = new MythUIProgressDialog(message, popupStack, "scalingprogressdialog"); if (file_checking->Create()) { popupStack->AddScreen(file_checking, false); file_checking->SetTotal(query.size()); } else { delete file_checking; file_checking = NULL; } QString name; if (query.isActive() && query.size() > 0) { while (query.next()) { name = m_startdir + query.value(0).toString(); if (name != QString::null) { if ((iter = music_files.find(name)) != music_files.end()) { if (music_files[name] == kDatabase) { if (file_checking) { file_checking->SetProgress(++counter); qApp->processEvents(); } continue; } else if (HasFileChanged(name, query.value(1).toString())) music_files[name] = kNeedUpdate; else music_files.erase(iter); } else { music_files[name] = kDatabase; } } if (file_checking) { file_checking->SetProgress(++counter); qApp->processEvents(); } } } if (file_checking) file_checking->Close(); }