Compare commits
8 Commits
7044dc1d90
...
53b7368daf
Author | SHA1 | Date | |
---|---|---|---|
53b7368daf | |||
c95b658131 | |||
de38d0335b | |||
d2ef265807 | |||
7af14ad7f3 | |||
2f272fe7af | |||
54d5932d8a | |||
8c61c5e96b |
@ -3,7 +3,6 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
@ -37,12 +36,7 @@ func AniListQuery(body interface{}, login bool) (json.RawMessage, string) {
|
||||
}
|
||||
|
||||
func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
|
||||
var user = a.GetAniListLoggedInUserId()
|
||||
// type Variables struct {
|
||||
// UserId int `json:"userId"`
|
||||
// MediaId int `json:"mediaId"`
|
||||
// ListType string `json:"listType"`
|
||||
// }
|
||||
var user = a.GetAniListLoggedInUser()
|
||||
|
||||
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 {
|
||||
var user = a.GetAniListLoggedInUserId()
|
||||
var user = a.GetAniListLoggedInUser()
|
||||
type Variables struct {
|
||||
Page int `json:"page"`
|
||||
PerPage int `json:"perPage"`
|
||||
@ -311,8 +305,6 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani
|
||||
|
||||
returnedBody, _ := AniListQuery(body, true)
|
||||
|
||||
fmt.Println("ReturnedBody: ", string(returnedBody))
|
||||
|
||||
var post AniListCurrentUserWatchList
|
||||
err := json.Unmarshal(returnedBody, &post)
|
||||
if err != nil {
|
||||
|
@ -12,6 +12,12 @@ type AniListUser 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"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
@ -27,14 +27,27 @@ var aniCtxShutdown, aniCancel = context.WithCancel(context.Background())
|
||||
|
||||
func (a *App) CheckIfAniListLoggedIn() bool {
|
||||
if (AniListJWT{} == aniListJwt) {
|
||||
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 {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) AniListLogin() {
|
||||
if a.CheckIfSimklLoggedIn() == false {
|
||||
if (AniListJWT{} == aniListJwt) {
|
||||
tokenType, err := aniRing.Get("anilistTokenType")
|
||||
expiresIn, err := aniRing.Get("anilistTokenExpiresIn")
|
||||
accessToken, err := aniRing.Get("anilistAccessToken")
|
||||
@ -150,7 +163,7 @@ func getAniListAuthorizationToken(content string) AniListJWT {
|
||||
return post
|
||||
}
|
||||
|
||||
func (a *App) GetAniListLoggedInUserId() AniListUser {
|
||||
func (a *App) GetAniListLoggedInUser() AniListUser {
|
||||
a.AniListLogin()
|
||||
body := struct {
|
||||
Query string `json:"query"`
|
||||
@ -160,6 +173,12 @@ func (a *App) GetAniListLoggedInUserId() AniListUser {
|
||||
Viewer {
|
||||
id
|
||||
name
|
||||
avatar {
|
||||
large
|
||||
medium
|
||||
}
|
||||
bannerImage
|
||||
siteUrl
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
@ -1,36 +1,39 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func SimklQuery(body interface{}, login bool) (json.RawMessage, string) {
|
||||
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")
|
||||
|
||||
func (a *App) SimklGetUserWatchlist() SimklWatchList {
|
||||
client := &http.Client{}
|
||||
res, reserr := client.Do(response)
|
||||
if reserr != nil {
|
||||
log.Printf("Failed at res, %s\n", err)
|
||||
|
||||
req, _ := http.NewRequest("GET", "https://api.simkl.com/sync/all-items/anime/watching", nil)
|
||||
|
||||
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
|
||||
}
|
||||
|
@ -7,10 +7,62 @@ type SimklJWT struct {
|
||||
}
|
||||
|
||||
type SimklUser struct {
|
||||
Data struct {
|
||||
Viewer struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
} `json:"Viewer"`
|
||||
} `json:"data"`
|
||||
User struct {
|
||||
Name string `json:"name" ts_type:"name"`
|
||||
JoinedAt string `json:"joined_at" ts_type:"joined_at"`
|
||||
Gender string `json:"gender" ts_type:"gender"`
|
||||
Avatar string `json:"avatar" ts_type:"avatar"`
|
||||
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"`
|
||||
}
|
||||
|
@ -25,7 +25,17 @@ var simklCtxShutdown, simklCancel = context.WithCancel(context.Background())
|
||||
|
||||
func (a *App) CheckIfSimklLoggedIn() bool {
|
||||
if (SimklJWT{} == simklJwt) {
|
||||
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 {
|
||||
return true
|
||||
}
|
||||
@ -144,28 +154,36 @@ func getSimklAuthorizationToken(content string) SimklJWT {
|
||||
return post
|
||||
}
|
||||
|
||||
func (a *App) GetSimklLoggedInUserId() SimklUser {
|
||||
func (a *App) GetSimklLoggedInUser() SimklUser {
|
||||
a.SimklLogin()
|
||||
body := struct {
|
||||
Query string `json:"query"`
|
||||
}{
|
||||
Query: `
|
||||
query {
|
||||
Viewer {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
||||
fmt.Println("Token: ", simklJwt.AccessToken)
|
||||
|
||||
client := &http.Client{}
|
||||
|
||||
req, _ := http.NewRequest("POST", "https://api.simkl.com/users/settings", nil)
|
||||
|
||||
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
|
||||
err := json.Unmarshal(user, &post)
|
||||
var user SimklUser
|
||||
|
||||
respBody, _ := io.ReadAll(response.Body)
|
||||
|
||||
err = json.Unmarshal(respBody, &user)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
}
|
||||
|
||||
return post
|
||||
return user
|
||||
}
|
||||
|
6
app.go
6
app.go
@ -2,7 +2,6 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
)
|
||||
|
||||
// App struct
|
||||
@ -20,8 +19,3 @@ func NewApp() *App {
|
||||
func (a *App) startup(ctx context.Context) {
|
||||
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)
|
||||
}
|
||||
|
17
bruno/AniTrack/Simkl/Get Items/GetUser WatchList.bru
Normal file
17
bruno/AniTrack/Simkl/Get Items/GetUser WatchList.bru
Normal 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}}
|
||||
}
|
@ -5,5 +5,6 @@ vars {
|
||||
SIMKL_CLIENT_SECRET: {{process.env.SIMKL_CLIENT_SECRET}}
|
||||
}
|
||||
vars:secret [
|
||||
code
|
||||
code,
|
||||
SIMKL_AUTH_TOKEN
|
||||
]
|
||||
|
@ -1,13 +1,22 @@
|
||||
<script lang="ts">
|
||||
import {anilistModal, GetAniListSingleItemAndOpenModal, title} from "./GetAniListSingleItemAndOpenModal.svelte";
|
||||
import {GetAniListUserWatchingList, SimklLogin} from "../wailsjs/go/main/App";
|
||||
import {MediaListSort} from "./anilist/types/AniListTypes";
|
||||
import {
|
||||
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 Header from "./Header.svelte";
|
||||
import StarRatting from '@ernane/svelte-star-rating'
|
||||
import {Modal} from "flowbite-svelte";
|
||||
import {Button, Modal} from "flowbite-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 = {
|
||||
readOnly: false,
|
||||
@ -19,7 +28,9 @@
|
||||
},
|
||||
score: 0.0,
|
||||
showScore: true,
|
||||
scoreFormat: function(){ return `(${this.score.toFixed(1)}/${this.countStars})` },
|
||||
scoreFormat: function () {
|
||||
return `(${this.score.toFixed(1)}/${this.countStars})`
|
||||
},
|
||||
name: "",
|
||||
starConfig: {
|
||||
size: 20,
|
||||
@ -31,11 +42,63 @@
|
||||
}
|
||||
|
||||
let aniListLoggedIn = false
|
||||
let aniListPrimary = true
|
||||
let simklUser: SimklUser
|
||||
let simklLoggedIn = false
|
||||
let aniListUser: AniListUser
|
||||
let aniListWatchlist: AniListCurrentUserWatchList
|
||||
export let simklWatchList = writable({} as SimklWatchList)
|
||||
let page = 1
|
||||
let perPage = 20
|
||||
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 {
|
||||
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
||||
aniListWatchlist = result
|
||||
@ -61,12 +124,16 @@
|
||||
<Header/>
|
||||
|
||||
<main>
|
||||
|
||||
|
||||
<button class="btn" on:click={anilistGetUserWatchlist}>Login to AniList</button>
|
||||
<button class="btn" on:click={SimklLogin}>Login to Simkl</button>
|
||||
{#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 aniListLoggedIn}
|
||||
@ -112,7 +179,7 @@
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4"></path>
|
||||
</svg>
|
||||
</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}
|
||||
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">
|
||||
@ -120,25 +187,25 @@
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<!-- <div class="relative max-w-sm">-->
|
||||
<!-- <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">-->
|
||||
<!-- <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>-->
|
||||
<!-- </div>-->
|
||||
<!-- <input-->
|
||||
<!-- datepicker-->
|
||||
<!-- datepicker-buttons-->
|
||||
<!-- datepicker-autoselect-today-->
|
||||
<!-- datepicker-autohide-->
|
||||
<!-- datepicker-title="Started At"-->
|
||||
<!-- id="startedAt"-->
|
||||
<!-- type="text"-->
|
||||
<!-- 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-->
|
||||
<!-- dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"-->
|
||||
<!-- placeholder="Select date">-->
|
||||
<!-- </div>-->
|
||||
<!-- <div class="relative max-w-sm">-->
|
||||
<!-- <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">-->
|
||||
<!-- <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>-->
|
||||
<!-- </div>-->
|
||||
<!-- <input-->
|
||||
<!-- datepicker-->
|
||||
<!-- datepicker-buttons-->
|
||||
<!-- datepicker-autoselect-today-->
|
||||
<!-- datepicker-autohide-->
|
||||
<!-- datepicker-title="Started At"-->
|
||||
<!-- id="startedAt"-->
|
||||
<!-- type="text"-->
|
||||
<!-- 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-->
|
||||
<!-- dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"-->
|
||||
<!-- placeholder="Select date">-->
|
||||
<!-- </div>-->
|
||||
<Modal title={$title} bind:open={$anilistModal} {size} autoclose={false}>
|
||||
<ChangeDataDialogue/>
|
||||
</Modal>
|
||||
|
@ -39,6 +39,12 @@ export interface AniListUser {
|
||||
"Viewer": {
|
||||
id: number,
|
||||
name: string,
|
||||
avatar: {
|
||||
large: string,
|
||||
medium: string,
|
||||
},
|
||||
bannerImage: string,
|
||||
siteUrl: string,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
59
frontend/src/simkl/types/simklTypes.ts
Normal file
59
frontend/src/simkl/types/simklTypes.ts
Normal 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
|
||||
}]
|
||||
}
|
10
frontend/wailsjs/go/main/App.d.ts
vendored
10
frontend/wailsjs/go/main/App.d.ts
vendored
@ -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 CheckIfAniListLoggedIn():Promise<boolean>;
|
||||
|
||||
export function CheckIfSimklLoggedIn():Promise<boolean>;
|
||||
|
||||
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 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>;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
export function CheckIfAniListLoggedIn() {
|
||||
return window['go']['main']['App']['CheckIfAniListLoggedIn']();
|
||||
}
|
||||
|
||||
export function CheckIfSimklLoggedIn() {
|
||||
return window['go']['main']['App']['CheckIfSimklLoggedIn']();
|
||||
}
|
||||
|
||||
export function GetAniListItem(arg1, arg2) {
|
||||
return window['go']['main']['App']['GetAniListItem'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetAniListLoggedInUserId() {
|
||||
return window['go']['main']['App']['GetAniListLoggedInUserId']();
|
||||
export function GetAniListLoggedInUser() {
|
||||
return window['go']['main']['App']['GetAniListLoggedInUser']();
|
||||
}
|
||||
|
||||
export function GetAniListUserWatchingList(arg1, arg2, arg3) {
|
||||
return window['go']['main']['App']['GetAniListUserWatchingList'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function GetSimklLoggedInUserId() {
|
||||
return window['go']['main']['App']['GetSimklLoggedInUserId']();
|
||||
export function GetSimklLoggedInUser() {
|
||||
return window['go']['main']['App']['GetSimklLoggedInUser']();
|
||||
}
|
||||
|
||||
export function Greet(arg1) {
|
||||
return window['go']['main']['App']['Greet'](arg1);
|
||||
export function SimklGetUserWatchlist() {
|
||||
return window['go']['main']['App']['SimklGetUserWatchlist']();
|
||||
}
|
||||
|
||||
export function SimklLogin() {
|
||||
|
@ -61,7 +61,7 @@ export namespace main {
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
@ -148,8 +148,9 @@ export namespace main {
|
||||
}
|
||||
}
|
||||
export class SimklUser {
|
||||
// Go type: struct { Viewer struct { ID int "json:\"id\""; Name string "json:\"name\"" } "json:\"Viewer\"" }
|
||||
data: any;
|
||||
user: user;
|
||||
account: account;
|
||||
connections: connections;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new SimklUser(source);
|
||||
@ -157,25 +158,21 @@ export namespace main {
|
||||
|
||||
constructor(source: any = {}) {
|
||||
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 {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
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;
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.anime = source["anime"];
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user