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") + } +}