1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2024-12-14 11:23:42 +02:00
Sonarr/NzbDrone.Core/Jobs/ConvertEpisodeJob.cs

57 lines
1.9 KiB
C#
Raw Normal View History

2011-12-02 04:33:17 +03:00
using System.Linq;
using System;
using Ninject;
using NLog;
using NzbDrone.Core.Model.Notification;
2011-12-02 04:33:17 +03:00
using NzbDrone.Core.Providers;
using NzbDrone.Core.Providers.Converting;
2012-10-22 10:05:27 +03:00
using NzbDrone.Core.Repository;
2011-12-02 04:33:17 +03:00
namespace NzbDrone.Core.Jobs
{
public class ConvertEpisodeJob : IJob
{
private readonly HandbrakeProvider _handbrakeProvider;
private readonly AtomicParsleyProvider _atomicParsleyProvider;
private readonly EpisodeProvider _episodeProvider;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
[Inject]
public ConvertEpisodeJob(HandbrakeProvider handbrakeProvider, AtomicParsleyProvider atomicParsleyProvider,
EpisodeProvider episodeProvider)
{
_handbrakeProvider = handbrakeProvider;
_atomicParsleyProvider = atomicParsleyProvider;
_episodeProvider = episodeProvider;
}
public string Name
{
get { return "Convert Episode"; }
}
public TimeSpan DefaultInterval
{
get { return TimeSpan.FromTicks(0); }
}
2012-09-10 22:04:17 +03:00
public void Start(ProgressNotification notification, dynamic options)
{
2012-09-10 22:04:17 +03:00
if (options == null || options.EpisodeId <= 0)
throw new ArgumentNullException(options);
2012-10-22 10:05:27 +03:00
Episode episode = _episodeProvider.GetEpisode(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);
}
}
}