mirror of
https://github.com/Radarr/Radarr
synced 2025-12-06 08:28:50 +01:00
New: Deprecate use of movie file tokens in Movie Folder Format
This commit is contained in:
parent
a5e5a63e45
commit
2c5c99e9b7
7 changed files with 71 additions and 20 deletions
|
|
@ -249,6 +249,9 @@ function Naming() {
|
|||
translate('MovieFolderFormatHelpText'),
|
||||
...movieFolderFormatHelpTexts,
|
||||
]}
|
||||
helpTextWarning={translate(
|
||||
'MovieFolderFormatHelpTextDeprecatedWarning'
|
||||
)}
|
||||
errors={[
|
||||
...movieFolderFormatErrors,
|
||||
...settings.movieFolderFormat.errors,
|
||||
|
|
|
|||
45
src/NzbDrone.Core/HealthCheck/Checks/NamingConfigCheck.cs
Normal file
45
src/NzbDrone.Core/HealthCheck/Checks/NamingConfigCheck.cs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Common.Extensions;
|
||||
using NzbDrone.Core.Datastore.Events;
|
||||
using NzbDrone.Core.Localization;
|
||||
using NzbDrone.Core.Organizer;
|
||||
|
||||
namespace NzbDrone.Core.HealthCheck.Checks
|
||||
{
|
||||
[CheckOn(typeof(ModelEvent<NamingConfig>))]
|
||||
public class NamingConfigCheck : HealthCheckBase, IProvideHealthCheck
|
||||
{
|
||||
private readonly INamingConfigService _namingConfigService;
|
||||
|
||||
public NamingConfigCheck(INamingConfigService namingConfigService, ILocalizationService localizationService)
|
||||
: base(localizationService)
|
||||
{
|
||||
_namingConfigService = namingConfigService;
|
||||
}
|
||||
|
||||
public override HealthCheck Check()
|
||||
{
|
||||
var namingConfig = _namingConfigService.GetConfig();
|
||||
|
||||
if (namingConfig.MovieFolderFormat.IsNotNullOrWhiteSpace())
|
||||
{
|
||||
var match = FileNameValidation.DeprecatedMovieFolderTokensRegex.Matches(namingConfig.MovieFolderFormat);
|
||||
|
||||
if (match.Any())
|
||||
{
|
||||
return new HealthCheck(
|
||||
GetType(),
|
||||
HealthCheckResult.Warning,
|
||||
_localizationService.GetLocalizedString(
|
||||
"NamingConfigMovieFolderFormatDeprecatedHealthCheckMessage", new Dictionary<string, object>
|
||||
{
|
||||
{ "tokens", string.Join(", ", match.Select(c => c.Value).ToArray()) },
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
return new HealthCheck(GetType());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1134,6 +1134,7 @@
|
|||
"MovieFilesTotaling": "Movie Files Totaling",
|
||||
"MovieFolderFormat": "Movie Folder Format",
|
||||
"MovieFolderFormatHelpText": "Used when adding a new movie or moving movies via the movie editor",
|
||||
"MovieFolderFormatHelpTextDeprecatedWarning": "Tokens associated with movie file properties have been deprecated and will no longer be supported in future major versions.",
|
||||
"MovieFolderImportedTooltip": "Movie imported from movie folder",
|
||||
"MovieFootNote": "Optionally control truncation to a maximum number of bytes including ellipsis (`...`). Truncating from the end (e.g. `{Movie Title:30}`) or the beginning (e.g. `{Movie Title:-30}`) are both supported.",
|
||||
"MovieGrabbedTooltip": "Movie grabbed from {indexer} and sent to {downloadClient}",
|
||||
|
|
@ -1173,6 +1174,7 @@
|
|||
"MustNotContainHelpText": "The release will be rejected if it contains one or more of terms (case insensitive)",
|
||||
"MyComputer": "My Computer",
|
||||
"Name": "Name",
|
||||
"NamingConfigMovieFolderFormatDeprecatedHealthCheckMessage": "Movie Folder Format must not contain deprecated file related tokens: {tokens}",
|
||||
"NamingSettings": "Naming Settings",
|
||||
"NamingSettingsLoadError": "Unable to load Naming settings",
|
||||
"Negate": "Negate",
|
||||
|
|
|
|||
|
|
@ -172,16 +172,17 @@ public string GetMovieFolder(Movie movie, NamingConfig namingConfig = null)
|
|||
namingConfig = _namingConfigService.GetConfig();
|
||||
}
|
||||
|
||||
var movieFile = movie.MovieFile;
|
||||
|
||||
var pattern = namingConfig.MovieFolderFormat;
|
||||
var tokenHandlers = new Dictionary<string, Func<TokenMatch, string>>(FileNameBuilderTokenEqualityComparer.Instance);
|
||||
var multipleTokens = TitleRegex.Matches(pattern).Count > 1;
|
||||
|
||||
var tokenHandlers = new Dictionary<string, Func<TokenMatch, string>>(FileNameBuilderTokenEqualityComparer.Instance);
|
||||
|
||||
AddMovieTokens(tokenHandlers, movie);
|
||||
AddReleaseDateTokens(tokenHandlers, movie.Year);
|
||||
AddIdTokens(tokenHandlers, movie);
|
||||
|
||||
var movieFile = movie.MovieFile;
|
||||
|
||||
if (movie.MovieFile != null)
|
||||
{
|
||||
AddQualityTokens(tokenHandlers, movie, movieFile);
|
||||
|
|
|
|||
|
|
@ -19,14 +19,13 @@ public class FileNameSampleService : IFilenameSampleService
|
|||
|
||||
private static MovieFile _movieFile;
|
||||
private static Movie _movie;
|
||||
private static MovieMetadata _movieMetadata;
|
||||
private static List<CustomFormat> _customFormats;
|
||||
|
||||
public FileNameSampleService(IBuildFileNames buildFileNames)
|
||||
{
|
||||
_buildFileNames = buildFileNames;
|
||||
|
||||
var mediaInfo = new MediaInfoModel()
|
||||
var mediaInfo = new MediaInfoModel
|
||||
{
|
||||
VideoFormat = "AVC",
|
||||
VideoBitDepth = 10,
|
||||
|
|
@ -50,7 +49,9 @@ public FileNameSampleService(IBuildFileNames buildFileNames)
|
|||
Edition = "Ultimate extended edition",
|
||||
};
|
||||
|
||||
_movieMetadata = new MovieMetadata
|
||||
_movie = new Movie
|
||||
{
|
||||
MovieMetadata = new MovieMetadata
|
||||
{
|
||||
Title = "The Movie: Title",
|
||||
OriginalTitle = "The Original Movie Title",
|
||||
|
|
@ -60,13 +61,7 @@ public FileNameSampleService(IBuildFileNames buildFileNames)
|
|||
Year = 2010,
|
||||
ImdbId = "tt0066921",
|
||||
TmdbId = 345691
|
||||
};
|
||||
|
||||
_movie = new Movie
|
||||
{
|
||||
MovieFile = _movieFile,
|
||||
MovieFileId = 1,
|
||||
MovieMetadata = _movieMetadata,
|
||||
},
|
||||
MovieMetadataId = 1
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ namespace NzbDrone.Core.Organizer
|
|||
{
|
||||
public static class FileNameValidation
|
||||
{
|
||||
public static readonly Regex DeprecatedMovieFolderTokensRegex = new (@"(\{[- ._\[\(]?(?:Original[- ._](?:Title|Filename)|Release[- ._]Group|Edition[- ._]Tags|Quality[- ._](?:Full|Title|Proper|Real)|MediaInfo[- ._](?:Video|VideoCodec|VideoBitDepth|Audio|AudioCodec|AudioChannels|AudioLanguages|AudioLanguagesAll|SubtitleLanguages|SubtitleLanguagesAll|3D|Simple|Full|VideoDynamicRange|VideoDynamicRangeType))[- ._\]\)]?\})",
|
||||
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
internal static readonly Regex OriginalTokenRegex = new (@"(\{Original[- ._](?:Title|Filename)\})",
|
||||
RegexOptions.Compiled | RegexOptions.IgnoreCase);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ public interface INamingConfigRepository : IBasicRepository<NamingConfig>
|
|||
|
||||
public class NamingConfigRepository : BasicRepository<NamingConfig>, INamingConfigRepository
|
||||
{
|
||||
protected override bool PublishModelEvents => true;
|
||||
|
||||
public NamingConfigRepository(IMainDatabase database, IEventAggregator eventAggregator)
|
||||
: base(database, eventAggregator)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue