Supporting multiple show with the same name but a different start year

This commit is contained in:
Zoe Roux 2020-11-16 20:49:33 +01:00
parent fb907509cb
commit 3cf74bc988

View File

@ -224,24 +224,28 @@ namespace Kyoo.Controllers
bool isMovie, bool isMovie,
Library library) Library library)
{ {
Show show = await libraryManager.GetShow(x => x.Path == showPath); Show old = await libraryManager.GetShow(x => x.Path == showPath);
if (show != null) if (old != null)
return show; return old;
show = await _metadataProvider.SearchShow(showTitle, isMovie, library); Show show = await _metadataProvider.SearchShow(showTitle, isMovie, library);
show.Path = showPath; show.Path = showPath;
show.People = await _metadataProvider.GetPeople(show, library); show.People = await _metadataProvider.GetPeople(show, library);
try try
{ {
await libraryManager.RegisterShow(show); await libraryManager.RegisterShow(show);
await _thumbnailsManager.Validate(show.People);
await _thumbnailsManager.Validate(show);
return show;
} }
catch (DuplicatedItemException) catch (DuplicatedItemException)
{ {
return await libraryManager.GetShow(show.Slug); old = await libraryManager.GetShow(show.Slug);
if (old.Path == showPath)
return old;
show.Slug += $"-{show.StartYear}";
await libraryManager.RegisterShow(show);
} }
await _thumbnailsManager.Validate(show.People);
await _thumbnailsManager.Validate(show);
return show;
} }
private async Task<Season> GetSeason(ILibraryManager libraryManager, private async Task<Season> GetSeason(ILibraryManager libraryManager,