pull/10889/merge
Alperen Kaplan 4 weeks ago committed by GitHub
commit 83b6cad2a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -6,6 +6,7 @@ using NLog;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Blocklisting;
using NzbDrone.Core.History;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser;
@ -42,7 +43,8 @@ namespace NzbDrone.Core.CustomFormats
Movie = remoteMovie.Movie,
Size = size,
Languages = remoteMovie.Languages,
IndexerFlags = remoteMovie.Release?.IndexerFlags ?? 0
IndexerFlags = remoteMovie.Release?.IndexerFlags ?? 0,
DownloadProtocol = remoteMovie.Release?.DownloadProtocol ?? 0
};
return ParseCustomFormat(input);
@ -79,7 +81,8 @@ namespace NzbDrone.Core.CustomFormats
Movie = movie,
Size = blocklist.Size ?? 0,
Languages = blocklist.Languages,
IndexerFlags = blocklist.IndexerFlags
IndexerFlags = blocklist.IndexerFlags,
DownloadProtocol = blocklist.Protocol
};
return ParseCustomFormat(input);
@ -91,6 +94,7 @@ namespace NzbDrone.Core.CustomFormats
long.TryParse(history.Data.GetValueOrDefault("size"), out var size);
Enum.TryParse(history.Data.GetValueOrDefault("indexerFlags"), true, out IndexerFlags indexerFlags);
Enum.TryParse(history.Data.GetValueOrDefault("protocol"), true, out DownloadProtocol downloadProtocol);
var movieInfo = new ParsedMovieInfo
{
@ -109,7 +113,8 @@ namespace NzbDrone.Core.CustomFormats
Movie = movie,
Size = size,
Languages = history.Languages,
IndexerFlags = indexerFlags
IndexerFlags = indexerFlags,
DownloadProtocol = downloadProtocol
};
return ParseCustomFormat(input);
@ -135,7 +140,8 @@ namespace NzbDrone.Core.CustomFormats
Size = localMovie.Size,
Languages = localMovie.Languages,
IndexerFlags = localMovie.IndexerFlags,
Filename = Path.GetFileName(localMovie.Path)
Filename = Path.GetFileName(localMovie.Path),
DownloadProtocol = localMovie.DownloadItem?.DownloadClientInfo?.Protocol ?? 0
};
return ParseCustomFormat(input);
@ -206,7 +212,8 @@ namespace NzbDrone.Core.CustomFormats
Size = movieFile.Size,
Languages = movieFile.Languages,
IndexerFlags = movieFile.IndexerFlags,
Filename = Path.GetFileName(movieFile.RelativePath)
Filename = Path.GetFileName(movieFile.RelativePath),
DownloadProtocol = movieFile.DownloadProtocol
};
return ParseCustomFormat(input, allCustomFormats);

@ -1,4 +1,5 @@
using System.Collections.Generic;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Languages;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser.Model;
@ -13,6 +14,7 @@ namespace NzbDrone.Core.CustomFormats
public IndexerFlags IndexerFlags { get; set; }
public List<Language> Languages { get; set; }
public string Filename { get; set; }
public DownloadProtocol DownloadProtocol { get; set; }
public CustomFormatInput()
{

@ -0,0 +1,36 @@
using FluentValidation;
using NzbDrone.Core.Annotations;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Validation;
namespace NzbDrone.Core.CustomFormats
{
public class DownloadProtocolSpecificationValidator : AbstractValidator<DownloadProtocolSpecification>
{
public DownloadProtocolSpecificationValidator()
{
RuleFor(c => c.Value).NotEmpty();
}
}
public class DownloadProtocolSpecification : CustomFormatSpecificationBase
{
private static readonly DownloadProtocolSpecificationValidator Validator = new DownloadProtocolSpecificationValidator();
public override int Order => 11;
public override string ImplementationName => "Download Protocol";
[FieldDefinition(1, Label = "CustomFormatsSpecificationDownloadProtocol", Type = FieldType.Select, SelectOptions = typeof(DownloadProtocol))]
public int Value { get; set; }
protected override bool IsSatisfiedByWithoutNegate(CustomFormatInput input)
{
return input.DownloadProtocol == (DownloadProtocol)Value;
}
public override NzbDroneValidationResult Validate()
{
return new NzbDroneValidationResult(Validator.Validate(this));
}
}
}

@ -0,0 +1,14 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration
{
[Migration(242)]
public class add_download_protocol_to_moviefiles : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("MovieFiles").AddColumn("DownloadProtocol").AsInt32().WithDefaultValue(0);
}
}
}

@ -203,6 +203,7 @@ namespace NzbDrone.Core.History
history.Data.Add("DownloadClient", message.DownloadClientInfo?.Type);
history.Data.Add("DownloadClientName", message.DownloadClientInfo?.Name);
history.Data.Add("ReleaseGroup", message.MovieInfo.ReleaseGroup);
history.Data.Add("Protocol", ((int)message.MovieInfo.DownloadItem?.DownloadClientInfo?.Protocol).ToString());
history.Data.Add("CustomFormatScore", message.MovieInfo.CustomFormatScore.ToString());
history.Data.Add("Size", message.MovieInfo.Size.ToString());
history.Data.Add("IndexerFlags", message.ImportedMovie.IndexerFlags.ToString());

@ -276,6 +276,7 @@
"CustomFormatsSettings": "Custom Formats Settings",
"CustomFormatsSettingsSummary": "Custom Formats and Settings",
"CustomFormatsSettingsTriggerInfo": "A Custom Format will be applied to a release or file when it matches at least one of each of the different condition types chosen.",
"CustomFormatsSpecificationDownloadProtocol": "Download Protocol",
"CustomFormatsSpecificationExceptLanguage": "Except Language",
"CustomFormatsSpecificationExceptLanguageHelpText": "Matches if any language other than the selected language is present",
"CustomFormatsSpecificationFlag": "Flag",

@ -2,6 +2,7 @@ using System;
using System.Collections.Generic;
using NzbDrone.Common.Extensions;
using NzbDrone.Core.Datastore;
using NzbDrone.Core.Indexers;
using NzbDrone.Core.Languages;
using NzbDrone.Core.MediaFiles.MediaInfo;
using NzbDrone.Core.Movies;
@ -26,6 +27,7 @@ namespace NzbDrone.Core.MediaFiles
public string Edition { get; set; }
public Movie Movie { get; set; }
public List<Language> Languages { get; set; }
public DownloadProtocol DownloadProtocol { get; set; }
public override string ToString()
{

@ -96,6 +96,7 @@ namespace NzbDrone.Core.MediaFiles.MovieImport
movieFile.Movie = localMovie.Movie;
movieFile.ReleaseGroup = localMovie.ReleaseGroup;
movieFile.Edition = localMovie.Edition;
movieFile.DownloadProtocol = localMovie.DownloadItem?.DownloadClientInfo?.Protocol ?? 0;
if (downloadClientItem?.DownloadId.IsNotNullOrWhiteSpace() == true)
{

Loading…
Cancel
Save