feat(sync): Detect reidentified series in Emby and Jellyfin

pull/4626/head
sephrat 3 years ago
parent 5938077d82
commit 9096e91d55

@ -157,6 +157,17 @@ namespace Ombi.Schedule.Jobs.Emby
}
var existingTv = await _repo.GetByEmbyId(tvShow.Id);
if (existingTv != null &&
( existingTv.ImdbId != tvShow.ProviderIds?.Imdb
|| existingTv.TheMovieDbId != tvShow.ProviderIds?.Tmdb
|| existingTv.TvDbId != tvShow.ProviderIds?.Tvdb))
{
_logger.LogCritical($"Series '{tvShow.Name}' has different IDs, probably a reidentification.");
await _repo.DeleteTv(existingTv);
existingTv = null;
}
if (existingTv == null)
{
_logger.LogDebug("Adding new TV Show {0}", tvShow.Name);

@ -132,6 +132,17 @@ namespace Ombi.Schedule.Jobs.Jellyfin
}
var existingTv = await _repo.GetByJellyfinId(tvShow.Id);
if (existingTv != null &&
( existingTv.ImdbId != tvShow.ProviderIds?.Imdb
|| existingTv.TheMovieDbId != tvShow.ProviderIds?.Tmdb
|| existingTv.TvDbId != tvShow.ProviderIds?.Tvdb))
{
_logger.LogDebug($"Series '{tvShow.Name}' has different IDs, probably a reidentification.");
await _repo.DeleteTv(existingTv);
existingTv = null;
}
if (existingTv == null)
{
_logger.LogDebug("Adding new TV Show {0}", tvShow.Name);

@ -102,6 +102,13 @@ namespace Ombi.Store.Repository
return InternalSaveChanges();
}
public override async Task DeleteTv(EmbyContent tv)
{
var episodesToDelete = GetAllEpisodes().Cast<EmbyEpisode>().Where(x => x.ParentId == tv.EmbyId).ToList();
Db.EmbyEpisode.RemoveRange(episodesToDelete);
await Delete(tv);
}
public override RecentlyAddedType RecentlyAddedType => RecentlyAddedType.Emby;
}
}

@ -14,6 +14,7 @@ namespace Ombi.Store.Repository
IQueryable<IMediaServerEpisode> GetAllEpisodes();
Task<IMediaServerEpisode> Add(IMediaServerEpisode content);
Task AddRange(IEnumerable<IMediaServerEpisode> content);
Task DeleteTv(Content tv);
void UpdateWithoutSave(IMediaServerContent existingContent);
}
}

@ -104,6 +104,13 @@ namespace Ombi.Store.Repository
return InternalSaveChanges();
}
public override async Task DeleteTv(JellyfinContent tv)
{
var episodesToDelete = GetAllEpisodes().Cast<JellyfinEpisode>().Where(x => x.ParentId == tv.JellyfinId).ToList();
Db.JellyfinEpisode.RemoveRange(episodesToDelete);
await Delete(tv);
}
public override RecentlyAddedType RecentlyAddedType => RecentlyAddedType.Jellyfin;
}
}

@ -22,5 +22,6 @@ namespace Ombi.Store.Repository
public abstract Task AddRange(IEnumerable<IMediaServerEpisode> content);
public abstract void UpdateWithoutSave(IMediaServerContent existingContent);
public abstract Task UpdateRange(IEnumerable<IMediaServerContent> existingContent);
public abstract Task DeleteTv(T tv);
}
}

@ -169,5 +169,12 @@ namespace Ombi.Store.Repository
Db.PlexServerContent.UpdateRange((IEnumerable<PlexServerContent>)existingContent);
return InternalSaveChanges();
}
public override Task DeleteTv(PlexServerContent tv)
{
// not used for now
// TODO: delete episodes, then delete series
throw new NotImplementedException();
}
}
}
Loading…
Cancel
Save