Skip to content

Commit

Permalink
Return preferred title from shoko not anidb obj
Browse files Browse the repository at this point in the history
  • Loading branch information
Mik1ll committed Aug 18, 2024
1 parent 46612a5 commit 449fc75
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions ScriptRenamer/ScriptRenamerVisitor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public ScriptRenamerVisitor(RelocationEventArgs<ScriptRenamerSettings> 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)
Expand All @@ -57,6 +58,7 @@ public ScriptRenamerVisitor(RelocationEventArgs<ScriptRenamerSettings> args, ILo
public List<IImportFolder> 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; }
Expand Down Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions ScriptRenamerTests/ParserTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ public void TestStringAtomCompare()
var context = parser.if_stmt().bool_expr();
var visitor = new ScriptRenamerVisitor
{
AnimeInfo = Mock.Of<ISeries>(a => a.PreferredTitle == "testing")
ShokoSeries = Mock.Of<IShokoSeries>(a => a.PreferredTitle == "testing")
};
var result = (bool)visitor.Visit(context);
Assert.IsTrue(result);
Expand Down Expand Up @@ -347,7 +347,7 @@ public void TestSetStmt()
var context = parser.start();
var visitor = new ScriptRenamerVisitor
{
AnimeInfo = Mock.Of<ISeries>(a => a.PreferredTitle == "wioewoihwoiehwoihweohwiowj")
ShokoSeries = Mock.Of<IShokoSeries>(a => a.PreferredTitle == "wioewoihwoiehwoihweohwiowj")
};
_ = visitor.Visit(context);
Assert.AreEqual("testtestingtestingwioewoihwoiehwoihweohwiowj", visitor.Filename);
Expand Down

0 comments on commit 449fc75

Please sign in to comment.