expanded go structs to give more info for watch and single anime
This commit is contained in:
		@@ -35,9 +35,11 @@ func AniListQuery(body interface{}, login bool) (json.RawMessage, string) {
 | 
				
			|||||||
	return returnedBody, ""
 | 
						return returnedBody, ""
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func (a *App) GetAniListItem(aniId int) any {
 | 
					func (a *App) GetAniListItem(aniId int) AniListGetSingleAnime {
 | 
				
			||||||
 | 
						var user = a.GetAniListLoggedInUserId()
 | 
				
			||||||
	type Variables struct {
 | 
						type Variables struct {
 | 
				
			||||||
		ID       int    `json:"id"`
 | 
							UserId   int    `json:"userId"`
 | 
				
			||||||
 | 
							MediaId  int    `json:"mediaId"`
 | 
				
			||||||
		ListType string `json:"listType"`
 | 
							ListType string `json:"listType"`
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	body := struct {
 | 
						body := struct {
 | 
				
			||||||
@@ -45,43 +47,78 @@ func (a *App) GetAniListItem(aniId int) any {
 | 
				
			|||||||
		Variables Variables `json:"variables"`
 | 
							Variables Variables `json:"variables"`
 | 
				
			||||||
	}{
 | 
						}{
 | 
				
			||||||
		Query: `
 | 
							Query: `
 | 
				
			||||||
		query ($id: Int!, $listType: MediaType) {
 | 
								query($userId: Int, $mediaId: Int, $listType: MediaType) {
 | 
				
			||||||
			Media (id: $id, type: $listType) {
 | 
								  MediaList(mediaId: $mediaId, userId: $userId, type: $listType) {
 | 
				
			||||||
				id
 | 
									id
 | 
				
			||||||
				idMal
 | 
									mediaId
 | 
				
			||||||
				title {
 | 
									userId
 | 
				
			||||||
 | 
									media {
 | 
				
			||||||
 | 
									  id
 | 
				
			||||||
 | 
									  idMal
 | 
				
			||||||
 | 
									  title {
 | 
				
			||||||
					romaji
 | 
										romaji
 | 
				
			||||||
					english
 | 
										english
 | 
				
			||||||
				}
 | 
										native
 | 
				
			||||||
				description
 | 
									  }
 | 
				
			||||||
				coverImage {
 | 
									  description
 | 
				
			||||||
					medium
 | 
									  coverImage {
 | 
				
			||||||
					large
 | 
										large
 | 
				
			||||||
					extraLarge
 | 
									  }
 | 
				
			||||||
					color
 | 
									  season
 | 
				
			||||||
 | 
									  seasonYear
 | 
				
			||||||
 | 
									  status
 | 
				
			||||||
 | 
									  episodes
 | 
				
			||||||
 | 
									  nextAiringEpisode {
 | 
				
			||||||
 | 
										airingAt
 | 
				
			||||||
 | 
										timeUntilAiring
 | 
				
			||||||
 | 
										episode
 | 
				
			||||||
 | 
									  }
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
				tags {
 | 
									status
 | 
				
			||||||
					id
 | 
									startedAt{
 | 
				
			||||||
					name
 | 
									  year
 | 
				
			||||||
					description
 | 
									  month
 | 
				
			||||||
					category
 | 
									  day
 | 
				
			||||||
					rank
 | 
					 | 
				
			||||||
					isGeneralSpoiler
 | 
					 | 
				
			||||||
					isMediaSpoiler
 | 
					 | 
				
			||||||
					isAdult
 | 
					 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
									completedAt{
 | 
				
			||||||
 | 
									  year
 | 
				
			||||||
 | 
									  month
 | 
				
			||||||
 | 
									  day
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									notes
 | 
				
			||||||
 | 
									progress
 | 
				
			||||||
 | 
									score
 | 
				
			||||||
 | 
									repeat
 | 
				
			||||||
 | 
									user {
 | 
				
			||||||
 | 
									  id
 | 
				
			||||||
 | 
									  name
 | 
				
			||||||
 | 
									  avatar {
 | 
				
			||||||
 | 
										large
 | 
				
			||||||
 | 
										medium
 | 
				
			||||||
 | 
									  }
 | 
				
			||||||
 | 
									  statistics {
 | 
				
			||||||
 | 
										anime {
 | 
				
			||||||
 | 
										  count
 | 
				
			||||||
 | 
										  statuses {
 | 
				
			||||||
 | 
											status
 | 
				
			||||||
 | 
											count
 | 
				
			||||||
 | 
										  }
 | 
				
			||||||
 | 
										}
 | 
				
			||||||
 | 
									  }
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								  }
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	`,
 | 
						`,
 | 
				
			||||||
		Variables: Variables{
 | 
							Variables: Variables{
 | 
				
			||||||
			ID:       aniId,
 | 
								MediaId:  aniId,
 | 
				
			||||||
 | 
								UserId:   user.Data.Viewer.ID,
 | 
				
			||||||
			ListType: "ANIME",
 | 
								ListType: "ANIME",
 | 
				
			||||||
		},
 | 
							},
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	returnedBody, _ := AniListQuery(body, false)
 | 
						returnedBody, _ := AniListQuery(body, false)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	var post interface{}
 | 
						var post AniListGetSingleAnime
 | 
				
			||||||
	err := json.Unmarshal(returnedBody, &post)
 | 
						err := json.Unmarshal(returnedBody, &post)
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		log.Printf("Failed at unmarshal, %s\n", err)
 | 
							log.Printf("Failed at unmarshal, %s\n", err)
 | 
				
			||||||
@@ -110,18 +147,28 @@ func (a *App) AniListSearch(query string) any {
 | 
				
			|||||||
					  perPage
 | 
										  perPage
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
					media (search: $search, type: $listType) {
 | 
										media (search: $search, type: $listType) {
 | 
				
			||||||
					  id
 | 
											id						
 | 
				
			||||||
					  idMal
 | 
											idMal
 | 
				
			||||||
					  title {
 | 
											title {
 | 
				
			||||||
						romaji
 | 
											  romaji
 | 
				
			||||||
						english
 | 
											  english
 | 
				
			||||||
					  }
 | 
											  native
 | 
				
			||||||
					  coverImage {
 | 
											}
 | 
				
			||||||
						extraLarge
 | 
											description
 | 
				
			||||||
						color
 | 
											coverImage {
 | 
				
			||||||
					  }
 | 
											  large
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
 | 
											season
 | 
				
			||||||
 | 
											seasonYear
 | 
				
			||||||
 | 
											status
 | 
				
			||||||
 | 
											episodes
 | 
				
			||||||
 | 
											nextAiringEpisode{
 | 
				
			||||||
 | 
											  airingAt
 | 
				
			||||||
 | 
											  timeUntilAiring
 | 
				
			||||||
 | 
											  episode
 | 
				
			||||||
 | 
											}
 | 
				
			||||||
					}
 | 
										}
 | 
				
			||||||
				  }
 | 
									}
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		`,
 | 
							`,
 | 
				
			||||||
		Variables: Variables{
 | 
							Variables: Variables{
 | 
				
			||||||
@@ -198,6 +245,16 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani
 | 
				
			|||||||
						}
 | 
											}
 | 
				
			||||||
					  }
 | 
										  }
 | 
				
			||||||
					  status
 | 
										  status
 | 
				
			||||||
 | 
										  startedAt {
 | 
				
			||||||
 | 
											year
 | 
				
			||||||
 | 
											month
 | 
				
			||||||
 | 
											day
 | 
				
			||||||
 | 
										  }
 | 
				
			||||||
 | 
										  completedAt {
 | 
				
			||||||
 | 
											year
 | 
				
			||||||
 | 
											month
 | 
				
			||||||
 | 
											day
 | 
				
			||||||
 | 
										  }
 | 
				
			||||||
					  notes
 | 
										  notes
 | 
				
			||||||
					  progress
 | 
										  progress
 | 
				
			||||||
					  score
 | 
										  score
 | 
				
			||||||
@@ -257,3 +314,111 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	return post
 | 
						return post
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					func (a *App) AniListUpdateEntry(
 | 
				
			||||||
 | 
						mediaId int,
 | 
				
			||||||
 | 
						progress string,
 | 
				
			||||||
 | 
						status string,
 | 
				
			||||||
 | 
						score float64,
 | 
				
			||||||
 | 
						repeat int,
 | 
				
			||||||
 | 
						notes string,
 | 
				
			||||||
 | 
						startYear int,
 | 
				
			||||||
 | 
						startMonth int,
 | 
				
			||||||
 | 
						startDay int,
 | 
				
			||||||
 | 
						completeYear int,
 | 
				
			||||||
 | 
						completeMonth int,
 | 
				
			||||||
 | 
						completeDay int,
 | 
				
			||||||
 | 
					) interface{} {
 | 
				
			||||||
 | 
						type StartedAt struct {
 | 
				
			||||||
 | 
							Year  int `json:"year"`
 | 
				
			||||||
 | 
							Month int `json:"month"`
 | 
				
			||||||
 | 
							Day   int `json:"day"`
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						type CompletedAt struct {
 | 
				
			||||||
 | 
							Year  int `json:"year"`
 | 
				
			||||||
 | 
							Month int `json:"month"`
 | 
				
			||||||
 | 
							Day   int `json:"day"`
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						type Variables struct {
 | 
				
			||||||
 | 
							MediaId     int         `json:"mediaId"`
 | 
				
			||||||
 | 
							Progress    string      `json:"progress"`
 | 
				
			||||||
 | 
							Status      string      `json:"status"`
 | 
				
			||||||
 | 
							Score       float64     `json:"score"`
 | 
				
			||||||
 | 
							Repeat      int         `json:"repeat"`
 | 
				
			||||||
 | 
							Notes       string      `json:"notes"`
 | 
				
			||||||
 | 
							StartedAt   StartedAt   `json:"startedAt"`
 | 
				
			||||||
 | 
							CompletedAt CompletedAt `json:"completedAt"`
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						body := struct {
 | 
				
			||||||
 | 
							Mutation  string    `json:"mutation"`
 | 
				
			||||||
 | 
							Variables Variables `json:"variables"`
 | 
				
			||||||
 | 
						}{
 | 
				
			||||||
 | 
							Mutation: `
 | 
				
			||||||
 | 
								mutation(
 | 
				
			||||||
 | 
								  $mediaId:Int, 
 | 
				
			||||||
 | 
								  $progress:Int, 
 | 
				
			||||||
 | 
								  $status:MediaListStatus,
 | 
				
			||||||
 | 
								  $score:Float,
 | 
				
			||||||
 | 
								  $repeat:Int,
 | 
				
			||||||
 | 
								  $notes:String,
 | 
				
			||||||
 | 
								  $startedAt:FuzzyDateInput,
 | 
				
			||||||
 | 
								  $completedAt:FuzzyDateInput,
 | 
				
			||||||
 | 
								){
 | 
				
			||||||
 | 
								  SaveMediaListEntry(
 | 
				
			||||||
 | 
									mediaId:$mediaId, 
 | 
				
			||||||
 | 
									progress:$progress, 
 | 
				
			||||||
 | 
									status:$status,
 | 
				
			||||||
 | 
									score:$score,
 | 
				
			||||||
 | 
									repeat:$repeat,
 | 
				
			||||||
 | 
									notes:$notes,
 | 
				
			||||||
 | 
									startedAt:$startedAt
 | 
				
			||||||
 | 
									completedAt:$completedAt
 | 
				
			||||||
 | 
								  ){   
 | 
				
			||||||
 | 
									mediaId
 | 
				
			||||||
 | 
									progress
 | 
				
			||||||
 | 
									status
 | 
				
			||||||
 | 
									score
 | 
				
			||||||
 | 
									repeat
 | 
				
			||||||
 | 
									notes
 | 
				
			||||||
 | 
									startedAt{
 | 
				
			||||||
 | 
									  year
 | 
				
			||||||
 | 
									  month
 | 
				
			||||||
 | 
									  day
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									completedAt{
 | 
				
			||||||
 | 
									  year
 | 
				
			||||||
 | 
									  month
 | 
				
			||||||
 | 
									  day
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
								  }
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							`,
 | 
				
			||||||
 | 
							Variables: Variables{
 | 
				
			||||||
 | 
								MediaId:  mediaId,
 | 
				
			||||||
 | 
								Progress: progress,
 | 
				
			||||||
 | 
								Status:   status,
 | 
				
			||||||
 | 
								Score:    score,
 | 
				
			||||||
 | 
								Repeat:   repeat,
 | 
				
			||||||
 | 
								Notes:    notes,
 | 
				
			||||||
 | 
								StartedAt: StartedAt{
 | 
				
			||||||
 | 
									Year:  startYear,
 | 
				
			||||||
 | 
									Month: startMonth,
 | 
				
			||||||
 | 
									Day:   startDay,
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								CompletedAt: CompletedAt{
 | 
				
			||||||
 | 
									Year:  completeYear,
 | 
				
			||||||
 | 
									Month: completeMonth,
 | 
				
			||||||
 | 
									Day:   completeDay,
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
							}}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						returnedBody, _ := AniListQuery(body, true)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						var post interface{}
 | 
				
			||||||
 | 
						err := json.Unmarshal(returnedBody, &post)
 | 
				
			||||||
 | 
						if err != nil {
 | 
				
			||||||
 | 
							log.Printf("Failed at unmarshal, %s\n", err)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return post
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										106
									
								
								AniListTypes.go
									
									
									
									
									
								
							
							
						
						
									
										106
									
								
								AniListTypes.go
									
									
									
									
									
								
							@@ -26,59 +26,67 @@ type AniListCurrentUserWatchList struct {
 | 
				
			|||||||
				LastPage    int  `json:"lastPage"`
 | 
									LastPage    int  `json:"lastPage"`
 | 
				
			||||||
				HasNextPage bool `json:"hasNextPage"`
 | 
									HasNextPage bool `json:"hasNextPage"`
 | 
				
			||||||
			} `json:"pageInfo"`
 | 
								} `json:"pageInfo"`
 | 
				
			||||||
			MediaList []struct {
 | 
								MediaList []MediaList `json:"mediaList"`
 | 
				
			||||||
				ID      int `json:"id"`
 | 
					 | 
				
			||||||
				MediaID int `json:"mediaId"`
 | 
					 | 
				
			||||||
				UserID  int `json:"userId"`
 | 
					 | 
				
			||||||
				Media   struct {
 | 
					 | 
				
			||||||
					ID    int `json:"id"`
 | 
					 | 
				
			||||||
					IDMal int `json:"idMal"`
 | 
					 | 
				
			||||||
					Title struct {
 | 
					 | 
				
			||||||
						Romaji  string `json:"romaji"`
 | 
					 | 
				
			||||||
						English string `json:"english"`
 | 
					 | 
				
			||||||
						Native  string `json:"native"`
 | 
					 | 
				
			||||||
					} `json:"title"`
 | 
					 | 
				
			||||||
					Description string `json:"description"`
 | 
					 | 
				
			||||||
					CoverImage  struct {
 | 
					 | 
				
			||||||
						Large string `json:"large"`
 | 
					 | 
				
			||||||
					} `json:"coverImage"`
 | 
					 | 
				
			||||||
					Season            string `json:"season"`
 | 
					 | 
				
			||||||
					SeasonYear        int    `json:"seasonYear"`
 | 
					 | 
				
			||||||
					Status            string `json:"status"`
 | 
					 | 
				
			||||||
					Episodes          int    `json:"episodes"`
 | 
					 | 
				
			||||||
					NextAiringEpisode struct {
 | 
					 | 
				
			||||||
						AiringAt        int `json:"airingAt"`
 | 
					 | 
				
			||||||
						TimeUntilAiring int `json:"timeUntilAiring"`
 | 
					 | 
				
			||||||
						Episode         int `json:"episode"`
 | 
					 | 
				
			||||||
					} `json:"nextAiringEpisode"`
 | 
					 | 
				
			||||||
				} `json:"media"`
 | 
					 | 
				
			||||||
				Status   string `json:"status"`
 | 
					 | 
				
			||||||
				Notes    string `json:"notes"`
 | 
					 | 
				
			||||||
				Progress int    `json:"progress"`
 | 
					 | 
				
			||||||
				Score    int    `json:"score"`
 | 
					 | 
				
			||||||
				Repeat   int    `json:"repeat"`
 | 
					 | 
				
			||||||
				User     struct {
 | 
					 | 
				
			||||||
					ID     int    `json:"id"`
 | 
					 | 
				
			||||||
					Name   string `json:"name"`
 | 
					 | 
				
			||||||
					Avatar struct {
 | 
					 | 
				
			||||||
						Large  string `json:"large"`
 | 
					 | 
				
			||||||
						Medium string `json:"medium"`
 | 
					 | 
				
			||||||
					} `json:"avatar"`
 | 
					 | 
				
			||||||
					Statistics struct {
 | 
					 | 
				
			||||||
						Anime struct {
 | 
					 | 
				
			||||||
							Count    int `json:"count"`
 | 
					 | 
				
			||||||
							Statuses []struct {
 | 
					 | 
				
			||||||
								Status string `json:"status"`
 | 
					 | 
				
			||||||
								Count  int    `json:"count"`
 | 
					 | 
				
			||||||
							} `json:"statuses"`
 | 
					 | 
				
			||||||
						} `json:"anime"`
 | 
					 | 
				
			||||||
					} `json:"statistics"`
 | 
					 | 
				
			||||||
				} `json:"user"`
 | 
					 | 
				
			||||||
			} `json:"mediaList"`
 | 
					 | 
				
			||||||
		} `json:"Page"`
 | 
							} `json:"Page"`
 | 
				
			||||||
	} `json:"data"`
 | 
						} `json:"data"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type AniListGetSingleAnime struct {
 | 
				
			||||||
 | 
						Data struct {
 | 
				
			||||||
 | 
							MediaList MediaList `json:"MediaList"`
 | 
				
			||||||
 | 
						} `json:"data"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					type MediaList struct {
 | 
				
			||||||
 | 
						ID      int `json:"id"`
 | 
				
			||||||
 | 
						MediaID int `json:"mediaId"`
 | 
				
			||||||
 | 
						UserID  int `json:"userId"`
 | 
				
			||||||
 | 
						Media   struct {
 | 
				
			||||||
 | 
							ID    int `json:"id"`
 | 
				
			||||||
 | 
							IDMal int `json:"idMal"`
 | 
				
			||||||
 | 
							Title struct {
 | 
				
			||||||
 | 
								Romaji  string `json:"romaji"`
 | 
				
			||||||
 | 
								English string `json:"english"`
 | 
				
			||||||
 | 
								Native  string `json:"native"`
 | 
				
			||||||
 | 
							} `json:"title"`
 | 
				
			||||||
 | 
							Description string `json:"description"`
 | 
				
			||||||
 | 
							CoverImage  struct {
 | 
				
			||||||
 | 
								Large string `json:"large"`
 | 
				
			||||||
 | 
							} `json:"coverImage"`
 | 
				
			||||||
 | 
							Season            string `json:"season"`
 | 
				
			||||||
 | 
							SeasonYear        int    `json:"seasonYear"`
 | 
				
			||||||
 | 
							Status            string `json:"status"`
 | 
				
			||||||
 | 
							Episodes          int    `json:"episodes"`
 | 
				
			||||||
 | 
							NextAiringEpisode struct {
 | 
				
			||||||
 | 
								AiringAt        int `json:"airingAt"`
 | 
				
			||||||
 | 
								TimeUntilAiring int `json:"timeUntilAiring"`
 | 
				
			||||||
 | 
								Episode         int `json:"episode"`
 | 
				
			||||||
 | 
							} `json:"nextAiringEpisode"`
 | 
				
			||||||
 | 
						} `json:"media"`
 | 
				
			||||||
 | 
						Status   string `json:"status"`
 | 
				
			||||||
 | 
						Notes    string `json:"notes"`
 | 
				
			||||||
 | 
						Progress int    `json:"progress"`
 | 
				
			||||||
 | 
						Score    int    `json:"score"`
 | 
				
			||||||
 | 
						Repeat   int    `json:"repeat"`
 | 
				
			||||||
 | 
						User     struct {
 | 
				
			||||||
 | 
							ID     int    `json:"id"`
 | 
				
			||||||
 | 
							Name   string `json:"name"`
 | 
				
			||||||
 | 
							Avatar struct {
 | 
				
			||||||
 | 
								Large  string `json:"large"`
 | 
				
			||||||
 | 
								Medium string `json:"medium"`
 | 
				
			||||||
 | 
							} `json:"avatar"`
 | 
				
			||||||
 | 
							Statistics struct {
 | 
				
			||||||
 | 
								Anime struct {
 | 
				
			||||||
 | 
									Count    int `json:"count"`
 | 
				
			||||||
 | 
									Statuses []struct {
 | 
				
			||||||
 | 
										Status string `json:"status"`
 | 
				
			||||||
 | 
										Count  int    `json:"count"`
 | 
				
			||||||
 | 
									} `json:"statuses"`
 | 
				
			||||||
 | 
								} `json:"anime"`
 | 
				
			||||||
 | 
							} `json:"statistics"`
 | 
				
			||||||
 | 
						} `json:"user"`
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var MediaListSort = struct {
 | 
					var MediaListSort = struct {
 | 
				
			||||||
	MediaId               string
 | 
						MediaId               string
 | 
				
			||||||
	MediaIdDesc           string
 | 
						MediaIdDesc           string
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user