Adds the music library scanning pipeline, its scanner, scan jobs, and path structure

This commit is contained in:
BinaryAlley committed 2026-10-09 20:53:00 +03:00
1 parent 9e118864c3
commit 35ac1dbdcb
38 files changed
+5119 -1150

No files matched your search

@@ -224,29 +224,29 @@ public class LibraryPathTemplateServiceTests
public void Parse_WhenRelativePathIsEmpty_ShouldReturnNull(string relativePath)
{
// Act
Result<ParsedLibraryPath?> result = _sut.Parse(LibraryType.Music, CreateMusicTemplate(), relativePath, '/');
Result<Optional<ParsedLibraryPath>> result = _sut.Parse(LibraryType.Music, CreateMusicTemplate(), relativePath, '/');
// Assert
Assert.False(result.IsFailure);
Assert.Null(result.Value);
Assert.False(result.Value.HasValue);
}
[Fact]
public void Parse_WhenTemplateIsEmpty_ShouldReturnNull()
{
// Act
Result<ParsedLibraryPath?> result = _sut.Parse(LibraryType.Music, LibraryPathTemplate.Empty(), "Pink Floyd/1973 - Time.mp3", '/');
Result<Optional<ParsedLibraryPath>> result = _sut.Parse(LibraryType.Music, LibraryPathTemplate.Empty(), "Pink Floyd/1973 - Time.mp3", '/');
// Assert
Assert.False(result.IsFailure);
Assert.Null(result.Value);
Assert.False(result.Value.HasValue);
}
[Fact]
public void Parse_WhenTemplateIsNotSupportedForTheLibraryType_ShouldReturnError()
{
// Act
Result<ParsedLibraryPath?> result = _sut.Parse(LibraryType.Book, CreateMusicTemplate(), "Pink Floyd/1973 - Time.mp3", '/');
Result<Optional<ParsedLibraryPath>> result = _sut.Parse(LibraryType.Book, CreateMusicTemplate(), "Pink Floyd/1973 - Time.mp3", '/');
// Assert
Assert.True(result.IsFailure);
@@ -261,11 +261,11 @@ public class LibraryPathTemplateServiceTests
LibraryPathTemplate template = CreateMusicTemplate();
// Act
Result<ParsedLibraryPath?> result = _sut.Parse(LibraryType.Music, template, "Pink Floyd/1973 - Time.mp3", '/');
Result<Optional<ParsedLibraryPath>> result = _sut.Parse(LibraryType.Music, template, "Pink Floyd/1973 - Time.mp3", '/');
// Assert
Assert.False(result.IsFailure);
ParsedLibraryPath parsedPath = result.Value!;
ParsedLibraryPath parsedPath = result.Value.Value;
Assert.Equal("Pink Floyd", parsedPath.GetString(LibraryPathPartKind.Artist).Value);
Assert.Equal(1973, parsedPath.GetInt(LibraryPathPartKind.ReleaseYear).Value);
Assert.Equal("Time", parsedPath.GetString(LibraryPathPartKind.TrackName).Value);
@@ -280,11 +280,11 @@ public class LibraryPathTemplateServiceTests
LibraryPathTemplate template = CreateMusicTemplate();
// Act
Result<ParsedLibraryPath?> result = _sut.Parse(LibraryType.Music, template, "Pink Floyd/no year/Time.mp3", '/');
Result<Optional<ParsedLibraryPath>> result = _sut.Parse(LibraryType.Music, template, "Pink Floyd/no year/Time.mp3", '/');
// Assert
Assert.False(result.IsFailure);
Assert.Null(result.Value);
Assert.False(result.Value.HasValue);
}
[Fact]
@@ -305,11 +305,11 @@ public class LibraryPathTemplateServiceTests
]);
// Act
Result<ParsedLibraryPath?> result = _sut.Parse(LibraryType.Music, template, "Pink Floyd/07", '/');
Result<Optional<ParsedLibraryPath>> result = _sut.Parse(LibraryType.Music, template, "Pink Floyd/07", '/');
// Assert
Assert.False(result.IsFailure);
Assert.Equal(7, result.Value!.GetInt(LibraryPathPartKind.TrackNumber).Value);
Assert.Equal(7, result.Value.Value.GetInt(LibraryPathPartKind.TrackNumber).Value);
}
[Fact]
@@ -330,11 +330,11 @@ public class LibraryPathTemplateServiceTests
]);
// Act
Result<ParsedLibraryPath?> result = _sut.Parse(LibraryType.Music, template, "Pink Floyd/007", '/');
Result<Optional<ParsedLibraryPath>> result = _sut.Parse(LibraryType.Music, template, "Pink Floyd/007", '/');
// Assert
Assert.False(result.IsFailure);
Assert.Null(result.Value);
Assert.False(result.Value.HasValue);
}
[Fact]
@@ -351,11 +351,11 @@ public class LibraryPathTemplateServiceTests
]);
// Act
Result<ParsedLibraryPath?> result = _sut.Parse(LibraryType.Music, template, "1973", '/');
Result<Optional<ParsedLibraryPath>> result = _sut.Parse(LibraryType.Music, template, "1973", '/');
// Assert
Assert.False(result.IsFailure);
Assert.Equal(1973, result.Value!.GetInt(LibraryPathPartKind.ReleaseYear).Value);
Assert.Equal(1973, result.Value.Value.GetInt(LibraryPathPartKind.ReleaseYear).Value);
}
[Fact]
@@ -372,11 +372,11 @@ public class LibraryPathTemplateServiceTests
]);
// Act
Result<ParsedLibraryPath?> result = _sut.Parse(LibraryType.Music, template, "73", '/');
Result<Optional<ParsedLibraryPath>> result = _sut.Parse(LibraryType.Music, template, "73", '/');
// Assert
Assert.False(result.IsFailure);
Assert.Null(result.Value);
Assert.False(result.Value.HasValue);
}
[Fact]
@@ -397,12 +397,12 @@ public class LibraryPathTemplateServiceTests
]);
// Act
Result<ParsedLibraryPath?> result = _sut.Parse(LibraryType.Music, template, "Pink Floyd/", '/');
Result<Optional<ParsedLibraryPath>> result = _sut.Parse(LibraryType.Music, template, "Pink Floyd/", '/');
// Assert
Assert.False(result.IsFailure);
Assert.Equal("Pink Floyd", result.Value!.GetString(LibraryPathPartKind.Artist).Value);
Assert.False(result.Value.GetInt(LibraryPathPartKind.DiscNumber).HasValue);
Assert.Equal("Pink Floyd", result.Value.Value.GetString(LibraryPathPartKind.Artist).Value);
Assert.False(result.Value.Value.GetInt(LibraryPathPartKind.DiscNumber).HasValue);
}
[Fact]
@@ -423,12 +423,12 @@ public class LibraryPathTemplateServiceTests
]);
// Act
Result<ParsedLibraryPath?> result = _sut.Parse(LibraryType.Music, template, "Pink Floyd/02", '/');
Result<Optional<ParsedLibraryPath>> result = _sut.Parse(LibraryType.Music, template, "Pink Floyd/02", '/');
// Assert
Assert.False(result.IsFailure);
Assert.Equal("Pink Floyd", result.Value!.GetString(LibraryPathPartKind.Artist).Value);
Assert.Equal(2, result.Value.GetInt(LibraryPathPartKind.DiscNumber).Value);
Assert.Equal("Pink Floyd", result.Value.Value.GetString(LibraryPathPartKind.Artist).Value);
Assert.Equal(2, result.Value.Value.GetInt(LibraryPathPartKind.DiscNumber).Value);
}
[Fact]
@@ -452,11 +452,11 @@ public class LibraryPathTemplateServiceTests
]);
// Act
Result<ParsedLibraryPath?> result = _sut.Parse(LibraryType.Music, template, "Tolkien/The Lord of the Rings - J.R.R. Tolkien", '/');
Result<Optional<ParsedLibraryPath>> result = _sut.Parse(LibraryType.Music, template, "Tolkien/The Lord of the Rings - J.R.R. Tolkien", '/');
// Assert
Assert.False(result.IsFailure);
Assert.Equal("Tolkien", result.Value!.GetString(LibraryPathPartKind.Author).Value);
Assert.Equal("Tolkien", result.Value.Value.GetString(LibraryPathPartKind.Author).Value);
}
/// <summary>
@@ -1,4 +1,5 @@
#region ========================================================================= USING =====================================================================================
using Lumina.Domain.Core.BoundedContexts.AudioLibraryBoundedContext.MusicLibraryAggregate.Services.Scanners;
using Lumina.Domain.Core.BoundedContexts.LibraryManagementBoundedContext.LibraryScanAggregate.Services.Scanners;
using Lumina.Domain.Core.BoundedContexts.WrittenContentLibraryBoundedContext.BookLibraryAggregate.Services.Scanners;
using Lumina.Domain.SharedKernel.Common.Enums.MediaLibrary;
@@ -33,6 +34,23 @@ public class MediaLibraryScannerFactoryTests
Assert.Same(expectedScanner, scanner);
}
[Fact]
public void CreateLibraryScanner_WhenLibraryTypeIsMusic_ShouldReturnMusicLibraryTypeScanner()
{
// Arrange
IMusicLibraryTypeScanner expectedScanner = Substitute.For<IMusicLibraryTypeScanner>();
ServiceCollection services = new();
services.AddSingleton(expectedScanner);
using ServiceProvider serviceProvider = services.BuildServiceProvider();
MediaLibraryScannerFactory sut = new(serviceProvider);
// Act
IMediaTypeScanner scanner = sut.CreateLibraryScanner(LibraryType.Music);
// Assert
Assert.Same(expectedScanner, scanner);
}
[Theory]
[InlineData(LibraryType.EBook)] // eBook scanner is not implemented
[InlineData(LibraryType.ComicBook)] // comic book scanner is not implemented
@@ -55,7 +73,6 @@ public class MediaLibraryScannerFactoryTests
[InlineData(LibraryType.InterviewVideo)] // interview video scanner is not implemented
[InlineData(LibraryType.CoverSongVideo)] // cover song video scanner is not implemented
[InlineData(LibraryType.PodcastVideo)] // podcast video scanner is not implemented
[InlineData(LibraryType.Music)] // music scanner is not implemented
[InlineData(LibraryType.Audiobook)] // audiobook scanner is not implemented
[InlineData(LibraryType.LiveRecordingAudio)] // live recording audio scanner is not implemented
[InlineData(LibraryType.InterviewAudio)] // interview audio scanner is not implemented