diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-09-06 10:14:48 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-09-06 10:14:48 +1000 |
| commit | dad14baa73a9a46c450193da43bf960b436f7ec5 (patch) | |
| tree | 1a14d80682b2bcf4c0e7524b6f854c7c6c9aa164 /src/database/index.cpp | |
| parent | a9008884c93946f26fd26448aeb716d005693d6c (diff) | |
| download | tangara-fw-dad14baa73a9a46c450193da43bf960b436f7ec5.tar.gz | |
Add an opus-specific tag parser
Diffstat (limited to 'src/database/index.cpp')
| -rw-r--r-- | src/database/index.cpp | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/database/index.cpp b/src/database/index.cpp index 844b33a3..6ec88622 100644 --- a/src/database/index.cpp +++ b/src/database/index.cpp @@ -37,7 +37,8 @@ const IndexInfo kAllAlbums{ .components = {Tag::kAlbum, Tag::kAlbumTrack}, }; -static auto missing_component_text(Tag tag) -> std::optional<std::string> { +static auto missing_component_text(const Track& track, Tag tag) + -> std::optional<std::string> { switch (tag) { case Tag::kArtist: return "Unknown Artist"; @@ -45,9 +46,10 @@ static auto missing_component_text(Tag tag) -> std::optional<std::string> { return "Unknown Album"; case Tag::kGenre: return "Unknown Genre"; + case Tag::kTitle: + return track.TitleOrFilename(); case Tag::kAlbumTrack: case Tag::kDuration: - case Tag::kTitle: default: return {}; } @@ -77,18 +79,14 @@ auto Index(const IndexInfo& info, const Track& t, leveldb::WriteBatch* batch) value = *text; } else { key.item = {}; - value = missing_component_text(info.components.at(i)).value_or(""); + value = missing_component_text(t, info.components.at(i)).value_or(""); } // If this is the last component, then we should also fill in the track id // and title. if (i == info.components.size() - 1) { key.track = t.data().id(); - if (info.components.at(i) != Tag::kTitle) { - value = t.TitleOrFilename(); - } - } else { - key.track = {}; + value = t.TitleOrFilename(); } auto encoded = EncodeIndexKey(key); |
