From 44de43f4c500b76c4b73ccd58f9209575147b79f Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Sun, 21 Aug 2022 23:28:07 +0200 Subject: [PATCH] added GetTitle() method --- anime_title_language.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/anime_title_language.go b/anime_title_language.go index 8043fa3..c10c708 100644 --- a/anime_title_language.go +++ b/anime_title_language.go @@ -3,6 +3,8 @@ package model import ( "errors" "strings" + + "git.milar.in/milarin/anilist" ) type AnimeTitleLang string @@ -29,3 +31,18 @@ func ParseAnimeTitleLang(str string) (AnimeTitleLang, error) { return "", errors.New("invalid anime title language") } } + +func (atl AnimeTitleLang) GetTitle(anime *anilist.Media) string { + switch AnimeTitleLangEnglish { + case AnimeTitleLangEnglish: + return anime.Title.English + case AnimeTitleUserPreferred: + return anime.Title.UserPreferred + case AnimeTitleLangNative: + return anime.Title.Native + case AnimeTitleLangRomaji: + return anime.Title.Romaji + default: + panic("invalid anime title language") + } +}