|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using NLog;
|
|
|
|
|
using NzbDrone.Common.Extensions;
|
|
|
|
|
using NzbDrone.Core.Blocklisting;
|
|
|
|
|
using NzbDrone.Core.Books;
|
|
|
|
@ -23,10 +24,12 @@ namespace NzbDrone.Core.CustomFormats
|
|
|
|
|
public class CustomFormatCalculationService : ICustomFormatCalculationService
|
|
|
|
|
{
|
|
|
|
|
private readonly ICustomFormatService _formatService;
|
|
|
|
|
private readonly Logger _logger;
|
|
|
|
|
|
|
|
|
|
public CustomFormatCalculationService(ICustomFormatService formatService)
|
|
|
|
|
public CustomFormatCalculationService(ICustomFormatService formatService, Logger logger)
|
|
|
|
|
{
|
|
|
|
|
_formatService = formatService;
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<CustomFormat> ParseCustomFormat(RemoteBook remoteBook, long size)
|
|
|
|
@ -145,26 +148,30 @@ namespace NzbDrone.Core.CustomFormats
|
|
|
|
|
return matches.OrderBy(x => x.Name).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static List<CustomFormat> ParseCustomFormat(BookFile bookFile, Author author, List<CustomFormat> allCustomFormats)
|
|
|
|
|
private List<CustomFormat> ParseCustomFormat(BookFile bookFile, Author author, List<CustomFormat> allCustomFormats)
|
|
|
|
|
{
|
|
|
|
|
var sceneName = string.Empty;
|
|
|
|
|
var releaseTitle = string.Empty;
|
|
|
|
|
|
|
|
|
|
if (bookFile.SceneName.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|
sceneName = bookFile.SceneName;
|
|
|
|
|
_logger.Trace("Using scene name for release title: {0}", bookFile.SceneName);
|
|
|
|
|
releaseTitle = bookFile.SceneName;
|
|
|
|
|
}
|
|
|
|
|
else if (bookFile.OriginalFilePath.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|
sceneName = bookFile.OriginalFilePath;
|
|
|
|
|
_logger.Trace("Using original file path for release title: {0}", bookFile.OriginalFilePath);
|
|
|
|
|
releaseTitle = bookFile.OriginalFilePath;
|
|
|
|
|
}
|
|
|
|
|
else if (bookFile.Path.IsNotNullOrWhiteSpace())
|
|
|
|
|
{
|
|
|
|
|
sceneName = Path.GetFileName(bookFile.Path);
|
|
|
|
|
_logger.Trace("Using path for release title: {0}", Path.GetFileName(bookFile.Path));
|
|
|
|
|
releaseTitle = Path.GetFileName(bookFile.Path);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var bookInfo = new ParsedBookInfo
|
|
|
|
|
{
|
|
|
|
|
AuthorName = author.Name,
|
|
|
|
|
ReleaseTitle = sceneName,
|
|
|
|
|
ReleaseTitle = releaseTitle,
|
|
|
|
|
Quality = bookFile.Quality,
|
|
|
|
|
ReleaseGroup = bookFile.ReleaseGroup
|
|
|
|
|
};
|
|
|
|
|