2013-04-10 00:47:04 +00:00
|
|
|
|
using System.Collections.Generic;
|
2013-02-27 03:19:22 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
2013-04-10 00:47:04 +00:00
|
|
|
|
using NzbDrone.Common.Eventing;
|
2013-02-27 03:19:22 +00:00
|
|
|
|
using NzbDrone.Core.Lifecycle;
|
2013-03-02 18:25:39 +00:00
|
|
|
|
|
2013-02-27 03:19:22 +00:00
|
|
|
|
|
|
|
|
|
namespace NzbDrone.Core.Qualities
|
|
|
|
|
{
|
|
|
|
|
public interface IQualityProfileService
|
|
|
|
|
{
|
|
|
|
|
QualityProfile Add(QualityProfile profile);
|
|
|
|
|
void Update(QualityProfile profile);
|
|
|
|
|
void Delete(int id);
|
|
|
|
|
List<QualityProfile> All();
|
|
|
|
|
QualityProfile Get(int id);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 00:47:04 +00:00
|
|
|
|
public class QualityProfileService : IQualityProfileService, IHandle<ApplicationStartedEvent>
|
2013-02-27 03:19:22 +00:00
|
|
|
|
{
|
|
|
|
|
private readonly IQualityProfileRepository _qualityProfileRepository;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public QualityProfileService(IQualityProfileRepository qualityProfileRepository, Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_qualityProfileRepository = qualityProfileRepository;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public QualityProfile Add(QualityProfile profile)
|
|
|
|
|
{
|
|
|
|
|
return _qualityProfileRepository.Insert(profile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Update(QualityProfile profile)
|
|
|
|
|
{
|
|
|
|
|
_qualityProfileRepository.Update(profile);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Delete(int id)
|
|
|
|
|
{
|
|
|
|
|
_qualityProfileRepository.Delete(id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<QualityProfile> All()
|
|
|
|
|
{
|
|
|
|
|
return _qualityProfileRepository.All().ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public QualityProfile Get(int id)
|
|
|
|
|
{
|
|
|
|
|
return _qualityProfileRepository.Get(id);
|
|
|
|
|
}
|
|
|
|
|
|
2013-04-10 00:47:04 +00:00
|
|
|
|
public void Handle(ApplicationStartedEvent message)
|
2013-02-27 03:19:22 +00:00
|
|
|
|
{
|
2013-02-27 08:21:53 +00:00
|
|
|
|
if (All().Any()) return;
|
2013-02-27 03:19:22 +00:00
|
|
|
|
|
|
|
|
|
_logger.Info("Setting up default quality profiles");
|
|
|
|
|
|
|
|
|
|
var sd = new QualityProfile { Name = "SD", Allowed = new List<Quality> { Quality.SDTV, Quality.DVD }, Cutoff = Quality.SDTV };
|
|
|
|
|
|
|
|
|
|
var hd = new QualityProfile
|
|
|
|
|
{
|
|
|
|
|
Name = "HD",
|
|
|
|
|
Allowed = new List<Quality> { Quality.HDTV720p, Quality.WEBDL720p, Quality.Bluray720p },
|
|
|
|
|
Cutoff = Quality.HDTV720p
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Add(sd);
|
|
|
|
|
Add(hd);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|