Sonarr/NzbDrone.Core/Jobs/Implementations/ConvertEpisodeJob.cs

54 lines
1.9 KiB
C#
Raw Normal View History

2011-12-02 01:33:17 +00:00
using System;
2013-03-05 05:37:33 +00:00
using System.Linq;
using NLog;
using NzbDrone.Core.Model.Notification;
using NzbDrone.Core.Providers.Converting;
2013-03-05 05:37:33 +00:00
using NzbDrone.Core.Tv;
2013-03-05 05:37:33 +00:00
namespace NzbDrone.Core.Jobs.Implementations
{
public class ConvertEpisodeJob : IJob
{
private readonly HandbrakeProvider _handbrakeProvider;
private readonly AtomicParsleyProvider _atomicParsleyProvider;
private readonly IEpisodeService _episodeService;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public ConvertEpisodeJob(HandbrakeProvider handbrakeProvider, AtomicParsleyProvider atomicParsleyProvider,
IEpisodeService episodeService)
{
_handbrakeProvider = handbrakeProvider;
_atomicParsleyProvider = atomicParsleyProvider;
_episodeService = episodeService;
}
public string Name
{
get { return "Convert Episode"; }
}
public TimeSpan DefaultInterval
{
get { return TimeSpan.FromTicks(0); }
}
2012-09-10 19:04:17 +00:00
public void Start(ProgressNotification notification, dynamic options)
{
2012-09-10 19:04:17 +00:00
if (options == null || options.EpisodeId <= 0)
throw new ArgumentNullException(options);
2013-02-22 23:55:43 +00:00
Episode episode = _episodeService.GetEpisode((int)options.EpisodeId);
notification.CurrentMessage = String.Format("Starting Conversion for {0}", episode);
var outputFile = _handbrakeProvider.ConvertFile(episode, notification);
if (String.IsNullOrEmpty(outputFile))
notification.CurrentMessage = String.Format("Conversion failed for {0}", episode);
_atomicParsleyProvider.RunAtomicParsley(episode, outputFile);
notification.CurrentMessage = String.Format("Conversion completed for {0}", episode);
}
}
}