added ability to change simkl status
This commit is contained in:
parent
a6b26171d4
commit
1b08918d8e
@ -160,3 +160,35 @@ func (a *App) SimklSyncRating(anime Anime, rating int) interface{} {
|
|||||||
|
|
||||||
return success
|
return success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) SimklSyncStatus(anime Anime, status string) interface{} {
|
||||||
|
url := "https://api.simkl.com/sync/add-to-list"
|
||||||
|
var show = SimklShowStatus{
|
||||||
|
Title: anime.Show.Title,
|
||||||
|
Ids: Ids{
|
||||||
|
Simkl: anime.Show.Ids.Simkl,
|
||||||
|
Mal: anime.Show.Ids.Mal,
|
||||||
|
Anilist: anime.Show.Ids.AniList,
|
||||||
|
},
|
||||||
|
To: status,
|
||||||
|
}
|
||||||
|
|
||||||
|
var shows []SimklShowStatus
|
||||||
|
|
||||||
|
shows = append(shows, show)
|
||||||
|
|
||||||
|
simklSync := struct {
|
||||||
|
Shows []SimklShowStatus `json:"shows" ts_type:"shows"`
|
||||||
|
}{shows}
|
||||||
|
|
||||||
|
respBody := SimklPostHelper(url, simklSync)
|
||||||
|
|
||||||
|
var success interface{}
|
||||||
|
|
||||||
|
err := json.Unmarshal(respBody, &success)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return success
|
||||||
|
}
|
||||||
|
@ -99,3 +99,9 @@ type ShowWithoutRating struct {
|
|||||||
Title string `json:"title" ts_type:"title"`
|
Title string `json:"title" ts_type:"title"`
|
||||||
Ids `json:"ids" ts_type:"ids"`
|
Ids `json:"ids" ts_type:"ids"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SimklShowStatus struct {
|
||||||
|
Title string `json:"title" ts_type:"title"`
|
||||||
|
Ids `json:"ids" ts_type:"ids"`
|
||||||
|
To string `json:"to" ts_type:"to"`
|
||||||
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
import type {SimklAnime} from "./simkl/types/simklTypes";
|
import type {SimklAnime} from "./simkl/types/simklTypes";
|
||||||
import { get } from 'svelte/store';
|
import { get } from 'svelte/store';
|
||||||
import {AniListUpdateEntry, SimklSyncEpisodes, SimklSyncRating} from "../wailsjs/go/main/App";
|
import {AniListUpdateEntry, SimklSyncEpisodes, SimklSyncRating, SimklSyncStatus} from "../wailsjs/go/main/App";
|
||||||
|
|
||||||
const simklWatch = get(simklWatchList);
|
const simklWatch = get(simklWatchList);
|
||||||
let isAniListLoggedIn: boolean
|
let isAniListLoggedIn: boolean
|
||||||
@ -32,6 +32,25 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type statusOption = {
|
||||||
|
id: number,
|
||||||
|
aniList: string,
|
||||||
|
simkl: string,
|
||||||
|
}
|
||||||
|
|
||||||
|
const statusOptions: statusOption[] = [
|
||||||
|
{ id: 0, aniList: "CURRENT", simkl: "watching"},
|
||||||
|
{ id: 1, aniList: "PLANNING", simkl: "plantowatch"},
|
||||||
|
{ id: 2, aniList: "COMPLETED", simkl: "completed"},
|
||||||
|
{ id: 3, aniList: "DROPPED", simkl: "dropped"},
|
||||||
|
{ id: 4, aniList: "PAUSED", simkl: "hold"},
|
||||||
|
{ id: 5, aniList: "REPEATING", simkl: "watching"}
|
||||||
|
]
|
||||||
|
|
||||||
|
let startingAnilistStatusOption: statusOption
|
||||||
|
|
||||||
|
startingAnilistStatusOption = statusOptions.filter(option => aniListAnime.data.MediaList.status === option.aniList)[0]
|
||||||
|
|
||||||
let items = [];
|
let items = [];
|
||||||
|
|
||||||
if(isAniListLoggedIn) {
|
if(isAniListLoggedIn) {
|
||||||
@ -141,7 +160,7 @@
|
|||||||
|
|
||||||
let values = {
|
let values = {
|
||||||
progress: aniListAnime.data.MediaList.progress,
|
progress: aniListAnime.data.MediaList.progress,
|
||||||
status: aniListAnime.data.MediaList.status,
|
status: startingAnilistStatusOption,
|
||||||
startedAt: {
|
startedAt: {
|
||||||
year: aniListAnime.data.MediaList.startedAt.year,
|
year: aniListAnime.data.MediaList.startedAt.year,
|
||||||
month: aniListAnime.data.MediaList.startedAt.month,
|
month: aniListAnime.data.MediaList.startedAt.month,
|
||||||
@ -197,7 +216,7 @@
|
|||||||
await AniListUpdateEntry(
|
await AniListUpdateEntry(
|
||||||
aniListAnime.data.MediaList.mediaId,
|
aniListAnime.data.MediaList.mediaId,
|
||||||
values.progress,
|
values.progress,
|
||||||
values.status,
|
values.status.aniList,
|
||||||
values.score,
|
values.score,
|
||||||
values.repeat,
|
values.repeat,
|
||||||
values.notes,
|
values.notes,
|
||||||
@ -227,6 +246,14 @@
|
|||||||
simklWatch.anime[simklAnimeIndex].user_rating = values.score
|
simklWatch.anime[simklAnimeIndex].user_rating = values.score
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (simklAnime.status !== values.status.simkl) {
|
||||||
|
SimklSyncStatus(simklAnime, values.status.simkl).then(value => {
|
||||||
|
console.log(value)
|
||||||
|
simklAnime.status = values.status.simkl
|
||||||
|
simklWatch.anime[simklAnimeIndex].status = values.status.simkl
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
@ -267,13 +294,9 @@
|
|||||||
dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
||||||
bind:value={values.status}
|
bind:value={values.status}
|
||||||
>
|
>
|
||||||
|
{#each statusOptions as option}
|
||||||
<option>CURRENT</option>
|
<option value={option}>{option.aniList}</option>
|
||||||
<option>PLANNING</option>
|
{/each}
|
||||||
<option>COMPLETED</option>
|
|
||||||
<option>DROPPED</option>
|
|
||||||
<option>PAUSED</option>
|
|
||||||
<option>REPEATING</option>
|
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
2
frontend/wailsjs/go/main/App.d.ts
vendored
2
frontend/wailsjs/go/main/App.d.ts
vendored
@ -27,3 +27,5 @@ export function SimklLogin():Promise<void>;
|
|||||||
export function SimklSyncEpisodes(arg1:main.Anime,arg2:number):Promise<any>;
|
export function SimklSyncEpisodes(arg1:main.Anime,arg2:number):Promise<any>;
|
||||||
|
|
||||||
export function SimklSyncRating(arg1:main.Anime,arg2:number):Promise<any>;
|
export function SimklSyncRating(arg1:main.Anime,arg2:number):Promise<any>;
|
||||||
|
|
||||||
|
export function SimklSyncStatus(arg1:main.Anime,arg2:string):Promise<any>;
|
||||||
|
@ -53,3 +53,7 @@ export function SimklSyncEpisodes(arg1, arg2) {
|
|||||||
export function SimklSyncRating(arg1, arg2) {
|
export function SimklSyncRating(arg1, arg2) {
|
||||||
return window['go']['main']['App']['SimklSyncRating'](arg1, arg2);
|
return window['go']['main']['App']['SimklSyncRating'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function SimklSyncStatus(arg1, arg2) {
|
||||||
|
return window['go']['main']['App']['SimklSyncStatus'](arg1, arg2);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user