Skip to content

Extracting description key properly #585

Closed

Description

@UnknownSuperficialNight

Reproducer

if let Some(desc) = tag.get_string(&ItemKey::Description) {
    return Some(desc.to_string());
}

Summary

I've been having issues getting the description key,

I'm on version 0.22.4 and I assumed comment method would fallback on description Nope

so for some reason tag.get_string(&ItemKey::Description) failed to get the description, instead I had to come up with this for it

// As a last resort, try to find a custom key named "DESCRIPTION" (case-insensitive)
for item in tag.items() {
    // Check if the key is an unknown/custom key and matches "description"
    if let ItemKey::Unknown(s) = item.key() {
        if s.eq_ignore_ascii_case("description") {
            if let Some(text) = item.value().text() {
                return Some(text.to_string());
            }
        }
    }
}

Not pretty, but it works for now till the next update

Expected behavior

Return the Description key's value when I do tag.get_string(&ItemKey::Description)

Assets

No response

Activity

  1. added
    bug
    on Jan 4, 2026
  2. Serial-ATA commented on Jan 5, 2026

    @Serial-ATA
    Owner

    I'm on version 0.22.4 and I assumed comment method would fallback on description Nope

    ItemKey::Comment and ItemKey::Description aren't the same thing AFAICT.

    Return the Description key's value when I do tag.get_string(&ItemKey::Description)

    To be clear, the actual issue is that the ItemKey conversion is case-sensitive, and not that Comment != Description?

  3. UnknownSuperficialNight commented on Jan 5, 2026

    @UnknownSuperficialNight
    ContributorAuthor

    I'm on version 0.22.4 and I assumed comment method would fallback on description Nope

    ItemKey::Comment and ItemKey::Description aren't the same thing AFAICT.

    * https://xiph.org/vorbis/doc/v-comment.html#fieldnames
      
      * It seems for Vorbis Comments "DESCRIPTION" was _meant_ to be the field for comments, but didn't catch on.
    
    * https://github.com/get-iplayer/get_iplayer/wiki/tagging
      
      * It only seems to have a special meaning in MP4 for video descriptions (probably from iTunes)
    

    Return the Description key's value when I do tag.get_string(&ItemKey::Description)

    To be clear, the actual issue is that the ItemKey conversion is case-sensitive, and not that Comment != Description?

    Ah, I see, thanks for the clarification (I use vorbis most the time so that's where I'm basing that apon)

    To be clear, the actual issue is that the ItemKey conversion is case-sensitive

    Has this been resolved in previous discussions or is this still a topic of discussion

  4. Serial-ATA commented on Jan 5, 2026

    @Serial-ATA
    Owner

    Has this been resolved in previous discussions or is this still a topic of discussion

    I thought it might be the issue, but conversions are already case-insensitive. There's just no mapping for "DESCRIPTION" -> ItemKey::Description for Vorbis Comments:

    gen_map!(
    VORBIS_MAP;
    "ALBUM" => AlbumTitle,
    "DISCSUBTITLE" => SetSubtitle,
    "GROUPING" => ContentGroup,
    "TITLE" => TrackTitle,
    "SUBTITLE" => TrackSubtitle,
    "WORK" => Work,
    "MOVEMENTNAME" => Movement,
    "MOVEMENT" => MovementNumber,
    "MOVEMENTTOTAL" => MovementTotal,
    "RELEASECOUNTRY" => ReleaseCountry,
    "ALBUMSORT" => AlbumTitleSortOrder,
    "ALBUMARTISTSORT" => AlbumArtistSortOrder,
    "TITLESORT" => TrackTitleSortOrder,
    "ARTISTSORT" => TrackArtistSortOrder,
    "ALBUMARTIST" | "ALBUM ARTIST" => AlbumArtist,
    "ALBUMARTISTS" | "ALBUM ARTISTS" => AlbumArtists,
    "ARTIST" => TrackArtist,
    "ARTISTS" => TrackArtists,
    "ARRANGER" => Arranger,
    "AUTHOR" | "WRITER" => Writer,
    "COMPOSER" => Composer,
    "CONDUCTOR" => Conductor,
    "DIRECTOR" => Director,
    "ENGINEER" => Engineer,
    "LYRICIST" => Lyricist,
    "DJMIXER" => MixDj,
    "MIXER" => MixEngineer,
    "PERFORMER" => Performer,
    "PRODUCER" => Producer,
    "PUBLISHER" => Publisher,
    "LABEL" | "ORGANIZATION" => Label,
    "REMIXER" | "MIXARTIST" => Remixer,
    "DISCNUMBER" => DiscNumber,
    "DISCTOTAL" | "TOTALDISCS" => DiscTotal,
    "TRACKNUMBER" => TrackNumber,
    "TRACKTOTAL" | "TOTALTRACKS" => TrackTotal,
    "RATING" => Popularimeter,
    "DATE" => RecordingDate,
    "YEAR" => Year,
    "ORIGINALDATE" | "ORIGINALYEAR" => OriginalReleaseDate,
    "RELEASEDATE" => ReleaseDate,
    "ISRC" => Isrc,
    "BARCODE" => Barcode,
    "ACOUSTID_ID" => AcoustId,
    "ACOUSTID_FINGERPRINT" => AcoustIdFingerprint,
    "CATALOGNUMBER" => CatalogNumber,
    "COMPILATION" => FlagCompilation,
    "MEDIA" => OriginalMediaType,
    "ENCODEDBY" | "ENCODED-BY" | "ENCODED_BY" => EncodedBy,
    "ENCODER" => EncoderSoftware,
    "ENCODING" | "ENCODERSETTINGS" => EncoderSettings,
    "REPLAYGAIN_ALBUM_GAIN" => ReplayGainAlbumGain,
    "REPLAYGAIN_ALBUM_PEAK" => ReplayGainAlbumPeak,
    "REPLAYGAIN_TRACK_GAIN" => ReplayGainTrackGain,
    "REPLAYGAIN_TRACK_PEAK" => ReplayGainTrackPeak,
    "GENRE" => Genre,
    "COLOR" => Color,
    "MOOD" => Mood,
    "BPM" => Bpm,
    // MusicBrainz Picard suggests "KEY" (VirtualDJ, Denon Engine DJ), but "INITIALKEY"
    // seems to be more common (Rekordbox, Serato DJ, Traktor DJ, Mixxx).
    // <https://picard-docs.musicbrainz.org/en/appendices/tag_mapping.html#initial-key>
    // <https://github.com/beetbox/beets/issues/637#issuecomment-39528023>
    "INITIALKEY" | "KEY" => InitialKey,
    "COPYRIGHT" => CopyrightMessage,
    "LICENSE" => License,
    "COMMENT" => Comment,
    "LANGUAGE" => Language,
    "SCRIPT" => Script,
    "LYRICS" => Lyrics,
    "UNSYNCEDLYRICS" => UnsyncLyrics,
    "MUSICBRAINZ_TRACKID" => MusicBrainzRecordingId,
    "MUSICBRAINZ_RELEASETRACKID" => MusicBrainzTrackId,
    "MUSICBRAINZ_ALBUMID" => MusicBrainzReleaseId,
    "MUSICBRAINZ_RELEASEGROUPID" => MusicBrainzReleaseGroupId,
    "MUSICBRAINZ_ARTISTID" => MusicBrainzArtistId,
    "MUSICBRAINZ_ALBUMARTISTID" => MusicBrainzReleaseArtistId,
    "MUSICBRAINZ_WORKID" => MusicBrainzWorkId
    );

    I guess I just skipped it when I added ItemKey::Description, since it's identical to ItemKey::Comment in this case.

    I'll have to look into "DESCRIPTION" more and see if maybe I should just merge it into ItemKey::Comment in Vorbis Comments. I've never seen it in the wild.

  5. added this to the 0.23.0 milestone on Jan 5, 2026
  6. Serial-ATA commented on Jan 7, 2026

    @Serial-ATA
    Owner

    Looked into it a bit, and it doesn't look like anyone really uses "DESCRIPTION" in Vorbis Comments. I think the original intent was for it to be a comment field, but "COMMENT" ended up winning.

    Since "DESCRIPTION" is a distinct field in MP4 though, I imagine some converted files in the wild have both "COMMENT"s and "DESCRIPTION"s, so I'll keep them distinct.

    In just about every case though, you probably just want ItemKey::Comment.

  7. UnknownSuperficialNight commented on Jan 7, 2026

    @UnknownSuperficialNight
    ContributorAuthor

    Looked into it a bit, and it doesn't look like anyone really uses "DESCRIPTION" in Vorbis Comments. I think the original intent was for it to be a comment field, but "COMMENT" ended up winning.

    Since "DESCRIPTION" is a distinct field in MP4 though, I imagine some converted files in the wild have both "COMMENT"s and "DESCRIPTION"s, so I'll keep them distinct.

    In just about every case though, you probably just want ItemKey::Comment.

    Makes sense.

    I thought it might be the issue, but conversions are already case-insensitive. There's just no mapping for "DESCRIPTION" -> ItemKey::Description for Vorbis Comments:

    Are you going to add mappings for DESCRIPTION to ItemKey::Description in vorbis?

  8. Serial-ATA commented on Jan 7, 2026

    @Serial-ATA
    Owner

    Are you going to add mappings for DESCRIPTION to ItemKey::Description in vorbis?

    Yep, fixed now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions