diff --git a/AniListFunctions.go b/AniListFunctions.go index 4c88520..db13e51 100644 --- a/AniListFunctions.go +++ b/AniListFunctions.go @@ -355,7 +355,7 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani return post } -func (a *App) AniListUpdateEntry(updateBody AniListUpdateVariables) interface{} { +func (a *App) AniListUpdateEntry(updateBody AniListUpdateVariables) AniListGetSingleAnime { body := struct { Query string `json:"query"` Variables AniListUpdateVariables `json:"variables"` @@ -381,12 +381,33 @@ func (a *App) AniListUpdateEntry(updateBody AniListUpdateVariables) interface{} startedAt:$startedAt completedAt:$completedAt ){ + id mediaId - progress + userId + media { + id + idMal + title { + romaji + english + native + } + description + coverImage { + large + } + season + seasonYear + status + episodes + nextAiringEpisode { + airingAt + timeUntilAiring + episode + } + isAdult + } status - score - repeat - notes startedAt{ year month @@ -397,6 +418,27 @@ func (a *App) AniListUpdateEntry(updateBody AniListUpdateVariables) interface{} month day } + notes + progress + score + repeat + user { + id + name + avatar{ + large + medium + } + statistics{ + anime{ + count + statuses{ + status + count + } + } + } + } } } `, @@ -405,11 +447,15 @@ func (a *App) AniListUpdateEntry(updateBody AniListUpdateVariables) interface{} returnedBody, _ := AniListQuery(body, true) - var post interface{} - err := json.Unmarshal(returnedBody, &post) + var returnedJson AniListUpdateReturn + err := json.Unmarshal(returnedBody, &returnedJson) if err != nil { log.Printf("Failed at unmarshal, %s\n", err) } + var post AniListGetSingleAnime + + post.Data.MediaList = returnedJson.Data.SaveMediaListEntry + return post } diff --git a/AniListTypes.go b/AniListTypes.go index 1d51f27..6cad8e6 100644 --- a/AniListTypes.go +++ b/AniListTypes.go @@ -43,6 +43,12 @@ type AniListGetSingleAnime struct { } `json:"data"` } +type AniListUpdateReturn struct { + Data struct { + SaveMediaListEntry MediaList `json:"SaveMediaListEntry"` + } +} + type MediaList struct { ID int `json:"id"` MediaID int `json:"mediaId"` diff --git a/MALFunctions.go b/MALFunctions.go index f19ea1e..6758c0b 100644 --- a/MALFunctions.go +++ b/MALFunctions.go @@ -55,7 +55,7 @@ func (a *App) GetMyAnimeList(count int) MALWatchlist { return malList } -func (a *App) MyAnimeListUpdate(anime MALAnime, update MALUploadStatus) MyListStatus { +func (a *App) MyAnimeListUpdate(anime MALAnime, update MALUploadStatus) MalListStatus { if update.NumTimesRewatched >= 1 { update.IsRewatching = true } else { @@ -70,7 +70,7 @@ func (a *App) MyAnimeListUpdate(anime MALAnime, update MALUploadStatus) MyListSt body.Set("comments", update.Comments) malUrl := "https://api.myanimelist.net/v2/anime/" + strconv.Itoa(anime.Id) + "/my_list_status" - var status MyListStatus + var status MalListStatus respBody := MALHelper("PATCH", malUrl, body) err := json.Unmarshal(respBody, &status) if err != nil { diff --git a/MALTypes.go b/MALTypes.go index e5fb078..2248902 100644 --- a/MALTypes.go +++ b/MALTypes.go @@ -91,13 +91,13 @@ type MALAnime struct { Id int `json:"id" ts_type:"id"` Name string `json:"name" ts_type:"name"` } `json:"genres" ts_type:"genres"` - CreatedAt string `json:"created_at" ts_type:"createdAt"` - UpdatedAt string `json:"updated_at" ts_type:"updatedAt"` - MediaType string `json:"media_type" ts_type:"mediaType"` - Status string `json:"status" ts_type:"status"` - MyListStatus MyListStatus `json:"my_list_status" ts_type:"myListStatus"` - NumEpisodes int `json:"num_episodes" ts_type:"numEpisodes"` - StartSeason struct { + CreatedAt string `json:"created_at" ts_type:"createdAt"` + UpdatedAt string `json:"updated_at" ts_type:"updatedAt"` + MediaType string `json:"media_type" ts_type:"mediaType"` + Status string `json:"status" ts_type:"status"` + MalListStatus MalListStatus `json:"my_list_status" ts_type:"MalListStatus"` + NumEpisodes int `json:"num_episodes" ts_type:"numEpisodes"` + StartSeason struct { Year int `json:"year" ts_type:"year"` Season string `json:"season" ts_type:"season"` } `json:"start_season" ts_type:"startSeason"` @@ -138,7 +138,7 @@ type MALAnime struct { } } -type MyListStatus struct { +type MalListStatus struct { Status string `json:"status" ts_type:"status"` Score int `json:"score" ts_type:"score"` NumEpisodesWatched int `json:"num_episodes_watched" ts_type:"numEpisodesWatched"` diff --git a/bruno/AniTrack/AniList/Get Items/AniList Item.bru b/bruno/AniTrack/AniList/Get Items/AniList Item.bru index 967138d..f1ad7a8 100644 --- a/bruno/AniTrack/AniList/Get Items/AniList Item.bru +++ b/bruno/AniTrack/AniList/Get Items/AniList Item.bru @@ -93,7 +93,7 @@ body:graphql { body:graphql:vars { { "userId": 413504, - "mediaId": 110, + "mediaId": 1, "listType": "ANIME" } } diff --git a/bruno/AniTrack/AniList/Set Items/AniList Change Episode Watched.bru b/bruno/AniTrack/AniList/Set Items/AniList Change Episode Watched.bru index 5cb35e7..831bfa6 100644 --- a/bruno/AniTrack/AniList/Set Items/AniList Change Episode Watched.bru +++ b/bruno/AniTrack/AniList/Set Items/AniList Change Episode Watched.bru @@ -19,12 +19,33 @@ headers { body:graphql { mutation($mediaId:Int, $progress:Int, $status:MediaListStatus){ SaveMediaListEntry(mediaId:$mediaId, progress:$progress, status:$status){ + id mediaId - progress + userId + media { + id + idMal + title { + romaji + english + native + } + description + coverImage { + large + } + season + seasonYear + status + episodes + nextAiringEpisode { + airingAt + timeUntilAiring + episode + } + isAdult + } status - score - repeat - notes startedAt{ year month @@ -35,14 +56,35 @@ body:graphql { month day } + notes + progress + score + repeat + user { + id + name + avatar{ + large + medium + } + statistics{ + anime{ + count + statuses{ + status + count + } + } + } + } } } } body:graphql:vars { { - "mediaId": 1, - "progress": 26, + "mediaId": 169417, + "progress": 12, "status":"COMPLETED" } } diff --git a/frontend/package.json b/frontend/package.json index f78b56d..ab77dba 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -26,6 +26,7 @@ }, "dependencies": { "@popperjs/core": "^2.11.8", + "@tanstack/svelte-table": "^8.20.5", "flowbite": "^2.4.1", "flowbite-svelte": "^0.46.15", "moment": "^2.30.1" diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index b244ed9..e626869 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -112,6 +112,7 @@ '/anime/:id': wrap({ asyncComponent: () => import('./routes/Anime.svelte'), conditions: [ + () => $aniListLoggedIn, async (detail) => { await GetAniListSingleItem(Number(detail.params.id), true) return Object.keys($aniListAnime).length!==0 diff --git a/frontend/src/helperComponents/AddAnimeServiceToTable.svelte b/frontend/src/helperComponents/AddAnimeServiceToTable.svelte new file mode 100644 index 0000000..9197fac --- /dev/null +++ b/frontend/src/helperComponents/AddAnimeServiceToTable.svelte @@ -0,0 +1,33 @@ + \ No newline at end of file diff --git a/frontend/src/helperComponents/AnimeTable.svelte b/frontend/src/helperComponents/AnimeTable.svelte new file mode 100644 index 0000000..ee22c9b --- /dev/null +++ b/frontend/src/helperComponents/AnimeTable.svelte @@ -0,0 +1,68 @@ + + +
Rating: {config.score * 2}
+{ratingInWords[config.score * 2]}
+