//Note: Since anime list endpoint, besides anime list, returns account stats, this method also
//updates Client with them
Since anime list endpoint, besides anime list, returns account stats, this method also
updates Client with them
// Note : Since anime list endpoint besides anime list returns account stats this method also // updates Client with them
func (c *Client) AnimeList(status MyStatus) ([]*Anime, error) {
	userListUrl := fmt.Sprintf(UserAnimeListEndpoint, c.Username, "all")
	req, err := http.NewRequest(http.MethodGet, userListUrl, nil)
	if err != nil {
		return nil, err
	}
	resp, err := http.DefaultClient.Do(req)
	if err != nil {
		return nil, err
	} else if resp.StatusCode != 200 {
		return nil, fmt.Errorf("server returned: %v", resp.Status)
	}
	decoder := xml.NewDecoder(resp.Body)
	decoder.Strict = false
	list := make([]*Anime, 0)
	for t, err := decoder.Token(); err != io.EOF; t, err = decoder.Token() {
		if t, ok := t.(xml.StartElement); ok {
			switch t.Name.Local {
			case "myinfo":
				decoder.DecodeElement(&c, &t)
			case "anime":
				anime := new(Anime)
				decoder.DecodeElement(&anime, &t)
				if anime.MyStatus == status || status == All {
					list = append(list, anime)
				}
			}
		}
	}
	return list, nil
}
func ( c * Client ) AnimeList ( status MyStatus ) ( [ ] * Anime , error ) { userListUrl := fmt . Sprintf ( UserAnimeListEndpoint , c . Username , " " ) req , err := http . NewRequest ( http . MethodGet , userListUrl , nil ) if err != nil { return nil , err } resp , err := http . DefaultClient . Do ( req ) if err != nil { return nil , err } else if resp . StatusCode != 200 { return nil , fmt . Errorf ( " " , resp . Status ) } decoder := xml . NewDecoder ( resp . Body ) decoder . Strict = false list := make ( [ ] * Anime , 0 ) for t , err := decoder . Token ( ) ; err != io . EOF ; t , err = decoder . Token ( ) { if t , ok := t . ( xml . StartElement ) ; ok { switch t . Name . Local { case " " : decoder . DecodeElement ( & c , & t ) case " " : anime := new ( Anime ) decoder . DecodeElement ( & anime , & t ) if anime . MyStatus == status || status == All { list = append ( list , anime ) } } } } return list , nil }
Since anime list endpoint, besides anime list, returns account stats, this method also
updates Client with them
Since anime list endpoint besides anime list returns account stats this method also updates Client with them
//NOTE: Anything other than `all` doesn't really work