Enhance movie import process and metadata handling
ci / build-backend (push) Successful in 1m33s
ci / build-frontend (push) Successful in 55s
ci / tests (push) Successful in 3m27s
ci / sonar (push) Successful in 6m55s

Refactored the movie import functionality to ensure that the title from the source is used for the show name, while the file name is retained as the original title. Improved the handling of metadata during the import process, allowing for better integration of original titles from various sources. Updated related classes and methods to streamline the import workflow and enhance user experience. Added tests to verify the correct assignment of titles and original names during the import process. Updated documentation to reflect these changes.
This commit is contained in:
Leonid Pershin
2026-07-28 03:14:19 +03:00
parent d859a9894c
commit d0bc0465e7
21 changed files with 926 additions and 698 deletions
@@ -107,6 +107,65 @@ public class ImportMoviesTests
.CleanupManualLeftoversAsync("Gladiator.2000.BDRip.mkv", Arg.Any<CancellationToken>());
}
[Fact]
public async Task NamesShowAsInTheSource_AndKeepsFileTitleAsOriginal()
{
// В таблице разбора «Название» — строка поиска: «Die Hard 2» там стоит ровно для того,
// чтобы найти «Крепкий орешек 2». В библиотеку должно попасть название источника,
// а латинское — остаться оригинальным.
var fixture = new TestDb();
var result = await ImportAsync(
fixture,
StorageWith("Die Hard 2 [1990 HDRip].avi"),
Resolver(
new ShowMetadata(
"42",
"Крепкий орешек 2",
1990,
"desc",
null,
[],
null,
null,
"Die Hard 2"
)
),
Substitute.For<IMediaProcessingQueue>(),
new MovieImportItem("Die Hard 2 [1990 HDRip].avi", null, "Die Hard 2", 1990, "42")
);
Assert.Equal(1, result.Enriched);
await using var db = fixture.New();
var show = await db.Shows.SingleAsync(CancellationToken.None);
Assert.Equal("Крепкий орешек 2", show.Name);
Assert.Equal("Die Hard 2", show.OriginalName);
}
[Fact]
public async Task KeepsTypedTitleAsOriginal_WhenSourceHasNoOriginal()
{
// У OMDb оригинального названия нет — тогда оригинальным становится то, что вписали
// в таблице: по нему потом ищутся релизы.
var fixture = new TestDb();
var result = await ImportAsync(
fixture,
StorageWith("Spaun.1997.VHSRip.avi"),
Resolver(new ShowMetadata("5", "Спаун", 1997, null, null, [], null, null)),
Substitute.For<IMediaProcessingQueue>(),
new MovieImportItem("Spaun.1997.VHSRip.avi", null, "Spaun", 1997, "5")
);
Assert.Equal(1, result.Enriched);
await using var db = fixture.New();
var show = await db.Shows.SingleAsync(CancellationToken.None);
Assert.Equal("Спаун", show.Name);
Assert.Equal("Spaun", show.OriginalName);
}
[Fact]
public async Task CreatesShowWithoutMetadata_WhenCandidateIsNotChosen()
{