Compare commits

...

8 Commits

15 changed files with 368 additions and 125 deletions

View File

@ -3,7 +3,6 @@ package main
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"log" "log"
"net/http" "net/http"
@ -37,12 +36,7 @@ func AniListQuery(body interface{}, login bool) (json.RawMessage, string) {
} }
func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime { func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
var user = a.GetAniListLoggedInUserId() var user = a.GetAniListLoggedInUser()
// type Variables struct {
// UserId int `json:"userId"`
// MediaId int `json:"mediaId"`
// ListType string `json:"listType"`
// }
var neededVariables interface{} var neededVariables interface{}
@ -207,7 +201,7 @@ func (a *App) AniListSearch(query string) any {
} }
func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) AniListCurrentUserWatchList { func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) AniListCurrentUserWatchList {
var user = a.GetAniListLoggedInUserId() var user = a.GetAniListLoggedInUser()
type Variables struct { type Variables struct {
Page int `json:"page"` Page int `json:"page"`
PerPage int `json:"perPage"` PerPage int `json:"perPage"`
@ -311,8 +305,6 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani
returnedBody, _ := AniListQuery(body, true) returnedBody, _ := AniListQuery(body, true)
fmt.Println("ReturnedBody: ", string(returnedBody))
var post AniListCurrentUserWatchList var post AniListCurrentUserWatchList
err := json.Unmarshal(returnedBody, &post) err := json.Unmarshal(returnedBody, &post)
if err != nil { if err != nil {

View File

@ -10,8 +10,14 @@ type AniListJWT struct {
type AniListUser struct { type AniListUser struct {
Data struct { Data struct {
Viewer struct { Viewer struct {
ID int `json:"id"` ID int `json:"id"`
Name string `json:"name"` Name string `json:"name"`
Avatar struct {
Large string `json:"large"`
Medium string `json:"medium"`
} `json:"avatar"`
BannerImage string `json:"bannerImage"`
SiteUrl string `json:"siteUrl"`
} `json:"Viewer"` } `json:"Viewer"`
} `json:"data"` } `json:"data"`
} }

View File

@ -27,14 +27,27 @@ var aniCtxShutdown, aniCancel = context.WithCancel(context.Background())
func (a *App) CheckIfAniListLoggedIn() bool { func (a *App) CheckIfAniListLoggedIn() bool {
if (AniListJWT{} == aniListJwt) { if (AniListJWT{} == aniListJwt) {
return false tokenType, err := aniRing.Get("anilistTokenType")
expiresIn, err := aniRing.Get("anilistTokenExpiresIn")
accessToken, err := aniRing.Get("anilistAccessToken")
refreshToken, err := aniRing.Get("anilistRefreshToken")
if err != nil {
return false
} else {
aniListJwt.TokenType = string(tokenType.Data)
aniListJwt.AccessToken = string(accessToken.Data)
aniListJwt.RefreshToken = string(refreshToken.Data)
expiresInString := string(expiresIn.Data)
aniListJwt.ExpiresIn, _ = strconv.Atoi(expiresInString)
return true
}
} else { } else {
return true return true
} }
} }
func (a *App) AniListLogin() { func (a *App) AniListLogin() {
if a.CheckIfSimklLoggedIn() == false { if (AniListJWT{} == aniListJwt) {
tokenType, err := aniRing.Get("anilistTokenType") tokenType, err := aniRing.Get("anilistTokenType")
expiresIn, err := aniRing.Get("anilistTokenExpiresIn") expiresIn, err := aniRing.Get("anilistTokenExpiresIn")
accessToken, err := aniRing.Get("anilistAccessToken") accessToken, err := aniRing.Get("anilistAccessToken")
@ -150,7 +163,7 @@ func getAniListAuthorizationToken(content string) AniListJWT {
return post return post
} }
func (a *App) GetAniListLoggedInUserId() AniListUser { func (a *App) GetAniListLoggedInUser() AniListUser {
a.AniListLogin() a.AniListLogin()
body := struct { body := struct {
Query string `json:"query"` Query string `json:"query"`
@ -160,6 +173,12 @@ func (a *App) GetAniListLoggedInUserId() AniListUser {
Viewer { Viewer {
id id
name name
avatar {
large
medium
}
bannerImage
siteUrl
} }
} }
`, `,

View File

@ -1,36 +1,39 @@
package main package main
import ( import (
"bytes"
"encoding/json" "encoding/json"
"fmt"
"io" "io"
"log" "log"
"net/http" "net/http"
"os"
) )
func SimklQuery(body interface{}, login bool) (json.RawMessage, string) { func (a *App) SimklGetUserWatchlist() SimklWatchList {
reader, _ := json.Marshal(body)
response, err := http.NewRequest("POST", "https://graphql.anilist.co", bytes.NewBuffer(reader))
if err != nil {
log.Printf("Failed at response, %s\n", err)
}
if login && (SimklJWT{}) != simklJwt {
response.Header.Add("Authorization", "Bearer "+simklJwt.AccessToken)
} else if login {
return nil, "Please login to anilist to make this request"
}
response.Header.Add("Content-Type", "application/json")
response.Header.Add("Accept", "application/json")
client := &http.Client{} client := &http.Client{}
res, reserr := client.Do(response)
if reserr != nil { req, _ := http.NewRequest("GET", "https://api.simkl.com/sync/all-items/anime/watching", nil)
log.Printf("Failed at res, %s\n", err)
req.Header.Add("Content-Type", "application/json")
req.Header.Add("Authorization", "Bearer "+simklJwt.AccessToken)
req.Header.Add("simkl-api-key", os.Getenv("SIMKL_CLIENT_ID"))
resp, err := client.Do(req)
if err != nil {
fmt.Println("Errored when sending request to the server")
return SimklWatchList{}
} }
defer res.Body.Close() defer resp.Body.Close()
respBody, _ := io.ReadAll(resp.Body)
returnedBody, err := io.ReadAll(res.Body) var watchlist SimklWatchList
return returnedBody, "" err = json.Unmarshal(respBody, &watchlist)
if err != nil {
log.Printf("Failed at unmarshal, %s\n", err)
}
return watchlist
} }

View File

@ -7,10 +7,62 @@ type SimklJWT struct {
} }
type SimklUser struct { type SimklUser struct {
Data struct { User struct {
Viewer struct { Name string `json:"name" ts_type:"name"`
ID int `json:"id"` JoinedAt string `json:"joined_at" ts_type:"joined_at"`
Name string `json:"name"` Gender string `json:"gender" ts_type:"gender"`
} `json:"Viewer"` Avatar string `json:"avatar" ts_type:"avatar"`
} `json:"data"` Bio string `json:"bio" ts_type:"bio"`
Loc string `json:"loc" ts_type:"loc"`
Age string `json:"age" ts_type:"age"`
} `json:"user" ts_type:"user"`
Account struct {
Id int `json:"id" ts_type:"id"`
Timezone string `json:"timezone" ts_type:"timezone"`
Type string `json:"type" ts_type:"type"`
} `json:"account" ts_type:"account"`
Connections struct {
Facebook bool `json:"facebook" ts_type:"facebook"`
} `json:"connections" ts_type:"connections"`
}
type SimklWatchList struct {
Anime []struct {
LastWatchedAt string `json:"last_watched_at" ts_type:"last_watched_at"`
Status string `json:"status" ts_type:"status"`
UserRating int `json:"user_rating" ts_type:"user_rating"`
LastWatched string `json:"last_watched" ts_type:"last_watched"`
NextToWatch string `json:"next_to_watch" ts_type:"next_to_watch"`
WatchedEpisodesCount int `json:"watched_episodes_count" ts_type:"watched_episodes_count"`
TotalEpisodesCount int `json:"total_episodes_count" ts_type:"total_episodes_count"`
NotAiredEpisodesCount int `json:"not_aired_episodes_count" ts_type:"not_aired_episodes_count"`
Show struct {
Title string `json:"title" ts_type:"title"`
Poster string `json:"poster" ts_type:"poster"`
Ids struct {
Simkl int `json:"simkl" ts_type:"simkl"`
Slug string `json:"slug" ts_type:"slug"`
OffJp string `json:"offjp" ts_type:"offjp"`
TW string `json:"tw" ts_type:"tw"`
ANN string `json:"ann" ts_type:"ann"`
Mal string `json:"mal" ts_type:"mal"`
Wikien string `json:"wikien" ts_type:"wikien"`
WikiJp string `json:"wikijp" ts_type:"wikijp"`
AllCin string `json:"allcin" ts_type:"allcin"`
IMDB string `json:"imdb" ts_type:"imdb"`
TMDB string `json:"tmdb" ts_type:"tmdb"`
Offen string `json:"offen" ts_type:"offen"`
Crunchyroll string `json:"crunchyroll" ts_type:"crunchyroll"`
TVDBSlug string `json:"tvdbslug" ts_type:"tvdbslug"`
AniList string `json:"anilist" ts_type:"anilist"`
AnimePlanet string `json:"animeplanet" ts_type:"animeplanet"`
AniSearch string `json:"anisearch" ts_type:"anisearch"`
Kitsu string `json:"kitsu" ts_type:"kitsu"`
LiveChart string `json:"livechart" ts_type:"livechart"`
TraktSlug string `json:"traktslug" ts_type:"traktslug"`
AniDB string `json:"anidb" ts_type:"anidb"`
} `json:"ids" ts_type:"ids"`
} `json:"show" ts_type:"show"`
AnimeType string `json:"anime_type" ts_type:"anime_type"`
} `json:"anime" ts_type:"anime"`
} }

View File

@ -25,7 +25,17 @@ var simklCtxShutdown, simklCancel = context.WithCancel(context.Background())
func (a *App) CheckIfSimklLoggedIn() bool { func (a *App) CheckIfSimklLoggedIn() bool {
if (SimklJWT{} == simklJwt) { if (SimklJWT{} == simklJwt) {
return false tokenType, err := simklRing.Get("SimklTokenType")
accessToken, err := simklRing.Get("SimklAccessToken")
scope, err := simklRing.Get("SimklScope")
if err != nil {
return false
} else {
simklJwt.TokenType = string(tokenType.Data)
simklJwt.AccessToken = string(accessToken.Data)
simklJwt.Scope = string(scope.Data)
return true
}
} else { } else {
return true return true
} }
@ -144,28 +154,36 @@ func getSimklAuthorizationToken(content string) SimklJWT {
return post return post
} }
func (a *App) GetSimklLoggedInUserId() SimklUser { func (a *App) GetSimklLoggedInUser() SimklUser {
a.SimklLogin() a.SimklLogin()
body := struct {
Query string `json:"query"` fmt.Println("Token: ", simklJwt.AccessToken)
}{
Query: ` client := &http.Client{}
query {
Viewer { req, _ := http.NewRequest("POST", "https://api.simkl.com/users/settings", nil)
id
name req.Header.Add("Content-Type", "application/json")
} req.Header.Add("Authorization", "Bearer "+simklJwt.AccessToken)
} req.Header.Add("simkl-api-key", os.Getenv("SIMKL_CLIENT_ID"))
`,
response, err := client.Do(req)
if err != nil {
log.Printf("Failed at request, %s\n", err)
return SimklUser{}
} }
user, _ := SimklQuery(body, true) defer response.Body.Close()
var post SimklUser var user SimklUser
err := json.Unmarshal(user, &post)
respBody, _ := io.ReadAll(response.Body)
err = json.Unmarshal(respBody, &user)
if err != nil { if err != nil {
log.Printf("Failed at unmarshal, %s\n", err) log.Printf("Failed at unmarshal, %s\n", err)
} }
return post return user
} }

6
app.go
View File

@ -2,7 +2,6 @@ package main
import ( import (
"context" "context"
"fmt"
) )
// App struct // App struct
@ -20,8 +19,3 @@ func NewApp() *App {
func (a *App) startup(ctx context.Context) { func (a *App) startup(ctx context.Context) {
a.ctx = ctx a.ctx = ctx
} }
// Greet returns a greeting for the given name
func (a *App) Greet(name string) string {
return fmt.Sprintf("Hello %s, It's show time!", name)
}

View File

@ -0,0 +1,17 @@
meta {
name: GetUser WatchList
type: http
seq: 2
}
get {
url: https://api.simkl.com/sync/all-items/anime/watching
body: none
auth: none
}
headers {
Authorization: Bearer {{SIMKL_AUTH_TOKEN}}
Content-Type: application/json
simkl-api-key: {{SIMKL_CLIENT_ID}}
}

View File

@ -5,5 +5,6 @@ vars {
SIMKL_CLIENT_SECRET: {{process.env.SIMKL_CLIENT_SECRET}} SIMKL_CLIENT_SECRET: {{process.env.SIMKL_CLIENT_SECRET}}
} }
vars:secret [ vars:secret [
code code,
SIMKL_AUTH_TOKEN
] ]

View File

@ -1,13 +1,22 @@
<script lang="ts"> <script lang="ts">
import {anilistModal, GetAniListSingleItemAndOpenModal, title} from "./GetAniListSingleItemAndOpenModal.svelte"; import {anilistModal, GetAniListSingleItemAndOpenModal, title} from "./GetAniListSingleItemAndOpenModal.svelte";
import {GetAniListUserWatchingList, SimklLogin} from "../wailsjs/go/main/App"; import {
import {MediaListSort} from "./anilist/types/AniListTypes"; CheckIfAniListLoggedIn,
CheckIfSimklLoggedIn,
GetAniListLoggedInUser,
GetAniListUserWatchingList,
GetSimklLoggedInUser, SimklGetUserWatchlist,
} from "../wailsjs/go/main/App";
import {type AniListUser, MediaListSort} from "./anilist/types/AniListTypes";
import type {AniListCurrentUserWatchList} from "./anilist/types/AniListCurrentUserWatchListType" import type {AniListCurrentUserWatchList} from "./anilist/types/AniListCurrentUserWatchListType"
import Header from "./Header.svelte"; import Header from "./Header.svelte";
import StarRatting from '@ernane/svelte-star-rating' import StarRatting from '@ernane/svelte-star-rating'
import {Modal} from "flowbite-svelte"; import {Button, Modal} from "flowbite-svelte";
import ChangeDataDialogue from "./ChangeDataDialogue.svelte"; import ChangeDataDialogue from "./ChangeDataDialogue.svelte";
import {onMount} from "svelte";
import type {SimklUser, SimklWatchList} from "./simkl/types/simklTypes";
import {writable} from "svelte/store";
const config = { const config = {
readOnly: false, readOnly: false,
@ -19,7 +28,9 @@
}, },
score: 0.0, score: 0.0,
showScore: true, showScore: true,
scoreFormat: function(){ return `(${this.score.toFixed(1)}/${this.countStars})` }, scoreFormat: function () {
return `(${this.score.toFixed(1)}/${this.countStars})`
},
name: "", name: "",
starConfig: { starConfig: {
size: 20, size: 20,
@ -31,11 +42,63 @@
} }
let aniListLoggedIn = false let aniListLoggedIn = false
let aniListPrimary = true
let simklUser: SimklUser
let simklLoggedIn = false
let aniListUser: AniListUser
let aniListWatchlist: AniListCurrentUserWatchList let aniListWatchlist: AniListCurrentUserWatchList
export let simklWatchList = writable({} as SimklWatchList)
let page = 1 let page = 1
let perPage = 20 let perPage = 20
const size = "xl" const size = "xl"
onMount(async () => {
await CheckIfAniListLoggedIn().then(result => {
if (result) {
GetAniListLoggedInUser().then(result => {
aniListUser = result
if (aniListPrimary) {
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
aniListWatchlist = result
aniListLoggedIn = true
})
} else {
aniListLoggedIn = result
}
})
}
})
await CheckIfSimklLoggedIn().then(result => {
if (result) {
GetSimklLoggedInUser().then(result => {
simklUser = result
SimklGetUserWatchlist().then(result => {
simklWatchList.set(result)
simklLoggedIn = result
})
})
}
})
})
function loginToSimkl(): void {
GetSimklLoggedInUser().then(result => {
simklUser = result
simklLoggedIn = true
})
}
function loginToAniList(): void {
GetAniListLoggedInUser().then(result => {
aniListUser = result
aniListLoggedIn = true
if (aniListPrimary) {
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then(result => aniListWatchlist = result)
}
})
}
function anilistGetUserWatchlist(): void { function anilistGetUserWatchlist(): void {
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => { GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
aniListWatchlist = result aniListWatchlist = result
@ -61,12 +124,16 @@
<Header/> <Header/>
<main> <main>
<button class="btn" on:click={anilistGetUserWatchlist}>Login to AniList</button>
<button class="btn" on:click={SimklLogin}>Login to Simkl</button>
{#if aniListLoggedIn} {#if aniListLoggedIn}
<div>You are logged in {aniListWatchlist.data.Page.mediaList[0].user.name}!</div> <div>You are logged into AniList, {aniListWatchlist.data.Page.mediaList[0].user.name}!</div>
{:else}
<button class="btn" on:click={loginToAniList}>Login to AniList</button>
{/if}
{#if simklLoggedIn}
<div>You are logged into Simkl, {simklUser.user.name}</div>
{:else}
<Button class="btn" on:click={loginToSimkl}>Login to Simkl</Button>
{/if} {/if}
{#if aniListLoggedIn} {#if aniListLoggedIn}
@ -112,7 +179,7 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4"></path> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4"></path>
</svg> </svg>
</button> </button>
<input bind:value={count} class="text-2xl font-bold mx-4" /> <input bind:value={count} class="text-2xl font-bold mx-4"/>
<button on:click={increment} <button on:click={increment}
class="flex justify-center items-center w-10 h-10 rounded-full text-white focus:outline-none bg-indigo-500 hover:bg-indigo-600"> class="flex justify-center items-center w-10 h-10 rounded-full text-white focus:outline-none bg-indigo-500 hover:bg-indigo-600">
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
@ -120,25 +187,25 @@
</svg> </svg>
</button> </button>
</div> </div>
<!-- <div class="relative max-w-sm">--> <!-- <div class="relative max-w-sm">-->
<!-- <div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">--> <!-- <div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">-->
<!-- <svg class="w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">--> <!-- <svg class="w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">-->
<!-- <path d="M20 4a2 2 0 0 0-2-2h-2V1a1 1 0 0 0-2 0v1h-3V1a1 1 0 0 0-2 0v1H6V1a1 1 0 0 0-2 0v1H2a2 2 0 0 0-2 2v2h20V4ZM0 18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8H0v10Zm5-8h10a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z"/>--> <!-- <path d="M20 4a2 2 0 0 0-2-2h-2V1a1 1 0 0 0-2 0v1h-3V1a1 1 0 0 0-2 0v1H6V1a1 1 0 0 0-2 0v1H2a2 2 0 0 0-2 2v2h20V4ZM0 18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8H0v10Zm5-8h10a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z"/>-->
<!-- </svg>--> <!-- </svg>-->
<!-- </div>--> <!-- </div>-->
<!-- <input--> <!-- <input-->
<!-- datepicker--> <!-- datepicker-->
<!-- datepicker-buttons--> <!-- datepicker-buttons-->
<!-- datepicker-autoselect-today--> <!-- datepicker-autoselect-today-->
<!-- datepicker-autohide--> <!-- datepicker-autohide-->
<!-- datepicker-title="Started At"--> <!-- datepicker-title="Started At"-->
<!-- id="startedAt"--> <!-- id="startedAt"-->
<!-- type="text"--> <!-- type="text"-->
<!-- class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500--> <!-- class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500-->
<!-- focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600--> <!-- focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600-->
<!-- dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"--> <!-- dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"-->
<!-- placeholder="Select date">--> <!-- placeholder="Select date">-->
<!-- </div>--> <!-- </div>-->
<Modal title={$title} bind:open={$anilistModal} {size} autoclose={false}> <Modal title={$title} bind:open={$anilistModal} {size} autoclose={false}>
<ChangeDataDialogue/> <ChangeDataDialogue/>
</Modal> </Modal>

View File

@ -39,6 +39,12 @@ export interface AniListUser {
"Viewer": { "Viewer": {
id: number, id: number,
name: string, name: string,
avatar: {
large: string,
medium: string,
},
bannerImage: string,
siteUrl: string,
} }
} }
} }

View File

@ -0,0 +1,59 @@
export type SimklUser = {
user: {
name: string,
joined_at: string,
gender: string,
avatar: string,
bio: string,
loc: string,
age: string,
},
account: {
id: number,
timezone: string,
type: string,
},
connections: {
facebook: boolean
}
}
export type SimklWatchList = {
anime: [{
last_watched_at: string,
status: string
user_rating: number,
last_watched: string,
next_to_watch: string,
watched_episodes_count: number,
total_episodes_count: number,
not_aired_episodes_count: number,
show: {
title: string,
poster: string,
ids: {
simkl: number,
slug: string,
offjp: string,
tw: string,
ann: string,
mal: string,
wikien: string,
wikijp: string,
allcin: string,
imdb: string,
offen: string,
crunchyroll: string,
tvdbslug: string,
anilist: string,
animeplanet: string,
anisearch: string,
kitsu: string,
livechart: string,
traktslug: string,
anidb: string,
}
},
anime_type: string
}]
}

View File

@ -8,14 +8,18 @@ export function AniListSearch(arg1:string):Promise<any>;
export function AniListUpdateEntry(arg1:number,arg2:string,arg3:string,arg4:number,arg5:number,arg6:string,arg7:number,arg8:number,arg9:number,arg10:number,arg11:number,arg12:number):Promise<any>; export function AniListUpdateEntry(arg1:number,arg2:string,arg3:string,arg4:number,arg5:number,arg6:string,arg7:number,arg8:number,arg9:number,arg10:number,arg11:number,arg12:number):Promise<any>;
export function CheckIfAniListLoggedIn():Promise<boolean>;
export function CheckIfSimklLoggedIn():Promise<boolean>;
export function GetAniListItem(arg1:number,arg2:boolean):Promise<main.AniListGetSingleAnime>; export function GetAniListItem(arg1:number,arg2:boolean):Promise<main.AniListGetSingleAnime>;
export function GetAniListLoggedInUserId():Promise<main.AniListUser>; export function GetAniListLoggedInUser():Promise<main.AniListUser>;
export function GetAniListUserWatchingList(arg1:number,arg2:number,arg3:string):Promise<main.AniListCurrentUserWatchList>; export function GetAniListUserWatchingList(arg1:number,arg2:number,arg3:string):Promise<main.AniListCurrentUserWatchList>;
export function GetSimklLoggedInUserId():Promise<main.SimklUser>; export function GetSimklLoggedInUser():Promise<main.SimklUser>;
export function Greet(arg1:string):Promise<string>; export function SimklGetUserWatchlist():Promise<main.SimklWatchList>;
export function SimklLogin():Promise<void>; export function SimklLogin():Promise<void>;

View File

@ -14,24 +14,32 @@ export function AniListUpdateEntry(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg
return window['go']['main']['App']['AniListUpdateEntry'](arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12); return window['go']['main']['App']['AniListUpdateEntry'](arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
} }
export function CheckIfAniListLoggedIn() {
return window['go']['main']['App']['CheckIfAniListLoggedIn']();
}
export function CheckIfSimklLoggedIn() {
return window['go']['main']['App']['CheckIfSimklLoggedIn']();
}
export function GetAniListItem(arg1, arg2) { export function GetAniListItem(arg1, arg2) {
return window['go']['main']['App']['GetAniListItem'](arg1, arg2); return window['go']['main']['App']['GetAniListItem'](arg1, arg2);
} }
export function GetAniListLoggedInUserId() { export function GetAniListLoggedInUser() {
return window['go']['main']['App']['GetAniListLoggedInUserId'](); return window['go']['main']['App']['GetAniListLoggedInUser']();
} }
export function GetAniListUserWatchingList(arg1, arg2, arg3) { export function GetAniListUserWatchingList(arg1, arg2, arg3) {
return window['go']['main']['App']['GetAniListUserWatchingList'](arg1, arg2, arg3); return window['go']['main']['App']['GetAniListUserWatchingList'](arg1, arg2, arg3);
} }
export function GetSimklLoggedInUserId() { export function GetSimklLoggedInUser() {
return window['go']['main']['App']['GetSimklLoggedInUserId'](); return window['go']['main']['App']['GetSimklLoggedInUser']();
} }
export function Greet(arg1) { export function SimklGetUserWatchlist() {
return window['go']['main']['App']['Greet'](arg1); return window['go']['main']['App']['SimklGetUserWatchlist']();
} }
export function SimklLogin() { export function SimklLogin() {

View File

@ -61,7 +61,7 @@ export namespace main {
} }
} }
export class AniListUser { export class AniListUser {
// Go type: struct { Viewer struct { ID int "json:\"id\""; Name string "json:\"name\"" } "json:\"Viewer\"" } // Go type: struct { Viewer struct { ID int "json:\"id\""; Name string "json:\"name\""; Avatar struct { Large string "json:\"large\""; Medium string "json:\"medium\"" } "json:\"avatar\""; BannerImage string "json:\"bannerImage\""; SiteUrl string "json:\"siteUrl\"" } "json:\"Viewer\"" }
data: any; data: any;
static createFrom(source: any = {}) { static createFrom(source: any = {}) {
@ -148,8 +148,9 @@ export namespace main {
} }
} }
export class SimklUser { export class SimklUser {
// Go type: struct { Viewer struct { ID int "json:\"id\""; Name string "json:\"name\"" } "json:\"Viewer\"" } user: user;
data: any; account: account;
connections: connections;
static createFrom(source: any = {}) { static createFrom(source: any = {}) {
return new SimklUser(source); return new SimklUser(source);
@ -157,26 +158,22 @@ export namespace main {
constructor(source: any = {}) { constructor(source: any = {}) {
if ('string' === typeof source) source = JSON.parse(source); if ('string' === typeof source) source = JSON.parse(source);
this.data = this.convertValues(source["data"], Object); this.user = source["user"];
this.account = source["account"];
this.connections = source["connections"];
}
}
export class SimklWatchList {
anime: anime;
static createFrom(source: any = {}) {
return new SimklWatchList(source);
} }
convertValues(a: any, classs: any, asMap: boolean = false): any { constructor(source: any = {}) {
if (!a) { if ('string' === typeof source) source = JSON.parse(source);
return a; this.anime = source["anime"];
} }
if (a.slice && a.map) {
return (a as any[]).map(elem => this.convertValues(elem, classs));
} else if ("object" === typeof a) {
if (asMap) {
for (const key of Object.keys(a)) {
a[key] = new classs(a[key]);
}
return a;
}
return new classs(a);
}
return a;
}
} }
} }