added GetTitle() method

This commit is contained in:
Timon Ringwald 2022-08-21 23:28:07 +02:00
parent 5e9f052f86
commit 44de43f4c5

View File

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