added tags to get functions for AniList and fixed AniList Post Data query

This commit is contained in:
John O'Keefe 2024-08-09 15:07:41 -04:00
parent 94c0f97e95
commit ce52ae20f5
2 changed files with 110 additions and 71 deletions

View File

@ -3,6 +3,7 @@ package main
import (
"bytes"
"encoding/json"
"fmt"
"io"
"log"
"net/http"
@ -90,6 +91,15 @@ func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
timeUntilAiring
episode
}
tags{
id
name
description
rank
isMediaSpoiler
isAdult
}
isAdult
}
status
startedAt{
@ -180,6 +190,15 @@ func (a *App) AniListSearch(query string) any {
timeUntilAiring
episode
}
tags{
id
name
description
rank
isMediaSpoiler
isAdult
}
isAdult
}
}
}
@ -256,6 +275,15 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani
timeUntilAiring
episode
}
tags{
id
name
description
rank
isMediaSpoiler
isAdult
}
isAdult
}
status
startedAt {
@ -330,7 +358,7 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani
func (a *App) AniListUpdateEntry(
mediaId int,
progress string,
progress int,
status string,
score float64,
repeat int,
@ -354,7 +382,7 @@ func (a *App) AniListUpdateEntry(
}
type Variables struct {
MediaId int `json:"mediaId"`
Progress string `json:"progress"`
Progress int `json:"progress"`
Status string `json:"status"`
Score float64 `json:"score"`
Repeat int `json:"repeat"`
@ -363,10 +391,10 @@ func (a *App) AniListUpdateEntry(
CompletedAt CompletedAt `json:"completedAt"`
}
body := struct {
Mutation string `json:"mutation"`
Query string `json:"query"`
Variables Variables `json:"variables"`
}{
Mutation: `
Query: `
mutation(
$mediaId:Int,
$progress:Int,
@ -427,6 +455,8 @@ func (a *App) AniListUpdateEntry(
returnedBody, _ := AniListQuery(body, true)
fmt.Println(string(returnedBody))
var post interface{}
err := json.Unmarshal(returnedBody, &post)
if err != nil {

View File

@ -68,6 +68,15 @@ type MediaList struct {
TimeUntilAiring int `json:"timeUntilAiring"`
Episode int `json:"episode"`
} `json:"nextAiringEpisode"`
Tags []struct {
Id int `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
Rank int `json:"rank"`
IsMediaSpoiler bool `json:"isMediaSpoiler"`
IsAdult bool `json:"isAdult"`
} `json:"tags"`
IsAdult bool `json:"isAdult"`
} `json:"media"`
Status string `json:"status"`
StartedAt struct {
@ -80,10 +89,10 @@ type MediaList struct {
Month int `json:"month"`
Day int `json:"day"`
} `json:"completedAt"`
Notes string `json:"notes"`
Progress int `json:"progress"`
Score int `json:"score"`
Repeat int `json:"repeat"`
Notes string `json:"notes"`
Progress int `json:"progress"`
Score float64 `json:"score"`
Repeat int `json:"repeat"`
User struct {
ID int `json:"id"`
Name string `json:"name"`
@ -103,66 +112,66 @@ type MediaList struct {
} `json:"user"`
}
var MediaListSort = struct {
MediaId string
MediaIdDesc string
Score string
ScoreDesc string
Status string
StatusDesc string
Progress string
ProgressDesc string
ProgressVolumes string
ProgressVolumesDesc string
Repeat string
RepeatDesc string
Priority string
PriorityDesc string
StartedOn string
StartedOnDesc string
FinishedOn string
FinishedOnDesc string
AddedTime string
AddedTimeDesc string
UpdatedTime string
UpdatedTimeDesc string
MediaTitleRomaji string
MediaTitleRomajiDesc string
MediaTitleEnglish string
MediaTitleEnglishDesc string
MediaTitleNative string
MediaTitleNativeDesc string
MediaPopularity string
MediaPopularityDesc string
}{
MediaId: "MEDIA_ID",
MediaIdDesc: "MEDIA_ID_DESC",
Score: "SCORE",
ScoreDesc: "SCORE_DESC",
Status: "STATUS",
StatusDesc: "STATUS_DESC",
Progress: "PROGRESS",
ProgressDesc: "PROGRESS_DESC",
ProgressVolumes: "PROGRESS_VOLUMES",
ProgressVolumesDesc: "PROGRESS_VOLUMES_DESC",
Repeat: "REPEAT",
RepeatDesc: "REPEAT_DESC",
Priority: "PRIORITY",
PriorityDesc: "PRIORITY_DESC",
StartedOn: "STARTED_ON",
StartedOnDesc: "STARTED_ON_DESC",
FinishedOn: "FINISHED_ON",
FinishedOnDesc: "FINISHED_ON_DESC",
AddedTime: "ADDED_TIME",
AddedTimeDesc: "ADDED_TIME_DESC",
UpdatedTime: "UPDATED_TIME",
UpdatedTimeDesc: "UPDATED_TIME_DESC",
MediaTitleRomaji: "MEDIA_TITLE_ROMAJI",
MediaTitleRomajiDesc: "MEDIA_TITLE_ROMAJI_DESC",
MediaTitleEnglish: "MEDIA_TITLE_ENGLISH",
MediaTitleEnglishDesc: "MEDIA_TITLE_ENGLISH_DESC",
MediaTitleNative: "MEDIA_TITLE_NATIVE",
MediaTitleNativeDesc: "MEDIA_TITLE_NATIVE_DESC",
MediaPopularity: "MEDIA_POPULARITY",
MediaPopularityDesc: "MEDIA_POPULARITY_DESC",
}
//var MediaListSort = struct {
// MediaId string
// MediaIdDesc string
// Score string
// ScoreDesc string
// Status string
// StatusDesc string
// Progress string
// ProgressDesc string
// ProgressVolumes string
// ProgressVolumesDesc string
// Repeat string
// RepeatDesc string
// Priority string
// PriorityDesc string
// StartedOn string
// StartedOnDesc string
// FinishedOn string
// FinishedOnDesc string
// AddedTime string
// AddedTimeDesc string
// UpdatedTime string
// UpdatedTimeDesc string
// MediaTitleRomaji string
// MediaTitleRomajiDesc string
// MediaTitleEnglish string
// MediaTitleEnglishDesc string
// MediaTitleNative string
// MediaTitleNativeDesc string
// MediaPopularity string
// MediaPopularityDesc string
//}{
// MediaId: "MEDIA_ID",
// MediaIdDesc: "MEDIA_ID_DESC",
// Score: "SCORE",
// ScoreDesc: "SCORE_DESC",
// Status: "STATUS",
// StatusDesc: "STATUS_DESC",
// Progress: "PROGRESS",
// ProgressDesc: "PROGRESS_DESC",
// ProgressVolumes: "PROGRESS_VOLUMES",
// ProgressVolumesDesc: "PROGRESS_VOLUMES_DESC",
// Repeat: "REPEAT",
// RepeatDesc: "REPEAT_DESC",
// Priority: "PRIORITY",
// PriorityDesc: "PRIORITY_DESC",
// StartedOn: "STARTED_ON",
// StartedOnDesc: "STARTED_ON_DESC",
// FinishedOn: "FINISHED_ON",
// FinishedOnDesc: "FINISHED_ON_DESC",
// AddedTime: "ADDED_TIME",
// AddedTimeDesc: "ADDED_TIME_DESC",
// UpdatedTime: "UPDATED_TIME",
// UpdatedTimeDesc: "UPDATED_TIME_DESC",
// MediaTitleRomaji: "MEDIA_TITLE_ROMAJI",
// MediaTitleRomajiDesc: "MEDIA_TITLE_ROMAJI_DESC",
// MediaTitleEnglish: "MEDIA_TITLE_ENGLISH",
// MediaTitleEnglishDesc: "MEDIA_TITLE_ENGLISH_DESC",
// MediaTitleNative: "MEDIA_TITLE_NATIVE",
// MediaTitleNativeDesc: "MEDIA_TITLE_NATIVE_DESC",
// MediaPopularity: "MEDIA_POPULARITY",
// MediaPopularityDesc: "MEDIA_POPULARITY_DESC",
//}