Enhance movie import process and metadata handling
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:
+61
-31
@@ -61,28 +61,17 @@ public sealed class ImportGridCommandHandler(
|
||||
foreach (var configLayer in command.Config.Layers)
|
||||
{
|
||||
var layer = EnsureLayer(template, configLayer);
|
||||
var (added, dropped) = await WriteSlotsAsync(
|
||||
layer,
|
||||
configLayer,
|
||||
groups,
|
||||
junctions,
|
||||
warnings,
|
||||
cancellationToken
|
||||
);
|
||||
|
||||
foreach (var configSlot in configLayer.Slots)
|
||||
{
|
||||
var input = ToInput(configSlot, groups, junctions, warnings);
|
||||
if (input is null)
|
||||
{
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
var applied = await writer.ApplyAsync(layer, null, input, cancellationToken);
|
||||
if (applied.IsSuccess)
|
||||
{
|
||||
created++;
|
||||
continue;
|
||||
}
|
||||
|
||||
skipped++;
|
||||
warnings.Add(
|
||||
$"Слот «{configSlot.Title}» ({configSlot.Start:HH\\:mm}): {applied.Error.Message}"
|
||||
);
|
||||
}
|
||||
created += added;
|
||||
skipped += dropped;
|
||||
}
|
||||
|
||||
Apply(template, command.Config, groups, junctions, warnings);
|
||||
@@ -101,6 +90,47 @@ public sealed class ImportGridCommandHandler(
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Пишет слоты одного слоя. Возвращает, сколько встало и сколько пропущено: слот, который
|
||||
/// не прошёл проверки, замечанием и остаётся — валить весь файл из-за одной строки нельзя.
|
||||
/// </summary>
|
||||
private async Task<(int Added, int Dropped)> WriteSlotsAsync(
|
||||
GridLayer layer,
|
||||
GridConfigLayer configLayer,
|
||||
IReadOnlyDictionary<string, Guid> groups,
|
||||
IReadOnlyDictionary<string, Guid> junctions,
|
||||
List<string> warnings,
|
||||
CancellationToken cancellationToken
|
||||
)
|
||||
{
|
||||
var added = 0;
|
||||
var dropped = 0;
|
||||
|
||||
foreach (var configSlot in configLayer.Slots)
|
||||
{
|
||||
var input = ToInput(configSlot, groups, junctions, warnings);
|
||||
if (input is null)
|
||||
{
|
||||
dropped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
var applied = await writer.ApplyAsync(layer, null, input, cancellationToken);
|
||||
if (applied.IsSuccess)
|
||||
{
|
||||
added++;
|
||||
continue;
|
||||
}
|
||||
|
||||
dropped++;
|
||||
warnings.Add(
|
||||
$"Слот «{configSlot.Title}» ({configSlot.Start:HH\\:mm}): {applied.Error.Message}"
|
||||
);
|
||||
}
|
||||
|
||||
return (added, dropped);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Заводит коллекции файла, которых нет в библиотеке. Существующая по имени не трогается: имя —
|
||||
/// это ключ узнаваемости, и дописывать в чужую коллекцию свои шоу импорт не вправе.
|
||||
@@ -266,17 +296,17 @@ public sealed class ImportGridCommandHandler(
|
||||
if (config.Rules is { } rules)
|
||||
template.SetRules(rules.ToJson());
|
||||
|
||||
if (config.FallbackGroup is { Length: > 0 } fallback)
|
||||
{
|
||||
if (Resolve(fallback, groups, "Группа", warnings) is { } groupId)
|
||||
template.SetFallbackGroup(groupId);
|
||||
}
|
||||
if (
|
||||
config.FallbackGroup is { Length: > 0 } fallback
|
||||
&& Resolve(fallback, groups, "Группа", warnings) is { } groupId
|
||||
)
|
||||
template.SetFallbackGroup(groupId);
|
||||
|
||||
if (config.DefaultJunction is { Length: > 0 } junction)
|
||||
{
|
||||
if (Resolve(junction, junctions, "Стык", warnings) is { } junctionId)
|
||||
template.SetDefaultJunction(junctionId);
|
||||
}
|
||||
if (
|
||||
config.DefaultJunction is { Length: > 0 } junction
|
||||
&& Resolve(junction, junctions, "Стык", warnings) is { } junctionId
|
||||
)
|
||||
template.SetDefaultJunction(junctionId);
|
||||
}
|
||||
|
||||
private static SlotInput? ToInput(
|
||||
|
||||
Reference in New Issue
Block a user