Captures the audio container of the music tracks

Adds a Container to the audio metadata, captured with TagLibSharp from the concrete type of the parsed file during the music library scan and stored on the track through a new column and an EF migration. The container is refreshed when a file changes, survives track and artist edits and provider enrichment, and is exposed read-only in the track responses, never settable through a request.

Extracts the container resolution into a testable resolver used by the scan pipeline and the ID3 plugin, refuses to read a file that is itself a reparse point during extraction, and updates the endpoint summaries, the API and domain documentation, and the tests.
This commit is contained in:
BinaryAlley committed 2026-10-14 13:40:28 +03:00
1 parent 4ffa81fffe
commit f29f89f31f
60 files changed
+4483 -68

No files matched your search

@@ -94,6 +94,11 @@ public class MusicLibraryScanItemMetadataEntity : IStorageEntity
/// </summary>
public string? AudioCodec { get; set; }
/// <summary>
/// Gets or sets the container of the audio file, for example MP3, FLAC, OGG, AAC, MP4 or WAV, if applicable.
/// </summary>
public string? Container { get; set; }
/// <summary>
/// Gets or sets the bitrate of the audio in kbps, if applicable.
/// </summary>
@@ -141,6 +141,11 @@ public class TrackEntity : IStorageEntity, IAuditableEntity
/// </summary>
public string? AudioCodec { get; set; }
/// <summary>
/// Gets or sets the container of the audio file, for example MP3, FLAC, OGG, AAC, MP4 or WAV, if applicable.
/// </summary>
public string? Container { get; set; }
/// <summary>
/// Gets or sets the bitrate of the audio in kbps, if applicable.
/// </summary>
@@ -202,6 +202,9 @@ public static class AudioMetadataDtoMapping
Optional<string> audioCodec = Optional<string>.FromNullable(dto.AudioCodec);
if (!audioCodec.HasValue)
audioCodec = track.Metadata.AudioCodec;
// The container is captured from the file itself: a provider that re-reads the file supplies it, and when it is absent the track keeps the stored
// container, which the domain enforces when the metadata is applied. The preserve rule therefore lives in one place, the domain update.
Optional<string> container = Optional<string>.FromNullable(dto.Container);
Optional<int> bitrate = Optional<int>.FromNullable(dto.Bitrate);
if (!bitrate.HasValue)
bitrate = track.Metadata.Bitrate;
@@ -220,6 +223,7 @@ public static class AudioMetadataDtoMapping
originalLanguage,
bitDepth,
audioCodec,
container,
bitrate,
track.Metadata.AcoustId,
track.Metadata.ReplayGainTrackGain,
@@ -63,6 +63,7 @@ public static class MusicTrackMetadataDtoMapping
if (dto.OriginalLanguage is not null && dto.OriginalLanguage.LanguageCode is not null && dto.OriginalLanguage.LanguageName is not null)
originalLanguage = LanguageInfo.Create(dto.OriginalLanguage.LanguageCode, dto.OriginalLanguage.LanguageName, Optional<string>.FromNullable(dto.OriginalLanguage.NativeName));
// The container is captured from the file itself and is never settable through a request; on an edit the track keeps the container it already has.
return AudioMetadata.Create(
dto.Title!,
Optional<string>.FromNullable(dto.OriginalTitle),
@@ -77,6 +78,7 @@ public static class MusicTrackMetadataDtoMapping
originalLanguage,
Optional<int>.FromNullable(dto.BitDepth),
Optional<string>.FromNullable(dto.AudioCodec),
Optional<string>.None(),
Optional<int>.FromNullable(dto.Bitrate),
Optional<string>.FromNullable(dto.AcoustId),
Optional<decimal>.FromNullable(dto.ReplayGainTrackGain),
@@ -84,6 +84,7 @@ public static class TrackEntityMapping
originalLanguage,
Optional<int>.FromNullable(repositoryEntity.BitDepth),
Optional<string>.FromNullable(repositoryEntity.AudioCodec),
Optional<string>.FromNullable(repositoryEntity.Container),
Optional<int>.FromNullable(repositoryEntity.Bitrate),
Optional<string>.FromNullable(repositoryEntity.AcoustId),
Optional<decimal>.FromNullable(repositoryEntity.ReplayGainTrackGain),
@@ -259,7 +260,8 @@ public static class TrackEntityMapping
[.. repositoryEntity.Moods.ToResponses()],
[.. repositoryEntity.Isrcs.ToResponses()],
[.. repositoryEntity.Contributors.Select(contributor => new MediaContributorReferenceDto(contributor.MediaContributorId, contributor.Role))],
[.. repositoryEntity.Ratings.ToResponses()]);
[.. repositoryEntity.Ratings.ToResponses()],
repositoryEntity.Container);
}
/// <summary>
@@ -52,6 +52,7 @@ public static class TrackMapping
Channels = domainEntity.Metadata.Channels,
BitDepth = domainEntity.Metadata.BitDepth.HasValue ? domainEntity.Metadata.BitDepth.Value : null,
AudioCodec = domainEntity.Metadata.AudioCodec.HasValue ? domainEntity.Metadata.AudioCodec.Value : null,
Container = domainEntity.Metadata.Container.HasValue ? domainEntity.Metadata.Container.Value : null,
Bitrate = domainEntity.Metadata.Bitrate.HasValue ? domainEntity.Metadata.Bitrate.Value : null,
AcoustId = domainEntity.Metadata.AcoustId.HasValue ? domainEntity.Metadata.AcoustId.Value : null,
ReplayGainTrackGain = domainEntity.Metadata.ReplayGainTrackGain.HasValue ? domainEntity.Metadata.ReplayGainTrackGain.Value : null,