added ability to change simkl rating
This commit is contained in:
@ -113,3 +113,50 @@ func (a *App) SimklSyncEpisodes(anime Anime, progress int) interface{} {
|
||||
|
||||
return success
|
||||
}
|
||||
|
||||
func (a *App) SimklSyncRating(anime Anime, rating int) interface{} {
|
||||
var url string
|
||||
var showWithRating = ShowWithRating{
|
||||
Title: anime.Show.Title,
|
||||
Ids: Ids{
|
||||
Simkl: anime.Show.Ids.Simkl,
|
||||
Mal: anime.Show.Ids.Mal,
|
||||
Anilist: anime.Show.Ids.AniList,
|
||||
},
|
||||
Rating: rating,
|
||||
}
|
||||
|
||||
var showWithoutRating = ShowWithoutRating{
|
||||
Title: anime.Show.Title,
|
||||
Ids: Ids{
|
||||
Simkl: anime.Show.Ids.Simkl,
|
||||
Mal: anime.Show.Ids.Mal,
|
||||
Anilist: anime.Show.Ids.AniList,
|
||||
},
|
||||
}
|
||||
|
||||
var shows []interface{}
|
||||
|
||||
if rating > 0 {
|
||||
shows = append(shows, showWithRating)
|
||||
url = "https://api.simkl.com/sync/ratings"
|
||||
} else {
|
||||
shows = append(shows, showWithoutRating)
|
||||
url = "https://api.simkl.com/sync/ratings/remove"
|
||||
}
|
||||
|
||||
simklSync := struct {
|
||||
Shows []interface{} `json:"shows" ts_type:"shows"`
|
||||
}{shows}
|
||||
|
||||
respBody := SimklPostHelper(url, simklSync)
|
||||
|
||||
var success interface{}
|
||||
|
||||
err := json.Unmarshal(respBody, &success)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
}
|
||||
|
||||
return success
|
||||
}
|
||||
|
Reference in New Issue
Block a user