Change track DB add method to give more details on failure when it happens.
This commit is contained in:
@@ -405,7 +405,7 @@ AudioTrack GroovePlayerMgr::getCurrentTrack(Wt::Dbo::Session* session)
|
||||
}
|
||||
|
||||
|
||||
bool GroovePlayerMgr::addFileToTrackDBIfTagged(Wt::Dbo::Session* session, std::filesystem::path file)
|
||||
GroovePlayerMgr::ScanResults GroovePlayerMgr::addFileToTrackDBIfTagged(Wt::Dbo::Session* session, std::filesystem::path file)
|
||||
{
|
||||
//Now check if tags exist and put into DB.
|
||||
struct GrooveFile* gfile = groove_file_open(file.c_str());
|
||||
@@ -418,7 +418,11 @@ bool GroovePlayerMgr::addFileToTrackDBIfTagged(Wt::Dbo::Session* session, std::f
|
||||
//Only accept song with all metadata for DB.
|
||||
Wt::log("info") << "Audio track " << file << " did not have all required tags.";
|
||||
groove_file_close(gfile);
|
||||
return false;
|
||||
if(artist_tag == nullptr && album_tag != nullptr && name_tag != nullptr && genre_tag != nullptr) return ScanResults::MISSING_ARTIST_TAG;
|
||||
if(artist_tag != nullptr && album_tag == nullptr && name_tag == nullptr && genre_tag == nullptr) return ScanResults::MISSING_ALBUM_TAG;
|
||||
if(artist_tag != nullptr && album_tag != nullptr && name_tag == nullptr && genre_tag != nullptr) return ScanResults::MISSING_TITLE_TAG;
|
||||
if(artist_tag != nullptr && album_tag != nullptr && name_tag != nullptr && genre_tag == nullptr) return ScanResults::MISSING_GENRE_TAG;
|
||||
return ScanResults::MISSING_MULTIPLE_TAGS;
|
||||
}
|
||||
|
||||
//Take fingerprint and compare to DB.
|
||||
@@ -444,7 +448,7 @@ bool GroovePlayerMgr::addFileToTrackDBIfTagged(Wt::Dbo::Session* session, std::f
|
||||
{
|
||||
//This track has a duplicate already.
|
||||
groove_file_close(gfile);
|
||||
return false;
|
||||
return ScanResults::DUPLICATE_TRACK;
|
||||
}
|
||||
|
||||
//Add to DB.
|
||||
@@ -463,13 +467,13 @@ bool GroovePlayerMgr::addFileToTrackDBIfTagged(Wt::Dbo::Session* session, std::f
|
||||
{
|
||||
Wt::log("info") << "Audio track " << newTrack->trackPath << " did not have cover art in the file.";
|
||||
groove_file_close(gfile);
|
||||
return false;
|
||||
return ScanResults::MISSING_COVERART_TAG;
|
||||
}
|
||||
|
||||
session->add(newTrack);
|
||||
transaction.commit();
|
||||
groove_file_close(gfile);
|
||||
return true;
|
||||
return ScanResults::ACCEPTED;
|
||||
}
|
||||
|
||||
void GroovePlayerMgr::removeOrphanedTracks(Wt::Dbo::Session* session)
|
||||
|
||||
@@ -50,6 +50,9 @@ public:
|
||||
std::list<AudioTrack> currentVoteBatch;
|
||||
std::list<std::pair<AudioTrack, int>> currentVoteStatus;
|
||||
bool voteEndedButNotNextTrackYet = false;
|
||||
|
||||
enum ScanResults {ACCEPTED = true, MISSING_ARTIST_TAG = false, MISSING_ALBUM_TAG = false, MISSING_TITLE_TAG = false, MISSING_GENRE_TAG = false, DUPLICATE_TRACK = false, MISSING_COVERART_TAG = false, MISSING_MULTIPLE_TAGS = false};
|
||||
ScanResults addFileToTrackDBIfTagged(Wt::Dbo::Session* session, std::filesystem::path file);
|
||||
private:
|
||||
enum PlayerEvents {NOTHING, GROOVE_NOWPLAYING, VOTING_ENDED, VOTE_CAST, PLAYING_PAUSED, PLAYING_RESUMED, SKIP_REQUESTED, SKIP_VOTE_CAST, SKIP_VOTING_ENDED, ADMIN_FORCE_SKIP};
|
||||
|
||||
@@ -68,7 +71,6 @@ private:
|
||||
std::thread* grooveAudioScanner;
|
||||
void grooveAudioScannerLoop();
|
||||
PlayerEvents getNextPlayerEvent(Wt::Dbo::Session* session);
|
||||
bool addFileToTrackDBIfTagged(Wt::Dbo::Session* session, std::filesystem::path file);
|
||||
void removeOrphanedTracks(Wt::Dbo::Session* session);
|
||||
|
||||
AudioTrack getCurrentTrack(Wt::Dbo::Session* session);
|
||||
|
||||
Reference in New Issue
Block a user