2011-10-07 07:36:47 +03:00
|
|
|
using System;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.IO;
|
|
|
|
using NLog;
|
2013-02-24 09:48:52 +03:00
|
|
|
using NzbDrone.Core.Configuration;
|
2013-02-19 09:01:03 +03:00
|
|
|
using NzbDrone.Core.Tv;
|
2011-10-07 07:36:47 +03:00
|
|
|
using NzbDrone.Core.Model;
|
2013-03-07 04:51:47 +03:00
|
|
|
|
2011-10-07 07:36:47 +03:00
|
|
|
|
|
|
|
namespace NzbDrone.Core.Providers.Converting
|
|
|
|
{
|
|
|
|
public class AtomicParsleyProvider
|
|
|
|
{
|
2013-02-24 09:48:52 +03:00
|
|
|
private readonly IConfigService _configService;
|
2011-10-07 07:36:47 +03:00
|
|
|
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
2013-02-24 09:48:52 +03:00
|
|
|
public AtomicParsleyProvider(IConfigService configService)
|
2011-10-07 07:36:47 +03:00
|
|
|
{
|
2013-02-24 09:48:52 +03:00
|
|
|
_configService = configService;
|
2011-10-07 07:36:47 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public AtomicParsleyProvider()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public virtual bool RunAtomicParsley(Episode episode, string outputFile)
|
|
|
|
{
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
2013-02-24 09:48:52 +03:00
|
|
|
var atomicParsleyLocation = _configService.GetValue("AtomicParsleyLocation", "");
|
|
|
|
var atomicParsleyTitleType = (AtomicParsleyTitleType) Convert.ToInt32(_configService.GetValue("AtomicParsley", 0));
|
2011-10-07 07:36:47 +03:00
|
|
|
|
|
|
|
var atomicParsleyCommand = String.Format("\"{0}\" --overWrite --title \"{1}\" --genre \"TV Shows\" --stik \"TV Show\" --TVShowName \"{2}\" --TVEpisodeNum \"{3}\" --TVSeason \"{4}\"",
|
|
|
|
outputFile, episode.Title, episode.Series.Title, episode.EpisodeNumber, episode.SeasonNumber);
|
|
|
|
|
|
|
|
//If Episode Number + Name should be in Episode Title (Number - Title)
|
|
|
|
if (atomicParsleyTitleType == AtomicParsleyTitleType.EpisodeNumber)
|
|
|
|
{
|
|
|
|
atomicParsleyCommand = String.Format("\"{0}\" --overWrite --title \"{3} - {1}\" --genre \"TV Shows\" --stik \"TV Show\" --TVShowName \"{2}\" --TVEpisodeNum \"{3}\" --TVSeason \"{4}\"",
|
|
|
|
outputFile, episode.Title, episode.Series.Title, episode.EpisodeNumber, episode.SeasonNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
//If Season/Episode Number + Name should be in Episode Title (SeasonNumber'x'EpisodeNumber - Title)
|
|
|
|
else if (atomicParsleyTitleType == AtomicParsleyTitleType.Both)
|
|
|
|
{
|
|
|
|
atomicParsleyCommand = String.Format("\"{0}\" --overWrite --title \"{4}x{3:00} - {1}\" --genre \"TV Shows\" --stik \"TV Show\" --TVShowName \"{2}\" --TVEpisodeNum \"{3}\" --TVSeason \"{4}\"",
|
|
|
|
outputFile, episode.Title, episode.Series.Title, episode.EpisodeNumber, episode.SeasonNumber);
|
|
|
|
}
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var process = new Process();
|
|
|
|
process.StartInfo.FileName = Path.Combine(atomicParsleyLocation, "AtomicParsley.exe");
|
|
|
|
process.StartInfo.Arguments = atomicParsleyCommand;
|
|
|
|
process.StartInfo.UseShellExecute = false;
|
|
|
|
process.StartInfo.CreateNoWindow = true;
|
|
|
|
process.StartInfo.RedirectStandardOutput = true;
|
|
|
|
//process.OutputDataReceived += new DataReceivedEventHandler(HandBrakeOutputDataReceived);
|
|
|
|
process.Start();
|
|
|
|
//process.BeginOutputReadLine();
|
|
|
|
process.WaitForExit();
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
Logger.DebugException(ex.Message, ex);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|