1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-11-04 10:02:40 +01:00

Fixed: Tmdb Rename Tokens

Fixes #4004
This commit is contained in:
Qstick 2019-12-26 21:11:44 -05:00
parent 10fc0b071f
commit 5e7f0f9d78
3 changed files with 58 additions and 5 deletions

View File

@ -0,0 +1,51 @@
using FizzWare.NBuilder;
using FluentAssertions;
using NUnit.Framework;
using NUnit.Framework.Internal;
using NzbDrone.Core.Organizer;
using NzbDrone.Core.Test.Framework;
using NzbDrone.Core.Movies;
namespace NzbDrone.Core.Test.OrganizerTests.FileNameBuilderTests
{
[TestFixture]
public class IdFixture : CoreTest<FileNameBuilder>
{
private Movie _movie;
private NamingConfig _namingConfig;
[SetUp]
public void Setup()
{
_movie = Builder<Movie>
.CreateNew()
.With(s => s.Title = "Movie Title")
.With(s => s.ImdbId = "tt12345")
.With(s => s.TmdbId = 123456)
.Build();
_namingConfig = NamingConfig.Default;
Mocker.GetMock<INamingConfigService>()
.Setup(c => c.GetConfig()).Returns(_namingConfig);
}
[Test]
public void should_add_imdb_id()
{
_namingConfig.MovieFolderFormat = "{Movie Title} ({ImdbId})";
Subject.GetMovieFolder(_movie)
.Should().Be($"Movie Title ({_movie.ImdbId})");
}
[Test]
public void should_add_tmdb_id()
{
_namingConfig.MovieFolderFormat = "{Movie Title} ({TmdbId})";
Subject.GetMovieFolder(_movie)
.Should().Be($"Movie Title ({_movie.TmdbId})");
}
}
}

View File

@ -91,7 +91,7 @@ public string BuildFileName(Movie movie, MovieFile movieFile, NamingConfig namin
AddMovieTokens(tokenHandlers, movie);
AddReleaseDateTokens(tokenHandlers, movie.Year);
AddImdbIdTokens(tokenHandlers, movie.ImdbId);
AddIdTokens(tokenHandlers, movie);
AddQualityTokens(tokenHandlers, movie, movieFile);
AddMediaInfoTokens(tokenHandlers, movieFile);
AddMovieFileTokens(tokenHandlers, movieFile);
@ -140,7 +140,7 @@ public string BuildMoviePath(Movie movie, NamingConfig namingConfig = null)
AddMovieTokens(tokenHandlers, movie);
AddReleaseDateTokens(tokenHandlers, movie.Year);
AddImdbIdTokens(tokenHandlers, movie.ImdbId);
AddIdTokens(tokenHandlers, movie);
if(movie.MovieFile != null)
{
@ -183,7 +183,7 @@ public string GetMovieFolder(Movie movie, NamingConfig namingConfig = null)
AddMovieTokens(tokenHandlers, movie);
AddReleaseDateTokens(tokenHandlers, movie.Year);
AddImdbIdTokens(tokenHandlers, movie.ImdbId);
AddIdTokens(tokenHandlers, movie);
if (movie.MovieFile != null)
{
@ -276,9 +276,10 @@ private void AddReleaseDateTokens(Dictionary<string, Func<TokenMatch, string>> t
tokenHandlers["{Release Year}"] = m => string.Format("{0}", releaseYear.ToString()); //Do I need m.CustomFormat?
}
private void AddImdbIdTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, string imdbId)
private void AddIdTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, Movie movie)
{
tokenHandlers["{IMDb Id}"] = m => $"{imdbId}";
tokenHandlers["{ImdbId}"] = m => movie.ImdbId ?? string.Empty;
tokenHandlers["{TmdbId}"] = m => movie.TmdbId.ToString();
}
private void AddMovieFileTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, MovieFile movieFile)

View File

@ -67,6 +67,7 @@ public FileNameSampleService(IBuildFileNames buildFileNames)
Title = "The Movie: Title",
Year = 2010,
ImdbId = "tt0066921",
TmdbId = 345691,
MovieFile = _movieFile,
MovieFileId = 1,
};