1
0
Fork 0
mirror of https://github.com/lidarr/Lidarr synced 2024-12-27 10:07:10 +00:00
Lidarr/NzbDrone.Core/Providers/DownloadProvider.cs

59 lines
1.8 KiB
C#
Raw Normal View History

2011-05-20 05:52:05 +00:00
using System;
using Ninject;
2011-05-20 05:52:05 +00:00
using NLog;
using NzbDrone.Core.Model;
using NzbDrone.Core.Repository;
namespace NzbDrone.Core.Providers
{
public class DownloadProvider
{
private readonly SabProvider _sabProvider;
private readonly HistoryProvider _historyProvider;
private readonly EpisodeProvider _episodeProvider;
2011-05-20 05:52:05 +00:00
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public DownloadProvider(SabProvider sabProvider, HistoryProvider historyProvider, EpisodeProvider episodeProvider)
2011-05-20 05:52:05 +00:00
{
_sabProvider = sabProvider;
_historyProvider = historyProvider;
_episodeProvider = episodeProvider;
2011-05-20 05:52:05 +00:00
}
public DownloadProvider()
{
}
public virtual bool DownloadReport(EpisodeParseResult parseResult)
{
var sabTitle = _sabProvider.GetSabTitle(parseResult);
if (_sabProvider.IsInQueue(sabTitle))
{
Logger.Warn("Episode {0} is already in sab's queue. skipping.", parseResult);
return false;
}
var addSuccess = _sabProvider.AddByUrl(parseResult.NzbUrl, sabTitle);
if (addSuccess)
{
foreach (var episode in parseResult.Episodes)
{
var history = new History();
history.Date = DateTime.Now;
history.Indexer = parseResult.Indexer;
2011-05-28 19:23:35 +00:00
history.IsProper = parseResult.Quality.Proper;
history.Quality = parseResult.Quality.QualityType;
history.NzbTitle = parseResult.NzbTitle;
history.EpisodeId = episode.EpisodeId;
_historyProvider.Add(history);
}
}
return addSuccess;
2011-05-20 05:52:05 +00:00
}
}
}