Import video files from root of unsroted dir

New: Import Files directly from unsorted directory (no subfolder
required)
This commit is contained in:
Mark McDowall 2012-08-27 03:15:22 -07:00
parent 5437f7599a
commit 3cdd479bb4
2 changed files with 35 additions and 2 deletions

View File

@ -284,11 +284,12 @@ namespace NzbDrone.Core.Providers
}
}
private List<string> GetVideoFiles(string path)
public List<string> GetVideoFiles(string path, bool allDirectories = true)
{
Logger.Debug("Scanning '{0}' for video files", path);
var filesOnDisk = _diskProvider.GetFiles(path, SearchOption.AllDirectories);
var searchOption = allDirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
var filesOnDisk = _diskProvider.GetFiles(path, searchOption);
var mediaFileList = filesOnDisk.Where(c => mediaExtentions.Contains(Path.GetExtension(c).ToLower())).ToList();

View File

@ -49,6 +49,19 @@ namespace NzbDrone.Core.Providers
Logger.ErrorException("An error has occurred while importing folder" + subfolder, e);
}
}
//Todo: Process files directly in the drop folder
foreach(var videoFile in _diskScanProvider.GetVideoFiles(dropFolder, false))
{
try
{
ProcessVideoFile(videoFile);
}
catch(Exception ex)
{
Logger.ErrorException("An error has occurred while importing video file" + videoFile, ex);
}
}
}
public virtual void ProcessDownload(DirectoryInfo subfolderInfo)
@ -109,6 +122,25 @@ namespace NzbDrone.Core.Providers
}
}
public virtual void ProcessVideoFile(string videoFile)
{
var seriesName = Parser.ParseSeriesName(Path.GetFileNameWithoutExtension(videoFile));
var series = _seriesProvider.FindSeries(seriesName);
if (series == null)
{
Logger.Trace("Unknown Series on Import: {0}", videoFile);
return;
}
var episodeFile = _diskScanProvider.ImportFile(series, videoFile);
if (episodeFile != null)
{
_diskScanProvider.MoveEpisodeFile(episodeFile, true);
_metadataProvider.CreateForEpisodeFile(episodeFile);
}
}
private void TagFolder(DirectoryInfo directory, PostDownloadStatusType status)
{
//Turning off tagging folder for now, to stop messing people's series folders.