diff --git a/plugin/myanimelist/api.go b/plugin/myanimelist/api.go index a781964..5f51419 100644 --- a/plugin/myanimelist/api.go +++ b/plugin/myanimelist/api.go @@ -38,7 +38,8 @@ type ( Year int `json:"year"` Season string `json:"season"` } `json:"start_season"` - AverageEpisodeDuration int `json:"average_episode_duration"` + AverageEpisodeDuration int `json:"average_episode_duration"` + Rating string `json:"rating"` Studios []struct { ID int `json:"id"` Name string `json:"name"` @@ -53,14 +54,15 @@ type ( // AnimeResult is an extra struct because we don't need all the fields AnimeResult struct { - ID int `json:"id"` - Title string `json:"title"` - Nsfw string `json:"nsfw"` + ID int `json:"id"` + Title string `json:"title"` + Nsfw string `json:"nsfw"` + Rating string `json:"rating"` } ) func (a *AnimeResult) NSFW() bool { - return a.Nsfw == "black" + return a.Rating == "r+" || a.Rating == "rx" } func (a *Anime) GetMainPicture() string { @@ -71,7 +73,7 @@ func (a *Anime) GetMainPicture() string { } func (a *Anime) NSFW() bool { - return a.Nsfw == "black" + return a.Rating == "r+" || a.Rating == "rx" } func (a *Anime) GetAlternativeTitles() []string { diff --git a/plugin/myanimelist/myanimelist.go b/plugin/myanimelist/myanimelist.go index 0f5998e..6e75482 100644 --- a/plugin/myanimelist/myanimelist.go +++ b/plugin/myanimelist/myanimelist.go @@ -78,7 +78,7 @@ func (p *Plugin) onSearch(c plugin.GobotContext) error { } q := requestUrl.Query() q.Set("q", c.Matches[1]) - q.Set("fields", "id,title,nsfw") + q.Set("fields", "id,title,nsfw,rating") q.Set("limit", "5") q.Set("nsfw", "true") requestUrl.RawQuery = q.Encode() @@ -137,7 +137,7 @@ func (p *Plugin) onAnime(c plugin.GobotContext) error { Path: fmt.Sprintf("/v2/anime/%s", c.Matches[1]), } q := requestUrl.Query() - q.Set("fields", "id,title,main_picture,alternative_titles,start_date,end_date,synopsis,mean,rank,popularity,nsfw,media_type,status,genres,num_episodes,start_season,average_episode_duration,studios") + q.Set("fields", "id,title,main_picture,alternative_titles,start_date,end_date,synopsis,mean,rank,popularity,nsfw,media_type,status,genres,num_episodes,start_season,average_episode_duration,rating,studios") requestUrl.RawQuery = q.Encode() err := httpUtils.GetRequestWithHeader(