added MAL update status and submit loader
This commit is contained in:
@ -55,10 +55,29 @@ func (a *App) GetMyAnimeList(count int) MALWatchlist {
|
||||
return malList
|
||||
}
|
||||
|
||||
func (a *App) MyAnimeListUpdate(anime MALAnime, update interface{}) MyListStatus {
|
||||
//var body url.Values
|
||||
func (a *App) MyAnimeListUpdate(anime MALAnime, update MALUploadStatus) MyListStatus {
|
||||
if update.NumTimesRewatched >= 1 {
|
||||
update.IsRewatching = true
|
||||
} else {
|
||||
update.IsRewatching = false
|
||||
}
|
||||
body := url.Values{}
|
||||
body.Set("status", update.Status)
|
||||
body.Set("is_rewatching", strconv.FormatBool(update.IsRewatching))
|
||||
body.Set("score", strconv.Itoa(update.Score))
|
||||
body.Set("num_watched_episodes", strconv.Itoa(update.NumWatchedEpisodes))
|
||||
body.Set("num_times_rewatched", strconv.Itoa(update.NumTimesRewatched))
|
||||
body.Set("comments", update.Comments)
|
||||
|
||||
return MyListStatus{}
|
||||
malUrl := "https://api.myanimelist.net/v2/anime/" + strconv.Itoa(anime.Id) + "/my_list_status"
|
||||
var status MyListStatus
|
||||
respBody := MALHelper("PATCH", malUrl, body)
|
||||
err := json.Unmarshal(respBody, &status)
|
||||
if err != nil {
|
||||
log.Printf("Failed to unmarshal json response, %s\n", err)
|
||||
}
|
||||
|
||||
return status
|
||||
}
|
||||
|
||||
func (a *App) GetMyAnimeListAnime(id int) MALAnime {
|
||||
|
Reference in New Issue
Block a user