Skip to content

Commit

Permalink
myanimelist: Use rating for NSFW
Browse files Browse the repository at this point in the history
  • Loading branch information
Brawl345 committed Dec 17, 2023
1 parent fb9aeae commit 7fcdaa8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
14 changes: 8 additions & 6 deletions plugin/myanimelist/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions plugin/myanimelist/myanimelist.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit 7fcdaa8

Please sign in to comment.