Sonarr/NzbDrone.Core/Providers/PostProcessingProvider.cs

35 lines
1.3 KiB
C#
Raw Normal View History

2011-04-10 02:44:01 +00:00
namespace NzbDrone.Core.Providers
{
2011-04-08 15:24:16 +00:00
public class PostProcessingProvider
{
private readonly MediaFileProvider _mediaFileProvider;
2011-04-09 00:08:03 +00:00
private readonly RenameProvider _renameProvider;
2011-04-10 02:44:01 +00:00
private readonly SeriesProvider _seriesProvider;
2011-04-08 23:55:23 +00:00
public PostProcessingProvider(SeriesProvider seriesProvider,
2011-04-10 02:44:01 +00:00
MediaFileProvider mediaFileProvider, RenameProvider renameProvider)
{
_seriesProvider = seriesProvider;
2011-04-10 02:44:01 +00:00
_mediaFileProvider = mediaFileProvider;
_renameProvider = renameProvider;
}
2011-04-08 15:24:16 +00:00
public virtual void ProcessEpisode(string dir, string nzbName)
{
var parsedSeries = Parser.ParseSeriesName(nzbName);
var series = _seriesProvider.FindSeries(parsedSeries);
if (series == null)
return;
//Import the files, and then rename the newly added ones.
var fileList = _mediaFileProvider.Scan(series, dir);
foreach (var file in fileList)
{
//Notifications will be sent from the Renamer, depending on the bool NewDownload (which will be set to true from here), a normal rename will be treated as such.
_renameProvider.RenameEpisodeFile(file.EpisodeFileId, true);
}
}
}
2011-04-10 02:44:01 +00:00
}