From 3ef83cc34e52fefba5f4927cf5dbea7a0549a094 Mon Sep 17 00:00:00 2001 From: Sonico Date: Wed, 20 Jul 2022 18:12:51 -0300 Subject: [PATCH] Add titleSort tag --- doc/protocol.rst | 1 + src/decoder/plugins/FfmpegMetaData.cxx | 2 ++ src/tag/Id3Scan.cxx | 5 +++++ src/tag/Names.c | 1 + src/tag/Type.h | 1 + 5 files changed, 10 insertions(+) diff --git a/doc/protocol.rst b/doc/protocol.rst index 16268852a..2b55aa124 100644 --- a/doc/protocol.rst +++ b/doc/protocol.rst @@ -283,6 +283,7 @@ The following tags are supported by :program:`MPD`: * **albumartist**: on multi-artist albums, this is the artist name which shall be used for the whole album. The exact meaning of this tag is not well-defined. * **albumartistsort**: same as albumartist, but for sorting. * **title**: the song title. +* **titlesort**: same as title, but for sorting. * **track**: the decimal track number within the album. * **name**: a name for this song. This is not the song title. The exact meaning of this tag is not well-defined. It is often used by badly configured internet radio stations with broken tags to squeeze both the artist name and the song title in one tag. * **genre**: the music genre. diff --git a/src/decoder/plugins/FfmpegMetaData.cxx b/src/decoder/plugins/FfmpegMetaData.cxx index 59b05c85b..6e2716d9f 100644 --- a/src/decoder/plugins/FfmpegMetaData.cxx +++ b/src/decoder/plugins/FfmpegMetaData.cxx @@ -40,11 +40,13 @@ static constexpr struct tag_table ffmpeg_tags[] = { /* from libavformat/id3v2.c */ { "album-sort", TAG_ALBUM_SORT }, { "artist-sort", TAG_ARTIST_SORT }, + { "title-sort", TAG_TITLE_SORT}, /* from libavformat/mov.c */ { "sort_album_artist", TAG_ALBUM_ARTIST_SORT }, { "sort_album", TAG_ALBUM_SORT }, { "sort_artist", TAG_ARTIST_SORT }, + { "sort_name", TAG_TITLE_SORT }, /* sentinel */ { nullptr, TAG_NUM_OF_ITEM_TYPES } diff --git a/src/tag/Id3Scan.cxx b/src/tag/Id3Scan.cxx index eaf16f979..79b67d499 100644 --- a/src/tag/Id3Scan.cxx +++ b/src/tag/Id3Scan.cxx @@ -55,6 +55,10 @@ #define ID3_FRAME_ALBUM_ARTIST "TPE2" #endif +#ifndef ID3_FRAME_TITLE_SORT +#define ID3_FRAME_TITLE_SORT "TSOT" +#endif + #ifndef ID3_FRAME_ORIGINAL_RELEASE_DATE #define ID3_FRAME_ORIGINAL_RELEASE_DATE "TDOR" #endif @@ -352,6 +356,7 @@ scan_id3_tag(const struct id3_tag *tag, TagHandler &handler) noexcept tag_id3_import_text(tag, ID3_FRAME_LABEL, TAG_LABEL, handler); tag_id3_import_text(tag, ID3_FRAME_MOOD, TAG_MOOD, handler); + tag_id3_import_text(tag, ID3_FRAME_TITLE_SORT, TAG_TITLE_SORT, handler); tag_id3_import_musicbrainz(tag, handler); tag_id3_import_ufid(tag, handler); diff --git a/src/tag/Names.c b/src/tag/Names.c index 88dd9d716..b4fef1f46 100644 --- a/src/tag/Names.c +++ b/src/tag/Names.c @@ -27,6 +27,7 @@ const char *const tag_item_names[TAG_NUM_OF_ITEM_TYPES] = { [TAG_ALBUM_ARTIST] = "AlbumArtist", [TAG_ALBUM_ARTIST_SORT] = "AlbumArtistSort", [TAG_TITLE] = "Title", + [TAG_TITLE_SORT] = "TitleSort", [TAG_TRACK] = "Track", [TAG_NAME] = "Name", [TAG_GENRE] = "Genre", diff --git a/src/tag/Type.h b/src/tag/Type.h index 4e3f80a29..c085610b0 100644 --- a/src/tag/Type.h +++ b/src/tag/Type.h @@ -42,6 +42,7 @@ enum TagType TAG_ALBUM_ARTIST, TAG_ALBUM_ARTIST_SORT, TAG_TITLE, + TAG_TITLE_SORT, TAG_TRACK, TAG_NAME, TAG_GENRE,