mirror of
https://github.com/Radarr/Radarr
synced 2025-12-06 08:28:50 +01:00
Fixed: Update AutoTags on movie add (#11079)
Co-authored-by: aden <aden@hughorse.net>
This commit is contained in:
parent
b5b4d4b971
commit
f5faf52469
4 changed files with 65 additions and 5 deletions
|
|
@ -56,6 +56,8 @@ public Movie AddMovie(Movie newMovie)
|
|||
_movieMetadataService.Upsert(newMovie.MovieMetadata.Value);
|
||||
newMovie.MovieMetadataId = newMovie.MovieMetadata.Value.Id;
|
||||
|
||||
_movieService.UpdateTags(newMovie);
|
||||
|
||||
_movieService.AddMovie(newMovie);
|
||||
|
||||
return newMovie;
|
||||
|
|
|
|||
|
|
@ -205,8 +205,14 @@ private void RescanMovie(Movie movie, bool isNew, CommandTrigger trigger)
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateTags(Movie movie)
|
||||
private void UpdateTags(Movie movie, bool isNew)
|
||||
{
|
||||
if (isNew)
|
||||
{
|
||||
_logger.Trace("Skipping tag update for {0}. Reason: New movie", movie);
|
||||
return;
|
||||
}
|
||||
|
||||
var tagsUpdated = _movieService.UpdateTags(movie);
|
||||
|
||||
if (tagsUpdated)
|
||||
|
|
@ -230,7 +236,7 @@ public void Execute(RefreshMovieCommand message)
|
|||
try
|
||||
{
|
||||
movie = RefreshMovieInfo(movieId);
|
||||
UpdateTags(movie);
|
||||
UpdateTags(movie, isNew);
|
||||
RescanMovie(movie, isNew, trigger);
|
||||
}
|
||||
catch (MovieNotFoundException)
|
||||
|
|
@ -240,7 +246,7 @@ public void Execute(RefreshMovieCommand message)
|
|||
catch (Exception e)
|
||||
{
|
||||
_logger.Error(e, "Couldn't refresh info for {0}", movie);
|
||||
UpdateTags(movie);
|
||||
UpdateTags(movie, isNew);
|
||||
RescanMovie(movie, isNew, trigger);
|
||||
throw;
|
||||
}
|
||||
|
|
@ -277,13 +283,13 @@ public void Execute(RefreshMovieCommand message)
|
|||
_logger.Error(e, "Couldn't refresh info for {0}", movieLocal);
|
||||
}
|
||||
|
||||
UpdateTags(movie);
|
||||
UpdateTags(movie, false);
|
||||
RescanMovie(movieLocal, false, trigger);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Debug("Skipping refresh of movie: {0}", movieLocal.Title);
|
||||
UpdateTags(movie);
|
||||
UpdateTags(movie, false);
|
||||
RescanMovie(movieLocal, false, trigger);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@
|
|||
using System.Linq;
|
||||
using FluentAssertions;
|
||||
using NUnit.Framework;
|
||||
using Radarr.Api.V3.AutoTagging;
|
||||
using Radarr.Http.ClientSchema;
|
||||
|
||||
namespace NzbDrone.Integration.Test.ApiTests
|
||||
{
|
||||
|
|
@ -29,6 +31,53 @@ public void add_movie_with_tags_should_store_them()
|
|||
result.Tags.Should().Equal(tag.Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Order(0)]
|
||||
public void add_movie_should_trigger_autotag()
|
||||
{
|
||||
var tag = EnsureTag("autotag-test");
|
||||
var movie = Movies.Lookup("imdb:tt0110912").Single();
|
||||
movie.Genres = new List<string> { "Thriller" };
|
||||
|
||||
var item = AutoTagging.Post(new AutoTaggingResource
|
||||
{
|
||||
Name = "Test",
|
||||
RemoveTagsAutomatically = false,
|
||||
Tags = new HashSet<int> { tag.Id },
|
||||
Specifications = new List<AutoTaggingSpecificationSchema>
|
||||
{
|
||||
new AutoTaggingSpecificationSchema
|
||||
{
|
||||
Name = "Test",
|
||||
Implementation = "GenreSpecification",
|
||||
ImplementationName = "Genre",
|
||||
Negate = false,
|
||||
Required = false,
|
||||
Fields = new List<Field>
|
||||
{
|
||||
new Field
|
||||
{
|
||||
Name = "value",
|
||||
Label = "Genre(s)",
|
||||
Type = "tag",
|
||||
Value = new List<string> { "Thriller" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
EnsureNoMovie(680, "Pulp Fiction");
|
||||
|
||||
movie.QualityProfileId = 1;
|
||||
movie.Path = Path.Combine(MovieRootFolder, movie.Title);
|
||||
|
||||
var result = Movies.Post(movie);
|
||||
|
||||
result.Should().NotBeNull();
|
||||
result.Tags.Should().Contain(tag.Id);
|
||||
}
|
||||
|
||||
[Test]
|
||||
[Order(0)]
|
||||
public void add_movie_without_profileid_should_return_badrequest()
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
using NzbDrone.Integration.Test.Client;
|
||||
using NzbDrone.SignalR;
|
||||
using NzbDrone.Test.Common.Categories;
|
||||
using Radarr.Api.V3.AutoTagging;
|
||||
using Radarr.Api.V3.Blocklist;
|
||||
using Radarr.Api.V3.Config;
|
||||
using Radarr.Api.V3.DownloadClient;
|
||||
|
|
@ -36,6 +37,7 @@ public abstract class IntegrationTestBase
|
|||
{
|
||||
protected RestClient RestClient { get; private set; }
|
||||
|
||||
public ClientBase<AutoTaggingResource> AutoTagging;
|
||||
public ClientBase<BlocklistResource> Blocklist;
|
||||
public CommandClient Commands;
|
||||
public ClientBase<TaskResource> Tasks;
|
||||
|
|
@ -99,6 +101,7 @@ protected virtual void InitRestClients()
|
|||
RestClient.AddDefaultHeader("Authentication", ApiKey);
|
||||
RestClient.AddDefaultHeader("X-Api-Key", ApiKey);
|
||||
|
||||
AutoTagging = new ClientBase<AutoTaggingResource>(RestClient, ApiKey);
|
||||
Blocklist = new ClientBase<BlocklistResource>(RestClient, ApiKey);
|
||||
Commands = new CommandClient(RestClient, ApiKey);
|
||||
Tasks = new ClientBase<TaskResource>(RestClient, ApiKey, "system/task");
|
||||
|
|
|
|||
Loading…
Reference in a new issue