[WIP] Added Artist/ReleaseInfo

This commit is contained in:
emeric
2019-01-23 13:22:43 +01:00
parent b76c60f437
commit 3e142b5507
77 changed files with 2706 additions and 716 deletions
+24 -4
View File
@@ -27,13 +27,11 @@
#include <Wt/WLocalDateTime.h>
#include "cover/CoverArtGrabber.hpp"
#include "database/Artist.hpp"
#include "database/Cluster.hpp"
#include "database/Release.hpp"
#include "database/ScanSettings.hpp"
#include "database/Track.hpp"
#include "utils/Logger.hpp"
#include "utils/Path.hpp"
#include "utils/Utils.hpp"
@@ -198,6 +196,12 @@ _db(connectionPool)
refreshScanSettings();
}
void
MediaScanner::setAddon(MediaScannerAddon& addon)
{
_addons.push_back(&addon);
}
void
MediaScanner::restart(void)
{
@@ -332,9 +336,11 @@ MediaScanner::scan(boost::system::error_code err)
LMS_LOG(DBUPDATER, INFO) << "Scan " << (_running ? "complete" : "aborted") << ". Changes = " << stats.nbChanges() << " (added = " << stats.additions << ", removed = " << stats.deletions << ", updated = " << stats.updates << "), Not changed = " << stats.skips << ", Scanned = " << stats.scans << " (errors = " << stats.scanErrors << ", not imported = " << stats.incompleteScans << "), duplicates = " << stats.nbDuplicates() << " (hash = " << stats.duplicateHashes << ", mbid = " << stats.duplicateMBID << ")";
// Save the last scan only if it has been completed
if (_running)
{
for (auto& addon : _addons)
addon->preScanComplete();
scheduleScan();
scanComplete().emit(stats);
@@ -365,6 +371,11 @@ MediaScanner::refreshScanSettings()
[](ClusterType::pointer clusterType) -> std::string { return clusterType->getName(); });
_metadataParser.setClusterTypeNames(clusterTypeNames);
transaction.commit();
for (auto& addon : _addons)
addon->refreshSettings();
}
void
@@ -492,12 +503,14 @@ MediaScanner::scanAudioFile(const boost::filesystem::path& file, bool forceScan,
// If file already exist, update data
// Otherwise, create it
bool trackAdded = false;
if (!track)
{
// Create a new song
track = Track::create(_db.getSession(), file);
LMS_LOG(DBUPDATER, INFO) << "Adding '" << file.string() << "'";
stats.additions++;
trackAdded = true;
}
else
{
@@ -583,6 +596,14 @@ MediaScanner::scanAudioFile(const boost::filesystem::path& file, bool forceScan,
}
transaction.commit();
for (auto& addon : _addons)
{
if (trackAdded)
addon->trackAdded(track.id());
else
addon->trackUpdated(track.id());
}
}
void
@@ -753,5 +774,4 @@ MediaScanner::checkDuplicatedAudioFiles(Stats& stats)
LMS_LOG(DBUPDATER, INFO) << "Checking duplicated audio files done!";
}
} // namespace Scanner
+10 -5
View File
@@ -26,10 +26,11 @@
#include <boost/asio/system_timer.hpp>
#include "metadata/TagLibParser.hpp"
#include "database/ScanSettings.hpp"
#include "database/DatabaseHandler.hpp"
#include "metadata/TagLibParser.hpp"
#include "MediaScannerAddon.hpp"
namespace Scanner {
@@ -39,6 +40,8 @@ class MediaScanner
MediaScanner(Wt::Dbo::SqlConnectionPool& connectionPool);
void setAddon(MediaScannerAddon& addon);
void start();
void stop();
void restart();
@@ -83,10 +86,10 @@ class MediaScanner
// Helpers
void refreshScanSettings();
void removeMissingTracks( Stats& stats );
void removeMissingTracks(Stats& stats);
void removeOrphanEntries();
void checkDuplicatedAudioFiles( Stats& stats );
void scanAudioFile( const boost::filesystem::path& file, bool forceScan, Stats& stats);
void checkDuplicatedAudioFiles(Stats& stats);
void scanAudioFile(const boost::filesystem::path& file, bool forceScan, Stats& stats);
bool _running;
Wt::WIOService _ioService;
@@ -106,6 +109,8 @@ class MediaScanner
MetaData::TagLibParser _metadataParser;
std::vector<MediaScannerAddon*> _addons;
}; // class MediaScanner
} // Scanner
+39
View File
@@ -0,0 +1,39 @@
/*
* Copyright (C) 2018 Emeric Poupon
*
* This file is part of LMS.
*
* LMS is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LMS is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LMS. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "database/Types.hpp"
namespace Scanner {
class MediaScannerAddon
{
public:
virtual void refreshSettings() = 0;
virtual void trackAdded(Database::IdType trackId) = 0;
virtual void trackToRemove(Database::IdType trackId) = 0;
virtual void trackUpdated(Database::IdType trackId) = 0;
virtual void preScanComplete() = 0;
};
} // ns Scanner