Add retroactive tag application to import lists

This commit introduces a new feature allowing tags to be retroactively applied to movies already in the database. Changes include database migration for the new column, updates to the frontend to manage this feature, and backend logic to handle retroactive tagging.
This commit is contained in:
Willie Slepecki 2024-10-04 13:47:43 -04:00
parent fa190c85a3
commit b1f128fee8
No known key found for this signature in database
GPG key ID: E3E418D6334CB1C7
9 changed files with 68 additions and 3 deletions

View file

@ -55,6 +55,7 @@ function EditImportListModalContent(props) {
rootFolderPath,
searchOnAdd,
tags,
retroApplyTags,
fields,
message
} = item;
@ -225,6 +226,18 @@ function EditImportListModalContent(props) {
/>
</FormGroup>
<FormGroup>
<FormLabel>{translate('RadarrRetroactiveApply')}</FormLabel>
<FormInputGroup
type={inputTypes.CHECK}
name="retroApplyTags"
helpText={translate('RetroApplyListTagsHelpText')}
{...retroApplyTags}
onChange={onInputChange}
/>
</FormGroup>
{
fields.map((field) => {
return (

View file

@ -82,6 +82,12 @@ const COLUMNS = [
isSortable: true,
isVisible: true,
},
{
name: 'retroApplyTags',
label: () => translate('RetroApplyTags'),
isSortable: true,
isVisible: true,
},
];
interface ManageImportListsModalContentProps {

View file

@ -19,6 +19,7 @@ interface ManageImportListsModalRowProps {
minimumAvailability: string;
implementation: string;
tags: number[];
retroApplyTags: boolean;
enabled: boolean;
enableAuto: boolean;
columns: Column[];
@ -38,6 +39,7 @@ function ManageImportListsModalRow(props: ManageImportListsModalRowProps) {
enabled,
enableAuto,
tags,
retroApplyTags,
onSelectedChange,
} = props;
@ -91,6 +93,10 @@ function ManageImportListsModalRow(props: ManageImportListsModalRowProps) {
<TableRowCell className={styles.tags}>
<TagListConnector tags={tags} />
</TableRowCell>
<TableRowCell className={styles.enabled}>
{retroApplyTags ? translate('Yes') : translate('No')}
</TableRowCell>
</TableRow>
);
}

View file

@ -221,7 +221,7 @@
<PropertyGroup Condition="'$(IsOSX)' == 'true' and
'$(RuntimeIdentifier)' == ''">
<_UsingDefaultRuntimeIdentifier>true</_UsingDefaultRuntimeIdentifier>
<RuntimeIdentifier>osx-x64</RuntimeIdentifier>
<RuntimeIdentifier>osx-$(Architecture)</RuntimeIdentifier>
</PropertyGroup>
</Project>

View file

@ -0,0 +1,13 @@
using FluentMigrator;
using NzbDrone.Core.Datastore.Migration.Framework;
namespace NzbDrone.Core.Datastore.Migration;
[Migration(241)]
public class add_retroapply_to_importlists : NzbDroneMigrationBase
{
protected override void MainDbUpgrade()
{
Alter.Table("ImportLists").AddColumn("RetroApplyTags").AsInt32().WithDefaultValue(0);
}
}

View file

@ -81,9 +81,10 @@ private void ProcessMovieReport(ImportListDefinition importList, ImportListMovie
return;
}
// Check to see if movie in DB
// Check to see if movie in DB and maybe apply retro-tags
if (dbMovies.Contains(report.TmdbId))
{
RetroApplyTags(importList, report);
_logger.Debug("{0} [{1}] Rejected, Movie Exists in DB", report.TmdbId, report.Title);
return;
}
@ -123,6 +124,26 @@ private void ProcessMovieReport(ImportListDefinition importList, ImportListMovie
}
}
private void RetroApplyTags(ImportListDefinition importList, ImportListMovie report)
{
if (importList.RetroApplyTags)
{
var movie = _movieService.FindByTmdbId(report.TmdbId);
var preCount = movie.Tags.Count;
foreach (var tag in importList.Tags)
{
movie.Tags.Add(tag);
}
if (preCount != movie.Tags.Count)
{
_movieService.UpdateMovie(movie);
_logger.Debug("{0} [{1}] Retro-Actively added tags to movie", report.TmdbId, report.Title);
}
}
}
private void ProcessListItems(ImportListFetchResult listFetchResult)
{
listFetchResult.Movies = listFetchResult.Movies.DistinctBy(x =>

View file

@ -841,6 +841,7 @@
"ListSyncLevelHelpText": "Movies in library will be handled based on your selection if they fall off or do not appear on your list(s)",
"ListSyncLevelHelpTextWarning": "Movie files will be permanently deleted, this can result in wiping your library if your lists are empty",
"ListTagsHelpText": "Tags list items will be added with",
"RetroApplyListTagsHelpText": "Retro-Actively apply tags to movies already in Radarr",
"ListWillRefreshEveryInterval": "List will refresh every {refreshInterval}",
"Lists": "Lists",
"Loading": "Loading",
@ -1366,6 +1367,7 @@
"Queued": "Queued",
"QuickImport": "Move Automatically",
"RadarrTags": "{appName} Tags",
"RadarrRetroactiveApply": "Retro-Apply Tags",
"Rating": "Rating",
"Ratings": "Ratings",
"ReadTheWikiForMoreInformation": "Read the Wiki for more information",

View file

@ -28,6 +28,7 @@ protected ProviderDefinition()
public ProviderMessage Message { get; set; }
public HashSet<int> Tags { get; set; }
public bool RetroApplyTags { get; set; }
[MemberwiseEqualityIgnore]
public IProviderConfig Settings

View file

@ -16,6 +16,7 @@ public class ProviderResource<T> : RestResource
public string InfoLink { get; set; }
public ProviderMessage Message { get; set; }
public HashSet<int> Tags { get; set; }
public bool RetroApplyTags { get; set; }
public List<T> Presets { get; set; }
}
@ -36,6 +37,7 @@ public virtual TProviderResource ToResource(TProviderDefinition definition)
ConfigContract = definition.ConfigContract,
Message = definition.Message,
Tags = definition.Tags,
RetroApplyTags = definition.RetroApplyTags,
Fields = SchemaBuilder.ToSchema(definition.Settings),
// radarr/supported is an disambiguation page. the # should be a header on the page with appropriate details/link
@ -60,7 +62,8 @@ public virtual TProviderDefinition ToModel(TProviderResource resource, TProvider
Implementation = resource.Implementation,
ConfigContract = resource.ConfigContract,
Message = resource.Message,
Tags = resource.Tags
Tags = resource.Tags,
RetroApplyTags = resource.RetroApplyTags,
};
var configContract = ReflectionExtensions.CoreAssembly.FindTypeByName(definition.ConfigContract);