mirror of
https://github.com/Radarr/Radarr
synced 2025-01-04 06:23:32 +00:00
parent
10fc0b071f
commit
5e7f0f9d78
3 changed files with 58 additions and 5 deletions
|
@ -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})");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -91,7 +91,7 @@ public string BuildFileName(Movie movie, MovieFile movieFile, NamingConfig namin
|
||||||
|
|
||||||
AddMovieTokens(tokenHandlers, movie);
|
AddMovieTokens(tokenHandlers, movie);
|
||||||
AddReleaseDateTokens(tokenHandlers, movie.Year);
|
AddReleaseDateTokens(tokenHandlers, movie.Year);
|
||||||
AddImdbIdTokens(tokenHandlers, movie.ImdbId);
|
AddIdTokens(tokenHandlers, movie);
|
||||||
AddQualityTokens(tokenHandlers, movie, movieFile);
|
AddQualityTokens(tokenHandlers, movie, movieFile);
|
||||||
AddMediaInfoTokens(tokenHandlers, movieFile);
|
AddMediaInfoTokens(tokenHandlers, movieFile);
|
||||||
AddMovieFileTokens(tokenHandlers, movieFile);
|
AddMovieFileTokens(tokenHandlers, movieFile);
|
||||||
|
@ -140,7 +140,7 @@ public string BuildMoviePath(Movie movie, NamingConfig namingConfig = null)
|
||||||
|
|
||||||
AddMovieTokens(tokenHandlers, movie);
|
AddMovieTokens(tokenHandlers, movie);
|
||||||
AddReleaseDateTokens(tokenHandlers, movie.Year);
|
AddReleaseDateTokens(tokenHandlers, movie.Year);
|
||||||
AddImdbIdTokens(tokenHandlers, movie.ImdbId);
|
AddIdTokens(tokenHandlers, movie);
|
||||||
|
|
||||||
if(movie.MovieFile != null)
|
if(movie.MovieFile != null)
|
||||||
{
|
{
|
||||||
|
@ -183,7 +183,7 @@ public string GetMovieFolder(Movie movie, NamingConfig namingConfig = null)
|
||||||
|
|
||||||
AddMovieTokens(tokenHandlers, movie);
|
AddMovieTokens(tokenHandlers, movie);
|
||||||
AddReleaseDateTokens(tokenHandlers, movie.Year);
|
AddReleaseDateTokens(tokenHandlers, movie.Year);
|
||||||
AddImdbIdTokens(tokenHandlers, movie.ImdbId);
|
AddIdTokens(tokenHandlers, movie);
|
||||||
|
|
||||||
if (movie.MovieFile != null)
|
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?
|
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)
|
private void AddMovieFileTokens(Dictionary<string, Func<TokenMatch, string>> tokenHandlers, MovieFile movieFile)
|
||||||
|
|
|
@ -67,6 +67,7 @@ public FileNameSampleService(IBuildFileNames buildFileNames)
|
||||||
Title = "The Movie: Title",
|
Title = "The Movie: Title",
|
||||||
Year = 2010,
|
Year = 2010,
|
||||||
ImdbId = "tt0066921",
|
ImdbId = "tt0066921",
|
||||||
|
TmdbId = 345691,
|
||||||
MovieFile = _movieFile,
|
MovieFile = _movieFile,
|
||||||
MovieFileId = 1,
|
MovieFileId = 1,
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue