2011-04-10 04:44:01 +02:00
namespace NzbDrone.Core.Providers
2011-03-03 09:50:33 +01:00
{
2011-04-08 17:24:16 +02:00
public class PostProcessingProvider
2011-03-03 09:50:33 +01:00
{
2011-04-10 03:34:36 +02:00
private readonly MediaFileProvider _mediaFileProvider ;
2011-04-09 02:08:03 +02:00
private readonly RenameProvider _renameProvider ;
2011-04-10 04:44:01 +02:00
private readonly SeriesProvider _seriesProvider ;
2011-03-03 09:50:33 +01:00
2011-04-09 01:55:23 +02:00
public PostProcessingProvider ( SeriesProvider seriesProvider ,
2011-04-10 04:44:01 +02:00
MediaFileProvider mediaFileProvider , RenameProvider renameProvider )
2011-03-03 09:50:33 +01:00
{
_seriesProvider = seriesProvider ;
2011-04-10 04:44:01 +02:00
_mediaFileProvider = mediaFileProvider ;
2011-03-03 09:50:33 +01:00
_renameProvider = renameProvider ;
}
2011-04-08 17:24:16 +02:00
public virtual void ProcessEpisode ( string dir , string nzbName )
2011-03-03 09:50:33 +01:00
{
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 )
{
2011-03-07 07:33:59 +01:00
//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.
2011-03-06 21:45:35 +01:00
_renameProvider . RenameEpisodeFile ( file . EpisodeFileId , true ) ;
2011-03-03 09:50:33 +01:00
}
}
}
2011-04-10 04:44:01 +02:00
}