mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2026-04-20 22:14:34 -04:00
New: Better interface for creating custom formats
This commit is contained in:
@@ -16,7 +16,6 @@ namespace NzbDrone.Core.CustomFormats
|
||||
List<CustomFormat> ParseCustomFormat(MovieFile movieFile);
|
||||
List<CustomFormat> ParseCustomFormat(Blacklist blacklist);
|
||||
List<CustomFormat> ParseCustomFormat(History.History history);
|
||||
List<CustomFormatMatchResult> MatchFormatTags(ParsedMovieInfo movieInfo);
|
||||
}
|
||||
|
||||
public class CustomFormatCalculationService : ICustomFormatCalculationService
|
||||
@@ -35,88 +34,54 @@ namespace NzbDrone.Core.CustomFormats
|
||||
}
|
||||
|
||||
public List<CustomFormat> ParseCustomFormat(ParsedMovieInfo movieInfo)
|
||||
{
|
||||
return MatchFormatTags(movieInfo)
|
||||
.Where(m => m.GoodMatch)
|
||||
.Select(r => r.CustomFormat)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CustomFormat> ParseCustomFormat(MovieFile movieFile)
|
||||
{
|
||||
return MatchFormatTags(movieFile)
|
||||
.Where(m => m.GoodMatch)
|
||||
.Select(r => r.CustomFormat)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CustomFormat> ParseCustomFormat(Blacklist blacklist)
|
||||
{
|
||||
return MatchFormatTags(blacklist)
|
||||
.Where(m => m.GoodMatch)
|
||||
.Select(r => r.CustomFormat)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CustomFormat> ParseCustomFormat(History.History history)
|
||||
{
|
||||
return MatchFormatTags(history)
|
||||
.Where(m => m.GoodMatch)
|
||||
.Select(r => r.CustomFormat)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<CustomFormatMatchResult> MatchFormatTags(ParsedMovieInfo movieInfo)
|
||||
{
|
||||
var formats = _formatService.All();
|
||||
|
||||
var matches = new List<CustomFormatMatchResult>();
|
||||
var matches = new List<CustomFormat>();
|
||||
|
||||
foreach (var customFormat in formats)
|
||||
{
|
||||
var tagTypeMatches = customFormat.FormatTags
|
||||
.GroupBy(t => t.TagType)
|
||||
.Select(g => new FormatTagMatchesGroup
|
||||
var specificationMatches = customFormat.Specifications
|
||||
.GroupBy(t => t.GetType())
|
||||
.Select(g => new SpecificationMatchesGroup
|
||||
{
|
||||
Type = g.Key,
|
||||
Matches = g.ToDictionary(t => t, t => t.DoesItMatch(movieInfo))
|
||||
Matches = g.ToDictionary(t => t, t => t.IsSatisfiedBy(movieInfo))
|
||||
})
|
||||
.ToList();
|
||||
|
||||
matches.Add(new CustomFormatMatchResult
|
||||
if (specificationMatches.All(x => x.DidMatch))
|
||||
{
|
||||
CustomFormat = customFormat,
|
||||
GroupMatches = tagTypeMatches
|
||||
});
|
||||
matches.Add(customFormat);
|
||||
}
|
||||
}
|
||||
|
||||
return matches;
|
||||
}
|
||||
|
||||
private List<CustomFormatMatchResult> MatchFormatTags(MovieFile file)
|
||||
public List<CustomFormat> ParseCustomFormat(MovieFile movieFile)
|
||||
{
|
||||
var info = new ParsedMovieInfo
|
||||
{
|
||||
MovieTitle = file.Movie.Title,
|
||||
SimpleReleaseTitle = file.GetSceneOrFileName().SimplifyReleaseTitle(),
|
||||
Quality = file.Quality,
|
||||
Languages = file.Languages,
|
||||
ReleaseGroup = file.ReleaseGroup,
|
||||
Edition = file.Edition,
|
||||
Year = file.Movie.Year,
|
||||
ImdbId = file.Movie.ImdbId,
|
||||
MovieTitle = movieFile.Movie.Title,
|
||||
SimpleReleaseTitle = movieFile.GetSceneOrFileName().SimplifyReleaseTitle(),
|
||||
Quality = movieFile.Quality,
|
||||
Languages = movieFile.Languages,
|
||||
ReleaseGroup = movieFile.ReleaseGroup,
|
||||
Edition = movieFile.Edition,
|
||||
Year = movieFile.Movie.Year,
|
||||
ImdbId = movieFile.Movie.ImdbId,
|
||||
ExtraInfo = new Dictionary<string, object>
|
||||
{
|
||||
{ "IndexerFlags", file.IndexerFlags },
|
||||
{ "Size", file.Size },
|
||||
{ "Filename", System.IO.Path.GetFileName(file.RelativePath) }
|
||||
{ "IndexerFlags", movieFile.IndexerFlags },
|
||||
{ "Size", movieFile.Size },
|
||||
{ "Filename", System.IO.Path.GetFileName(movieFile.RelativePath) }
|
||||
}
|
||||
};
|
||||
|
||||
return MatchFormatTags(info);
|
||||
return ParseCustomFormat(info);
|
||||
}
|
||||
|
||||
private List<CustomFormatMatchResult> MatchFormatTags(Blacklist blacklist)
|
||||
public List<CustomFormat> ParseCustomFormat(Blacklist blacklist)
|
||||
{
|
||||
var parsed = _parsingService.ParseMovieInfo(blacklist.SourceTitle, null);
|
||||
|
||||
@@ -137,10 +102,10 @@ namespace NzbDrone.Core.CustomFormats
|
||||
}
|
||||
};
|
||||
|
||||
return MatchFormatTags(info);
|
||||
return ParseCustomFormat(info);
|
||||
}
|
||||
|
||||
private List<CustomFormatMatchResult> MatchFormatTags(History.History history)
|
||||
public List<CustomFormat> ParseCustomFormat(History.History history)
|
||||
{
|
||||
var movie = _movieService.GetMovie(history.MovieId);
|
||||
var parsed = _parsingService.ParseMovieInfo(history.SourceTitle, null);
|
||||
@@ -165,7 +130,7 @@ namespace NzbDrone.Core.CustomFormats
|
||||
}
|
||||
};
|
||||
|
||||
return MatchFormatTags(info);
|
||||
return ParseCustomFormat(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user