1
0
mirror of https://github.com/Radarr/Radarr.git synced 2024-10-05 23:57:20 +02:00

New: Additional info passed in for Script Import and Custom Script

(cherry picked from commit 3f0268b79f6f5953191da4a765ba24159e15974d)
This commit is contained in:
Jendrik Weise 2023-07-11 05:49:49 +02:00 committed by Qstick
parent 4a66a832b3
commit 8c34946134
2 changed files with 34 additions and 0 deletions

View File

@ -7,7 +7,9 @@
using NzbDrone.Common.Processes;
using NzbDrone.Core.Configuration;
using NzbDrone.Core.MediaFiles.MediaInfo;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Parser.Model;
using NzbDrone.Core.Tags;
namespace NzbDrone.Core.MediaFiles
{
@ -22,18 +24,21 @@ public class ImportScriptService : IImportScript
private readonly IVideoFileInfoReader _videoFileInfoReader;
private readonly IProcessProvider _processProvider;
private readonly IConfigService _configService;
private readonly ITagService _tagService;
private readonly Logger _logger;
public ImportScriptService(IProcessProvider processProvider,
IVideoFileInfoReader videoFileInfoReader,
IConfigService configService,
IConfigFileProvider configFileProvider,
ITagService tagService,
Logger logger)
{
_processProvider = processProvider;
_videoFileInfoReader = videoFileInfoReader;
_configService = configService;
_configFileProvider = configFileProvider;
_tagService = tagService;
_logger = logger;
}
@ -64,6 +69,9 @@ public ScriptImportDecision TryImport(string sourcePath, string destinationFileP
environmentVariables.Add("Radarr_Movie_Path", movie.Path);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.MovieMetadata.Value.TmdbId.ToString());
environmentVariables.Add("Radarr_Movie_ImdbId", movie.MovieMetadata.Value.ImdbId ?? string.Empty);
environmentVariables.Add("Radarr_Movie_OriginalLanguage", IsoLanguages.Get(movie.MovieMetadata.Value.OriginalLanguage).ThreeLetterCode);
environmentVariables.Add("Radarr_Movie_Genres", string.Join("|", movie.MovieMetadata.Value.Genres));
environmentVariables.Add("Radarr_Movie_Tags", string.Join("|", movie.Tags.Select(t => _tagService.GetTag(t).Label)));
environmentVariables.Add("Radarr_Movie_In_Cinemas_Date", movie.MovieMetadata.Value.InCinemas.ToString() ?? string.Empty);
environmentVariables.Add("Radarr_Movie_Physical_Release_Date", movie.MovieMetadata.Value.PhysicalRelease.ToString() ?? string.Empty);

View File

@ -13,6 +13,8 @@
using NzbDrone.Core.MediaFiles;
using NzbDrone.Core.MediaFiles.MediaInfo;
using NzbDrone.Core.Movies;
using NzbDrone.Core.Parser;
using NzbDrone.Core.Tags;
using NzbDrone.Core.ThingiProvider;
using NzbDrone.Core.Validation;
@ -24,18 +26,21 @@ public class CustomScript : NotificationBase<CustomScriptSettings>
private readonly IConfigService _configService;
private readonly IDiskProvider _diskProvider;
private readonly IProcessProvider _processProvider;
private readonly ITagRepository _tagRepository;
private readonly Logger _logger;
public CustomScript(IConfigFileProvider configFileProvider,
IConfigService configService,
IDiskProvider diskProvider,
IProcessProvider processProvider,
ITagRepository tagRepository,
Logger logger)
{
_configFileProvider = configFileProvider;
_configService = configService;
_diskProvider = diskProvider;
_processProvider = processProvider;
_tagRepository = tagRepository;
_logger = logger;
}
@ -58,6 +63,9 @@ public override void OnGrab(GrabMessage message)
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.MovieMetadata.Value.Title);
environmentVariables.Add("Radarr_Movie_Year", movie.MovieMetadata.Value.Year.ToString());
environmentVariables.Add("Radarr_Movie_OriginalLanguage", IsoLanguages.Get(movie.MovieMetadata.Value.OriginalLanguage).ThreeLetterCode);
environmentVariables.Add("Radarr_Movie_Genres", string.Join("|", movie.MovieMetadata.Value.Genres));
environmentVariables.Add("Radarr_Movie_Tags", string.Join("|", movie.Tags.Select(t => _tagRepository.Get(t).Label)));
environmentVariables.Add("Radarr_Movie_ImdbId", movie.MovieMetadata.Value.ImdbId ?? string.Empty);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.MovieMetadata.Value.TmdbId.ToString());
environmentVariables.Add("Radarr_Movie_In_Cinemas_Date", movie.MovieMetadata.Value.InCinemas.ToString() ?? string.Empty);
@ -93,6 +101,9 @@ public override void OnDownload(DownloadMessage message)
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.MovieMetadata.Value.Title);
environmentVariables.Add("Radarr_Movie_Year", movie.MovieMetadata.Value.Year.ToString());
environmentVariables.Add("Radarr_Movie_OriginalLanguage", IsoLanguages.Get(movie.MovieMetadata.Value.OriginalLanguage).ThreeLetterCode);
environmentVariables.Add("Radarr_Movie_Genres", string.Join("|", movie.MovieMetadata.Value.Genres));
environmentVariables.Add("Radarr_Movie_Tags", string.Join("|", movie.Tags.Select(t => _tagRepository.Get(t).Label)));
environmentVariables.Add("Radarr_Movie_Path", movie.Path);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.MovieMetadata.Value.ImdbId ?? string.Empty);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.MovieMetadata.Value.TmdbId.ToString());
@ -146,6 +157,9 @@ public override void OnMovieRename(Movie movie, List<RenamedMovieFile> renamedFi
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.MovieMetadata.Value.Title);
environmentVariables.Add("Radarr_Movie_Year", movie.MovieMetadata.Value.Year.ToString());
environmentVariables.Add("Radarr_Movie_OriginalLanguage", IsoLanguages.Get(movie.MovieMetadata.Value.OriginalLanguage).ThreeLetterCode);
environmentVariables.Add("Radarr_Movie_Genres", string.Join("|", movie.MovieMetadata.Value.Genres));
environmentVariables.Add("Radarr_Movie_Tags", string.Join("|", movie.Tags.Select(t => _tagRepository.Get(t).Label)));
environmentVariables.Add("Radarr_Movie_Path", movie.Path);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.MovieMetadata.Value.ImdbId ?? string.Empty);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.MovieMetadata.Value.TmdbId.ToString());
@ -170,6 +184,9 @@ public override void OnMovieAdded(Movie movie)
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.MovieMetadata.Value.Title);
environmentVariables.Add("Radarr_Movie_Year", movie.MovieMetadata.Value.Year.ToString());
environmentVariables.Add("Radarr_Movie_OriginalLanguage", IsoLanguages.Get(movie.MovieMetadata.Value.OriginalLanguage).ThreeLetterCode);
environmentVariables.Add("Radarr_Movie_Genres", string.Join("|", movie.MovieMetadata.Value.Genres));
environmentVariables.Add("Radarr_Movie_Tags", string.Join("|", movie.Tags.Select(t => _tagRepository.Get(t).Label)));
environmentVariables.Add("Radarr_Movie_Path", movie.Path);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.MovieMetadata.Value.ImdbId ?? string.Empty);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.MovieMetadata.Value.TmdbId.ToString());
@ -192,6 +209,9 @@ public override void OnMovieFileDelete(MovieFileDeleteMessage deleteMessage)
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.Title);
environmentVariables.Add("Radarr_Movie_Year", movie.Year.ToString());
environmentVariables.Add("Radarr_Movie_OriginalLanguage", IsoLanguages.Get(movie.MovieMetadata.Value.OriginalLanguage).ThreeLetterCode);
environmentVariables.Add("Radarr_Movie_Genres", string.Join("|", movie.MovieMetadata.Value.Genres));
environmentVariables.Add("Radarr_Movie_Tags", string.Join("|", movie.Tags.Select(t => _tagRepository.Get(t).Label)));
environmentVariables.Add("Radarr_Movie_Path", movie.Path);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.MovieMetadata.Value.ImdbId ?? string.Empty);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.MovieMetadata.Value.TmdbId.ToString());
@ -219,6 +239,9 @@ public override void OnMovieDelete(MovieDeleteMessage deleteMessage)
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.MovieMetadata.Value.Title);
environmentVariables.Add("Radarr_Movie_Year", movie.MovieMetadata.Value.Year.ToString());
environmentVariables.Add("Radarr_Movie_OriginalLanguage", IsoLanguages.Get(movie.MovieMetadata.Value.OriginalLanguage).ThreeLetterCode);
environmentVariables.Add("Radarr_Movie_Genres", string.Join("|", movie.MovieMetadata.Value.Genres));
environmentVariables.Add("Radarr_Movie_Tags", string.Join("|", movie.Tags.Select(t => _tagRepository.Get(t).Label)));
environmentVariables.Add("Radarr_Movie_Path", movie.Path);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.MovieMetadata.Value.ImdbId ?? string.Empty);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.MovieMetadata.Value.TmdbId.ToString());
@ -288,6 +311,9 @@ public override void OnManualInteractionRequired(ManualInteractionRequiredMessag
environmentVariables.Add("Radarr_Movie_Id", movie.Id.ToString());
environmentVariables.Add("Radarr_Movie_Title", movie.MovieMetadata.Value.Title);
environmentVariables.Add("Radarr_Movie_Year", movie.MovieMetadata.Value.Year.ToString());
environmentVariables.Add("Radarr_Movie_OriginalLanguage", IsoLanguages.Get(movie.MovieMetadata.Value.OriginalLanguage).ThreeLetterCode);
environmentVariables.Add("Radarr_Movie_Genres", string.Join("|", movie.MovieMetadata.Value.Genres));
environmentVariables.Add("Radarr_Movie_Tags", string.Join("|", movie.Tags.Select(t => _tagRepository.Get(t).Label)));
environmentVariables.Add("Radarr_Movie_Path", movie.Path);
environmentVariables.Add("Radarr_Movie_ImdbId", movie.MovieMetadata.Value.ImdbId ?? string.Empty);
environmentVariables.Add("Radarr_Movie_TmdbId", movie.MovieMetadata.Value.TmdbId.ToString());