Skip to content

Commit

Permalink
Added an option to skip playlists that are refering to a single album…
Browse files Browse the repository at this point in the history
… + skip playlists that are empty, fixes #577
  • Loading branch information
epoupon committed Jan 15, 2025
1 parent 4a75e52 commit 1d15be1
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 35 deletions.
36 changes: 25 additions & 11 deletions approot/admin-scansettings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<!--FORMS message blocks-->

<message id="Lms.Admin.Database.template">
<form class="row g-3">
<form class="row g-3 mb-3">
<legend>${tr:Lms.Admin.Database.scan-settings}</legend>
<div class="col-sm-6">
<label class="form-label" for="${id:update-period}">
Expand All @@ -24,15 +24,7 @@
${update-start-time-info}
</div>
</div>
<div class="col-12">
<label class="form-label" for="${id:similarity-engine-type}">
${tr:Lms.Admin.Database.similarity-engine-type}
</label>
${similarity-engine-type class="form-control"}
<div class="invalid-feedback">
${similarity-engine-type-info}
</div>
</div>
<legend>${tr:Lms.Admin.Database.tag-parsing}</legend>
<div class="col-12">
<label class="form-label" for="${id:extra-tags-to-scan}">
${tr:Lms.Admin.Database.extra-tags-to-scan}
Expand All @@ -54,10 +46,32 @@
</label>
${default-tag-delimiter-container class="row gy-3"}
</div>
<legend>${tr:Lms.Admin.Database.misc}</legend>
<div class="col-12">
<div class="form-check">
${skip-single-release-playlists class="form-check-input"}
<label class="form-check-label" for="${id:skip-single-release-playlists}">
${tr:Lms.Admin.Database.skip-single-release-playlists}
</label>
<div class="invalid-feedback">
${skip-single-release-playlists-info}
</div>
</div>
</div>
<div class="col-12">
${save-btn class="btn btn-primary me-1"}${discard-btn class="btn btn-secondary"}
<label class="form-label" for="${id:similarity-engine-type}">
${tr:Lms.Admin.Database.similarity-engine-type}
</label>
${similarity-engine-type class="form-control"}
<div class="invalid-feedback">
${similarity-engine-type-info}
</div>
</div>
</form>
<hr/>
<div class="col-12">
${save-btn class="btn btn-primary me-1"}${discard-btn class="btn btn-secondary"}
</div>
</message>

<message id="Lms.Admin.Database.template.line-edit-entry">
Expand Down
3 changes: 3 additions & 0 deletions approot/messages.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<message id="Lms.Admin.Database.extra-tags-to-scan">Extra tags to scan</message>
<message id="Lms.Admin.Database.hourly">Hourly</message>
<message id="Lms.Admin.Database.immediate-scan">Scan now!</message>
<message id="Lms.Admin.Database.misc">Miscellaneous</message>
<message id="Lms.Admin.Database.monthly">Monthly</message>
<message id="Lms.Admin.Database.never">Never</message>
<message id="Lms.Admin.Database.scan-aborted">Scan aborted!</message>
Expand All @@ -87,7 +88,9 @@
<message id="Lms.Admin.Database.similarity-engine-type">Similarity engine</message>
<message id="Lms.Admin.Database.similarity-engine-type.clusters">Tag-based</message>
<message id="Lms.Admin.Database.similarity-engine-type.none">None</message>
<message id="Lms.Admin.Database.skip-single-release-playlists">Skip playlists that contain tracks from the same album</message>
<message id="Lms.Admin.Database.tag-delimiter-must-not-contain-only-spaces">The tag delimiter must not consist solely of spaces</message>
<message id="Lms.Admin.Database.tag-parsing">Tag parsing</message>
<message id="Lms.Admin.Database.update-period">Update period</message>
<message id="Lms.Admin.Database.update-start-time">Update start time</message>
<message id="Lms.Admin.Database.weekly">Weekly</message>
Expand Down
3 changes: 3 additions & 0 deletions approot/messages_fr.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<message id="Lms.Admin.Database.extra-tags-to-scan">Tags supplémentaires à scanner</message>
<message id="Lms.Admin.Database.hourly">Toutes les heures</message>
<message id="Lms.Admin.Database.immediate-scan">Scanner maintenant !</message>
<message id="Lms.Admin.Database.misc">Divers</message>
<message id="Lms.Admin.Database.monthly">Tous les mois</message>
<message id="Lms.Admin.Database.never">Jamais</message>
<message id="Lms.Admin.Database.scan-aborted">Scan interrompu !</message>
Expand All @@ -87,7 +88,9 @@
<message id="Lms.Admin.Database.similarity-engine-type">Moteur de similarité</message>
<message id="Lms.Admin.Database.similarity-engine-type.clusters">Basé sur les tags</message>
<message id="Lms.Admin.Database.similarity-engine-type.none">Aucun</message>
<message id="Lms.Admin.Database.skip-single-release-playlists">Ignorer les playlists contenant des pistes d'un même album</message>
<message id="Lms.Admin.Database.tag-delimiter-must-not-contain-only-spaces">Le délimiteur de tag ne doit pas comporter uniquement des espaces</message>
<message id="Lms.Admin.Database.tag-parsing">Analyse des tags</message>
<message id="Lms.Admin.Database.update-period">Périodicité des mises à jour</message>
<message id="Lms.Admin.Database.update-start-time">Heure de départ de la mise à jour</message>
<message id="Lms.Admin.Database.weekly">Toutes les semaines</message>
Expand Down
3 changes: 3 additions & 0 deletions approot/messages_it.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<message id="Lms.Admin.Database.extra-tags-to-scan">Tag aggiuntivi da scansionare</message>
<message id="Lms.Admin.Database.hourly">Ogni ora</message>
<message id="Lms.Admin.Database.immediate-scan">Scansiona ora!</message>
<message id="Lms.Admin.Database.misc">Varie</message>
<message id="Lms.Admin.Database.monthly">Mensile</message>
<message id="Lms.Admin.Database.never">Mai</message>
<message id="Lms.Admin.Database.scan-aborted">Scansione annullata!</message>
Expand All @@ -87,7 +88,9 @@
<message id="Lms.Admin.Database.similarity-engine-type">Motore di similarità</message>
<message id="Lms.Admin.Database.similarity-engine-type.clusters">Basato su tag</message>
<message id="Lms.Admin.Database.similarity-engine-type.none">Nessuno</message>
<message id="Lms.Admin.Database.skip-single-release-playlists">Salta le playlist che contengono brani dello stesso album</message>
<message id="Lms.Admin.Database.tag-delimiter-must-not-contain-only-spaces">Il delimitatore del tag non deve consistere esclusivamente di spazi</message>
<message id="Lms.Admin.Database.tag-parsing">Analisi dei tag</message>
<message id="Lms.Admin.Database.update-period">Frequenza di aggiornamento</message>
<message id="Lms.Admin.Database.update-start-time">Orario di aggiornamento</message>
<message id="Lms.Admin.Database.weekly">Settimanale</message>
Expand Down
3 changes: 3 additions & 0 deletions approot/messages_pl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<message id="Lms.Admin.Database.extra-tags-to-scan">Szukaj dodatkowych znaczników</message>
<message id="Lms.Admin.Database.hourly">Co godzinę</message>
<message id="Lms.Admin.Database.immediate-scan">Skanuj teraz!</message>
<message id="Lms.Admin.Database.misc">Różne</message>
<message id="Lms.Admin.Database.monthly">Co miesiąc</message>
<message id="Lms.Admin.Database.never">Nigdy</message>
<message id="Lms.Admin.Database.scan-aborted">Skanowanie przerwane!</message>
Expand All @@ -88,7 +89,9 @@
<message id="Lms.Admin.Database.similarity-engine-type">Metoda sprawdzania podobieństwa</message>
<message id="Lms.Admin.Database.similarity-engine-type.clusters">Oparta o znaczniki</message>
<message id="Lms.Admin.Database.similarity-engine-type.none">Żadna</message>
<message id="Lms.Admin.Database.skip-single-release-playlists">Pomiń playlisty zawierające utwory z tego samego albumu</message>
<message id="Lms.Admin.Database.tag-delimiter-must-not-contain-only-spaces">Rozdzielacz nie może się składać z samych białych znaków</message>
<message id="Lms.Admin.Database.tag-parsing">Analiza tagów</message>
<message id="Lms.Admin.Database.update-period">Okres aktualizacji</message>
<message id="Lms.Admin.Database.update-start-time">Czas startu aktualizacji</message>
<message id="Lms.Admin.Database.weekly">Co tydzień</message>
Expand Down
3 changes: 3 additions & 0 deletions approot/messages_zh.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@

<message id="Lms.Admin.Database.hourly">每小时</message>
<message id="Lms.Admin.Database.immediate-scan">立即扫描!</message>

<message id="Lms.Admin.Database.monthly">每月</message>
<message id="Lms.Admin.Database.never">从不</message>

Expand All @@ -88,6 +89,8 @@





<message id="Lms.Admin.Database.update-period">更新周期</message>
<message id="Lms.Admin.Database.update-start-time">更新开始时间</message>
<message id="Lms.Admin.Database.weekly">每周</message>
Expand Down
9 changes: 8 additions & 1 deletion src/libs/database/impl/Migration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace lms::db
{
namespace
{
static constexpr Version LMS_DATABASE_VERSION{ 77 };
static constexpr Version LMS_DATABASE_VERSION{ 78 };
}

VersionInfo::VersionInfo()
Expand Down Expand Up @@ -1029,6 +1029,12 @@ FROM tracklist)");
utils::executeCommand(*session.getDboSession(), "UPDATE scan_settings SET scan_version = scan_version + 1");
}

void migrateFromV77(Session& session)
{
// added new scan settings: skip single release playlists (default value is conservative, no need to rescan)
utils::executeCommand(*session.getDboSession(), "ALTER TABLE scan_settings ADD COLUMN skip_single_release_playlists BOOLEAN NOT NULL DEFAULT(FALSE)");
}

bool doDbMigration(Session& session)
{
constexpr std::string_view outdatedMsg{ "Outdated database, please rebuild it (delete the .db file and restart)" };
Expand Down Expand Up @@ -1082,6 +1088,7 @@ FROM tracklist)");
{ 74, migrateFromV74 },
{ 75, migrateFromV75 },
{ 76, migrateFromV76 },
{ 77, migrateFromV77 },
};

bool migrationPerformed{};
Expand Down
9 changes: 9 additions & 0 deletions src/libs/database/impl/ScanSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,15 @@ namespace lms::db
}
}

void ScanSettings::setSkipSingleReleasePlayLists(bool value)
{
if (_skipSingleReleasePlayLists != value)
{
_skipSingleReleasePlayLists = value;
incScanVersion();
}
}

void ScanSettings::incScanVersion()
{
_scanVersion += 1;
Expand Down
4 changes: 4 additions & 0 deletions src/libs/database/include/database/ScanSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ namespace lms::db
SimilarityEngineType getSimilarityEngineType() const { return _similarityEngineType; }
std::vector<std::string> getArtistTagDelimiters() const;
std::vector<std::string> getDefaultTagDelimiters() const;
bool getSkipSingleReleasePlayLists() const { return _skipSingleReleasePlayLists; }

// Setters
void setUpdateStartTime(Wt::WTime t) { _startTime = t; }
Expand All @@ -78,6 +79,7 @@ namespace lms::db
void setSimilarityEngineType(SimilarityEngineType type) { _similarityEngineType = type; }
void setArtistTagDelimiters(std::span<const std::string_view> delimiters);
void setDefaultTagDelimiters(std::span<const std::string_view> delimiters);
void setSkipSingleReleasePlayLists(bool value);
void incScanVersion();

template<class Action>
Expand All @@ -90,6 +92,7 @@ namespace lms::db
Wt::Dbo::field(a, _extraTagsToScan, "extra_tags_to_scan");
Wt::Dbo::field(a, _artistTagDelimiters, "artist_tag_delimiters");
Wt::Dbo::field(a, _defaultTagDelimiters, "default_tag_delimiters");
Wt::Dbo::field(a, _skipSingleReleasePlayLists, "skip_single_release_playlists");
}

private:
Expand All @@ -100,5 +103,6 @@ namespace lms::db
std::string _extraTagsToScan;
std::string _artistTagDelimiters;
std::string _defaultTagDelimiters;
bool _skipSingleReleasePlayLists{ false };
};
} // namespace lms::db
1 change: 1 addition & 0 deletions src/libs/database/include/database/Track.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ namespace lms::db
std::vector<ObjectPtr<Artist>> getArtists(core::EnumSet<TrackArtistLinkType> artistLinkTypes) const; // no type means all
std::vector<ArtistId> getArtistIds(core::EnumSet<TrackArtistLinkType> artistLinkTypes) const; // no type means all
std::vector<ObjectPtr<TrackArtistLink>> getArtistLinks() const;
ReleaseId getReleaseId() const { return _release.id(); }
ObjectPtr<Release> getRelease() const { return _release; }
std::vector<ObjectPtr<Cluster>> getClusters() const;
std::vector<ClusterId> getClusterIds() const;
Expand Down
3 changes: 2 additions & 1 deletion src/libs/services/scanner/impl/ScannerService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,6 @@ namespace lms::scanner
return;

LMS_LOG(DBUPDATER, DEBUG, "Scanner settings updated");
LMS_LOG(DBUPDATER, DEBUG, "skipDuplicateMBID = " << newSettings.skipDuplicateMBID);
LMS_LOG(DBUPDATER, DEBUG, "Using scan settings version " << newSettings.scanVersion);

_settings = std::move(newSettings);
Expand Down Expand Up @@ -406,6 +405,8 @@ namespace lms::scanner

newSettings.artistTagDelimiters = scanSettings->getArtistTagDelimiters();
newSettings.defaultTagDelimiters = scanSettings->getDefaultTagDelimiters();

newSettings.skipSingleReleasePlayLists = scanSettings->getSkipSingleReleasePlayLists();
}

return newSettings;
Expand Down
2 changes: 2 additions & 0 deletions src/libs/services/scanner/impl/ScannerSettings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ namespace lms::scanner
std::vector<std::string> extraTags;
std::vector<std::string> artistTagDelimiters;
std::vector<std::string> defaultTagDelimiters;
bool skipSingleReleasePlayLists{};

std::vector<MediaLibraryInfo> mediaLibraries;

bool operator==(const ScannerSettings& rhs) const = default;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ namespace lms::scanner
stats.deletions++;
}
context.stats.errors.emplace_back(_file, ScanErrorType::CannotReadPlayListFile);
LMS_LOG(DBUPDATER, DEBUG, "Removed playlist file " << _file);
return;
}

Expand Down
Loading

0 comments on commit 1d15be1

Please sign in to comment.