1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Manual join of Series for EpisodesBetweenDates

This commit is contained in:
Mark McDowall 2013-04-16 23:55:39 -07:00
parent df38aa2307
commit a4d69cc5ce
9 changed files with 33 additions and 12 deletions

View File

@ -54,7 +54,7 @@ public void UpdateMappings()
public string GetSceneName(int seriesId, int seasonNumber = -1)
{
var tvDbId = _seriesService.FindByTvdbId(seriesId).TvDbId;
var tvDbId = _seriesService.FindByTvdbId(seriesId).TvdbId;
var mapping = _repository.FindByTvdbId(tvDbId);

View File

@ -55,7 +55,7 @@ private void DownloadCover(Series series, MediaCover cover)
}
catch (Exception e)
{
_logger.ErrorException("Couldn't download media cover for " + series.TvDbId, e);
_logger.ErrorException("Couldn't download media cover for " + series.TvdbId, e);
}
}

View File

@ -47,7 +47,7 @@ private static IRestClient BuildClient(string resource, string method)
private static Series MapSeries(Show show)
{
var series = new Series();
series.TvDbId = show.tvdb_id;
series.TvdbId = show.tvdb_id;
series.TvRageId = show.tvrage_id;
series.ImdbId = show.imdb_id;
series.Title = show.title;

View File

@ -47,15 +47,19 @@ public class EpisodeService : IEpisodeService,
private readonly IEpisodeRepository _episodeRepository;
private readonly IEventAggregator _eventAggregator;
private readonly IConfigService _configService;
private readonly ISeriesService _seriesService;
private readonly Logger _logger;
public EpisodeService(IProvideEpisodeInfo episodeInfoProxy, ISeasonRepository seasonRepository, IEpisodeRepository episodeRepository, IEventAggregator eventAggregator, IConfigService configService, Logger logger)
public EpisodeService(IProvideEpisodeInfo episodeInfoProxy, ISeasonRepository seasonRepository,
IEpisodeRepository episodeRepository, IEventAggregator eventAggregator,
IConfigService configService, ISeriesService seriesService, Logger logger)
{
_episodeInfoProxy = episodeInfoProxy;
_seasonRepository = seasonRepository;
_episodeRepository = episodeRepository;
_eventAggregator = eventAggregator;
_configService = configService;
_seriesService = seriesService;
_logger = logger;
}
@ -89,7 +93,6 @@ public List<Episode> GetEpisodesBySeason(int seriesId, int seasonNumber)
return _episodeRepository.GetEpisodes(seriesId, seasonNumber);
}
public List<Episode> EpisodesWithoutFiles(bool includeSpecials)
{
return _episodeRepository.EpisodesWithoutFiles(includeSpecials);
@ -111,7 +114,7 @@ public void RefreshEpisodeInfo(Series series)
var successCount = 0;
var failCount = 0;
var tvdbEpisodes = _episodeInfoProxy.GetEpisodeInfo(series.TvDbId);
var tvdbEpisodes = _episodeInfoProxy.GetEpisodeInfo(series.TvdbId);
var seriesEpisodes = GetEpisodeBySeries(series.Id);
var updateList = new List<Episode>();
@ -281,7 +284,15 @@ public void UpdateEpisodes(List<Episode> episodes)
public List<Episode> EpisodesBetweenDates(DateTime start, DateTime end)
{
return _episodeRepository.EpisodesBetweenDates(start.ToUniversalTime(), end.ToUniversalTime());
var episodes = _episodeRepository.EpisodesBetweenDates(start.ToUniversalTime(), end.ToUniversalTime());
var series = _seriesService.GetSeriesInList(episodes.Select(e => e.SeriesId).Distinct());
episodes.ForEach(e =>
{
e.Series = series.SingleOrDefault(s => s.Id == e.SeriesId);
});
return episodes;
}
public void Handle(EpisodeGrabbedEvent message)

View File

@ -24,7 +24,7 @@ public Series()
Images = new List<MediaCover.MediaCover>();
}
public int TvDbId { get; set; }
public int TvdbId { get; set; }
public int TvRageId { get; set; }
public string ImdbId { get; set; }
public string Title { get; set; }

View File

@ -13,6 +13,7 @@ public interface ISeriesRepository : IBasicRepository<Series>
Series FindByTvdbId(int tvdbId);
void SetSeriesType(int seriesId, SeriesTypes seriesTypes);
void SetTvRageId(int seriesId, int tvRageId);
List<Series> SeriesIsInList(IEnumerable<int> ids);
}
public class SeriesRepository : BasicRepository<Series>, ISeriesRepository
@ -39,7 +40,7 @@ public Series FindByTitle(string cleanTitle)
public Series FindByTvdbId(int tvdbId)
{
return Query.SingleOrDefault(s => s.TvDbId.Equals(tvdbId));
return Query.SingleOrDefault(s => s.TvdbId.Equals(tvdbId));
}
public void SetSeriesType(int seriesId, SeriesTypes seriesType)
@ -51,5 +52,10 @@ public void SetTvRageId(int seriesId, int tvRageId)
{
SetFields(new Series { Id = seriesId, TvRageId = tvRageId }, s => s.TvRageId);
}
public List<Series> SeriesIsInList(IEnumerable<int> ids)
{
return Query.Where(String.Format("Id IN ({0})", String.Join(",", ids)));
}
}
}

View File

@ -32,6 +32,7 @@ public interface ISeriesService
List<Series> GetAllSeries();
void UpdateSeries(Series series);
bool SeriesPathExists(string folder);
List<Series> GetSeriesInList(IEnumerable<int> seriesIds);
}
public class SeriesService : ISeriesService, IHandleAsync<SeriesAddedEvent>
@ -63,11 +64,10 @@ public bool IsMonitored(int id)
return _seriesRepository.Get(id).Monitored;
}
public Series UpdateSeriesInfo(int seriesId)
{
var series = _seriesRepository.Get(seriesId);
var seriesInfo = _seriesInfoProxy.GetSeriesInfo(series.TvDbId);
var seriesInfo = _seriesInfoProxy.GetSeriesInfo(series.TvdbId);
series.Title = seriesInfo.Title;
series.AirTime = seriesInfo.AirTime;
@ -179,6 +179,11 @@ public bool SeriesPathExists(string folder)
return _seriesRepository.SeriesPathExists(folder);
}
public List<Series> GetSeriesInList(IEnumerable<int> seriesIds)
{
return _seriesRepository.SeriesIsInList(seriesIds);
}
public void HandleAsync(SeriesAddedEvent message)
{
UpdateSeriesInfo(message.Series.Id);

View File

@ -2,7 +2,6 @@
<FileVersion>1</FileVersion>
<AutoEnableOnStartup>True</AutoEnableOnStartup>
<AllowParallelTestExecution>true</AllowParallelTestExecution>
<AllowTestsToRunInParallelWithThemselves>true</AllowTestsToRunInParallelWithThemselves>
<FrameworkUtilisationTypeForNUnit>UseDynamicAnalysis</FrameworkUtilisationTypeForNUnit>
<FrameworkUtilisationTypeForGallio>Disabled</FrameworkUtilisationTypeForGallio>
<FrameworkUtilisationTypeForMSpec>Disabled</FrameworkUtilisationTypeForMSpec>