mirror of
https://github.com/Sonarr/Sonarr.git
synced 2024-12-10 11:10:40 +02:00
Minor cleanups.
This commit is contained in:
parent
34f8f0a78f
commit
83aa6330d1
@ -123,78 +123,6 @@ public void GetEpisodes_invalid_series()
|
|||||||
Mocker.Resolve<EpisodeProvider>().GetEpisode(1);
|
Mocker.Resolve<EpisodeProvider>().GetEpisode(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void AttachSeries_empty_list()
|
|
||||||
{
|
|
||||||
//Act
|
|
||||||
var result = Mocker.Resolve<EpisodeProvider>().AttachSeries(new List<Episode>());
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
result.Should().HaveCount(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void AttachSeries_list_success()
|
|
||||||
{
|
|
||||||
var fakeSeries = Builder<Series>.CreateNew().With(s => s.SeriesId = 12).Build();
|
|
||||||
var fakeEpisodes = Builder<Episode>.CreateListOfSize(5)
|
|
||||||
.All().With(e => e.SeriesId = 12).Build();
|
|
||||||
|
|
||||||
Mocker.GetMock<SeriesProvider>()
|
|
||||||
.Setup(c => c.GetSeries(12))
|
|
||||||
.Returns(fakeSeries);
|
|
||||||
|
|
||||||
//Act
|
|
||||||
|
|
||||||
fakeEpisodes.Should().OnlyContain(e => e.Series == null);
|
|
||||||
var returnedSeries = Mocker.Resolve<EpisodeProvider>().AttachSeries(fakeEpisodes);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
fakeEpisodes.Should().OnlyContain(e => e.Series == fakeSeries);
|
|
||||||
returnedSeries.Should().BeEquivalentTo(fakeEpisodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void AttachSeries_null_episode_should_return_null()
|
|
||||||
{
|
|
||||||
Episode episode = null;
|
|
||||||
|
|
||||||
//Act
|
|
||||||
var result = Mocker.Resolve<EpisodeProvider>().AttachSeries(episode);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
result.Should().BeNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
public void AttachSeries_single_success()
|
|
||||||
{
|
|
||||||
var fakeSeries = Builder<Series>.CreateNew().With(s => s.SeriesId = 12).Build();
|
|
||||||
var fakeEpisodes = Builder<Episode>.CreateNew().With(e => e.SeriesId = 12).Build();
|
|
||||||
|
|
||||||
Mocker.GetMock<SeriesProvider>()
|
|
||||||
.Setup(c => c.GetSeries(12))
|
|
||||||
.Returns(fakeSeries);
|
|
||||||
|
|
||||||
//Act
|
|
||||||
var returnedEpisode = Mocker.Resolve<EpisodeProvider>().AttachSeries(fakeEpisodes);
|
|
||||||
|
|
||||||
//Assert
|
|
||||||
fakeEpisodes.Series.Should().Be(fakeSeries);
|
|
||||||
returnedEpisode.Should().Be(fakeEpisodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
|
||||||
[ExpectedException(typeof(InvalidOperationException), ExpectedMessage = "Sequence contains no elements")]
|
|
||||||
public void AttachSeries_single_invalid_series()
|
|
||||||
{
|
|
||||||
Mocker.SetConstant(TestDbHelper.GetEmptyDatabase());
|
|
||||||
Mocker.Resolve<SeriesProvider>();
|
|
||||||
var fakeEpisodes = Builder<Episode>.CreateNew().With(e => e.SeriesId = 12).Build();
|
|
||||||
|
|
||||||
//Act
|
|
||||||
var returnedEpisode = Mocker.Resolve<EpisodeProvider>().AttachSeries(fakeEpisodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void GetEpisodesBySeason_success()
|
public void GetEpisodesBySeason_success()
|
||||||
|
@ -19,7 +19,7 @@ namespace NzbDrone.Core
|
|||||||
{
|
{
|
||||||
public class CentralDispatch
|
public class CentralDispatch
|
||||||
{
|
{
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
private readonly EnviromentProvider _enviromentProvider;
|
private readonly EnviromentProvider _enviromentProvider;
|
||||||
|
|
||||||
public StandardKernel Kernel { get; private set; }
|
public StandardKernel Kernel { get; private set; }
|
||||||
@ -28,7 +28,7 @@ public CentralDispatch()
|
|||||||
{
|
{
|
||||||
_enviromentProvider = new EnviromentProvider();
|
_enviromentProvider = new EnviromentProvider();
|
||||||
|
|
||||||
Logger.Debug("Initializing Kernel:");
|
logger.Debug("Initializing Kernel:");
|
||||||
Kernel = new StandardKernel();
|
Kernel = new StandardKernel();
|
||||||
|
|
||||||
InitDatabase();
|
InitDatabase();
|
||||||
@ -43,7 +43,7 @@ public CentralDispatch()
|
|||||||
|
|
||||||
private void InitDatabase()
|
private void InitDatabase()
|
||||||
{
|
{
|
||||||
Logger.Info("Initializing Database...");
|
logger.Info("Initializing Database...");
|
||||||
|
|
||||||
var appDataPath = _enviromentProvider.GetAppDataPath();
|
var appDataPath = _enviromentProvider.GetAppDataPath();
|
||||||
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);
|
if (!Directory.Exists(appDataPath)) Directory.CreateDirectory(appDataPath);
|
||||||
@ -75,14 +75,14 @@ private void InitReporting()
|
|||||||
|
|
||||||
private void InitQuality()
|
private void InitQuality()
|
||||||
{
|
{
|
||||||
Logger.Info("Initializing Quality...");
|
logger.Debug("Initializing Quality...");
|
||||||
Kernel.Get<QualityProvider>().SetupDefaultProfiles();
|
Kernel.Get<QualityProvider>().SetupDefaultProfiles();
|
||||||
Kernel.Get<QualityTypeProvider>().SetupDefault();
|
Kernel.Get<QualityTypeProvider>().SetupDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitIndexers()
|
private void InitIndexers()
|
||||||
{
|
{
|
||||||
Logger.Info("Initializing Indexers...");
|
logger.Debug("Initializing Indexers...");
|
||||||
Kernel.Bind<IndexerBase>().To<NzbsOrg>();
|
Kernel.Bind<IndexerBase>().To<NzbsOrg>();
|
||||||
Kernel.Bind<IndexerBase>().To<NzbMatrix>();
|
Kernel.Bind<IndexerBase>().To<NzbMatrix>();
|
||||||
Kernel.Bind<IndexerBase>().To<NzbsRUs>();
|
Kernel.Bind<IndexerBase>().To<NzbsRUs>();
|
||||||
@ -95,7 +95,7 @@ private void InitIndexers()
|
|||||||
|
|
||||||
private void InitJobs()
|
private void InitJobs()
|
||||||
{
|
{
|
||||||
Logger.Info("Initializing Background Jobs...");
|
logger.Debug("Initializing Background Jobs...");
|
||||||
|
|
||||||
Kernel.Bind<JobProvider>().ToSelf().InSingletonScope();
|
Kernel.Bind<JobProvider>().ToSelf().InSingletonScope();
|
||||||
|
|
||||||
@ -120,13 +120,17 @@ private void InitJobs()
|
|||||||
Kernel.Bind<IJob>().To<RecentBacklogSearchJob>().InSingletonScope();
|
Kernel.Bind<IJob>().To<RecentBacklogSearchJob>().InSingletonScope();
|
||||||
Kernel.Bind<IJob>().To<CheckpointJob>().InSingletonScope();
|
Kernel.Bind<IJob>().To<CheckpointJob>().InSingletonScope();
|
||||||
|
|
||||||
|
Kernel.Bind<IJob>().To<FakeNotificationJob>().InSingletonScope();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Kernel.Get<JobProvider>().Initialize();
|
Kernel.Get<JobProvider>().Initialize();
|
||||||
Kernel.Get<WebTimer>().StartTimer(30);
|
Kernel.Get<WebTimer>().StartTimer(30);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void InitExternalNotifications()
|
private void InitExternalNotifications()
|
||||||
{
|
{
|
||||||
Logger.Info("Initializing External Notifications...");
|
logger.Info("Initializing External Notifications...");
|
||||||
Kernel.Bind<ExternalNotificationBase>().To<Xbmc>();
|
Kernel.Bind<ExternalNotificationBase>().To<Xbmc>();
|
||||||
Kernel.Bind<ExternalNotificationBase>().To<Smtp>();
|
Kernel.Bind<ExternalNotificationBase>().To<Smtp>();
|
||||||
Kernel.Bind<ExternalNotificationBase>().To<Twitter>();
|
Kernel.Bind<ExternalNotificationBase>().To<Twitter>();
|
||||||
@ -143,28 +147,28 @@ public void DedicateToHost()
|
|||||||
{
|
{
|
||||||
var pid = _enviromentProvider.NzbDroneProcessIdFromEnviroment;
|
var pid = _enviromentProvider.NzbDroneProcessIdFromEnviroment;
|
||||||
|
|
||||||
Logger.Debug("Attaching to parent process ({0}) for automatic termination.", pid);
|
logger.Debug("Attaching to parent process ({0}) for automatic termination.", pid);
|
||||||
|
|
||||||
var hostProcess = Process.GetProcessById(Convert.ToInt32(pid));
|
var hostProcess = Process.GetProcessById(Convert.ToInt32(pid));
|
||||||
|
|
||||||
hostProcess.EnableRaisingEvents = true;
|
hostProcess.EnableRaisingEvents = true;
|
||||||
hostProcess.Exited += (delegate
|
hostProcess.Exited += (delegate
|
||||||
{
|
{
|
||||||
Logger.Info("Host has been terminated. Shutting down web server.");
|
logger.Info("Host has been terminated. Shutting down web server.");
|
||||||
ShutDown();
|
ShutDown();
|
||||||
});
|
});
|
||||||
|
|
||||||
Logger.Debug("Successfully Attached to host. Process [{0}]", hostProcess.ProcessName);
|
logger.Debug("Successfully Attached to host. Process [{0}]", hostProcess.ProcessName);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.FatalException("An error has occurred while dedicating to host.", e);
|
logger.FatalException("An error has occurred while dedicating to host.", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void ShutDown()
|
private static void ShutDown()
|
||||||
{
|
{
|
||||||
Logger.Info("Shutting down application...");
|
logger.Info("Shutting down application...");
|
||||||
WebTimer.Stop();
|
WebTimer.Stop();
|
||||||
Process.GetCurrentProcess().Kill();
|
Process.GetCurrentProcess().Kill();
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ namespace NzbDrone.Core.Providers
|
|||||||
public class EpisodeProvider
|
public class EpisodeProvider
|
||||||
{
|
{
|
||||||
|
|
||||||
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
private static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
//this will remove (1),(2) from the end of multi part episodes.
|
//this will remove (1),(2) from the end of multi part episodes.
|
||||||
private static readonly Regex multiPartCleanupRegex = new Regex(@"\(\d+\)$", RegexOptions.Compiled);
|
private static readonly Regex multiPartCleanupRegex = new Regex(@"\(\d+\)$", RegexOptions.Compiled);
|
||||||
@ -123,7 +123,7 @@ public virtual IList<Episode> GetEpisodesBySeason(long seriesId, int seasonNumbe
|
|||||||
|
|
||||||
public virtual void MarkEpisodeAsFetched(int episodeId)
|
public virtual void MarkEpisodeAsFetched(int episodeId)
|
||||||
{
|
{
|
||||||
Logger.Trace("Marking episode {0} as fetched.", episodeId);
|
logger.Trace("Marking episode {0} as fetched.", episodeId);
|
||||||
_database.Execute("UPDATE Episodes SET GrabDate=@0 WHERE EpisodeId=@1", DateTime.Now, episodeId);
|
_database.Execute("UPDATE Episodes SET GrabDate=@0 WHERE EpisodeId=@1", DateTime.Now, episodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ public virtual IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseR
|
|||||||
if (!parseResult.Series.IsDaily)
|
if (!parseResult.Series.IsDaily)
|
||||||
{
|
{
|
||||||
//Todo: Collect this as a Series we want to treat as a daily series, or possible parsing error
|
//Todo: Collect this as a Series we want to treat as a daily series, or possible parsing error
|
||||||
Logger.Warn("Found daily-style episode for non-daily series: {0}. {1}", parseResult.Series.Title, parseResult.OriginalString);
|
logger.Warn("Found daily-style episode for non-daily series: {0}. {1}", parseResult.Series.Title, parseResult.OriginalString);
|
||||||
return new List<Episode>();
|
return new List<Episode>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ public virtual IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseR
|
|||||||
|
|
||||||
if (episodeInfo == null && autoAddNew)
|
if (episodeInfo == null && autoAddNew)
|
||||||
{
|
{
|
||||||
Logger.Info("Episode {0} doesn't exist in db. adding it now. {1}", parseResult, parseResult.OriginalString);
|
logger.Info("Episode {0} doesn't exist in db. adding it now. {1}", parseResult, parseResult.OriginalString);
|
||||||
episodeInfo = new Episode
|
episodeInfo = new Episode
|
||||||
{
|
{
|
||||||
SeriesId = parseResult.Series.SeriesId,
|
SeriesId = parseResult.Series.SeriesId,
|
||||||
@ -199,7 +199,7 @@ public virtual IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseR
|
|||||||
//if still null we should add the temp episode
|
//if still null we should add the temp episode
|
||||||
if (episodeInfo == null && autoAddNew)
|
if (episodeInfo == null && autoAddNew)
|
||||||
{
|
{
|
||||||
Logger.Info("Episode {0} doesn't exist in db. adding it now. {1}", parseResult, parseResult.OriginalString);
|
logger.Info("Episode {0} doesn't exist in db. adding it now. {1}", parseResult, parseResult.OriginalString);
|
||||||
episodeInfo = new Episode
|
episodeInfo = new Episode
|
||||||
{
|
{
|
||||||
SeriesId = parseResult.Series.SeriesId,
|
SeriesId = parseResult.Series.SeriesId,
|
||||||
@ -231,7 +231,7 @@ public virtual IList<Episode> GetEpisodesByParseResult(EpisodeParseResult parseR
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Logger.Debug("Unable to find {0}-S{1:00}E{2:00}", parseResult.Series.Title, parseResult.SeasonNumber, episodeNumber);
|
logger.Debug("Unable to find {0}-S{1:00}E{2:00}", parseResult.Series.Title, parseResult.SeasonNumber, episodeNumber);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,7 +269,7 @@ public virtual IList<Episode> EpisodesWithFiles()
|
|||||||
|
|
||||||
public virtual void RefreshEpisodeInfo(Series series)
|
public virtual void RefreshEpisodeInfo(Series series)
|
||||||
{
|
{
|
||||||
Logger.Info("Starting episode info refresh for series: {0}", series.Title.WithDefault(series.SeriesId));
|
logger.Info("Starting episode info refresh for series: {0}", series.Title.WithDefault(series.SeriesId));
|
||||||
int successCount = 0;
|
int successCount = 0;
|
||||||
int failCount = 0;
|
int failCount = 0;
|
||||||
var tvDbSeriesInfo = _tvDbProvider.GetSeries(series.SeriesId, true);
|
var tvDbSeriesInfo = _tvDbProvider.GetSeries(series.SeriesId, true);
|
||||||
@ -287,15 +287,15 @@ public virtual void RefreshEpisodeInfo(Series series)
|
|||||||
string.IsNullOrWhiteSpace(episode.EpisodeName))
|
string.IsNullOrWhiteSpace(episode.EpisodeName))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
Logger.Trace("Updating info for [{0}] - S{1}E{2}", tvDbSeriesInfo.SeriesName, episode.SeasonNumber, episode.EpisodeNumber);
|
logger.Trace("Updating info for [{0}] - S{1}E{2}", tvDbSeriesInfo.SeriesName, episode.SeasonNumber, episode.EpisodeNumber);
|
||||||
|
|
||||||
//first check using tvdbId, this should cover cases when and episode number in a season is changed
|
//first check using tvdbId, this should cover cases when and episode number in a season is changed
|
||||||
var episodeToUpdate = seriesEpisodes.Where(e => e.TvDbEpisodeId == episode.Id).SingleOrDefault();
|
var episodeToUpdate = seriesEpisodes.SingleOrDefault(e => e.TvDbEpisodeId == episode.Id);
|
||||||
|
|
||||||
//not found, try using season/episode number
|
//not found, try using season/episode number
|
||||||
if (episodeToUpdate == null)
|
if (episodeToUpdate == null)
|
||||||
{
|
{
|
||||||
episodeToUpdate = seriesEpisodes.Where(e => e.SeasonNumber == episode.SeasonNumber && e.EpisodeNumber == episode.EpisodeNumber).SingleOrDefault();
|
episodeToUpdate = seriesEpisodes.SingleOrDefault(e => e.SeasonNumber == episode.SeasonNumber && e.EpisodeNumber == episode.EpisodeNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Episode doesn't exist locally
|
//Episode doesn't exist locally
|
||||||
@ -336,7 +336,7 @@ public virtual void RefreshEpisodeInfo(Series series)
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.FatalException(
|
logger.FatalException(
|
||||||
String.Format("An error has occurred while updating episode info for series {0}", tvDbSeriesInfo.SeriesName), e);
|
String.Format("An error has occurred while updating episode info for series {0}", tvDbSeriesInfo.SeriesName), e);
|
||||||
failCount++;
|
failCount++;
|
||||||
}
|
}
|
||||||
@ -345,7 +345,7 @@ public virtual void RefreshEpisodeInfo(Series series)
|
|||||||
_database.InsertMany(newList);
|
_database.InsertMany(newList);
|
||||||
_database.UpdateMany(updateList);
|
_database.UpdateMany(updateList);
|
||||||
|
|
||||||
Logger.Info("Finished episode refresh for series: {0}. Successful: {1} - Failed: {2} ",
|
logger.Info("Finished episode refresh for series: {0}. Successful: {1} - Failed: {2} ",
|
||||||
tvDbSeriesInfo.SeriesName, successCount, failCount);
|
tvDbSeriesInfo.SeriesName, successCount, failCount);
|
||||||
|
|
||||||
//DeleteEpisodesNotInTvdb
|
//DeleteEpisodesNotInTvdb
|
||||||
@ -374,13 +374,13 @@ public virtual bool IsIgnored(int seriesId, int seasonNumber)
|
|||||||
var lastSeasonsEpisodes = _database.Fetch<Episode>(@"SELECT * FROM Episodes
|
var lastSeasonsEpisodes = _database.Fetch<Episode>(@"SELECT * FROM Episodes
|
||||||
WHERE SeriesId=@0 AND SeasonNumber=@1", seriesId, seasonNumber - 1);
|
WHERE SeriesId=@0 AND SeasonNumber=@1", seriesId, seasonNumber - 1);
|
||||||
|
|
||||||
if (lastSeasonsEpisodes != null && lastSeasonsEpisodes.Count > 0 && lastSeasonsEpisodes.Count == lastSeasonsEpisodes.Where(e => e.Ignored).Count())
|
if (lastSeasonsEpisodes != null && lastSeasonsEpisodes.Any() && lastSeasonsEpisodes.Count == lastSeasonsEpisodes.Count(e => e.Ignored))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (episodes.Count == episodes.Where(e => e.Ignored).Count())
|
if (episodes.Count == episodes.Count(e => e.Ignored))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@ -398,31 +398,31 @@ public virtual IList<int> GetEpisodeNumbersBySeason(int seriesId, int seasonNumb
|
|||||||
|
|
||||||
public virtual void SetSeasonIgnore(long seriesId, int seasonNumber, bool isIgnored)
|
public virtual void SetSeasonIgnore(long seriesId, int seasonNumber, bool isIgnored)
|
||||||
{
|
{
|
||||||
Logger.Info("Setting ignore flag on Series:{0} Season:{1} to {2}", seriesId, seasonNumber, isIgnored);
|
logger.Info("Setting ignore flag on Series:{0} Season:{1} to {2}", seriesId, seasonNumber, isIgnored);
|
||||||
|
|
||||||
_database.Execute(@"UPDATE Episodes SET Ignored = @0
|
_database.Execute(@"UPDATE Episodes SET Ignored = @0
|
||||||
WHERE SeriesId = @1 AND SeasonNumber = @2 AND Ignored = @3",
|
WHERE SeriesId = @1 AND SeasonNumber = @2 AND Ignored = @3",
|
||||||
isIgnored, seriesId, seasonNumber, !isIgnored);
|
isIgnored, seriesId, seasonNumber, !isIgnored);
|
||||||
|
|
||||||
Logger.Info("Ignore flag for Series:{0} Season:{1} successfully set to {2}", seriesId, seasonNumber, isIgnored);
|
logger.Info("Ignore flag for Series:{0} Season:{1} successfully set to {2}", seriesId, seasonNumber, isIgnored);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SetEpisodeIgnore(int episodeId, bool isIgnored)
|
public virtual void SetEpisodeIgnore(int episodeId, bool isIgnored)
|
||||||
{
|
{
|
||||||
Logger.Info("Setting ignore flag on Episode:{0} to {1}", episodeId, isIgnored);
|
logger.Info("Setting ignore flag on Episode:{0} to {1}", episodeId, isIgnored);
|
||||||
|
|
||||||
_database.Execute(@"UPDATE Episodes SET Ignored = @0
|
_database.Execute(@"UPDATE Episodes SET Ignored = @0
|
||||||
WHERE EpisodeId = @1",
|
WHERE EpisodeId = @1",
|
||||||
isIgnored, episodeId);
|
isIgnored, episodeId);
|
||||||
|
|
||||||
Logger.Info("Ignore flag for Episode:{0} successfully set to {1}", episodeId, isIgnored);
|
logger.Info("Ignore flag for Episode:{0} successfully set to {1}", episodeId, isIgnored);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual bool IsFirstOrLastEpisodeOfSeason(int seriesId, int seasonNumber, int episodeNumber)
|
public virtual bool IsFirstOrLastEpisodeOfSeason(int seriesId, int seasonNumber, int episodeNumber)
|
||||||
{
|
{
|
||||||
var episodes = GetEpisodesBySeason(seriesId, seasonNumber).OrderBy(e => e.EpisodeNumber);
|
var episodes = GetEpisodesBySeason(seriesId, seasonNumber).OrderBy(e => e.EpisodeNumber);
|
||||||
|
|
||||||
if (episodes.Count() == 0)
|
if (!episodes.Any())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//Ensure that this is either the first episode
|
//Ensure that this is either the first episode
|
||||||
@ -433,29 +433,9 @@ public virtual bool IsFirstOrLastEpisodeOfSeason(int seriesId, int seasonNumber,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<Episode> AttachSeries(IList<Episode> episodes)
|
|
||||||
{
|
|
||||||
if (episodes.Count == 0) return episodes;
|
|
||||||
|
|
||||||
if (episodes.Select(c => c.SeriesId).Distinct().Count() > 1)
|
|
||||||
throw new ArgumentException("Episodes belong to more than one series.");
|
|
||||||
|
|
||||||
var series = _seriesProvider.GetSeries(episodes.First().SeriesId);
|
|
||||||
episodes.ToList().ForEach(c => c.Series = series);
|
|
||||||
|
|
||||||
return episodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Episode AttachSeries(Episode episode)
|
|
||||||
{
|
|
||||||
if (episode == null) return episode;
|
|
||||||
episode.Series = _seriesProvider.GetSeries(episode.SeriesId);
|
|
||||||
return episode;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void DeleteEpisodesNotInTvdb(Series series, TvdbSeries tvDbSeriesInfo)
|
public virtual void DeleteEpisodesNotInTvdb(Series series, TvdbSeries tvDbSeriesInfo)
|
||||||
{
|
{
|
||||||
Logger.Trace("Starting deletion of episodes that no longer exist in TVDB: {0}", series.Title.WithDefault(series.SeriesId));
|
logger.Trace("Starting deletion of episodes that no longer exist in TVDB: {0}", series.Title.WithDefault(series.SeriesId));
|
||||||
|
|
||||||
//Delete Episodes not matching TvDbIds for this series
|
//Delete Episodes not matching TvDbIds for this series
|
||||||
var tvDbIds = tvDbSeriesInfo.Episodes.Select(e => e.Id);
|
var tvDbIds = tvDbSeriesInfo.Episodes.Select(e => e.Id);
|
||||||
@ -466,7 +446,7 @@ public virtual void DeleteEpisodesNotInTvdb(Series series, TvdbSeries tvDbSeries
|
|||||||
|
|
||||||
_database.Execute(tvDbIdQuery);
|
_database.Execute(tvDbIdQuery);
|
||||||
|
|
||||||
Logger.Trace("Deleted episodes that no longer exist in TVDB for {0}", series.SeriesId);
|
logger.Trace("Deleted episodes that no longer exist in TVDB for {0}", series.SeriesId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void SetPostDownloadStatus(List<int> episodeIds, PostDownloadStatusType postDownloadStatus)
|
public virtual void SetPostDownloadStatus(List<int> episodeIds, PostDownloadStatusType postDownloadStatus)
|
||||||
@ -478,7 +458,7 @@ public virtual void SetPostDownloadStatus(List<int> episodeIds, PostDownloadStat
|
|||||||
var episodeIdQuery = String.Format(@"UPDATE Episodes SET PostDownloadStatus = {0}
|
var episodeIdQuery = String.Format(@"UPDATE Episodes SET PostDownloadStatus = {0}
|
||||||
WHERE EpisodeId IN ({1})", (int)postDownloadStatus, episodeIdString);
|
WHERE EpisodeId IN ({1})", (int)postDownloadStatus, episodeIdString);
|
||||||
|
|
||||||
Logger.Trace("Updating PostDownloadStatus for all episodeIds in {0}", episodeIdString);
|
logger.Trace("Updating PostDownloadStatus for all episodeIds in {0}", episodeIdString);
|
||||||
_database.Execute(episodeIdQuery);
|
_database.Execute(episodeIdQuery);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
@using NzbDrone.Common
|
|
||||||
@using NzbDrone.Core.Instrumentation
|
@using NzbDrone.Core.Instrumentation
|
||||||
@using NzbDrone.Web.Helpers
|
@model IEnumerable<Log>
|
||||||
@model IEnumerable<NzbDrone.Core.Instrumentation.Log>
|
|
||||||
@{ ViewBag.Title = "Logs";}
|
@{ ViewBag.Title = "Logs";}
|
||||||
@section ActionMenu{
|
@section ActionMenu{
|
||||||
<ul class="sub-menu">
|
<ul class="sub-menu">
|
||||||
@ -9,35 +7,42 @@
|
|||||||
<li>@Html.ActionLink("File", "File", "Log")</li>
|
<li>@Html.ActionLink("File", "File", "Log")</li>
|
||||||
</ul>
|
</ul>
|
||||||
}
|
}
|
||||||
|
|
||||||
@section HeaderContent{
|
@section HeaderContent{
|
||||||
<style>
|
<style>
|
||||||
#logGrid td {
|
#logGrid td
|
||||||
|
{
|
||||||
padding: 2px 8px 2px 8px;
|
padding: 2px 8px 2px 8px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
}
|
}
|
||||||
|
|
||||||
<div class="infoBox">
|
<div class="infoBox">
|
||||||
Log entries older than 30 days are automatically deleted.</div>
|
Log entries older than 30 days are automatically deleted.</div>
|
||||||
|
|
||||||
<div class="grid-container">
|
<div class="grid-container">
|
||||||
<table id="logGrid" class="dataTablesGrid hidden-grid">
|
<table id="logGrid" class="dataTablesGrid hidden-grid">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Time</th>
|
<th>
|
||||||
<th>Level</th>
|
Time
|
||||||
<th>Source</th>
|
</th>
|
||||||
<th>Message</th>
|
<th>
|
||||||
|
Level
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Source
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Message
|
||||||
|
</th>
|
||||||
@*Details Column*@
|
@*Details Column*@
|
||||||
<th style="display: none;">Details</th>
|
<th style="display: none;">
|
||||||
|
Details
|
||||||
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@section Scripts{
|
@section Scripts{
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
@ -62,9 +67,13 @@
|
|||||||
{sWidth: '240px', "mDataProp": "Source" }, //Source
|
{sWidth: '240px', "mDataProp": "Source" }, //Source
|
||||||
{sWidth: 'auto', "mDataProp": "Message", "bSortable": false }, //Message
|
{sWidth: 'auto', "mDataProp": "Message", "bSortable": false }, //Message
|
||||||
{sWidth: 'auto', "mDataProp": "Details", "bSortable": false, "bVisible": false, "fnRender": function (row) {
|
{sWidth: 'auto', "mDataProp": "Details", "bSortable": false, "bVisible": false, "fnRender": function (row) {
|
||||||
var result = "<div>Method: " + row.aData["Method"] + "</div>" +
|
var result = "<div>Method: " + row.aData["Method"] + "</div>";
|
||||||
"<div>Exception Type: " + row.aData["ExceptionType"] + "</div>" +
|
|
||||||
|
if (row.aData["ExceptionType"] !== null) {
|
||||||
|
result += "<div>Exception Type: " + row.aData["ExceptionType"] + "</div>" +
|
||||||
"<div class=\"stackFrame\">Exception: " + row.aData["Exception"] + "</div>";
|
"<div class=\"stackFrame\">Exception: " + row.aData["Exception"] + "</div>";
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
} //Details
|
} //Details
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System;
|
using System;
|
||||||
using InstallService;
|
|
||||||
|
|
||||||
namespace ServiceInstall
|
namespace ServiceInstall
|
||||||
{
|
{
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
using System.Linq;
|
||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
|
|
||||||
namespace InstallService
|
namespace ServiceInstall
|
||||||
{
|
{
|
||||||
internal static class ServiceHelper
|
internal static class ServiceHelper
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System;
|
using System;
|
||||||
using UninstallService;
|
|
||||||
|
|
||||||
namespace ServiceUninstall
|
namespace ServiceUninstall
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Security.Principal;
|
using System.Security.Principal;
|
||||||
|
|
||||||
namespace UninstallService
|
namespace ServiceUninstall
|
||||||
{
|
{
|
||||||
internal static class ServiceHelper
|
internal static class ServiceHelper
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user