1
0
mirror of https://github.com/Sonarr/Sonarr.git synced 2025-01-27 11:21:43 +02:00
Sonarr/NzbDrone.Core/Providers/PostProcessingProvider.cs

49 lines
1.5 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using NzbDrone.Core.Helpers;
2011-04-03 20:50:12 -07:00
using NzbDrone.Core.Providers.Core;
namespace NzbDrone.Core.Providers
{
2011-04-08 08:24:16 -07:00
public class PostProcessingProvider
{
2011-04-08 16:55:23 -07:00
private readonly SeriesProvider _seriesProvider;
private readonly MediaFileProvider _mediaFileProvider;
2011-04-08 17:08:03 -07:00
private readonly RenameProvider _renameProvider;
2011-04-08 16:55:23 -07:00
public PostProcessingProvider(SeriesProvider seriesProvider,
MediaFileProvider mediaFileProvider, RenameProvider renameProvider)
{
_seriesProvider = seriesProvider;
_mediaFileProvider = mediaFileProvider;
_renameProvider = renameProvider;
}
2011-04-08 08:24:16 -07:00
#region PostProcessingProvider Members
2011-04-08 08:24:16 -07: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);
}
}
#endregion
}
}