mirror of
https://github.com/Radarr/Radarr
synced 2025-01-30 19:31:35 +00:00
EpisodeProvider - RefreshSeasonInfo by Season added, updates only the supplied season.
This commit is contained in:
parent
ac20da426b
commit
fd4cf86694
2 changed files with 60 additions and 0 deletions
|
@ -171,6 +171,65 @@ public void RefreshEpisodeInfo(int seriesId)
|
|||
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount);
|
||||
}
|
||||
|
||||
public void RefreshEpisodeInfo(Season season)
|
||||
{
|
||||
Logger.Info("Starting episode info refresh for season {0} of series:{1}", season.SeasonNumber, season.SeriesId);
|
||||
int successCount = 0;
|
||||
int failCount = 0;
|
||||
var targetSeries = _tvDb.GetSeries(season.SeriesId, true);
|
||||
|
||||
var updateList = new List<Episode>();
|
||||
var newList = new List<Episode>();
|
||||
|
||||
foreach (var episode in targetSeries.Episodes.Where(e => e.SeasonId == season.SeasonId))
|
||||
{
|
||||
try
|
||||
{
|
||||
//DateTime throws an error in SQLServer per message below:
|
||||
//SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM.
|
||||
//So lets hack it so it works for SQLServer (as well as SQLite), perhaps we can find a better solution
|
||||
//Todo: Fix this hack
|
||||
if (episode.FirstAired < new DateTime(1753, 1, 1))
|
||||
episode.FirstAired = new DateTime(1753, 1, 1);
|
||||
|
||||
Logger.Trace("Updating info for series:{0} - episode:{1}", targetSeries.SeriesName, episode.EpisodeNumber);
|
||||
var newEpisode = new Episode()
|
||||
{
|
||||
AirDate = episode.FirstAired,
|
||||
EpisodeId = episode.Id,
|
||||
EpisodeNumber = episode.EpisodeNumber,
|
||||
Language = episode.Language.Abbriviation,
|
||||
Overview = episode.Overview,
|
||||
SeasonId = episode.SeasonId,
|
||||
SeasonNumber = episode.SeasonNumber,
|
||||
SeriesId = season.SeriesId,
|
||||
Title = episode.EpisodeName
|
||||
};
|
||||
|
||||
if (_sonicRepo.Exists<Episode>(e => e.EpisodeId == newEpisode.EpisodeId))
|
||||
{
|
||||
updateList.Add(newEpisode);
|
||||
}
|
||||
else
|
||||
{
|
||||
newList.Add(newEpisode);
|
||||
}
|
||||
|
||||
successCount++;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.FatalException(String.Format("An error has occurred while updating episode info for season {0} of series {1}", season.SeasonNumber, season.SeriesId), e);
|
||||
failCount++;
|
||||
}
|
||||
}
|
||||
|
||||
_sonicRepo.AddMany(newList);
|
||||
_sonicRepo.UpdateMany(updateList);
|
||||
|
||||
Logger.Debug("Finished episode refresh for series:{0}. Successful:{1} - Failed:{2} ", targetSeries.SeriesName, successCount, failCount);
|
||||
}
|
||||
|
||||
private bool IsSeasonIgnored(EpisodeModel episode)
|
||||
{
|
||||
//Check if this Season is ignored
|
||||
|
|
|
@ -20,6 +20,7 @@ public interface IEpisodeProvider
|
|||
bool IsNeeded(EpisodeModel episode);
|
||||
|
||||
void RefreshEpisodeInfo(int seriesId);
|
||||
void RefreshEpisodeInfo(Season season);
|
||||
IList<Episode> GetEpisodeBySeason(long seasonId);
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue