|
|
@ -2,6 +2,7 @@
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.IO;
|
|
|
|
using System.IO;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Linq;
|
|
|
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
using NLog;
|
|
|
|
using NLog;
|
|
|
|
using Ninject;
|
|
|
|
using Ninject;
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
|
using NzbDrone.Core.Model;
|
|
|
@ -21,6 +22,8 @@ namespace NzbDrone.Core.Providers
|
|
|
|
private readonly EpisodeProvider _episodeProvider;
|
|
|
|
private readonly EpisodeProvider _episodeProvider;
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly Regex StatusRegex = new Regex(@"^_[\w_]*_", RegexOptions.Compiled);
|
|
|
|
|
|
|
|
|
|
|
|
private static readonly List<PostDownloadInfoModel> InfoList = new List<PostDownloadInfoModel>();
|
|
|
|
private static readonly List<PostDownloadInfoModel> InfoList = new List<PostDownloadInfoModel>();
|
|
|
|
|
|
|
|
|
|
|
|
[Inject]
|
|
|
|
[Inject]
|
|
|
@ -69,6 +72,8 @@ namespace NzbDrone.Core.Providers
|
|
|
|
|
|
|
|
|
|
|
|
var folderStatus = GetPostDownloadStatusForFolder(subfolderInfo.Name);
|
|
|
|
var folderStatus = GetPostDownloadStatusForFolder(subfolderInfo.Name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (folderStatus == PostDownloadStatusType.Unpacking)
|
|
|
|
if (folderStatus == PostDownloadStatusType.Unpacking)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ProcessFailedOrUnpackingDownload(subfolderInfo, PostDownloadStatusType.Unpacking);
|
|
|
|
ProcessFailedOrUnpackingDownload(subfolderInfo, PostDownloadStatusType.Unpacking);
|
|
|
@ -86,8 +91,7 @@ namespace NzbDrone.Core.Providers
|
|
|
|
if (folderStatus != PostDownloadStatusType.NoError)
|
|
|
|
if (folderStatus != PostDownloadStatusType.NoError)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//Retry processing on the download
|
|
|
|
//Retry processing on the download
|
|
|
|
ReProcessDownload(new PostDownloadInfoModel{ Name = subfolderInfo.FullName, Status = folderStatus });
|
|
|
|
ReProcessDownload(new PostDownloadInfoModel { Name = subfolderInfo.FullName, Status = folderStatus });
|
|
|
|
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -165,7 +169,7 @@ namespace NzbDrone.Core.Providers
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//Remove the error prefix before processing
|
|
|
|
//Remove the error prefix before processing
|
|
|
|
var parseResult = Parser.ParseTitle(directoryInfo.Name.Substring(GetPrefixLength(postDownloadStatus)));
|
|
|
|
var parseResult = Parser.ParseTitle(RemoveStatusFromFolderName(directoryInfo.Name));
|
|
|
|
|
|
|
|
|
|
|
|
parseResult.Series = _seriesProvider.FindSeries(parseResult.CleanTitle);
|
|
|
|
parseResult.Series = _seriesProvider.FindSeries(parseResult.CleanTitle);
|
|
|
|
|
|
|
|
|
|
|
@ -215,25 +219,6 @@ namespace NzbDrone.Core.Providers
|
|
|
|
ProcessDownload(directoryInfo);
|
|
|
|
ProcessDownload(directoryInfo);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int GetPrefixLength(PostDownloadStatusType postDownloadStatus)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//_UNPACK_ & _FAILED_ have a length of 8
|
|
|
|
|
|
|
|
if (postDownloadStatus == PostDownloadStatusType.Unpacking || postDownloadStatus == PostDownloadStatusType.Failed)
|
|
|
|
|
|
|
|
return 8;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (postDownloadStatus == PostDownloadStatusType.Unknown)
|
|
|
|
|
|
|
|
return 10;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (postDownloadStatus == PostDownloadStatusType.Processed)
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (postDownloadStatus == PostDownloadStatusType.NoError)
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Return the 11 (_NzbDrone_) + trailing underscore + postDownloadStatus length
|
|
|
|
|
|
|
|
return 11 + postDownloadStatus.ToString().Length;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void Add(PostDownloadInfoModel model)
|
|
|
|
public void Add(PostDownloadInfoModel model)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
InfoList.Add(model);
|
|
|
|
InfoList.Add(model);
|
|
|
@ -278,7 +263,7 @@ namespace NzbDrone.Core.Providers
|
|
|
|
var error = String.Format("_NzbDrone_{0}_", postDownloadStatus.ToString());
|
|
|
|
var error = String.Format("_NzbDrone_{0}_", postDownloadStatus.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
if (existingError != PostDownloadStatusType.NoError)
|
|
|
|
if (existingError != PostDownloadStatusType.NoError)
|
|
|
|
newFolderName = directoryInfo.Name.Substring(GetPrefixLength(existingError));
|
|
|
|
newFolderName = RemoveStatusFromFolderName(directoryInfo.Name);
|
|
|
|
|
|
|
|
|
|
|
|
if (postDownloadStatus == PostDownloadStatusType.Unknown)
|
|
|
|
if (postDownloadStatus == PostDownloadStatusType.Unknown)
|
|
|
|
error = "_NzbDrone_";
|
|
|
|
error = "_NzbDrone_";
|
|
|
@ -294,5 +279,10 @@ namespace NzbDrone.Core.Providers
|
|
|
|
|
|
|
|
|
|
|
|
return Path.Combine(parent, newName);
|
|
|
|
return Path.Combine(parent, newName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string RemoveStatusFromFolderName(string folderName)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return StatusRegex.Replace(folderName, string.Empty);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|