diff --git a/ScriptRenamer/ScriptRenamerVisitor.cs b/ScriptRenamer/ScriptRenamerVisitor.cs index e574c54..ac504bd 100644 --- a/ScriptRenamer/ScriptRenamerVisitor.cs +++ b/ScriptRenamer/ScriptRenamerVisitor.cs @@ -30,7 +30,8 @@ public ScriptRenamerVisitor(RelocationEventArgs args, ILo _logger = logger; Renaming = args.RenameEnabled; Moving = args.MoveEnabled; - AnimeInfo = args.Series.Select(s => s.AnidbAnime).FirstOrDefault(); + ShokoSeries = args.Series.FirstOrDefault(); + AnimeInfo = ShokoSeries?.AnidbAnime; EpisodeInfo = args.Episodes.Select(se => se.AnidbEpisode).Where(e => e.SeriesID == AnimeInfo?.ID) .OrderBy(e => e.Type == EpisodeType.Other ? (EpisodeType)int.MinValue : e.Type) .ThenBy(e => e.EpisodeNumber) @@ -57,6 +58,7 @@ public ScriptRenamerVisitor(RelocationEventArgs args, ILo public List AvailableFolders { get; set; } = new(); public IVideoFile FileInfo { get; set; } public ISeries AnimeInfo { get; set; } + public IShokoSeries ShokoSeries { get; set; } public IShokoGroup GroupInfo { get; set; } public IEpisode EpisodeInfo { get; set; } public string Script { get; set; } @@ -166,7 +168,7 @@ public override object VisitString_labels([NotNull] SRP.String_labelsContext con int pad = context.number_atom() is null ? 0 : (int)Visit(context.number_atom()); return context.label.Type switch { - SRP.ANIMETITLEPREFERRED => AnimeInfo.PreferredTitle, + SRP.ANIMETITLEPREFERRED => ShokoSeries.PreferredTitle, SRP.ANIMETITLEROMAJI => AnimeTitleLanguage(TitleLanguage.Romaji), SRP.ANIMETITLEENGLISH => AnimeTitleLanguage(TitleLanguage.English), SRP.ANIMETITLEJAPANESE => AnimeTitleLanguage(TitleLanguage.Japanese), diff --git a/ScriptRenamerTests/ParserTest.cs b/ScriptRenamerTests/ParserTest.cs index 5f24cca..e406f26 100644 --- a/ScriptRenamerTests/ParserTest.cs +++ b/ScriptRenamerTests/ParserTest.cs @@ -248,7 +248,7 @@ public void TestStringAtomCompare() var context = parser.if_stmt().bool_expr(); var visitor = new ScriptRenamerVisitor { - AnimeInfo = Mock.Of(a => a.PreferredTitle == "testing") + ShokoSeries = Mock.Of(a => a.PreferredTitle == "testing") }; var result = (bool)visitor.Visit(context); Assert.IsTrue(result); @@ -347,7 +347,7 @@ public void TestSetStmt() var context = parser.start(); var visitor = new ScriptRenamerVisitor { - AnimeInfo = Mock.Of(a => a.PreferredTitle == "wioewoihwoiehwoihweohwiowj") + ShokoSeries = Mock.Of(a => a.PreferredTitle == "wioewoihwoiehwoihweohwiowj") }; _ = visitor.Visit(context); Assert.AreEqual("testtestingtestingwioewoihwoiehwoihweohwiowj", visitor.Filename);