added GetTitle() method
This commit is contained in:
parent
5e9f052f86
commit
44de43f4c5
@ -3,6 +3,8 @@ package model
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"git.milar.in/milarin/anilist"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AnimeTitleLang string
|
type AnimeTitleLang string
|
||||||
@ -29,3 +31,18 @@ func ParseAnimeTitleLang(str string) (AnimeTitleLang, error) {
|
|||||||
return "", errors.New("invalid anime title language")
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user