Compare commits
82 Commits
90b68b717a
...
0.1.6
Author | SHA1 | Date | |
---|---|---|---|
d08283bd2d | |||
73d349ee1a | |||
c9c6650829 | |||
896c6640e2 | |||
18c744c1cf | |||
dde5d20537 | |||
314646e7f5 | |||
72dfbf4a03 | |||
d4ad4bc430 | |||
49681f3ffb | |||
d98d0e77c1 | |||
8e57b4b259 | |||
1e1c891173 | |||
5ee9c42352 | |||
23ec111c60 | |||
f24ee9edfd | |||
1fd453f399 | |||
3ab77ea8d3 | |||
3edfed6272 | |||
aa81102194 | |||
0c90c3e29d | |||
2292ae32c2 | |||
31cc19ba7a | |||
5c712454d5 | |||
10430caddf | |||
9a6c844691 | |||
476507a695 | |||
1fdb859f05 | |||
064a2c7f7d | |||
bd39268c0a | |||
2cffd54c4d | |||
7e3369d0f0 | |||
e229311190 | |||
753ecd968e | |||
30c48dcf9b | |||
9b28f2fb0a | |||
0bf784562a | |||
ea2c4475de | |||
572366eb91 | |||
77dc48fcf2 | |||
c7694900e3 | |||
00930f611e | |||
5cdf86a147 | |||
74afb317d1 | |||
a24a187c7f | |||
9f8014ff00 | |||
4c329d6b9d | |||
be6c3439ca | |||
4866f49d13 | |||
60a38ff569 | |||
45b11fa8f4 | |||
908325628f | |||
5915bb28b8 | |||
cbcb07d2f1 | |||
d611ed8b3a | |||
77e361b5b2 | |||
aeec8f79b2 | |||
5a34c89cd5 | |||
f5001cff04 | |||
4fa38b5252 | |||
8d87100373 | |||
7b503875ca | |||
ca6727d2b6 | |||
58fb1e41c2 | |||
c962a6ac9b | |||
8ae3b8dd22 | |||
e3ed5bb2b9 | |||
4d9012b43c | |||
6ebf5ac48e | |||
55cb0e2bd5 | |||
f37622010f | |||
8f884ce1a1 | |||
5fc3a1792a | |||
862c78d3b8 | |||
a433df84db | |||
76ea4f73ec | |||
fb2d5fbdea | |||
3b5518113e | |||
3c7ca15376 | |||
22ff290a81 | |||
f9c6f4b827 | |||
eb7ad5d1a3 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -29,3 +29,4 @@ package.json.md5
|
|||||||
package-lock.json
|
package-lock.json
|
||||||
.idea
|
.idea
|
||||||
.env
|
.env
|
||||||
|
environment.go
|
@ -17,26 +17,29 @@ func AniListQuery(body interface{}, login bool) (json.RawMessage, string) {
|
|||||||
if login && (AniListJWT{}) != aniListJwt {
|
if login && (AniListJWT{}) != aniListJwt {
|
||||||
response.Header.Add("Authorization", "Bearer "+aniListJwt.AccessToken)
|
response.Header.Add("Authorization", "Bearer "+aniListJwt.AccessToken)
|
||||||
} else if login {
|
} else if login {
|
||||||
return nil, "Please login to anilist to make this request"
|
return nil, "Please login to AniList to make this request"
|
||||||
}
|
}
|
||||||
response.Header.Add("Content-Type", "application/json")
|
response.Header.Add("Content-Type", "application/json")
|
||||||
response.Header.Add("Accept", "application/json")
|
response.Header.Add("Accept", "application/json")
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
res, reserr := client.Do(response)
|
res, resErr := client.Do(response)
|
||||||
if reserr != nil {
|
if resErr != nil {
|
||||||
log.Printf("Failed at res, %s\n", err)
|
log.Printf("Failed at res, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
|
|
||||||
returnedBody, err := io.ReadAll(res.Body)
|
returnedBody, err := io.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
return nil, "Could not read the returned body."
|
||||||
|
}
|
||||||
|
|
||||||
return returnedBody, ""
|
return returnedBody, res.Status
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
|
func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
|
||||||
var user = a.GetAniListLoggedInUser()
|
user := a.GetAniListLoggedInUser()
|
||||||
|
|
||||||
var neededVariables interface{}
|
var neededVariables interface{}
|
||||||
|
|
||||||
@ -138,14 +141,44 @@ func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
|
|||||||
Variables: neededVariables,
|
Variables: neededVariables,
|
||||||
}
|
}
|
||||||
|
|
||||||
returnedBody, _ := AniListQuery(body, false)
|
returnedBody, status := AniListQuery(body, login)
|
||||||
|
|
||||||
var post AniListGetSingleAnime
|
var post AniListGetSingleAnime
|
||||||
|
|
||||||
|
if status == "404 Not Found" && !login {
|
||||||
|
return post
|
||||||
|
}
|
||||||
|
|
||||||
|
if status == "404 Not Found" {
|
||||||
|
post = a.GetAniListItem(aniId, false)
|
||||||
|
}
|
||||||
|
|
||||||
err := json.Unmarshal(returnedBody, &post)
|
err := json.Unmarshal(returnedBody, &post)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed at unmarshal, %s\n", err)
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !login {
|
||||||
|
post.Data.MediaList.UserID = user.Data.Viewer.ID
|
||||||
|
post.Data.MediaList.Status = ""
|
||||||
|
post.Data.MediaList.StartedAt.Year = 0
|
||||||
|
post.Data.MediaList.StartedAt.Month = 0
|
||||||
|
post.Data.MediaList.StartedAt.Day = 0
|
||||||
|
post.Data.MediaList.CompletedAt.Year = 0
|
||||||
|
post.Data.MediaList.CompletedAt.Month = 0
|
||||||
|
post.Data.MediaList.CompletedAt.Day = 0
|
||||||
|
post.Data.MediaList.Notes = ""
|
||||||
|
post.Data.MediaList.Progress = 0
|
||||||
|
post.Data.MediaList.Score = 0
|
||||||
|
post.Data.MediaList.Repeat = 0
|
||||||
|
post.Data.MediaList.User.ID = user.Data.Viewer.ID
|
||||||
|
post.Data.MediaList.User.Name = user.Data.Viewer.Name
|
||||||
|
post.Data.MediaList.User.Avatar.Large = user.Data.Viewer.Avatar.Large
|
||||||
|
post.Data.MediaList.User.Avatar.Medium = user.Data.Viewer.Avatar.Medium
|
||||||
|
post.Data.MediaList.User.Statistics.Anime.Count = 0
|
||||||
|
// This provides an empty array and frees up the memory from the garbage collector
|
||||||
|
post.Data.MediaList.User.Statistics.Anime.Statuses = nil
|
||||||
|
}
|
||||||
|
|
||||||
return post
|
return post
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,7 +252,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.GetAniListLoggedInUser()
|
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"`
|
||||||
@ -330,14 +363,25 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
returnedBody, _ := AniListQuery(body, true)
|
returnedBody, status := AniListQuery(body, true)
|
||||||
|
|
||||||
|
var badPost struct {
|
||||||
|
Errors []struct {
|
||||||
|
Message string `json:"message"`
|
||||||
|
Status int `json:"status"`
|
||||||
|
Locations []struct {
|
||||||
|
Line int `json:"line"`
|
||||||
|
Column int `json:"column"`
|
||||||
|
} `json:"locations"`
|
||||||
|
} `json:"errors"`
|
||||||
|
Data any `json:"data"`
|
||||||
|
}
|
||||||
var post AniListCurrentUserWatchList
|
var post AniListCurrentUserWatchList
|
||||||
|
if status == "200 OK" {
|
||||||
err := json.Unmarshal(returnedBody, &post)
|
err := json.Unmarshal(returnedBody, &post)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed at unmarshal, %s\n", err)
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Getting the real total, finding the real last page and storing that in the Page info
|
// Getting the real total, finding the real last page and storing that in the Page info
|
||||||
statuses := post.Data.Page.MediaList[0].User.Statistics.Anime.Statuses
|
statuses := post.Data.Page.MediaList[0].User.Statistics.Anime.Statuses
|
||||||
var total int
|
var total int
|
||||||
@ -351,47 +395,23 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani
|
|||||||
|
|
||||||
post.Data.Page.PageInfo.Total = total
|
post.Data.Page.PageInfo.Total = total
|
||||||
post.Data.Page.PageInfo.LastPage = lastPage
|
post.Data.Page.PageInfo.LastPage = lastPage
|
||||||
|
}
|
||||||
|
|
||||||
|
if status == "403 Forbidden" {
|
||||||
|
err := json.Unmarshal(returnedBody, &badPost)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
|
}
|
||||||
|
log.Fatal(badPost.Errors[0].Message)
|
||||||
|
}
|
||||||
|
|
||||||
return post
|
return post
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) AniListUpdateEntry(
|
func (a *App) AniListUpdateEntry(updateBody AniListUpdateVariables) AniListGetSingleAnime {
|
||||||
mediaId int,
|
|
||||||
progress int,
|
|
||||||
status string,
|
|
||||||
score float64,
|
|
||||||
repeat int,
|
|
||||||
notes string,
|
|
||||||
startYear int,
|
|
||||||
startMonth int,
|
|
||||||
startDay int,
|
|
||||||
completeYear int,
|
|
||||||
completeMonth int,
|
|
||||||
completeDay int,
|
|
||||||
) interface{} {
|
|
||||||
type StartedAt struct {
|
|
||||||
Year int `json:"year"`
|
|
||||||
Month int `json:"month"`
|
|
||||||
Day int `json:"day"`
|
|
||||||
}
|
|
||||||
type CompletedAt struct {
|
|
||||||
Year int `json:"year"`
|
|
||||||
Month int `json:"month"`
|
|
||||||
Day int `json:"day"`
|
|
||||||
}
|
|
||||||
type Variables struct {
|
|
||||||
MediaId int `json:"mediaId"`
|
|
||||||
Progress int `json:"progress"`
|
|
||||||
Status string `json:"status"`
|
|
||||||
Score float64 `json:"score"`
|
|
||||||
Repeat int `json:"repeat"`
|
|
||||||
Notes string `json:"notes"`
|
|
||||||
StartedAt StartedAt `json:"startedAt"`
|
|
||||||
CompletedAt CompletedAt `json:"completedAt"`
|
|
||||||
}
|
|
||||||
body := struct {
|
body := struct {
|
||||||
Query string `json:"query"`
|
Query string `json:"query"`
|
||||||
Variables Variables `json:"variables"`
|
Variables AniListUpdateVariables `json:"variables"`
|
||||||
}{
|
}{
|
||||||
Query: `
|
Query: `
|
||||||
mutation(
|
mutation(
|
||||||
@ -414,12 +434,33 @@ func (a *App) AniListUpdateEntry(
|
|||||||
startedAt:$startedAt
|
startedAt:$startedAt
|
||||||
completedAt:$completedAt
|
completedAt:$completedAt
|
||||||
){
|
){
|
||||||
|
id
|
||||||
mediaId
|
mediaId
|
||||||
progress
|
userId
|
||||||
|
media {
|
||||||
|
id
|
||||||
|
idMal
|
||||||
|
title {
|
||||||
|
romaji
|
||||||
|
english
|
||||||
|
native
|
||||||
|
}
|
||||||
|
description
|
||||||
|
coverImage {
|
||||||
|
large
|
||||||
|
}
|
||||||
|
season
|
||||||
|
seasonYear
|
||||||
|
status
|
||||||
|
episodes
|
||||||
|
nextAiringEpisode {
|
||||||
|
airingAt
|
||||||
|
timeUntilAiring
|
||||||
|
episode
|
||||||
|
}
|
||||||
|
isAdult
|
||||||
|
}
|
||||||
status
|
status
|
||||||
score
|
|
||||||
repeat
|
|
||||||
notes
|
|
||||||
startedAt{
|
startedAt{
|
||||||
year
|
year
|
||||||
month
|
month
|
||||||
@ -430,31 +471,76 @@ func (a *App) AniListUpdateEntry(
|
|||||||
month
|
month
|
||||||
day
|
day
|
||||||
}
|
}
|
||||||
|
notes
|
||||||
|
progress
|
||||||
|
score
|
||||||
|
repeat
|
||||||
|
user {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
avatar{
|
||||||
|
large
|
||||||
|
medium
|
||||||
|
}
|
||||||
|
statistics{
|
||||||
|
anime{
|
||||||
|
count
|
||||||
|
statuses{
|
||||||
|
status
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`,
|
||||||
|
Variables: updateBody,
|
||||||
|
}
|
||||||
|
|
||||||
|
returnedBody, _ := AniListQuery(body, true)
|
||||||
|
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) AniListDeleteEntry(mediaListId int) DeleteAniListReturn {
|
||||||
|
type Variables = struct {
|
||||||
|
Id int `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
body := struct {
|
||||||
|
Query string `json:"query"`
|
||||||
|
Variables Variables `json:"variables"`
|
||||||
|
}{
|
||||||
|
Query: `
|
||||||
|
mutation(
|
||||||
|
$id:Int,
|
||||||
|
){
|
||||||
|
DeleteMediaListEntry(
|
||||||
|
id:$id,
|
||||||
|
){
|
||||||
|
deleted
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
Variables: Variables{
|
Variables: Variables{
|
||||||
MediaId: mediaId,
|
Id: mediaListId,
|
||||||
Progress: progress,
|
|
||||||
Status: status,
|
|
||||||
Score: score,
|
|
||||||
Repeat: repeat,
|
|
||||||
Notes: notes,
|
|
||||||
StartedAt: StartedAt{
|
|
||||||
Year: startYear,
|
|
||||||
Month: startMonth,
|
|
||||||
Day: startDay,
|
|
||||||
},
|
},
|
||||||
CompletedAt: CompletedAt{
|
}
|
||||||
Year: completeYear,
|
|
||||||
Month: completeMonth,
|
|
||||||
Day: completeDay,
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
|
|
||||||
returnedBody, _ := AniListQuery(body, true)
|
returnedBody, _ := AniListQuery(body, true)
|
||||||
|
|
||||||
var post interface{}
|
var post DeleteAniListReturn
|
||||||
err := json.Unmarshal(returnedBody, &post)
|
err := json.Unmarshal(returnedBody, &post)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed at unmarshal, %s\n", err)
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
|
@ -43,6 +43,12 @@ type AniListGetSingleAnime struct {
|
|||||||
} `json:"data"`
|
} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type AniListUpdateReturn struct {
|
||||||
|
Data struct {
|
||||||
|
SaveMediaListEntry MediaList `json:"SaveMediaListEntry"`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
type MediaList struct {
|
type MediaList struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
MediaID int `json:"mediaId"`
|
MediaID int `json:"mediaId"`
|
||||||
@ -112,6 +118,35 @@ type MediaList struct {
|
|||||||
} `json:"user"`
|
} `json:"user"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type StartedAt struct {
|
||||||
|
Year int `json:"year"`
|
||||||
|
Month int `json:"month"`
|
||||||
|
Day int `json:"day"`
|
||||||
|
}
|
||||||
|
type CompletedAt struct {
|
||||||
|
Year int `json:"year"`
|
||||||
|
Month int `json:"month"`
|
||||||
|
Day int `json:"day"`
|
||||||
|
}
|
||||||
|
type AniListUpdateVariables struct {
|
||||||
|
MediaId int `json:"mediaId"`
|
||||||
|
Progress int `json:"progress"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Score float64 `json:"score"`
|
||||||
|
Repeat int `json:"repeat"`
|
||||||
|
Notes string `json:"notes"`
|
||||||
|
StartedAt StartedAt `json:"startedAt"`
|
||||||
|
CompletedAt CompletedAt `json:"completedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type DeleteAniListReturn struct {
|
||||||
|
Data struct {
|
||||||
|
DeleteMediaListEntry struct {
|
||||||
|
Deleted bool `json:"deleted"`
|
||||||
|
} `json:"DeleteMediaListEntry"`
|
||||||
|
} `json:"data"`
|
||||||
|
}
|
||||||
|
|
||||||
//var MediaListSort = struct {
|
//var MediaListSort = struct {
|
||||||
// MediaId string
|
// MediaId string
|
||||||
// MediaIdDesc string
|
// MediaIdDesc string
|
||||||
|
@ -3,12 +3,12 @@ package main
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -21,17 +21,21 @@ var aniListJwt AniListJWT
|
|||||||
|
|
||||||
var aniRing, _ = keyring.Open(keyring.Config{
|
var aniRing, _ = keyring.Open(keyring.Config{
|
||||||
ServiceName: "AniTrack",
|
ServiceName: "AniTrack",
|
||||||
|
KeychainName: "AniTrack",
|
||||||
|
KeychainSynchronizable: false,
|
||||||
|
KeychainTrustApplication: true,
|
||||||
|
KeychainAccessibleWhenUnlocked: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
var aniCtxShutdown, aniCancel = context.WithCancel(context.Background())
|
var aniCtxShutdown, aniCancel = context.WithCancel(context.Background())
|
||||||
|
|
||||||
func (a *App) CheckIfAniListLoggedIn() bool {
|
func (a *App) CheckIfAniListLoggedIn() bool {
|
||||||
if (AniListJWT{} == aniListJwt) {
|
if (AniListJWT{} == aniListJwt) {
|
||||||
tokenType, err := aniRing.Get("anilistTokenType")
|
tokenType, tokenErr := aniRing.Get("anilistTokenType")
|
||||||
expiresIn, err := aniRing.Get("anilistTokenExpiresIn")
|
expiresIn, expiresInErr := aniRing.Get("anilistTokenExpiresIn")
|
||||||
accessToken, err := aniRing.Get("anilistAccessToken")
|
refreshToken, refreshTokenErr := aniRing.Get("anilistRefreshToken")
|
||||||
refreshToken, err := aniRing.Get("anilistRefreshToken")
|
accessToken, accessTokenErr := aniRing.Get("anilistAccessToken")
|
||||||
if err != nil || len(accessToken.Data) == 0 {
|
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
aniListJwt.TokenType = string(tokenType.Data)
|
aniListJwt.TokenType = string(tokenType.Data)
|
||||||
@ -47,13 +51,13 @@ func (a *App) CheckIfAniListLoggedIn() bool {
|
|||||||
|
|
||||||
func (a *App) AniListLogin() {
|
func (a *App) AniListLogin() {
|
||||||
if (AniListJWT{} == aniListJwt) {
|
if (AniListJWT{} == aniListJwt) {
|
||||||
tokenType, err := aniRing.Get("anilistTokenType")
|
tokenType, tokenErr := aniRing.Get("anilistTokenType")
|
||||||
expiresIn, err := aniRing.Get("anilistTokenExpiresIn")
|
expiresIn, expiresInErr := aniRing.Get("anilistTokenExpiresIn")
|
||||||
accessToken, err := aniRing.Get("anilistAccessToken")
|
refreshToken, refreshTokenErr := aniRing.Get("anilistRefreshToken")
|
||||||
refreshToken, err := aniRing.Get("anilistRefreshToken")
|
accessToken, accessTokenErr := aniRing.Get("anilistAccessToken")
|
||||||
if err != nil || len(accessToken.Data) == 0 {
|
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
||||||
getAniListCodeUrl := "https://anilist.co/api/v2/oauth/authorize?client_id=" + os.Getenv("ANILIST_APP_ID") + "&redirect_uri=" + os.Getenv("ANILIST_CALLBACK_URI") + "&response_type=code"
|
getAniListCodeUrl := "https://anilist.co/api/v2/oauth/authorize?client_id=" + Environment.ANILIST_APP_ID + "&redirect_uri=" + Environment.ANILIST_CALLBACK_URI + "&response_type=code"
|
||||||
runtime.BrowserOpenURL(a.ctx, getAniListCodeUrl)
|
runtime.BrowserOpenURL(*wailsContext, getAniListCodeUrl)
|
||||||
|
|
||||||
serverDone := &sync.WaitGroup{}
|
serverDone := &sync.WaitGroup{}
|
||||||
serverDone.Add(1)
|
serverDone.Add(1)
|
||||||
@ -79,7 +83,6 @@ func (a *App) handleAniListCallback(wg *sync.WaitGroup) {
|
|||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
content := r.FormValue("code")
|
content := r.FormValue("code")
|
||||||
|
|
||||||
if content != "" {
|
if content != "" {
|
||||||
aniListJwt = getAniListAuthorizationToken(content)
|
aniListJwt = getAniListAuthorizationToken(content)
|
||||||
_ = aniRing.Set(keyring.Item{
|
_ = aniRing.Set(keyring.Item{
|
||||||
@ -98,7 +101,7 @@ func (a *App) handleAniListCallback(wg *sync.WaitGroup) {
|
|||||||
Key: "anilistRefreshToken",
|
Key: "anilistRefreshToken",
|
||||||
Data: []byte(aniListJwt.RefreshToken),
|
Data: []byte(aniListJwt.RefreshToken),
|
||||||
})
|
})
|
||||||
_, err := runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
|
_, err := runtime.MessageDialog(*wailsContext, runtime.MessageDialogOptions{
|
||||||
Title: "AniList Authorization",
|
Title: "AniList Authorization",
|
||||||
Message: "It is now safe to close your browser tab",
|
Message: "It is now safe to close your browser tab",
|
||||||
})
|
})
|
||||||
@ -121,7 +124,7 @@ func (a *App) handleAniListCallback(wg *sync.WaitGroup) {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||||
log.Fatalf("listen: %s\n", err)
|
log.Fatalf("listen: %s\n", err)
|
||||||
}
|
}
|
||||||
fmt.Println("Shutting down...")
|
fmt.Println("Shutting down...")
|
||||||
@ -133,9 +136,9 @@ func getAniListAuthorizationToken(content string) AniListJWT {
|
|||||||
resource := "/api/v2/oauth/token"
|
resource := "/api/v2/oauth/token"
|
||||||
data := url.Values{}
|
data := url.Values{}
|
||||||
data.Set("grant_type", "authorization_code")
|
data.Set("grant_type", "authorization_code")
|
||||||
data.Set("client_id", os.Getenv("ANILIST_APP_ID"))
|
data.Set("client_id", Environment.ANILIST_APP_ID)
|
||||||
data.Set("client_secret", os.Getenv("ANILIST_SECRET_TOKEN"))
|
data.Set("client_secret", Environment.ANILIST_SECRET_TOKEN)
|
||||||
data.Set("redirect_uri", os.Getenv("ANILIST_CALLBACK_URI"))
|
data.Set("redirect_uri", Environment.ANILIST_CALLBACK_URI)
|
||||||
data.Set("code", content)
|
data.Set("code", content)
|
||||||
|
|
||||||
u, _ := url.ParseRequestURI(apiUrl)
|
u, _ := url.ParseRequestURI(apiUrl)
|
||||||
@ -146,19 +149,21 @@ func getAniListAuthorizationToken(content string) AniListJWT {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed at response, %s\n", err)
|
log.Printf("Failed at response, %s\n", err)
|
||||||
}
|
}
|
||||||
response.Header.Add("content-type", "application/x-www-form-urlencoded")
|
response.Header.Add("Content-type", "application/x-www-form-urlencoded")
|
||||||
response.Header.Add("Content-Type", "application/json")
|
|
||||||
response.Header.Add("Accept", "application/json")
|
response.Header.Add("Accept", "application/json")
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
res, reserr := client.Do(response)
|
res, resErr := client.Do(response)
|
||||||
if reserr != nil {
|
if resErr != nil {
|
||||||
log.Printf("Failed at res, %s\n", err)
|
log.Printf("Failed at res, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
|
|
||||||
returnedBody, err := io.ReadAll(res.Body)
|
returnedBody, err := io.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Could not read returned body, %s\n.", err)
|
||||||
|
}
|
||||||
|
|
||||||
var post AniListJWT
|
var post AniListJWT
|
||||||
err = json.Unmarshal(returnedBody, &post)
|
err = json.Unmarshal(returnedBody, &post)
|
||||||
@ -203,14 +208,14 @@ func (a *App) GetAniListLoggedInUser() AniListUser {
|
|||||||
|
|
||||||
func (a *App) LogoutAniList() string {
|
func (a *App) LogoutAniList() string {
|
||||||
if (AniListJWT{} != aniListJwt) {
|
if (AniListJWT{} != aniListJwt) {
|
||||||
err := aniRing.Remove("anilistTokenType")
|
typeErr := aniRing.Remove("anilistTokenType")
|
||||||
err = aniRing.Remove("anilistTokenExpiresIn")
|
expiresInErr := aniRing.Remove("anilistTokenExpiresIn")
|
||||||
err = aniRing.Remove("anilistAccessToken")
|
accessTokenErr := aniRing.Remove("anilistAccessToken")
|
||||||
err = aniRing.Remove("anilistRefreshToken")
|
refreshTokenErr := aniRing.Remove("anilistRefreshToken")
|
||||||
|
if typeErr != nil || expiresInErr != nil || accessTokenErr != nil || refreshTokenErr != nil {
|
||||||
if err != nil {
|
fmt.Println("AniList Logout Failed")
|
||||||
fmt.Println("AniList Logout Failed", err)
|
|
||||||
}
|
}
|
||||||
|
aniListJwt = AniListJWT{}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "AniList Logged Out Successfully"
|
return "AniList Logged Out Successfully"
|
||||||
|
116
MALFunctions.go
Normal file
116
MALFunctions.go
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"net/http"
|
||||||
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
func MALHelper(method string, malUrl string, body url.Values) (json.RawMessage, string) {
|
||||||
|
client := &http.Client{}
|
||||||
|
|
||||||
|
req, _ := http.NewRequest(method, malUrl, strings.NewReader(body.Encode()))
|
||||||
|
|
||||||
|
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
req.Header.Add("Authorization", "Bearer "+myAnimeListJwt.AccessToken)
|
||||||
|
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("Errored when sending request to the server")
|
||||||
|
message, _ := json.Marshal(struct {
|
||||||
|
Message string `json:"message" ts_type:"message"`
|
||||||
|
}{
|
||||||
|
Message: "Errored when sending request to the server" + err.Error(),
|
||||||
|
})
|
||||||
|
|
||||||
|
return message, resp.Status
|
||||||
|
}
|
||||||
|
|
||||||
|
defer resp.Body.Close()
|
||||||
|
respBody, _ := io.ReadAll(resp.Body)
|
||||||
|
|
||||||
|
if resp.Status == "401 Unauthorized" {
|
||||||
|
refreshMyAnimeListAuthorizationToken()
|
||||||
|
MALHelper(method, malUrl, body)
|
||||||
|
}
|
||||||
|
|
||||||
|
return respBody, resp.Status
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) GetMyAnimeList(count int) MALWatchlist {
|
||||||
|
limit := strconv.Itoa(count)
|
||||||
|
user := a.GetMyAnimeListLoggedInUser()
|
||||||
|
malUrl := "https://api.myanimelist.net/v2/users/" + user.Name + "/animelist?fields=list_status&status=watching&limit=" + limit
|
||||||
|
|
||||||
|
var malList MALWatchlist
|
||||||
|
|
||||||
|
respBody, resStatus := MALHelper("GET", malUrl, nil)
|
||||||
|
|
||||||
|
if resStatus == "200 OK" {
|
||||||
|
err := json.Unmarshal(respBody, &malList)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to unmarshal json response, %s\n", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return malList
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) MyAnimeListUpdate(anime MALAnime, update MALUploadStatus) MalListStatus {
|
||||||
|
if update.NumTimesRewatched >= 1 {
|
||||||
|
update.IsRewatching = true
|
||||||
|
} else {
|
||||||
|
update.IsRewatching = false
|
||||||
|
}
|
||||||
|
body := url.Values{}
|
||||||
|
body.Set("status", update.Status)
|
||||||
|
body.Set("is_rewatching", strconv.FormatBool(update.IsRewatching))
|
||||||
|
body.Set("score", strconv.Itoa(update.Score))
|
||||||
|
body.Set("num_watched_episodes", strconv.Itoa(update.NumWatchedEpisodes))
|
||||||
|
body.Set("num_times_rewatched", strconv.Itoa(update.NumTimesRewatched))
|
||||||
|
body.Set("comments", update.Comments)
|
||||||
|
|
||||||
|
malUrl := "https://api.myanimelist.net/v2/anime/" + strconv.Itoa(anime.Id) + "/my_list_status"
|
||||||
|
var status MalListStatus
|
||||||
|
respBody, respStatus := MALHelper("PATCH", malUrl, body)
|
||||||
|
|
||||||
|
if respStatus == "200 OK" {
|
||||||
|
err := json.Unmarshal(respBody, &status)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to unmarshal json response, %s\n", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) GetMyAnimeListAnime(id int) MALAnime {
|
||||||
|
malUrl := "https://api.myanimelist.net/v2/anime/" + strconv.Itoa(id) + "?fields=id,title,main_picture,alternative_titles,start_date,end_date,synopsis,mean,rank,popularity,num_list_users,num_scoring_users,nsfw,genres,created_at,updated_at,media_type,status,my_list_status,num_episodes,start_season,broadcast,source,average_episode_duration,rating,pictures,background,related_anime,recommendations,studios,statistics"
|
||||||
|
respBody, respStatus := MALHelper("GET", malUrl, nil)
|
||||||
|
var malAnime MALAnime
|
||||||
|
|
||||||
|
if respStatus == "200 OK" {
|
||||||
|
err := json.Unmarshal(respBody, &malAnime)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed to unmarshal json response, %s\n", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return malAnime
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) DeleteMyAnimeListEntry(id int) bool {
|
||||||
|
malUrl := "https://api.myanimelist.net/v2/anime/" + strconv.Itoa(id) + "/my_list_status"
|
||||||
|
_, respStatus := MALHelper("DELETE", malUrl, nil)
|
||||||
|
if respStatus == "200 OK" {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
124
MALTypes.go
124
MALTypes.go
@ -1,5 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
|
import "time"
|
||||||
|
|
||||||
type MyAnimeListJWT struct {
|
type MyAnimeListJWT struct {
|
||||||
TokenType string `json:"token_type"`
|
TokenType string `json:"token_type"`
|
||||||
ExpiresIn int `json:"expires_in"`
|
ExpiresIn int `json:"expires_in"`
|
||||||
@ -37,3 +39,125 @@ type AnimeStatistics struct {
|
|||||||
NumTimesRewatched int `json:"num_times_rewatched" ts_type:"numTimesRewatched"`
|
NumTimesRewatched int `json:"num_times_rewatched" ts_type:"numTimesRewatched"`
|
||||||
MeanScore float64 `json:"mean_score" ts_type:"meanScore"`
|
MeanScore float64 `json:"mean_score" ts_type:"meanScore"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type MALWatchlist struct {
|
||||||
|
Data []struct {
|
||||||
|
Node struct {
|
||||||
|
Id int `json:"id" ts_type:"id"`
|
||||||
|
Title string `json:"title" ts_type:"title"`
|
||||||
|
MainPicture struct {
|
||||||
|
Medium string `json:"medium" ts_type:"medium"`
|
||||||
|
Large string `json:"large" ts_type:"large"`
|
||||||
|
} `json:"main_picture" ts_type:"mainPicture"`
|
||||||
|
} `json:"node" ts_type:"node"`
|
||||||
|
ListStatus struct {
|
||||||
|
Status string `json:"status" ts_type:"status"`
|
||||||
|
Score int `json:"score" ts_type:"score"`
|
||||||
|
NumEpisodesWatched int `json:"num_episodes_watched" ts_type:"numEpisodesWatched"`
|
||||||
|
IsRewatching bool `json:"is_rewatching" ts_type:"isRewatching"`
|
||||||
|
UpdatedAt time.Time `json:"updated_at" ts_type:"updatedAt"`
|
||||||
|
StartDate string `json:"start_date" ts_type:"startDate"`
|
||||||
|
FinishDate string `json:"finish_date" ts_type:"finishDate"`
|
||||||
|
} `json:"list_status" ts_type:"listStatus"`
|
||||||
|
} `json:"data" ts_type:"data"`
|
||||||
|
Paging struct {
|
||||||
|
Previous string `json:"previous" ts_type:"previous"`
|
||||||
|
Next string `json:"next" ts_type:"next"`
|
||||||
|
} `json:"paging" ts_type:"paging"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MALAnime struct {
|
||||||
|
Id int `json:"id" ts_type:"id"`
|
||||||
|
Title string `json:"title" ts_type:"title"`
|
||||||
|
MainPicture struct {
|
||||||
|
Large string `json:"large" ts_type:"large"`
|
||||||
|
Medium string `json:"medium" ts_type:"medium"`
|
||||||
|
} `json:"main_picture" ts_type:"mainPicture"`
|
||||||
|
AlternativeTitles struct {
|
||||||
|
Synonyms []string `json:"synonyms" ts_type:"synonyms"`
|
||||||
|
En string `json:"en" ts_type:"en"`
|
||||||
|
Ja string `json:"ja" ts_type:"ja"`
|
||||||
|
} `json:"alternative_titles" ts_type:"alternativeTitles"`
|
||||||
|
StartDate string `json:"start_date" ts_type:"startDate"`
|
||||||
|
EndDate string `json:"end_date" ts_type:"endDate"`
|
||||||
|
Synopsis string `json:"synopsis" ts_type:"synopsis"`
|
||||||
|
Mean float64 `json:"mean" ts_type:"mean"`
|
||||||
|
Rank int `json:"rank" ts_type:"rank"`
|
||||||
|
Popularity int `json:"popularity" ts_type:"popularity"`
|
||||||
|
NumListUsers int `json:"num_list_users" ts_type:"numListUsers"`
|
||||||
|
NumScoringUsers int `json:"num_scoring_users" ts_type:"numScoringUsers"`
|
||||||
|
NSFW string `json:"nsfw" ts_type:"nsfw"`
|
||||||
|
Genres []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"`
|
||||||
|
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"`
|
||||||
|
Broadcast struct {
|
||||||
|
DayOfTheWeek string `json:"day_of_the_week" ts_type:"dayOfTheWeek"`
|
||||||
|
StartTime string `json:"start_time" ts_type:"startTime"`
|
||||||
|
} `json:"broadcast" ts_type:"broadcast"`
|
||||||
|
Source string `json:"source" ts_type:"source"`
|
||||||
|
AverageEpisodeDuration int `json:"average_episode_duration" ts_type:"averageEpisodeDuration"`
|
||||||
|
Rating string `json:"rating" ts_type:"rating"`
|
||||||
|
Studios []struct {
|
||||||
|
Id int `json:"id" ts_type:"id"`
|
||||||
|
Name string `json:"name" ts_type:"name"`
|
||||||
|
} `json:"studios" ts_type:"studios"`
|
||||||
|
Pictures []struct {
|
||||||
|
Large string `json:"large" ts_type:"large"`
|
||||||
|
Medium string `json:"medium" ts_type:"medium"`
|
||||||
|
} `json:"pictures" ts_type:"pictures"`
|
||||||
|
Background string `json:"background" ts_type:"background"`
|
||||||
|
RelatedAnime []struct {
|
||||||
|
Node MALAnime `json:"node" ts_type:"node"`
|
||||||
|
RelationType string `json:"relation_type" ts_type:"relationType"`
|
||||||
|
RelationTypeFormatted string `json:"relation_type_formatted" ts_type:"relationTypeFormatted"`
|
||||||
|
} `json:"related_anime" ts_type:"relatedAnime"`
|
||||||
|
Recommendations []struct {
|
||||||
|
Node MALAnime `json:"node" ts_type:"node"`
|
||||||
|
NumRecommendations int `json:"num_recommendations" ts_type:"numRecommendations"`
|
||||||
|
} `json:"recommendations" ts_type:"recommendations"`
|
||||||
|
Statistics struct {
|
||||||
|
NumListUsers int `json:"num_list_users" ts_type:"numListUsers"`
|
||||||
|
Status struct {
|
||||||
|
Watching string `json:"watching" ts_type:"watching"`
|
||||||
|
Completed string `json:"completed" ts_type:"completed"`
|
||||||
|
OnHold string `json:"on_hold" ts_type:"onHold"`
|
||||||
|
Dropped string `json:"dropped" ts_type:"dropped"`
|
||||||
|
PlanToWatch string `json:"plan_to_watch" ts_type:"planToWatch"`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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"`
|
||||||
|
IsRewatching bool `json:"is_rewatching" ts_type:"isRewatching"`
|
||||||
|
StartDate string `json:"start_date" ts_type:"startDate"`
|
||||||
|
FinishDate string `json:"finish_date" ts_type:"finishDate"`
|
||||||
|
Priority int `json:"priority" ts_type:"priority"`
|
||||||
|
NumTimesRewatched int `json:"num_times_rewatched" ts_type:"numTimesRewatched"`
|
||||||
|
RewatchValue int `json:"rewatch_value" ts_type:"rewatchValue"`
|
||||||
|
Tags []string `json:"tags" ts_type:"tags"`
|
||||||
|
Comments string `json:"comments" ts_type:"comments"`
|
||||||
|
UpdatedAt string `json:"updated_at" ts_type:"updatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type MALUploadStatus struct {
|
||||||
|
Status string `json:"status"`
|
||||||
|
IsRewatching bool `json:"is_rewatching"`
|
||||||
|
Score int `json:"score"`
|
||||||
|
NumWatchedEpisodes int `json:"num_watched_episodes"`
|
||||||
|
NumTimesRewatched int `json:"num_times_rewatched"`
|
||||||
|
Comments string `json:"comments"`
|
||||||
|
}
|
||||||
|
@ -5,13 +5,13 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
@ -25,6 +25,10 @@ var myAnimeListJwt MyAnimeListJWT
|
|||||||
|
|
||||||
var myAnimeListRing, _ = keyring.Open(keyring.Config{
|
var myAnimeListRing, _ = keyring.Open(keyring.Config{
|
||||||
ServiceName: "AniTrack",
|
ServiceName: "AniTrack",
|
||||||
|
KeychainName: "AniTrack",
|
||||||
|
KeychainSynchronizable: false,
|
||||||
|
KeychainTrustApplication: true,
|
||||||
|
KeychainAccessibleWhenUnlocked: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
var myAnimeListCtxShutdown, myAnimeListCancel = context.WithCancel(context.Background())
|
var myAnimeListCtxShutdown, myAnimeListCancel = context.WithCancel(context.Background())
|
||||||
@ -47,7 +51,7 @@ func base64URLEncode(str []byte) string {
|
|||||||
|
|
||||||
func verifier() (*CodeVerifier, error) {
|
func verifier() (*CodeVerifier, error) {
|
||||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||||
b := make([]byte, length, length)
|
b := make([]byte, length)
|
||||||
for i := 0; i < length; i++ {
|
for i := 0; i < length; i++ {
|
||||||
b[i] = byte(r.Intn(255))
|
b[i] = byte(r.Intn(255))
|
||||||
}
|
}
|
||||||
@ -68,16 +72,17 @@ func (v *CodeVerifier) CodeChallengeS256() string {
|
|||||||
|
|
||||||
func (a *App) CheckIfMyAnimeListLoggedIn() bool {
|
func (a *App) CheckIfMyAnimeListLoggedIn() bool {
|
||||||
if (MyAnimeListJWT{} == myAnimeListJwt) {
|
if (MyAnimeListJWT{} == myAnimeListJwt) {
|
||||||
tokenType, err := myAnimeListRing.Get("MyAnimeListTokenType")
|
tokenType, tokenErr := myAnimeListRing.Get("MyAnimeListTokenType")
|
||||||
expiresIn, err := myAnimeListRing.Get("MyAnimeListExpiresIn")
|
expiresIn, expiresInErr := myAnimeListRing.Get("MyAnimeListExpiresIn")
|
||||||
accessToken, err := myAnimeListRing.Get("MyAnimeListAccessToken")
|
refreshToken, refreshTokenErr := myAnimeListRing.Get("MyAnimeListAccessToken")
|
||||||
refreshToken, err := myAnimeListRing.Get("MyAnimeListRefreshToken")
|
accessToken, accessTokenErr := myAnimeListRing.Get("MyAnimeListRefreshToken")
|
||||||
if err != nil || len(accessToken.Data) == 0 {
|
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
|
var expiresInConvertErr error
|
||||||
myAnimeListJwt.TokenType = string(tokenType.Data)
|
myAnimeListJwt.TokenType = string(tokenType.Data)
|
||||||
myAnimeListJwt.ExpiresIn, err = strconv.Atoi(string(expiresIn.Data))
|
myAnimeListJwt.ExpiresIn, expiresInConvertErr = strconv.Atoi(string(expiresIn.Data))
|
||||||
if err != nil {
|
if expiresInConvertErr != nil {
|
||||||
fmt.Println("unable to convert string to int")
|
fmt.Println("unable to convert string to int")
|
||||||
}
|
}
|
||||||
myAnimeListJwt.AccessToken = string(accessToken.Data)
|
myAnimeListJwt.AccessToken = string(accessToken.Data)
|
||||||
@ -90,23 +95,25 @@ func (a *App) CheckIfMyAnimeListLoggedIn() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) MyAnimeListLogin() {
|
func (a *App) MyAnimeListLogin() {
|
||||||
if a.CheckIfMyAnimeListLoggedIn() == false {
|
if !a.CheckIfMyAnimeListLoggedIn() {
|
||||||
tokenType, err := myAnimeListRing.Get("MyAnimeListTokenType")
|
fmt.Println("check logged in function failed")
|
||||||
expiresIn, err := myAnimeListRing.Get("MyAnimeListExpiresIn")
|
tokenType, tokenErr := myAnimeListRing.Get("MyAnimeListTokenType")
|
||||||
accessToken, err := myAnimeListRing.Get("MyAnimeListAccessToken")
|
expiresIn, expiresInErr := myAnimeListRing.Get("MyAnimeListExpiresIn")
|
||||||
refreshToken, err := myAnimeListRing.Get("MyAnimeListRefreshToken")
|
refreshToken, refreshTokenErr := myAnimeListRing.Get("MyAnimeListAccessToken")
|
||||||
if err != nil || len(accessToken.Data) == 0 {
|
accessToken, accessTokenErr := myAnimeListRing.Get("MyAnimeListRefreshToken")
|
||||||
|
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
||||||
verifier, _ := verifier()
|
verifier, _ := verifier()
|
||||||
getMyAnimeListCodeUrl := "https://myanimelist.net/v1/oauth2/authorize?response_type=code&client_id=" + os.Getenv("MAL_CLIENT_ID") + "&redirect_uri=" + os.Getenv("MAL_CALLBACK_URI") + "&code_challenge=" + verifier.Value + "&code_challenge_method=plain"
|
getMyAnimeListCodeUrl := "https://myanimelist.net/v1/oauth2/authorize?response_type=code&client_id=" + Environment.MAL_CLIENT_ID + "&redirect_uri=" + Environment.MAL_CALLBACK_URI + "&code_challenge=" + verifier.Value + "&code_challenge_method=plain"
|
||||||
runtime.BrowserOpenURL(a.ctx, getMyAnimeListCodeUrl)
|
runtime.BrowserOpenURL(*wailsContext, getMyAnimeListCodeUrl)
|
||||||
serverDone := &sync.WaitGroup{}
|
serverDone := &sync.WaitGroup{}
|
||||||
serverDone.Add(1)
|
serverDone.Add(1)
|
||||||
a.handleMyAnimeListCallback(serverDone, verifier)
|
a.handleMyAnimeListCallback(serverDone, verifier)
|
||||||
serverDone.Wait()
|
serverDone.Wait()
|
||||||
} else {
|
} else {
|
||||||
|
var expiresInConvertErr error
|
||||||
myAnimeListJwt.TokenType = string(tokenType.Data)
|
myAnimeListJwt.TokenType = string(tokenType.Data)
|
||||||
myAnimeListJwt.ExpiresIn, err = strconv.Atoi(string(expiresIn.Data))
|
myAnimeListJwt.ExpiresIn, expiresInConvertErr = strconv.Atoi(string(expiresIn.Data))
|
||||||
if err != nil {
|
if expiresInConvertErr != nil {
|
||||||
fmt.Println("unable to convert string to int in Login function")
|
fmt.Println("unable to convert string to int in Login function")
|
||||||
}
|
}
|
||||||
myAnimeListJwt.AccessToken = string(accessToken.Data)
|
myAnimeListJwt.AccessToken = string(accessToken.Data)
|
||||||
@ -145,7 +152,7 @@ func (a *App) handleMyAnimeListCallback(wg *sync.WaitGroup, verifier *CodeVerifi
|
|||||||
Key: "MyAnimeListRefreshToken",
|
Key: "MyAnimeListRefreshToken",
|
||||||
Data: []byte(myAnimeListJwt.RefreshToken),
|
Data: []byte(myAnimeListJwt.RefreshToken),
|
||||||
})
|
})
|
||||||
_, err := runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
|
_, err := runtime.MessageDialog(*wailsContext, runtime.MessageDialogOptions{
|
||||||
Title: "MyAnimeList Authorization",
|
Title: "MyAnimeList Authorization",
|
||||||
Message: "It is now safe to close your browser tab",
|
Message: "It is now safe to close your browser tab",
|
||||||
})
|
})
|
||||||
@ -168,7 +175,7 @@ func (a *App) handleMyAnimeListCallback(wg *sync.WaitGroup, verifier *CodeVerifi
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||||
log.Fatalf("listen: %s\n", err)
|
log.Fatalf("listen: %s\n", err)
|
||||||
}
|
}
|
||||||
fmt.Println("Shutting down...")
|
fmt.Println("Shutting down...")
|
||||||
@ -185,9 +192,9 @@ func getMyAnimeListAuthorizationToken(content string, verifier *CodeVerifier) My
|
|||||||
CodeVerifier *CodeVerifier `json:"code_verifier"`
|
CodeVerifier *CodeVerifier `json:"code_verifier"`
|
||||||
}{
|
}{
|
||||||
GrantType: "authorization_code",
|
GrantType: "authorization_code",
|
||||||
ClientID: os.Getenv("MAL_CLIENT_ID"),
|
ClientID: Environment.MAL_CLIENT_ID,
|
||||||
ClientSecret: os.Getenv("MAL_CLIENT_SECRET"),
|
ClientSecret: Environment.MAL_CLIENT_SECRET,
|
||||||
RedirectURI: os.Getenv("MAL_CALLBACK_URI"),
|
RedirectURI: Environment.MAL_CALLBACK_URI,
|
||||||
Code: content,
|
Code: content,
|
||||||
CodeVerifier: verifier,
|
CodeVerifier: verifier,
|
||||||
}
|
}
|
||||||
@ -207,14 +214,17 @@ func getMyAnimeListAuthorizationToken(content string, verifier *CodeVerifier) My
|
|||||||
response.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
response.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
res, reserr := client.Do(response)
|
res, resErr := client.Do(response)
|
||||||
if reserr != nil {
|
if resErr != nil {
|
||||||
log.Printf("Failed at res, %s\n", err)
|
log.Printf("Failed at res, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
|
|
||||||
returnedBody, err := io.ReadAll(res.Body)
|
returnedBody, err := io.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Could not read returned body, %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
var post MyAnimeListJWT
|
var post MyAnimeListJWT
|
||||||
err = json.Unmarshal(returnedBody, &post)
|
err = json.Unmarshal(returnedBody, &post)
|
||||||
@ -225,6 +235,77 @@ func getMyAnimeListAuthorizationToken(content string, verifier *CodeVerifier) My
|
|||||||
return post
|
return post
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func refreshMyAnimeListAuthorizationToken() {
|
||||||
|
dataForURLs := struct {
|
||||||
|
GrantType string `json:"grant_type"`
|
||||||
|
RefreshToken string `json:"refresh_token"`
|
||||||
|
ClientID string `json:"client_id"`
|
||||||
|
ClientSecret string `json:"client_secret"`
|
||||||
|
RedirectURI string `json:"redirect_uri"`
|
||||||
|
}{
|
||||||
|
GrantType: "refresh_token",
|
||||||
|
RefreshToken: myAnimeListJwt.RefreshToken,
|
||||||
|
ClientID: Environment.MAL_CLIENT_ID,
|
||||||
|
ClientSecret: Environment.MAL_CLIENT_SECRET,
|
||||||
|
RedirectURI: Environment.MAL_CALLBACK_URI,
|
||||||
|
}
|
||||||
|
|
||||||
|
data := url.Values{}
|
||||||
|
data.Set("grant_type", dataForURLs.GrantType)
|
||||||
|
data.Set("refresh_token", dataForURLs.RefreshToken)
|
||||||
|
data.Set("client_id", dataForURLs.ClientID)
|
||||||
|
data.Set("client_secret", dataForURLs.ClientSecret)
|
||||||
|
data.Set("redirect_uri", dataForURLs.RedirectURI)
|
||||||
|
|
||||||
|
response, err := http.NewRequest("POST", "https://myanimelist.net/v1/oauth2/token", strings.NewReader(data.Encode()))
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed at response, %s\n", err)
|
||||||
|
}
|
||||||
|
response.Header.Add("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
res, resErr := client.Do(response)
|
||||||
|
if resErr != nil {
|
||||||
|
log.Printf("Failed at res, %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
returnedBody, err := io.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Could not read returned body, %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(returnedBody, &myAnimeListJwt)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = myAnimeListRing.Set(keyring.Item{
|
||||||
|
Key: "MyAnimeListTokenType",
|
||||||
|
Data: []byte(myAnimeListJwt.TokenType),
|
||||||
|
})
|
||||||
|
_ = myAnimeListRing.Set(keyring.Item{
|
||||||
|
Key: "MyAnimeListExpiresIn",
|
||||||
|
Data: []byte(strconv.Itoa(myAnimeListJwt.ExpiresIn)),
|
||||||
|
})
|
||||||
|
_ = myAnimeListRing.Set(keyring.Item{
|
||||||
|
Key: "MyAnimeListAccessToken",
|
||||||
|
Data: []byte(myAnimeListJwt.AccessToken),
|
||||||
|
})
|
||||||
|
_ = myAnimeListRing.Set(keyring.Item{
|
||||||
|
Key: "MyAnimeListRefreshToken",
|
||||||
|
Data: []byte(myAnimeListJwt.RefreshToken),
|
||||||
|
})
|
||||||
|
_, err = runtime.MessageDialog(*wailsContext, runtime.MessageDialogOptions{
|
||||||
|
Title: "MyAnimeList Authorization",
|
||||||
|
Message: "It is now safe to close your browser tab",
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (a *App) GetMyAnimeListLoggedInUser() MyAnimeListUser {
|
func (a *App) GetMyAnimeListLoggedInUser() MyAnimeListUser {
|
||||||
a.MyAnimeListLogin()
|
a.MyAnimeListLogin()
|
||||||
|
|
||||||
@ -234,10 +315,9 @@ func (a *App) GetMyAnimeListLoggedInUser() MyAnimeListUser {
|
|||||||
|
|
||||||
req.Header.Add("Content-Type", "application/json")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
req.Header.Add("Authorization", "Bearer "+myAnimeListJwt.AccessToken)
|
req.Header.Add("Authorization", "Bearer "+myAnimeListJwt.AccessToken)
|
||||||
req.Header.Add("myAnimeList-api-key", os.Getenv("MAL_CLIENT_ID"))
|
req.Header.Add("myAnimeList-api-key", Environment.MAL_CLIENT_ID)
|
||||||
|
|
||||||
response, err := client.Do(req)
|
response, err := client.Do(req)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed at request, %s\n", err)
|
log.Printf("Failed at request, %s\n", err)
|
||||||
return MyAnimeListUser{}
|
return MyAnimeListUser{}
|
||||||
@ -259,14 +339,14 @@ func (a *App) GetMyAnimeListLoggedInUser() MyAnimeListUser {
|
|||||||
|
|
||||||
func (a *App) LogoutMyAnimeList() string {
|
func (a *App) LogoutMyAnimeList() string {
|
||||||
if (MyAnimeListJWT{} != myAnimeListJwt) {
|
if (MyAnimeListJWT{} != myAnimeListJwt) {
|
||||||
err := myAnimeListRing.Remove("MyAnimeListTokenType")
|
typeErr := myAnimeListRing.Remove("MyAnimeListTokenType")
|
||||||
err = myAnimeListRing.Remove("MyAnimeListExpiresIn")
|
expiresInErr := myAnimeListRing.Remove("MyAnimeListExpiresIn")
|
||||||
err = myAnimeListRing.Remove("MyAnimeListAccessToken")
|
accessTokenErr := myAnimeListRing.Remove("MyAnimeListAccessToken")
|
||||||
err = myAnimeListRing.Remove("MyAnimeListRefreshToken")
|
refreshTokenErr := myAnimeListRing.Remove("MyAnimeListRefreshToken")
|
||||||
|
if typeErr != nil || expiresInErr != nil || accessTokenErr != nil || refreshTokenErr != nil {
|
||||||
if err != nil {
|
fmt.Println("MAL Logout Failed")
|
||||||
fmt.Println("MAL Logout Failed", err)
|
|
||||||
}
|
}
|
||||||
|
myAnimeListJwt = MyAnimeListJWT{}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "MAL Logged Out Successfully"
|
return "MAL Logged Out Successfully"
|
||||||
|
29
README.md
29
README.md
@ -2,10 +2,35 @@
|
|||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
||||||
Track anime shows by syncing with various services. Anilist, MyAnimeList, Kitsu, Simkl...
|
Track the anime you are watching by syncing with various services. Anilist, MyAnimeList, Simkl...
|
||||||
|
|
||||||
This has been built with the official Wails Svelte-TS template.
|
This has been built with the official Wails Svelte-TS template.
|
||||||
|
|
||||||
|
To run as is, please feel free to download a binary from the releases page.
|
||||||
|
|
||||||
|
If you are getting too many errors due to api usage, please build from source.
|
||||||
|
|
||||||
|
## Build from Source
|
||||||
|
|
||||||
|
### Get API Keys
|
||||||
|
First you will need your own API keys for the various services the app connects to.
|
||||||
|
AniList: [AniList Developer App](https://anilist.co/settings/developer)
|
||||||
|
MyAnimeList: [MyAnimeList Developer App](https://myanimelist.net/apiconfig/create)
|
||||||
|
Simkl: [Simkl Developer](https://simkl.com/settings/developer/)
|
||||||
|
|
||||||
|
- Name: AniTrack
|
||||||
|
- Redirect URL: http://localhost:6734/callback
|
||||||
|
- App Type: web
|
||||||
|
- Homepage URL: http://localhost or the Github URL
|
||||||
|
- Company Name: AniTrack
|
||||||
|
- Commercial/Non-Commercial: non-commercial
|
||||||
|
- Purpose of Use: hobbyist
|
||||||
|
|
||||||
|
Once you have the IDs, Keys, and Secrets create an environment.go file based on the environment.go.example and fill in the fields.
|
||||||
|
|
||||||
|
### Install Wails and Dependencies
|
||||||
|
Please follow the instructions [here](https://wails.io/docs/gettingstarted/installation) to get Wails up and running and follow the instructions below.
|
||||||
|
|
||||||
## Live Development
|
## Live Development
|
||||||
|
|
||||||
To run in live development mode, run `wails dev` in the project directory. This will run a Vite development
|
To run in live development mode, run `wails dev` in the project directory. This will run a Vite development
|
||||||
@ -15,4 +40,4 @@ to this in your browser, and you can call your Go code from devtools.
|
|||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
To build a redistributable, production mode package, use `wails build`.
|
To build a redistributable, production mode package, use `wails build --clean`.
|
||||||
|
@ -7,55 +7,34 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"reflect"
|
||||||
|
"slices"
|
||||||
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *App) SimklGetUserWatchlist() SimklWatchList {
|
var SimklWatchList SimklWatchListType
|
||||||
client := &http.Client{}
|
|
||||||
|
|
||||||
req, _ := http.NewRequest("GET", "https://api.simkl.com/sync/all-items/anime/watching", nil)
|
func SimklHelper(method string, url string, body interface{}) json.RawMessage {
|
||||||
|
|
||||||
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 resp.Body.Close()
|
|
||||||
respBody, _ := io.ReadAll(resp.Body)
|
|
||||||
|
|
||||||
var watchlist SimklWatchList
|
|
||||||
|
|
||||||
err = json.Unmarshal(respBody, &watchlist)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("Failed at unmarshal, %s\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
return watchlist
|
|
||||||
}
|
|
||||||
|
|
||||||
func SimklPostHelper(url string, body interface{}) json.RawMessage {
|
|
||||||
reader, _ := json.Marshal(body)
|
reader, _ := json.Marshal(body)
|
||||||
|
var req *http.Request
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
|
|
||||||
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(reader))
|
if body != nil {
|
||||||
|
req, _ = http.NewRequest(method, url, bytes.NewBuffer(reader))
|
||||||
|
} else {
|
||||||
|
req, _ = http.NewRequest(method, url, nil)
|
||||||
|
}
|
||||||
|
|
||||||
req.Header.Add("Content-Type", "application/json")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
req.Header.Add("Authorization", "Bearer "+simklJwt.AccessToken)
|
req.Header.Add("Authorization", "Bearer "+simklJwt.AccessToken)
|
||||||
req.Header.Add("simkl-api-key", os.Getenv("SIMKL_CLIENT_ID"))
|
req.Header.Add("simkl-api-key", Environment.SIMKL_CLIENT_ID)
|
||||||
|
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Errored when sending request to the server")
|
fmt.Println("Errored when sending request to the server")
|
||||||
message, _ := json.Marshal(struct {
|
message, _ := json.Marshal(struct {
|
||||||
Message string `json:"message" ts_type:"message"`
|
Message string `json:"message"`
|
||||||
}{
|
}{
|
||||||
Message: "Errored when sending request to the server" + err.Error(),
|
Message: "Errored when sending request to the server" + err.Error(),
|
||||||
})
|
})
|
||||||
@ -67,11 +46,42 @@ func SimklPostHelper(url string, body interface{}) json.RawMessage {
|
|||||||
respBody, _ := io.ReadAll(resp.Body)
|
respBody, _ := io.ReadAll(resp.Body)
|
||||||
|
|
||||||
return respBody
|
return respBody
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) SimklSyncEpisodes(anime Anime, progress int) interface{} {
|
func (a *App) SimklGetUserWatchlist() SimklWatchListType {
|
||||||
|
method := "GET"
|
||||||
|
url := "https://api.simkl.com/sync/all-items/anime"
|
||||||
|
|
||||||
|
respBody := SimklHelper(method, url, nil)
|
||||||
|
|
||||||
|
var errCheck struct {
|
||||||
|
Error string `json:"error"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err := json.Unmarshal(respBody, &errCheck)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if errCheck.Error != "" {
|
||||||
|
a.LogoutSimkl()
|
||||||
|
return SimklWatchListType{}
|
||||||
|
}
|
||||||
|
|
||||||
|
var watchlist SimklWatchListType
|
||||||
|
|
||||||
|
err = json.Unmarshal(respBody, &watchlist)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
SimklWatchList = watchlist
|
||||||
|
|
||||||
|
return watchlist
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) SimklSyncEpisodes(anime SimklAnime, progress int) SimklAnime {
|
||||||
var episodes []Episode
|
var episodes []Episode
|
||||||
var url string
|
var url string
|
||||||
var shows []SimklPostShow
|
var shows []SimklPostShow
|
||||||
@ -102,7 +112,7 @@ func (a *App) SimklSyncEpisodes(anime Anime, progress int) interface{} {
|
|||||||
|
|
||||||
simklSync := SimklSyncHistoryType{shows}
|
simklSync := SimklSyncHistoryType{shows}
|
||||||
|
|
||||||
respBody := SimklPostHelper(url, simklSync)
|
respBody := SimklHelper("POST", url, simklSync)
|
||||||
|
|
||||||
var success interface{}
|
var success interface{}
|
||||||
|
|
||||||
@ -111,12 +121,22 @@ func (a *App) SimklSyncEpisodes(anime Anime, progress int) interface{} {
|
|||||||
log.Printf("Failed at unmarshal, %s\n", err)
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return success
|
for i, simklAnime := range SimklWatchList.Anime {
|
||||||
|
if anime.Show.Ids.Simkl == simklAnime.Show.Ids.Simkl {
|
||||||
|
SimklWatchList.Anime[i].WatchedEpisodesCount = progress
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
anime.WatchedEpisodesCount = progress
|
||||||
|
|
||||||
|
WatchListUpdate(anime)
|
||||||
|
|
||||||
|
return anime
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) SimklSyncRating(anime Anime, rating int) interface{} {
|
func (a *App) SimklSyncRating(anime SimklAnime, rating int) SimklAnime {
|
||||||
var url string
|
var url string
|
||||||
var showWithRating = ShowWithRating{
|
showWithRating := ShowWithRating{
|
||||||
Title: anime.Show.Title,
|
Title: anime.Show.Title,
|
||||||
Ids: Ids{
|
Ids: Ids{
|
||||||
Simkl: anime.Show.Ids.Simkl,
|
Simkl: anime.Show.Ids.Simkl,
|
||||||
@ -126,7 +146,7 @@ func (a *App) SimklSyncRating(anime Anime, rating int) interface{} {
|
|||||||
Rating: rating,
|
Rating: rating,
|
||||||
}
|
}
|
||||||
|
|
||||||
var showWithoutRating = ShowWithoutRating{
|
showWithoutRating := ShowWithoutRating{
|
||||||
Title: anime.Show.Title,
|
Title: anime.Show.Title,
|
||||||
Ids: Ids{
|
Ids: Ids{
|
||||||
Simkl: anime.Show.Ids.Simkl,
|
Simkl: anime.Show.Ids.Simkl,
|
||||||
@ -149,7 +169,7 @@ func (a *App) SimklSyncRating(anime Anime, rating int) interface{} {
|
|||||||
Shows []interface{} `json:"shows" ts_type:"shows"`
|
Shows []interface{} `json:"shows" ts_type:"shows"`
|
||||||
}{shows}
|
}{shows}
|
||||||
|
|
||||||
respBody := SimklPostHelper(url, simklSync)
|
respBody := SimklHelper("POST", url, simklSync)
|
||||||
|
|
||||||
var success interface{}
|
var success interface{}
|
||||||
|
|
||||||
@ -158,12 +178,22 @@ func (a *App) SimklSyncRating(anime Anime, rating int) interface{} {
|
|||||||
log.Printf("Failed at unmarshal, %s\n", err)
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return success
|
for i, simklAnime := range SimklWatchList.Anime {
|
||||||
|
if anime.Show.Ids.Simkl == simklAnime.Show.Ids.Simkl {
|
||||||
|
SimklWatchList.Anime[i].UserRating = rating
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
anime.UserRating = rating
|
||||||
|
|
||||||
|
WatchListUpdate(anime)
|
||||||
|
|
||||||
|
return anime
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) SimklSyncStatus(anime Anime, status string) interface{} {
|
func (a *App) SimklSyncStatus(anime SimklAnime, status string) SimklAnime {
|
||||||
url := "https://api.simkl.com/sync/add-to-list"
|
url := "https://api.simkl.com/sync/add-to-list"
|
||||||
var show = SimklShowStatus{
|
show := SimklShowStatus{
|
||||||
Title: anime.Show.Title,
|
Title: anime.Show.Title,
|
||||||
Ids: Ids{
|
Ids: Ids{
|
||||||
Simkl: anime.Show.Ids.Simkl,
|
Simkl: anime.Show.Ids.Simkl,
|
||||||
@ -181,7 +211,7 @@ func (a *App) SimklSyncStatus(anime Anime, status string) interface{} {
|
|||||||
Shows []SimklShowStatus `json:"shows" ts_type:"shows"`
|
Shows []SimklShowStatus `json:"shows" ts_type:"shows"`
|
||||||
}{shows}
|
}{shows}
|
||||||
|
|
||||||
respBody := SimklPostHelper(url, simklSync)
|
respBody := SimklHelper("POST", url, simklSync)
|
||||||
|
|
||||||
var success interface{}
|
var success interface{}
|
||||||
|
|
||||||
@ -190,5 +220,129 @@ func (a *App) SimklSyncStatus(anime Anime, status string) interface{} {
|
|||||||
log.Printf("Failed at unmarshal, %s\n", err)
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return success
|
for i, simklAnime := range SimklWatchList.Anime {
|
||||||
|
if anime.Show.Ids.Simkl == simklAnime.Show.Ids.Simkl {
|
||||||
|
SimklWatchList.Anime[i].Status = status
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
anime.Status = status
|
||||||
|
|
||||||
|
WatchListUpdate(anime)
|
||||||
|
|
||||||
|
return anime
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) SimklSearch(aniListAnime MediaList) SimklAnime {
|
||||||
|
var result SimklAnime
|
||||||
|
|
||||||
|
if reflect.DeepEqual(SimklWatchList, SimklWatchListType{}) {
|
||||||
|
fmt.Println("Watchlist empty. Calling...")
|
||||||
|
SimklWatchList = a.SimklGetUserWatchlist()
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, anime := range SimklWatchList.Anime {
|
||||||
|
id, err := strconv.Atoi(anime.Show.Ids.AniList)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("AniList ID does not exist on " + anime.Show.Title)
|
||||||
|
}
|
||||||
|
if id == aniListAnime.Media.ID {
|
||||||
|
result = anime
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if reflect.DeepEqual(result, SimklAnime{}) {
|
||||||
|
var anime SimklSearchType
|
||||||
|
url := "https://api.simkl.com/search/id?anilist=" + strconv.Itoa(aniListAnime.Media.ID)
|
||||||
|
|
||||||
|
respBody := SimklHelper("GET", url, nil)
|
||||||
|
|
||||||
|
err := json.Unmarshal(respBody, &anime)
|
||||||
|
|
||||||
|
if len(anime) == 0 {
|
||||||
|
url = "https://api.simkl.com/search/id?mal=" + strconv.Itoa(aniListAnime.Media.IDMal)
|
||||||
|
respBody = SimklHelper("GET", url, nil)
|
||||||
|
fmt.Println(string(respBody))
|
||||||
|
err = json.Unmarshal(respBody, &anime)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(anime) == 0 {
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, watchListAnime := range SimklWatchList.Anime {
|
||||||
|
id := watchListAnime.Show.Ids.Simkl
|
||||||
|
if id == anime[0].Ids.Simkl {
|
||||||
|
result = watchListAnime
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if reflect.DeepEqual(result, SimklAnime{}) && len(anime) > 0 {
|
||||||
|
result.Show.Title = anime[0].Title
|
||||||
|
result.Show.Poster = anime[0].Poster
|
||||||
|
result.Show.Ids.Simkl = anime[0].Ids.Simkl
|
||||||
|
result.Show.Ids.Slug = anime[0].Ids.Slug
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *App) SimklSyncRemove(anime SimklAnime) bool {
|
||||||
|
url := "https://api.simkl.com/sync/history/remove"
|
||||||
|
var showArray []SimklShowStatus
|
||||||
|
|
||||||
|
singleShow := SimklShowStatus{
|
||||||
|
Title: anime.Show.Title,
|
||||||
|
Ids: Ids{
|
||||||
|
Simkl: anime.Show.Ids.Simkl,
|
||||||
|
Mal: anime.Show.Ids.Mal,
|
||||||
|
Anilist: anime.Show.Ids.AniList,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
showArray = append(showArray, singleShow)
|
||||||
|
|
||||||
|
show := struct {
|
||||||
|
Shows []SimklShowStatus `json:"shows"`
|
||||||
|
}{
|
||||||
|
Shows: showArray,
|
||||||
|
}
|
||||||
|
|
||||||
|
respBody := SimklHelper("POST", url, show)
|
||||||
|
|
||||||
|
var success SimklDeleteType
|
||||||
|
|
||||||
|
err := json.Unmarshal(respBody, &success)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if success.Deleted.Shows >= 1 {
|
||||||
|
for i, simklAnime := range SimklWatchList.Anime {
|
||||||
|
if simklAnime.Show.Ids.Simkl == anime.Show.Ids.Simkl {
|
||||||
|
SimklWatchList.Anime = slices.Delete(SimklWatchList.Anime, i, i+1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func WatchListUpdate(anime SimklAnime) {
|
||||||
|
updated := false
|
||||||
|
for i, simklAnime := range SimklWatchList.Anime {
|
||||||
|
if simklAnime.Show.Ids.Simkl == anime.Show.Ids.Simkl {
|
||||||
|
SimklWatchList.Anime[i] = anime
|
||||||
|
updated = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !updated {
|
||||||
|
SimklWatchList.Anime = append(SimklWatchList.Anime, anime)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,14 +26,14 @@ type SimklUser struct {
|
|||||||
} `json:"connections" ts_type:"connections"`
|
} `json:"connections" ts_type:"connections"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type SimklWatchList struct {
|
type SimklWatchListType struct {
|
||||||
Anime []Anime `json:"anime" ts_type:"anime"`
|
Anime []SimklAnime `json:"anime" ts_type:"anime"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Anime struct {
|
type SimklAnime struct {
|
||||||
LastWatchedAt string `json:"last_watched_at" ts_type:"last_watched_at"`
|
LastWatchedAt string `json:"last_watched_at" ts_type:"last_watched_at"`
|
||||||
Status string `json:"status" ts_type:"status"`
|
Status string `json:"status" ts_type:"status"`
|
||||||
UserRating float64 `json:"user_rating" ts_type:"user_rating"`
|
UserRating int `json:"user_rating" ts_type:"user_rating"`
|
||||||
LastWatched string `json:"last_watched" ts_type:"last_watched"`
|
LastWatched string `json:"last_watched" ts_type:"last_watched"`
|
||||||
NextToWatch string `json:"next_to_watch" ts_type:"next_to_watch"`
|
NextToWatch string `json:"next_to_watch" ts_type:"next_to_watch"`
|
||||||
WatchedEpisodesCount int `json:"watched_episodes_count" ts_type:"watched_episodes_count"`
|
WatchedEpisodesCount int `json:"watched_episodes_count" ts_type:"watched_episodes_count"`
|
||||||
@ -105,3 +105,29 @@ type SimklShowStatus struct {
|
|||||||
Ids `json:"ids" ts_type:"ids"`
|
Ids `json:"ids" ts_type:"ids"`
|
||||||
To string `json:"to" ts_type:"to"`
|
To string `json:"to" ts_type:"to"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SimklSearchType []struct {
|
||||||
|
Type string `json:"type"`
|
||||||
|
Title string `json:"title"`
|
||||||
|
Poster string `json:"poster"`
|
||||||
|
Year int `json:"year"`
|
||||||
|
Status string `json:"status"`
|
||||||
|
Ids struct {
|
||||||
|
Simkl int `json:"simkl"`
|
||||||
|
Slug string `json:"slug"`
|
||||||
|
} `json:"ids"`
|
||||||
|
TotalEpisodes int `json:"total_episodes"`
|
||||||
|
AnimeType string `json:"anime_type"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type SimklDeleteType struct {
|
||||||
|
Deleted struct {
|
||||||
|
Movies int `json:"movies"`
|
||||||
|
Shows int `json:"shows"`
|
||||||
|
Episodes int `json:"episodes"`
|
||||||
|
} `json:"deleted"`
|
||||||
|
NotFound struct {
|
||||||
|
Movies []interface{} `json:"movies"`
|
||||||
|
Shows []interface{} `json:"shows"`
|
||||||
|
} `json:"not_found"`
|
||||||
|
}
|
||||||
|
@ -4,11 +4,11 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"github.com/99designs/keyring"
|
"github.com/99designs/keyring"
|
||||||
@ -19,16 +19,20 @@ var simklJwt SimklJWT
|
|||||||
|
|
||||||
var simklRing, _ = keyring.Open(keyring.Config{
|
var simklRing, _ = keyring.Open(keyring.Config{
|
||||||
ServiceName: "AniTrack",
|
ServiceName: "AniTrack",
|
||||||
|
KeychainName: "AniTrack",
|
||||||
|
KeychainSynchronizable: false,
|
||||||
|
KeychainTrustApplication: true,
|
||||||
|
KeychainAccessibleWhenUnlocked: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
var simklCtxShutdown, simklCancel = context.WithCancel(context.Background())
|
var simklCtxShutdown, simklCancel = context.WithCancel(context.Background())
|
||||||
|
|
||||||
func (a *App) CheckIfSimklLoggedIn() bool {
|
func (a *App) CheckIfSimklLoggedIn() bool {
|
||||||
if (SimklJWT{} == simklJwt) {
|
if (SimklJWT{} == simklJwt) {
|
||||||
tokenType, err := simklRing.Get("SimklTokenType")
|
tokenType, tokenTypeErr := simklRing.Get("SimklTokenType")
|
||||||
accessToken, err := simklRing.Get("SimklAccessToken")
|
accessToken, accessTokenErr := simklRing.Get("SimklAccessToken")
|
||||||
scope, err := simklRing.Get("SimklScope")
|
scope, scopeErr := simklRing.Get("SimklScope")
|
||||||
if err != nil || len(accessToken.Data) == 0 {
|
if (tokenTypeErr != nil || accessTokenErr != nil || scopeErr != nil) || len(accessToken.Data) == 0 {
|
||||||
return false
|
return false
|
||||||
} else {
|
} else {
|
||||||
simklJwt.TokenType = string(tokenType.Data)
|
simklJwt.TokenType = string(tokenType.Data)
|
||||||
@ -42,13 +46,13 @@ func (a *App) CheckIfSimklLoggedIn() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) SimklLogin() {
|
func (a *App) SimklLogin() {
|
||||||
if a.CheckIfSimklLoggedIn() == false {
|
if !a.CheckIfSimklLoggedIn() {
|
||||||
tokenType, err := simklRing.Get("SimklTokenType")
|
tokenType, tokenTypeErr := simklRing.Get("SimklTokenType")
|
||||||
accessToken, err := simklRing.Get("SimklAccessToken")
|
accessToken, accessTokenErr := simklRing.Get("SimklAccessToken")
|
||||||
scope, err := simklRing.Get("SimklScope")
|
scope, scopeErr := simklRing.Get("SimklScope")
|
||||||
if err != nil || len(accessToken.Data) == 0 {
|
if (tokenTypeErr != nil || accessTokenErr != nil || scopeErr != nil) || len(accessToken.Data) == 0 {
|
||||||
getSimklCodeUrl := "https://simkl.com/oauth/authorize?response_type=code&client_id=" + os.Getenv("SIMKL_CLIENT_ID") + "&redirect_uri=" + os.Getenv("SIMKL_CALLBACK_URI")
|
getSimklCodeUrl := "https://simkl.com/oauth/authorize?response_type=code&client_id=" + Environment.SIMKL_CLIENT_ID + "&redirect_uri=" + Environment.SIMKL_CALLBACK_URI
|
||||||
runtime.BrowserOpenURL(a.ctx, getSimklCodeUrl)
|
runtime.BrowserOpenURL(*wailsContext, getSimklCodeUrl)
|
||||||
|
|
||||||
serverDone := &sync.WaitGroup{}
|
serverDone := &sync.WaitGroup{}
|
||||||
serverDone.Add(1)
|
serverDone.Add(1)
|
||||||
@ -88,7 +92,7 @@ func (a *App) handleSimklCallback(wg *sync.WaitGroup) {
|
|||||||
Key: "SimklScope",
|
Key: "SimklScope",
|
||||||
Data: []byte(simklJwt.Scope),
|
Data: []byte(simklJwt.Scope),
|
||||||
})
|
})
|
||||||
_, err := runtime.MessageDialog(a.ctx, runtime.MessageDialogOptions{
|
_, err := runtime.MessageDialog(*wailsContext, runtime.MessageDialogOptions{
|
||||||
Title: "Simkl Authorization",
|
Title: "Simkl Authorization",
|
||||||
Message: "It is now safe to close your browser tab",
|
Message: "It is now safe to close your browser tab",
|
||||||
})
|
})
|
||||||
@ -111,7 +115,7 @@ func (a *App) handleSimklCallback(wg *sync.WaitGroup) {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||||
log.Fatalf("listen: %s\n", err)
|
log.Fatalf("listen: %s\n", err)
|
||||||
}
|
}
|
||||||
fmt.Println("Shutting down...")
|
fmt.Println("Shutting down...")
|
||||||
@ -127,9 +131,9 @@ func getSimklAuthorizationToken(content string) SimklJWT {
|
|||||||
Code string `json:"code"`
|
Code string `json:"code"`
|
||||||
}{
|
}{
|
||||||
GrantType: "authorization_code",
|
GrantType: "authorization_code",
|
||||||
ClientID: os.Getenv("SIMKL_CLIENT_ID"),
|
ClientID: Environment.SIMKL_CLIENT_ID,
|
||||||
ClientSecret: os.Getenv("SIMKL_CLIENT_SECRET"),
|
ClientSecret: Environment.SIMKL_CLIENT_SECRET,
|
||||||
RedirectURI: os.Getenv("SIMKL_CALLBACK_URI"),
|
RedirectURI: Environment.SIMKL_CALLBACK_URI,
|
||||||
Code: content,
|
Code: content,
|
||||||
}
|
}
|
||||||
jsonData, err := json.Marshal(data)
|
jsonData, err := json.Marshal(data)
|
||||||
@ -144,14 +148,17 @@ func getSimklAuthorizationToken(content string) SimklJWT {
|
|||||||
response.Header.Add("Content-Type", "application/json")
|
response.Header.Add("Content-Type", "application/json")
|
||||||
|
|
||||||
client := &http.Client{}
|
client := &http.Client{}
|
||||||
res, reserr := client.Do(response)
|
res, resErr := client.Do(response)
|
||||||
if reserr != nil {
|
if resErr != nil {
|
||||||
log.Printf("Failed at res, %s\n", err)
|
log.Printf("Failed at res, %s\n", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
defer res.Body.Close()
|
defer res.Body.Close()
|
||||||
|
|
||||||
returnedBody, err := io.ReadAll(res.Body)
|
returnedBody, err := io.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Could not read returned body, %s\n.", err)
|
||||||
|
}
|
||||||
|
|
||||||
var post SimklJWT
|
var post SimklJWT
|
||||||
err = json.Unmarshal(returnedBody, &post)
|
err = json.Unmarshal(returnedBody, &post)
|
||||||
@ -171,10 +178,9 @@ func (a *App) GetSimklLoggedInUser() SimklUser {
|
|||||||
|
|
||||||
req.Header.Add("Content-Type", "application/json")
|
req.Header.Add("Content-Type", "application/json")
|
||||||
req.Header.Add("Authorization", "Bearer "+simklJwt.AccessToken)
|
req.Header.Add("Authorization", "Bearer "+simklJwt.AccessToken)
|
||||||
req.Header.Add("simkl-api-key", os.Getenv("SIMKL_CLIENT_ID"))
|
req.Header.Add("simkl-api-key", Environment.SIMKL_CLIENT_ID)
|
||||||
|
|
||||||
response, err := client.Do(req)
|
response, err := client.Do(req)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Failed at request, %s\n", err)
|
log.Printf("Failed at request, %s\n", err)
|
||||||
return SimklUser{}
|
return SimklUser{}
|
||||||
@ -182,10 +188,25 @@ func (a *App) GetSimklLoggedInUser() SimklUser {
|
|||||||
|
|
||||||
defer response.Body.Close()
|
defer response.Body.Close()
|
||||||
|
|
||||||
var user SimklUser
|
|
||||||
|
|
||||||
respBody, _ := io.ReadAll(response.Body)
|
respBody, _ := io.ReadAll(response.Body)
|
||||||
|
|
||||||
|
var errCheck struct {
|
||||||
|
Error string `json:"error"`
|
||||||
|
Message string `json:"message"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err = json.Unmarshal(respBody, &errCheck)
|
||||||
|
if err != nil {
|
||||||
|
log.Printf("Failed at unmarshal, %s\n", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if errCheck.Error != "" {
|
||||||
|
a.LogoutSimkl()
|
||||||
|
return SimklUser{}
|
||||||
|
}
|
||||||
|
|
||||||
|
var user SimklUser
|
||||||
|
|
||||||
err = json.Unmarshal(respBody, &user)
|
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)
|
||||||
@ -196,13 +217,14 @@ func (a *App) GetSimklLoggedInUser() SimklUser {
|
|||||||
|
|
||||||
func (a *App) LogoutSimkl() string {
|
func (a *App) LogoutSimkl() string {
|
||||||
if (SimklJWT{} != simklJwt) {
|
if (SimklJWT{} != simklJwt) {
|
||||||
err := simklRing.Remove("SimklTokenType")
|
tokenTypeErr := simklRing.Remove("SimklTokenType")
|
||||||
err = simklRing.Remove("SimklAccessToken")
|
accessTokenErr := simklRing.Remove("SimklAccessToken")
|
||||||
err = simklRing.Remove("SimklScope")
|
scopeErr := simklRing.Remove("SimklScope")
|
||||||
|
|
||||||
if err != nil {
|
if tokenTypeErr != nil || accessTokenErr != nil || scopeErr != nil {
|
||||||
fmt.Println("Simkl Logout Failed", err)
|
fmt.Println("Simkl Logout Failed")
|
||||||
}
|
}
|
||||||
|
simklJwt = SimklJWT{}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "Simkl Logged Out Successfully"
|
return "Simkl Logged Out Successfully"
|
||||||
|
25
app.go
25
app.go
@ -2,8 +2,19 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
_ "embed"
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/options"
|
||||||
|
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||||
|
"strings"
|
||||||
|
|
||||||
|
"github.com/tidwall/gjson"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//go:embed wails.json
|
||||||
|
var wailsJSON string
|
||||||
|
|
||||||
|
var wailsContext *context.Context
|
||||||
|
|
||||||
// App struct
|
// App struct
|
||||||
type App struct {
|
type App struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
@ -17,6 +28,18 @@ func NewApp() *App {
|
|||||||
// startup is called when the app starts. The context is saved
|
// startup is called when the app starts. The context is saved
|
||||||
// so we can call the runtime methods
|
// so we can call the runtime methods
|
||||||
func (a *App) startup(ctx context.Context) {
|
func (a *App) startup(ctx context.Context) {
|
||||||
a.ctx = ctx
|
version := gjson.Get(wailsJSON, "info.productVersion")
|
||||||
|
wailsContext = &ctx
|
||||||
|
runtime.WindowSetTitle(ctx, "AniTrack "+version.String())
|
||||||
//runtime.WindowMaximise(ctx)
|
//runtime.WindowMaximise(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *App) onSecondInstanceLaunch(secondInstanceData options.SecondInstanceData) {
|
||||||
|
var secondInstanceArgs = secondInstanceData.Args
|
||||||
|
|
||||||
|
println("user opened second instance", strings.Join(secondInstanceData.Args, ","))
|
||||||
|
println("user opened second from", secondInstanceData.WorkingDirectory)
|
||||||
|
runtime.WindowUnminimise(*wailsContext)
|
||||||
|
runtime.Show(*wailsContext)
|
||||||
|
go runtime.EventsEmit(*wailsContext, "launchArgs", secondInstanceArgs)
|
||||||
|
}
|
||||||
|
90
bruno/AniTrack/AniList/Get Items/AniChart.bru
Normal file
90
bruno/AniTrack/AniList/Get Items/AniChart.bru
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
meta {
|
||||||
|
name: AniChart
|
||||||
|
type: graphql
|
||||||
|
seq: 5
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: https://graphql.anilist.co
|
||||||
|
body: graphql
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
|
|
||||||
|
body:graphql {
|
||||||
|
# Write your query or mutation here
|
||||||
|
query ($page: Int, $perPage: Int, $airingAt_greater:Int) {
|
||||||
|
Page(page: $page, perPage: $perPage) {
|
||||||
|
pageInfo {
|
||||||
|
total
|
||||||
|
perPage
|
||||||
|
currentPage
|
||||||
|
lastPage
|
||||||
|
hasNextPage
|
||||||
|
}
|
||||||
|
airingSchedules(airingAt_greater:$airingAt_greater){
|
||||||
|
id
|
||||||
|
airingAt
|
||||||
|
timeUntilAiring
|
||||||
|
episode
|
||||||
|
mediaId
|
||||||
|
media{
|
||||||
|
id
|
||||||
|
title{
|
||||||
|
english
|
||||||
|
romaji
|
||||||
|
native
|
||||||
|
}
|
||||||
|
type
|
||||||
|
format
|
||||||
|
status
|
||||||
|
startDate{
|
||||||
|
year
|
||||||
|
month
|
||||||
|
day
|
||||||
|
}
|
||||||
|
endDate{
|
||||||
|
year
|
||||||
|
month
|
||||||
|
day
|
||||||
|
}
|
||||||
|
season
|
||||||
|
seasonYear
|
||||||
|
episodes
|
||||||
|
duration
|
||||||
|
coverImage{
|
||||||
|
medium
|
||||||
|
large
|
||||||
|
color
|
||||||
|
extraLarge
|
||||||
|
}
|
||||||
|
bannerImage
|
||||||
|
genres
|
||||||
|
averageScore
|
||||||
|
meanScore
|
||||||
|
popularity
|
||||||
|
trending
|
||||||
|
favourites
|
||||||
|
tags{
|
||||||
|
id
|
||||||
|
name
|
||||||
|
description
|
||||||
|
category
|
||||||
|
rank
|
||||||
|
isGeneralSpoiler
|
||||||
|
isMediaSpoiler
|
||||||
|
isAdult
|
||||||
|
}
|
||||||
|
isAdult
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body:graphql:vars {
|
||||||
|
{
|
||||||
|
"page": 50,
|
||||||
|
"perPage": 20,
|
||||||
|
"airingAt_greater": 1730260800
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ post {
|
|||||||
headers {
|
headers {
|
||||||
Content-Type: "application/json"
|
Content-Type: "application/json"
|
||||||
Accept: "application/json"
|
Accept: "application/json"
|
||||||
|
Authorization: Bearer {{ANILIST_ACCESS_TOKEN}}
|
||||||
}
|
}
|
||||||
|
|
||||||
body:graphql {
|
body:graphql {
|
||||||
@ -24,7 +25,7 @@ body:graphql {
|
|||||||
media {
|
media {
|
||||||
id
|
id
|
||||||
idMal
|
idMal
|
||||||
tags{
|
tags {
|
||||||
id
|
id
|
||||||
name
|
name
|
||||||
description
|
description
|
||||||
@ -92,7 +93,7 @@ body:graphql {
|
|||||||
body:graphql:vars {
|
body:graphql:vars {
|
||||||
{
|
{
|
||||||
"userId": 413504,
|
"userId": 413504,
|
||||||
"mediaId": 157371,
|
"mediaId": 170998,
|
||||||
"listType": "ANIME"
|
"listType": "ANIME"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -53,7 +53,7 @@ body:graphql {
|
|||||||
|
|
||||||
body:graphql:vars {
|
body:graphql:vars {
|
||||||
{
|
{
|
||||||
"search": "frieren",
|
"search": "dan-da-dan",
|
||||||
"listType": "ANIME"
|
"listType": "ANIME"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,12 +19,33 @@ headers {
|
|||||||
body:graphql {
|
body:graphql {
|
||||||
mutation($mediaId:Int, $progress:Int, $status:MediaListStatus){
|
mutation($mediaId:Int, $progress:Int, $status:MediaListStatus){
|
||||||
SaveMediaListEntry(mediaId:$mediaId, progress:$progress, status:$status){
|
SaveMediaListEntry(mediaId:$mediaId, progress:$progress, status:$status){
|
||||||
|
id
|
||||||
mediaId
|
mediaId
|
||||||
progress
|
userId
|
||||||
|
media {
|
||||||
|
id
|
||||||
|
idMal
|
||||||
|
title {
|
||||||
|
romaji
|
||||||
|
english
|
||||||
|
native
|
||||||
|
}
|
||||||
|
description
|
||||||
|
coverImage {
|
||||||
|
large
|
||||||
|
}
|
||||||
|
season
|
||||||
|
seasonYear
|
||||||
|
status
|
||||||
|
episodes
|
||||||
|
nextAiringEpisode {
|
||||||
|
airingAt
|
||||||
|
timeUntilAiring
|
||||||
|
episode
|
||||||
|
}
|
||||||
|
isAdult
|
||||||
|
}
|
||||||
status
|
status
|
||||||
score
|
|
||||||
repeat
|
|
||||||
notes
|
|
||||||
startedAt{
|
startedAt{
|
||||||
year
|
year
|
||||||
month
|
month
|
||||||
@ -35,14 +56,35 @@ body:graphql {
|
|||||||
month
|
month
|
||||||
day
|
day
|
||||||
}
|
}
|
||||||
|
notes
|
||||||
|
progress
|
||||||
|
score
|
||||||
|
repeat
|
||||||
|
user {
|
||||||
|
id
|
||||||
|
name
|
||||||
|
avatar{
|
||||||
|
large
|
||||||
|
medium
|
||||||
|
}
|
||||||
|
statistics{
|
||||||
|
anime{
|
||||||
|
count
|
||||||
|
statuses{
|
||||||
|
status
|
||||||
|
count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body:graphql:vars {
|
body:graphql:vars {
|
||||||
{
|
{
|
||||||
"mediaId": 1,
|
"mediaId": 169417,
|
||||||
"progress": 26,
|
"progress": 12,
|
||||||
"status":"COMPLETED"
|
"status":"COMPLETED"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
31
bruno/AniTrack/AniList/Set Items/Delete Media.bru
Normal file
31
bruno/AniTrack/AniList/Set Items/Delete Media.bru
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
meta {
|
||||||
|
name: Delete Media
|
||||||
|
type: graphql
|
||||||
|
seq: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: https://graphql.anilist.co
|
||||||
|
body: graphql
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
|
|
||||||
|
headers {
|
||||||
|
Authorization: Bearer {{ANILIST_ACCESS_TOKEN}}
|
||||||
|
Content-Type: application/json
|
||||||
|
Accept: application/json
|
||||||
|
}
|
||||||
|
|
||||||
|
body:graphql {
|
||||||
|
mutation($id:Int){
|
||||||
|
DeleteMediaListEntry(id:$id){
|
||||||
|
deleted
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
body:graphql:vars {
|
||||||
|
{
|
||||||
|
"id":430978266
|
||||||
|
}
|
||||||
|
}
|
25
bruno/AniTrack/MAL/Get AnimeList.bru
Normal file
25
bruno/AniTrack/MAL/Get AnimeList.bru
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
meta {
|
||||||
|
name: Get AnimeList
|
||||||
|
type: http
|
||||||
|
seq: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: https://api.myanimelist.net/v2/users/{{MAL_USER}}/animelist?fields=list_status&status=watching&limit=1000
|
||||||
|
body: formUrlEncoded
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
params:query {
|
||||||
|
fields: list_status
|
||||||
|
status: watching
|
||||||
|
limit: 1000
|
||||||
|
}
|
||||||
|
|
||||||
|
headers {
|
||||||
|
:
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{MAL_ACCESS_TOKEN}}
|
||||||
|
}
|
24
bruno/AniTrack/MAL/Get Authorization.bru
Normal file
24
bruno/AniTrack/MAL/Get Authorization.bru
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
meta {
|
||||||
|
name: Get Authorization
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: https://myanimelist.net/v1/oauth2/token
|
||||||
|
body: formUrlEncoded
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
|
|
||||||
|
headers {
|
||||||
|
Content-Type: application/x-www-form-urlencoded
|
||||||
|
}
|
||||||
|
|
||||||
|
body:form-urlencoded {
|
||||||
|
grant_type: authorization_code
|
||||||
|
client_id: {{MAL_CLIENT_ID}}
|
||||||
|
client_secret: {{MAL_CLIENT_SECRET}}
|
||||||
|
redirect_uri: {{MAL_CALLBACK_URI}}
|
||||||
|
code: {{MAL_CODE}}
|
||||||
|
code_verifier: {{MAL_VERIFIER}}
|
||||||
|
}
|
19
bruno/AniTrack/MAL/Get Single Anime.bru
Normal file
19
bruno/AniTrack/MAL/Get Single Anime.bru
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
meta {
|
||||||
|
name: Get Single Anime
|
||||||
|
type: http
|
||||||
|
seq: 5
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: https://api.myanimelist.net/v2/anime/57380?fields=id,title,main_picture,alternative_titles,start_date,end_date,synopsis,mean,rank,popularity,num_list_users,num_scoring_users,nsfw,genres,created_at,updated_at,media_type,status,my_list_status,num_episodes,start_season,broadcast,source,average_episode_duration,rating,pictures,background,related_anime,recommendations,studios,statistics
|
||||||
|
body: none
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
params:query {
|
||||||
|
fields: id,title,main_picture,alternative_titles,start_date,end_date,synopsis,mean,rank,popularity,num_list_users,num_scoring_users,nsfw,genres,created_at,updated_at,media_type,status,my_list_status,num_episodes,start_season,broadcast,source,average_episode_duration,rating,pictures,background,related_anime,recommendations,studios,statistics
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{MAL_ACCESS_TOKEN}}
|
||||||
|
}
|
18
bruno/AniTrack/MAL/MAL Oauth Page.bru
Normal file
18
bruno/AniTrack/MAL/MAL Oauth Page.bru
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
meta {
|
||||||
|
name: MAL Oauth Page
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: https://myanimelist.net/v1/oauth2/authorize?response_type=code&client_id={{MAL_CLIENT_ID}}&redirect_uri={{MAL_CALLBACK_URI}}
|
||||||
|
body: none
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
|
|
||||||
|
params:query {
|
||||||
|
response_type: code
|
||||||
|
client_id: {{MAL_CLIENT_ID}}
|
||||||
|
redirect_uri: {{MAL_CALLBACK_URI}}
|
||||||
|
:
|
||||||
|
}
|
19
bruno/AniTrack/MAL/Update Anime Status.bru
Normal file
19
bruno/AniTrack/MAL/Update Anime Status.bru
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
meta {
|
||||||
|
name: Update Anime Status
|
||||||
|
type: http
|
||||||
|
seq: 4
|
||||||
|
}
|
||||||
|
|
||||||
|
patch {
|
||||||
|
url: https://api.myanimelist.net/v2/anime/50205/my_list_status
|
||||||
|
body: formUrlEncoded
|
||||||
|
auth: bearer
|
||||||
|
}
|
||||||
|
|
||||||
|
auth:bearer {
|
||||||
|
token: {{MAL_ACCESS_TOKEN}}
|
||||||
|
}
|
||||||
|
|
||||||
|
body:form-urlencoded {
|
||||||
|
num_watched_episodes: 3
|
||||||
|
}
|
19
bruno/AniTrack/Simkl/Get Items/Get Anime Full Info.bru
Normal file
19
bruno/AniTrack/Simkl/Get Items/Get Anime Full Info.bru
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
meta {
|
||||||
|
name: Get Anime Full Info
|
||||||
|
type: http
|
||||||
|
seq: 3
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: https://api.simkl.com/anime/40084?extended=full
|
||||||
|
body: none
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
|
|
||||||
|
params:query {
|
||||||
|
extended: full
|
||||||
|
}
|
||||||
|
|
||||||
|
headers {
|
||||||
|
simkl-api-key: {{SIMKL_CLIENT_ID}}
|
||||||
|
}
|
@ -5,7 +5,7 @@ meta {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get {
|
get {
|
||||||
url: https://api.simkl.com/sync/all-items/anime/watching
|
url: https://api.simkl.com/sync/all-items/anime/
|
||||||
body: none
|
body: none
|
||||||
auth: none
|
auth: none
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,19 @@
|
|||||||
|
meta {
|
||||||
|
name: Search By MalID to Get Simkl ID
|
||||||
|
type: http
|
||||||
|
seq: 1
|
||||||
|
}
|
||||||
|
|
||||||
|
get {
|
||||||
|
url: https://api.simkl.com/search/id?anilist=174576
|
||||||
|
body: none
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
|
|
||||||
|
params:query {
|
||||||
|
anilist: 174576
|
||||||
|
}
|
||||||
|
|
||||||
|
headers {
|
||||||
|
simkl-api-key: {{SIMKL_CLIENT_ID}}
|
||||||
|
}
|
@ -1,16 +0,0 @@
|
|||||||
meta {
|
|
||||||
name: Search By MalID
|
|
||||||
type: http
|
|
||||||
seq: 1
|
|
||||||
}
|
|
||||||
|
|
||||||
get {
|
|
||||||
url: https://api.simkl.com/search/id?client_id={{SIMKL_CLIENT_ID}}&simkl=2307708
|
|
||||||
body: none
|
|
||||||
auth: none
|
|
||||||
}
|
|
||||||
|
|
||||||
params:query {
|
|
||||||
client_id: {{SIMKL_CLIENT_ID}}
|
|
||||||
simkl: 2307708
|
|
||||||
}
|
|
29
bruno/AniTrack/Simkl/Post Items/Delete Entry.bru
Normal file
29
bruno/AniTrack/Simkl/Post Items/Delete Entry.bru
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
meta {
|
||||||
|
name: Delete Entry
|
||||||
|
type: http
|
||||||
|
seq: 2
|
||||||
|
}
|
||||||
|
|
||||||
|
post {
|
||||||
|
url: https://api.simkl.com/sync/history/remove
|
||||||
|
body: json
|
||||||
|
auth: none
|
||||||
|
}
|
||||||
|
|
||||||
|
headers {
|
||||||
|
Authorization: Bearer {{SIMKL_AUTH_TOKEN}}
|
||||||
|
Content-Type: application/json
|
||||||
|
simkl-api-key: {{SIMKL_CLIENT_ID}}
|
||||||
|
}
|
||||||
|
|
||||||
|
body:json {
|
||||||
|
{
|
||||||
|
"shows": [
|
||||||
|
{
|
||||||
|
"ids": {
|
||||||
|
"simkl": 909121
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
@ -8,9 +8,11 @@ vars {
|
|||||||
MAL_CALLBACK_URI: {{process.env.MAL_CALLBACK_URI}}
|
MAL_CALLBACK_URI: {{process.env.MAL_CALLBACK_URI}}
|
||||||
}
|
}
|
||||||
vars:secret [
|
vars:secret [
|
||||||
|
ANILIST_ACCESS_TOKEN,
|
||||||
code,
|
code,
|
||||||
SIMKL_AUTH_TOKEN,
|
SIMKL_AUTH_TOKEN,
|
||||||
ANILIST_ACCESS_TOKEN,
|
|
||||||
MAL_CODE,
|
MAL_CODE,
|
||||||
MAL_VERIFIER
|
MAL_VERIFIER,
|
||||||
|
MAL_USER,
|
||||||
|
~MAL_ACCESS_TOKEN
|
||||||
]
|
]
|
||||||
|
11
build/AniTrack.desktop
Executable file
11
build/AniTrack.desktop
Executable file
@ -0,0 +1,11 @@
|
|||||||
|
[Desktop Entry]
|
||||||
|
Name=AniTrack
|
||||||
|
Comment=A manual synchronizer for various Anime trackers.
|
||||||
|
Exec=/home/nymusicman/Applications/AniTrack
|
||||||
|
Icon=AniTrack
|
||||||
|
Terminal=false
|
||||||
|
Type=Application
|
||||||
|
StartupNotify=true
|
||||||
|
Categories=Internet
|
||||||
|
Keywords=anitrack;anilist;simkl;mal;myanimelist;anime;sync
|
||||||
|
Path=
|
BIN
build/AniTrack.png
Normal file
BIN
build/AniTrack.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 53 KiB |
Binary file not shown.
Before Width: | Height: | Size: 130 KiB |
@ -1,6 +1,11 @@
|
|||||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
<plist version="1.0">
|
<plist version="1.0">
|
||||||
<dict>
|
<dict>
|
||||||
|
<key>NSAppTransportSecurity</key>
|
||||||
|
<dict>
|
||||||
|
<key>NSAllowsLocalNetworking</key>
|
||||||
|
<true />
|
||||||
|
</dict>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 15 KiB |
16
environmentType.go
Normal file
16
environmentType.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
type EnvironmentStruct struct {
|
||||||
|
ANILIST_SECRET_TOKEN string
|
||||||
|
ANILIST_APP_ID string
|
||||||
|
ANILIST_APP_NAME string
|
||||||
|
ANILIST_CALLBACK_URI string
|
||||||
|
SIMKL_CLIENT_ID string
|
||||||
|
SIMKL_CLIENT_SECRET string
|
||||||
|
SIMKL_CALLBACK_URI string
|
||||||
|
MAL_CLIENT_ID string
|
||||||
|
MAL_CLIENT_SECRET string
|
||||||
|
MAL_CALLBACK_URI string
|
||||||
|
}
|
||||||
|
|
||||||
|
// created a separate environment.go file and add var Environment EnvironmentStruct = {}
|
@ -1,13 +1,16 @@
|
|||||||
<!DOCTYPE html>
|
<!doctype html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8"/>
|
<meta charset="UTF-8" />
|
||||||
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||||||
<title>AniTrack</title>
|
<title>AniTrack</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="app"></div>
|
<div id="app"></div>
|
||||||
<script src="./src/main.ts" type="module"></script>
|
<script src="./src/main.ts" type="module"></script>
|
||||||
<script src="./node_modules/flowbite/dist/flowbite.js"></script>
|
<script
|
||||||
</body>
|
src="./node_modules/flowbite/dist/flowbite.js"
|
||||||
|
type="module"
|
||||||
|
></script>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -10,24 +10,25 @@
|
|||||||
"check": "svelte-check --tsconfig ./tsconfig.json"
|
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltejs/vite-plugin-svelte": "^1.0.1",
|
"@sveltejs/vite-plugin-svelte": "^2.4.1",
|
||||||
"@tsconfig/svelte": "^3.0.0",
|
"@tsconfig/svelte": "^4.0.1",
|
||||||
"autoprefixer": "^10.4.19",
|
"autoprefixer": "^10.4.20",
|
||||||
"postcss": "^8.4.39",
|
"postcss": "^8.4.45",
|
||||||
"svelte": "^3.49.0",
|
"svelte": "^4.0.0",
|
||||||
"svelte-check": "^2.8.0",
|
"svelte-check": "^3.4.3",
|
||||||
"svelte-preprocess": "^4.10.7",
|
"svelte-headless-table": "^0.18.2",
|
||||||
"tailwind-merge": "^2.4.0",
|
"svelte-preprocess": "^5.0.3",
|
||||||
"tailwindcss": "^3.4.6",
|
"svelte-spa-router": "^4.0.1",
|
||||||
"tslib": "^2.4.0",
|
"tailwind-merge": "^2.5.2",
|
||||||
"typescript": "^4.6.4",
|
"tailwindcss": "^3.4.10",
|
||||||
"vite": "^3.0.7"
|
"tslib": "^2.7.0",
|
||||||
|
"typescript": "^5.0.0",
|
||||||
|
"vite": "^4.5.5"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@ernane/svelte-star-rating": "^1.1.7",
|
|
||||||
"@popperjs/core": "^2.11.8",
|
"@popperjs/core": "^2.11.8",
|
||||||
"flowbite": "^2.4.1",
|
"flowbite": "^2.5.1",
|
||||||
"flowbite-svelte": "^0.46.15",
|
"flowbite-svelte": "^0.46.16",
|
||||||
"moment": "^2.30.1"
|
"moment": "^2.30.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,233 +1,44 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {
|
import {
|
||||||
aniListLoggedIn,
|
aniListAnime,
|
||||||
anilistModal,
|
GetAnimeSingleItem,
|
||||||
aniListPrimary,
|
} from "./helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
aniListUser,
|
|
||||||
malUser,
|
|
||||||
malLoggedIn,
|
|
||||||
aniListWatchlist,
|
|
||||||
GetAniListSingleItemAndOpenModal,
|
|
||||||
simklLoggedIn,
|
|
||||||
simklUser,
|
|
||||||
simklWatchList,
|
|
||||||
title,
|
|
||||||
watchListPage,
|
|
||||||
animePerPage,
|
|
||||||
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
|
||||||
import {
|
|
||||||
CheckIfAniListLoggedIn,
|
|
||||||
CheckIfSimklLoggedIn,
|
|
||||||
CheckIfMyAnimeListLoggedIn,
|
|
||||||
GetAniListLoggedInUser,
|
|
||||||
GetAniListUserWatchingList,
|
|
||||||
GetSimklLoggedInUser,
|
|
||||||
SimklGetUserWatchlist,
|
|
||||||
GetMyAnimeListLoggedInUser,
|
|
||||||
} from "../wailsjs/go/main/App";
|
|
||||||
import {MediaListSort} from "./anilist/types/AniListTypes";
|
|
||||||
import type {AniListCurrentUserWatchList} from "./anilist/types/AniListCurrentUserWatchListType"
|
|
||||||
import Header from "./Header.svelte";
|
|
||||||
import {Rating} from "flowbite-svelte";
|
|
||||||
import {default as Modal} from "./modal/Modal.svelte"
|
|
||||||
import ChangeDataDialogue from "./ChangeDataDialogue.svelte";
|
|
||||||
import {onMount} from "svelte";
|
import {onMount} from "svelte";
|
||||||
|
import Router from "svelte-spa-router"
|
||||||
|
import Home from "./routes/Home.svelte";
|
||||||
let isAniListLoggedIn: boolean
|
import {wrap} from "svelte-spa-router/wrap";
|
||||||
let isAniListPrimary: boolean
|
import Spinner from "./helperComponents/Spinner.svelte";
|
||||||
let aniListWatchListLoaded: AniListCurrentUserWatchList
|
import Header from "./helperComponents/Header.svelte";
|
||||||
|
import {CheckIfAniListLoggedInAndLoadWatchList} from "./helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
|
||||||
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
import { CheckIfMALLoggedInAndSetUser } from "./helperModules/CheckIfMyAnimeListLoggedIn.svelte";
|
||||||
aniListPrimary.subscribe((value) => isAniListPrimary = value)
|
import {CheckIfSimklLoggedInAndSetUser} from "./helperModules/CheckIsSimklLoggedIn.svelte"
|
||||||
aniListWatchlist.subscribe((value) => aniListWatchListLoaded = value)
|
import {CheckIfAniListLoggedIn} from "../wailsjs/go/main/App";
|
||||||
|
import {AniListGetSingleAnimeDefaultData} from "./helperDefaults/AniListGetSingleAnime";
|
||||||
|
|
||||||
let page: number
|
|
||||||
let perPage: number
|
|
||||||
watchListPage.subscribe(value => page = value)
|
|
||||||
animePerPage.subscribe(value => perPage = value)
|
|
||||||
const size = "xl"
|
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
await CheckIfAniListLoggedIn().then(result => {
|
await CheckIfAniListLoggedInAndLoadWatchList()
|
||||||
if (result) {
|
await CheckIfMALLoggedInAndSetUser()
|
||||||
GetAniListLoggedInUser().then(result => {
|
await CheckIfSimklLoggedInAndSetUser()
|
||||||
aniListUser.set(result)
|
|
||||||
if (isAniListPrimary) {
|
|
||||||
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
|
||||||
aniListWatchlist.set(result)
|
|
||||||
aniListLoggedIn.set(true)
|
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
aniListLoggedIn.set(result)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
await CheckIfMyAnimeListLoggedIn().then(result => {
|
|
||||||
if (result) {
|
|
||||||
GetMyAnimeListLoggedInUser().then(result => {
|
|
||||||
malUser.set(result)
|
|
||||||
malLoggedIn.set(result)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
await CheckIfSimklLoggedIn().then(result => {
|
|
||||||
if (result) {
|
|
||||||
GetSimklLoggedInUser().then(result => {
|
|
||||||
simklUser.set(result)
|
|
||||||
SimklGetUserWatchlist().then(result => {
|
|
||||||
simklWatchList.set(result)
|
|
||||||
simklLoggedIn.set(result)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
function ChangeWatchListPage(newPage: number) {
|
|
||||||
GetAniListUserWatchingList(newPage, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
|
||||||
watchListPage.set(newPage)
|
|
||||||
aniListWatchlist.set(result)
|
|
||||||
aniListLoggedIn.set(true)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Header/>
|
<Header />
|
||||||
|
<Router routes={{
|
||||||
<main>
|
'/': Home,
|
||||||
{#if isAniListLoggedIn}
|
'/anime/:id': wrap({
|
||||||
<div class="mx-auto max-w-2xl p-4 sm:p-6 lg:max-w-7xl lg:px-8">
|
asyncComponent: () => import('./routes/AnimeRoutePage.svelte'),
|
||||||
<h1 class="text-left text-xl font-bold mb-4">Your AniList WatchList</h1>
|
conditions: [
|
||||||
|
async () => await CheckIfAniListLoggedIn(),
|
||||||
<div class="mb-8">
|
async (detail) => {
|
||||||
<nav aria-label="Page navigation example">
|
aniListAnime.update(value => {
|
||||||
<ul class="inline-flex -space-x-px text-base h-10">
|
value = AniListGetSingleAnimeDefaultData
|
||||||
{#if page === 1}
|
return value
|
||||||
|
})
|
||||||
<li>
|
await GetAnimeSingleItem(Number(detail.params.id), true)
|
||||||
<button disabled
|
return Object.keys($aniListAnime).length!==0
|
||||||
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 cursor-default">Previous</button>
|
},
|
||||||
</li>
|
],
|
||||||
{:else}
|
loadingComponent: Spinner
|
||||||
<li>
|
}),
|
||||||
<button on:click={() => ChangeWatchListPage(page-1)}
|
// '*': "Not Found"
|
||||||
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Previous</button>
|
}} />
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
{#each {length: aniListWatchListLoaded.data.Page.pageInfo.lastPage} as _, i}
|
|
||||||
{#if i+1 === page}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(i+1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight border border-gray-300 bg-gray-100 dark:border-gray-700 dark:bg-gray-700 dark:text-white">{i+1}</button>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(i+1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">{i+1}</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
|
||||||
{#if page === aniListWatchListLoaded.data.Page.pageInfo.lastPage}
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<button disabled
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 cursor-default">Next</button>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(page+1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Next</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 xl:gap-x-8">
|
|
||||||
{#each aniListWatchListLoaded.data.Page.mediaList as media}
|
|
||||||
<div class="aspect-h-1 aspect-w-1 w-full overflow-hidden rounded-lg xl:aspect-h-8 xl:aspect-w-7">
|
|
||||||
<div class="flex flex-col items-center group">
|
|
||||||
<button on:click={() => GetAniListSingleItemAndOpenModal(media.media.id, true)}>
|
|
||||||
<img class="rounded-lg" src={media.media.coverImage.large} alt={
|
|
||||||
media.media.title.english === "" ?
|
|
||||||
media.media.title.romaji :
|
|
||||||
media.media.title.english
|
|
||||||
}/>
|
|
||||||
</button>
|
|
||||||
<Rating id="anime-rating" total={5} size={35} rating={media.score/2.0}/>
|
|
||||||
<button class="mt-4 text-md font-semibold text-white-700"
|
|
||||||
on:click={() => GetAniListSingleItemAndOpenModal(media.media.id, true)}>
|
|
||||||
{
|
|
||||||
media.media.title.english === "" ?
|
|
||||||
media.media.title.romaji :
|
|
||||||
media.media.title.english
|
|
||||||
}
|
|
||||||
</button>
|
|
||||||
<p class="mt-1 text-lg font-medium text-white-900">{media.progress}
|
|
||||||
/ {media.media.nextAiringEpisode.episode !== 0 ?
|
|
||||||
media.media.nextAiringEpisode.episode - 1 : media.media.episodes}</p>
|
|
||||||
{#if media.media.episodes > 0}
|
|
||||||
<p class="mt-1 text-lg font-medium text-white-900">Total
|
|
||||||
Episodes: {media.media.episodes}</p>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="mt-8">
|
|
||||||
<nav aria-label="Page navigation example">
|
|
||||||
<ul class="inline-flex -space-x-px text-base h-10">
|
|
||||||
{#if page === 1}
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<button disabled
|
|
||||||
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 cursor-default">Previous</button>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(page-1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight text-gray-500 bg-white border border-e-0 border-gray-300 rounded-s-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Previous</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
{#each {length: aniListWatchListLoaded.data.Page.pageInfo.lastPage} as _, i}
|
|
||||||
{#if i+1 === page}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(i+1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight border border-gray-300 bg-gray-100 dark:border-gray-700 dark:bg-gray-700 dark:text-white">{i+1}</button>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(i+1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">{i+1}</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
{/each}
|
|
||||||
{#if page === aniListWatchListLoaded.data.Page.pageInfo.lastPage}
|
|
||||||
|
|
||||||
<li>
|
|
||||||
<button disabled
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 cursor-default">Next</button>
|
|
||||||
</li>
|
|
||||||
{:else}
|
|
||||||
<li>
|
|
||||||
<button on:click={() => ChangeWatchListPage(page+1)}
|
|
||||||
class="flex items-center justify-center px-4 h-10 leading-tight text-gray-500 bg-white border border-gray-300 rounded-e-lg hover:bg-gray-100 hover:text-gray-700 dark:bg-gray-800 dark:border-gray-700 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white">Next</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
</ul>
|
|
||||||
</nav>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<Modal title={$title} bind:open={$anilistModal} {size} autoclose={false}>
|
|
||||||
<ChangeDataDialogue/>
|
|
||||||
</Modal>
|
|
||||||
</main>
|
|
||||||
|
@ -1,76 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
|
|
||||||
import {Avatar} from "flowbite-svelte";
|
|
||||||
import type {AniListUser} from "./anilist/types/AniListTypes";
|
|
||||||
import {aniListLoggedIn, aniListUser, malLoggedIn, simklLoggedIn, logoutOfAniList, logoutOfMAL, logoutOfSimkl} from "./GlobalVariablesAndHelperFunctions.svelte"
|
|
||||||
import * as runtime from "../wailsjs/runtime";
|
|
||||||
|
|
||||||
let currentAniListUser: AniListUser
|
|
||||||
let isAniListLoggedIn: boolean
|
|
||||||
let isSimklLoggedIn: boolean
|
|
||||||
let isMALLoggedIn: boolean
|
|
||||||
|
|
||||||
aniListUser.subscribe((value) => currentAniListUser = value)
|
|
||||||
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
|
||||||
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
|
|
||||||
malLoggedIn.subscribe((value) => isMALLoggedIn = value)
|
|
||||||
|
|
||||||
function dropdownUser(): void {
|
|
||||||
let dropdown = document.querySelector("#userDropdown")
|
|
||||||
dropdown.classList.toggle("hidden")
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<div class="relative">
|
|
||||||
<button id="userDropdownButton" on:click={dropdownUser}>
|
|
||||||
{#if isAniListLoggedIn}
|
|
||||||
<Avatar src="{currentAniListUser.data.Viewer.avatar.medium}" class="cursor-pointer"
|
|
||||||
dot={{ color: 'green' }}/>
|
|
||||||
{:else}
|
|
||||||
<Avatar class="cursor-pointer" dot={{ color: 'red' }}/>
|
|
||||||
{/if}
|
|
||||||
</button>
|
|
||||||
<div id="userDropdown"
|
|
||||||
class="absolute hidden right-0 2xl:left-1/2 2xl:-translate-x-1/2 z-10 bg-white divide-y divide-gray-100 rounded-lg shadow w-44 dark:bg-gray-700 dark:divide-gray-600">
|
|
||||||
<div class="px-4 py-3 text-sm text-gray-900 dark:text-white">
|
|
||||||
{#if isAniListLoggedIn}
|
|
||||||
<div>{currentAniListUser.data.Viewer.name}</div>
|
|
||||||
{:else}
|
|
||||||
<div>You are not logged into AniList</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
<ul class="py-2 text-sm text-gray-700 dark:text-gray-200"
|
|
||||||
aria-labelledby="dropdownUserAvatarButton">
|
|
||||||
{#if isAniListLoggedIn}
|
|
||||||
<li>
|
|
||||||
<button on:click={logoutOfAniList}
|
|
||||||
class="block px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
|
|
||||||
Logout Anilist
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
{#if isMALLoggedIn}
|
|
||||||
<li>
|
|
||||||
<button on:click={logoutOfMAL}
|
|
||||||
class="block px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
|
|
||||||
Logout MAL
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
{#if isSimklLoggedIn}
|
|
||||||
<li>
|
|
||||||
<button on:click={logoutOfSimkl}
|
|
||||||
class="block px-4 py-2 w-full hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">
|
|
||||||
Logout Simkl
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
{/if}
|
|
||||||
</ul>
|
|
||||||
<div class="py-2">
|
|
||||||
<button on:click={() => runtime.Quit()}
|
|
||||||
class="block px-4 py-2 w-full text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">
|
|
||||||
Exit Application
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@ -1,440 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import {
|
|
||||||
anilistModal,
|
|
||||||
simklWatchList,
|
|
||||||
aniListLoggedIn,
|
|
||||||
simklLoggedIn
|
|
||||||
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
|
||||||
import {aniListAnime} from "./GlobalVariablesAndHelperFunctions.svelte";
|
|
||||||
import {Button} from "flowbite-svelte";
|
|
||||||
// @ts-ignore
|
|
||||||
import StarRatting from "@ernane/svelte-star-rating"
|
|
||||||
import moment from 'moment'
|
|
||||||
import { Table, TableBody, TableBodyCell, TableBodyRow, TableHead, TableHeadCell } from 'flowbite-svelte';
|
|
||||||
import { writable } from 'svelte/store';
|
|
||||||
import type {SimklAnime} from "./simkl/types/simklTypes";
|
|
||||||
import { get } from 'svelte/store';
|
|
||||||
import {AniListUpdateEntry, SimklSyncEpisodes, SimklSyncRating, SimklSyncStatus} from "../wailsjs/go/main/App";
|
|
||||||
|
|
||||||
const simklWatch = get(simklWatchList);
|
|
||||||
let isAniListLoggedIn: boolean
|
|
||||||
let isSimklLoggedIn: boolean
|
|
||||||
let simklAnimeIndex: number
|
|
||||||
let simklAnime: SimklAnime | undefined = undefined
|
|
||||||
|
|
||||||
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
|
||||||
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
|
|
||||||
|
|
||||||
for (let i = 0; i < simklWatch.anime.length; i++) {
|
|
||||||
if (Number(simklWatch.anime[i].show.ids.mal) === aniListAnime.data.MediaList.media.idMal) {
|
|
||||||
simklAnimeIndex = i
|
|
||||||
simklAnime = simklWatch.anime[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
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 = [];
|
|
||||||
|
|
||||||
if(isAniListLoggedIn) {
|
|
||||||
items.push({
|
|
||||||
id: aniListAnime.data.MediaList.id,
|
|
||||||
service: "AniList",
|
|
||||||
progress: aniListAnime.data.MediaList.progress,
|
|
||||||
status: aniListAnime.data.MediaList.status,
|
|
||||||
startedAt: `${aniListAnime.data.MediaList.startedAt.month}-${aniListAnime.data.MediaList.startedAt.day}-${aniListAnime.data.MediaList.startedAt.year}`,
|
|
||||||
completedAt: `${aniListAnime.data.MediaList.completedAt.month}-${aniListAnime.data.MediaList.completedAt.day}-${aniListAnime.data.MediaList.completedAt.year}`,
|
|
||||||
score: aniListAnime.data.MediaList.score,
|
|
||||||
repeat: aniListAnime.data.MediaList.repeat,
|
|
||||||
notes: aniListAnime.data.MediaList.notes
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if(isSimklLoggedIn && simklAnime !== undefined) {
|
|
||||||
items.push({
|
|
||||||
id: simklAnime.show.ids.simkl,
|
|
||||||
service: "Simkl",
|
|
||||||
progress: simklAnime.watched_episodes_count,
|
|
||||||
status: simklAnime.status,
|
|
||||||
startedAt: "",
|
|
||||||
completedAt: "",
|
|
||||||
score: simklAnime.user_rating,
|
|
||||||
repeat: 0,
|
|
||||||
notes: ""
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const sortKey = writable('service'); // default sort key
|
|
||||||
const sortDirection = writable(1); // default sort direction (ascending)
|
|
||||||
const sortItems = writable(items.slice()); // make a copy of the items array
|
|
||||||
|
|
||||||
// Define a function to sort the items
|
|
||||||
const sortTable = (key: any) => {
|
|
||||||
// If the same key is clicked, reverse the sort direction
|
|
||||||
if ($sortKey === key) {
|
|
||||||
sortDirection.update((val) => -val);
|
|
||||||
} else {
|
|
||||||
sortKey.set(key);
|
|
||||||
sortDirection.set(1);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$: {
|
|
||||||
const key = $sortKey;
|
|
||||||
const direction = $sortDirection;
|
|
||||||
const sorted = [...$sortItems].sort((a, b) => {
|
|
||||||
const aVal = a[key];
|
|
||||||
const bVal = b[key];
|
|
||||||
if (aVal < bVal) {
|
|
||||||
return -direction;
|
|
||||||
} else if (aVal > bVal) {
|
|
||||||
return direction;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
sortItems.set(sorted);
|
|
||||||
}
|
|
||||||
|
|
||||||
const ratingInWords = {
|
|
||||||
0: "Not Reviewed",
|
|
||||||
1: "Apalling",
|
|
||||||
2: "Horrible",
|
|
||||||
3: "Very Bad",
|
|
||||||
4: "Bad",
|
|
||||||
5: "Average",
|
|
||||||
6: "Fine",
|
|
||||||
7: "Good",
|
|
||||||
8: "Very Good",
|
|
||||||
9: "Great",
|
|
||||||
10: "Masterpiece",
|
|
||||||
}
|
|
||||||
|
|
||||||
const hide = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
anilistModal.set(false)
|
|
||||||
};
|
|
||||||
|
|
||||||
const title = aniListAnime.data.MediaList.media.title.english !== "" ?
|
|
||||||
aniListAnime.data.MediaList.media.title.english :
|
|
||||||
aniListAnime.data.MediaList.media.title.romaji
|
|
||||||
|
|
||||||
let config = {
|
|
||||||
readOnly: false,
|
|
||||||
countStars: 5,
|
|
||||||
range: {
|
|
||||||
min: 0,
|
|
||||||
max: 5,
|
|
||||||
step: 0.5
|
|
||||||
},
|
|
||||||
score: aniListAnime.data.MediaList.score / 2,
|
|
||||||
showScore: false,
|
|
||||||
scoreFormat: function () {
|
|
||||||
return `(${this.score.toFixed(1)}/${this.countStars})`
|
|
||||||
},
|
|
||||||
name: "",
|
|
||||||
starConfig: {
|
|
||||||
size: 32,
|
|
||||||
fillColor: '#F9ED4F',
|
|
||||||
strokeColor: "#e2c714",
|
|
||||||
unfilledColor: '#FFF',
|
|
||||||
strokeUnfilledColor: '#000'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let values = {
|
|
||||||
progress: aniListAnime.data.MediaList.progress,
|
|
||||||
status: startingAnilistStatusOption,
|
|
||||||
startedAt: {
|
|
||||||
year: aniListAnime.data.MediaList.startedAt.year,
|
|
||||||
month: aniListAnime.data.MediaList.startedAt.month,
|
|
||||||
day: aniListAnime.data.MediaList.startedAt.day
|
|
||||||
},
|
|
||||||
completedAt: {
|
|
||||||
year: aniListAnime.data.MediaList.completedAt.year,
|
|
||||||
month: aniListAnime.data.MediaList.completedAt.month,
|
|
||||||
day: aniListAnime.data.MediaList.completedAt.day
|
|
||||||
},
|
|
||||||
repeat: aniListAnime.data.MediaList.repeat,
|
|
||||||
score: aniListAnime.data.MediaList.score,
|
|
||||||
notes: aniListAnime.data.MediaList.notes
|
|
||||||
}
|
|
||||||
let startedAtDate: string
|
|
||||||
let completedAtDate: string
|
|
||||||
|
|
||||||
const changeRating = (e) => {
|
|
||||||
config.score = e.target.valueAsNumber
|
|
||||||
values.score = e.target.valueAsNumber * 2
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (values.startedAt.year > 0) {
|
|
||||||
let startedAtISODate = new Date(values.startedAt.year, values.startedAt.month - 1, values.startedAt.day)
|
|
||||||
let startedAtMoment = moment(startedAtISODate)
|
|
||||||
startedAtDate = startedAtMoment.format('YYYY-MM-DD')
|
|
||||||
}
|
|
||||||
|
|
||||||
const transformStartedAtDate = (e) => {
|
|
||||||
const re = /^([0-9]{4})-([0-9]{2})-([0-9]{2})/
|
|
||||||
const date = re.exec(e.target.value)
|
|
||||||
values.startedAt.year = Number(date[1])
|
|
||||||
values.startedAt.month = Number(date[2])
|
|
||||||
values.startedAt.day = Number(date[3])
|
|
||||||
}
|
|
||||||
|
|
||||||
if (values.completedAt.year > 0) {
|
|
||||||
let completedAtISODate = new Date(values.completedAt.year, values.completedAt.month - 1, values.completedAt.day)
|
|
||||||
let completedAtMoment = moment(completedAtISODate)
|
|
||||||
completedAtDate = completedAtMoment.format('YYYY-MM-DD')
|
|
||||||
}
|
|
||||||
|
|
||||||
const transformCompletedAtDate = (e) => {
|
|
||||||
const re = /^([0-9]{4})-([0-9]{2})-([0-9]{2})/
|
|
||||||
const date = re.exec(e.target.value)
|
|
||||||
values.completedAt.year = Number(date[1])
|
|
||||||
values.completedAt.month = Number(date[2])
|
|
||||||
values.completedAt.day = Number(date[3])
|
|
||||||
}
|
|
||||||
|
|
||||||
const submitData = async () => {
|
|
||||||
await AniListUpdateEntry(
|
|
||||||
aniListAnime.data.MediaList.mediaId,
|
|
||||||
values.progress,
|
|
||||||
values.status.aniList,
|
|
||||||
values.score,
|
|
||||||
values.repeat,
|
|
||||||
values.notes,
|
|
||||||
values.startedAt.year,
|
|
||||||
values.startedAt.month,
|
|
||||||
values.startedAt.day,
|
|
||||||
values.completedAt.year,
|
|
||||||
values.completedAt.month,
|
|
||||||
values.completedAt.day
|
|
||||||
).then((value) => {
|
|
||||||
console.log(value)
|
|
||||||
})
|
|
||||||
|
|
||||||
if (simklLoggedIn) {
|
|
||||||
if (simklAnime.watched_episodes_count !== values.progress) {
|
|
||||||
await SimklSyncEpisodes(simklAnime, values.progress).then(value => {
|
|
||||||
console.log(value)
|
|
||||||
simklAnime.watched_episodes_count = values.progress
|
|
||||||
simklWatch.anime[simklAnimeIndex].watched_episodes_count = values.progress
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
if (simklAnime.user_rating !== values.score) {
|
|
||||||
await SimklSyncRating(simklAnime, values.score).then(value => {
|
|
||||||
console.log(value)
|
|
||||||
simklAnime.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>
|
|
||||||
|
|
||||||
<div id="inapp-data">
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-10 grid-flow-col gap-4">
|
|
||||||
<div class="md:col-span-2 space-y-3">
|
|
||||||
<img class="rounded-lg" src={aniListAnime.data.MediaList.media.coverImage.large} alt="{title} Cover Image">
|
|
||||||
<StarRatting bind:config on:change={changeRating}/>
|
|
||||||
<p>Rating: {config.score * 2}</p>
|
|
||||||
<p>{ratingInWords[config.score * 2]}</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="md:col-span-8 ">
|
|
||||||
<div class="flex flex-col md:flex-row md:pl-10 md:pr-10 pt-5 pb-5 justify-center md:gap-x-24 lg:gap-x-56">
|
|
||||||
<div>
|
|
||||||
<label for="episodes" class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Episode
|
|
||||||
Progress</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
name="episodes"
|
|
||||||
min="0"
|
|
||||||
id="episodes"
|
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600
|
|
||||||
focus:border-primary-600 block w-24 p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400
|
|
||||||
dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"
|
|
||||||
bind:value={values.progress}
|
|
||||||
required>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<label for="status"
|
|
||||||
class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Status</label>
|
|
||||||
<select id="status"
|
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500
|
|
||||||
focus:border-blue-500 block 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"
|
|
||||||
bind:value={values.status}
|
|
||||||
>
|
|
||||||
{#each statusOptions as option}
|
|
||||||
<option value={option}>{option.aniList}</option>
|
|
||||||
{/each}
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-col md:flex-row md:pl-10 md:pr-10 pt-5 pb-5 justify-center md:gap-x-16 lg:gap-x-36">
|
|
||||||
|
|
||||||
<div>
|
|
||||||
|
|
||||||
<label for="startedAt" class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Date
|
|
||||||
Started</label>
|
|
||||||
<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
|
|
||||||
id="startedAt"
|
|
||||||
type="date"
|
|
||||||
name="startedAt"
|
|
||||||
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"
|
|
||||||
value={startedAtDate}
|
|
||||||
placeholder="Date Started"
|
|
||||||
on:change={transformStartedAtDate}
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
|
|
||||||
<label for="completedAt" class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Date
|
|
||||||
Completed</label>
|
|
||||||
<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
|
|
||||||
id="completedAt"
|
|
||||||
type="date"
|
|
||||||
name="completedAt"
|
|
||||||
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"
|
|
||||||
value={completedAtDate}
|
|
||||||
placeholder="Date Completed"
|
|
||||||
on:change={transformCompletedAtDate}
|
|
||||||
>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<label for="repeat"
|
|
||||||
class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Rewatched</label>
|
|
||||||
<input
|
|
||||||
type="number"
|
|
||||||
name="repeat"
|
|
||||||
min="0"
|
|
||||||
id="repeat"
|
|
||||||
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-primary-600
|
|
||||||
focus:border-primary-600 block w-24 p-2.5 dark:bg-gray-600 dark:border-gray-500 dark:placeholder-gray-400
|
|
||||||
dark:text-white dark:focus:ring-primary-500 dark:focus:border-primary-500"
|
|
||||||
bind:value={values.repeat}
|
|
||||||
required>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-col md:flex-row md:pl-10 md:pr-10 pt-5 pb-5 justify-center">
|
|
||||||
<div class="w-full">
|
|
||||||
<label for="notes" class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white">Your
|
|
||||||
notes</label>
|
|
||||||
<textarea id="notes" rows="3"
|
|
||||||
class="block p-2.5 w-full text-sm text-gray-900 bg-gray-50 rounded-lg border border-gray-300 focus:ring-blue-500 focus:border-blue-500 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="Write your thoughts here..."
|
|
||||||
bind:value={values.notes}></textarea>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="external-data">
|
|
||||||
<div id="anilist-data" class="flex flex-col md:flex-row md:pl-10 md:pr-10 pt-5 pb-5 justify-center md:gap-x-16 lg:gap-x-36 group">
|
|
||||||
<h2 class="text-left mb-1 text-base font-semibold text-gray-900 dark:text-white">AniList</h2>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<Table hoverable={true}>
|
|
||||||
<TableHead>
|
|
||||||
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('id')}>ID</TableHeadCell>
|
|
||||||
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('service')}>Service</TableHeadCell>
|
|
||||||
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('progress')}>Episode Progress</TableHeadCell>
|
|
||||||
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('status')}>Status</TableHeadCell>
|
|
||||||
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('startedAt')}>Date Started</TableHeadCell>
|
|
||||||
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('completedAt')}>Date Completed</TableHeadCell>
|
|
||||||
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('score')}>Rating</TableHeadCell>
|
|
||||||
<TableHeadCell class="cursor-pointer" on:click={() => sortTable('repeat')}>Rewatches</TableHeadCell>
|
|
||||||
<TableHeadCell>Notes</TableHeadCell>
|
|
||||||
</TableHead>
|
|
||||||
<TableBody tableBodyClass="divide-y">
|
|
||||||
{#each $sortItems as item}
|
|
||||||
<TableBodyRow>
|
|
||||||
<TableBodyCell class="overflow-x-auto">{item.id}</TableBodyCell>
|
|
||||||
<TableBodyCell class="overflow-x-auto">{item.service}</TableBodyCell>
|
|
||||||
<TableBodyCell class="overflow-x-auto">{item.progress}</TableBodyCell>
|
|
||||||
<TableBodyCell class="overflow-x-auto">{item.status}</TableBodyCell>
|
|
||||||
<TableBodyCell class="overflow-x-auto">{item.startedAt}</TableBodyCell>
|
|
||||||
<TableBodyCell class="overflow-x-auto">{item.completedAt}</TableBodyCell>
|
|
||||||
<TableBodyCell class="overflow-x-auto">{item.score}</TableBodyCell>
|
|
||||||
<TableBodyCell class="overflow-x-auto">{item.repeat}</TableBodyCell>
|
|
||||||
<TableBodyCell class="overflow-x-auto">{item.notes}</TableBodyCell>
|
|
||||||
</TableBodyRow>
|
|
||||||
{/each}
|
|
||||||
</TableBody>
|
|
||||||
</Table>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="bg-white rounded-lg shadow max-w-4-4 dark:bg-gray-800">
|
|
||||||
<div class="w-full mx-auto max-w-screen-xl p-4 md:flex md:items-center md:justify-end">
|
|
||||||
<Button
|
|
||||||
class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:ring-blue-300 font-medium
|
|
||||||
rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-blue-600 dark:hover:bg-blue-700 focus:outline-none
|
|
||||||
dark:focus:ring-blue-800"
|
|
||||||
on:click={submitData}>Sync Changes
|
|
||||||
</Button>
|
|
||||||
<Button
|
|
||||||
class="text-gray-900 bg-white border border-gray-300 focus:outline-none hover:bg-gray-100 focus:ring-4
|
|
||||||
focus:ring-gray-100 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-gray-800 dark:text-white
|
|
||||||
dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-600 dark:focus:ring-gray-700"
|
|
||||||
on:click={hide}>
|
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div>
|
|
||||||
<h3 class="text-2xl">
|
|
||||||
Summary
|
|
||||||
</h3>
|
|
||||||
<p>{@html aniListAnime.data.MediaList.media.description}</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
@ -1,106 +0,0 @@
|
|||||||
<script lang="ts" context="module">
|
|
||||||
import {
|
|
||||||
GetAniListItem,
|
|
||||||
GetAniListLoggedInUser, GetAniListUserWatchingList, GetMyAnimeListLoggedInUser,
|
|
||||||
GetSimklLoggedInUser, LogoutAniList, LogoutMyAnimeList, LogoutSimkl
|
|
||||||
} from "../wailsjs/go/main/App";
|
|
||||||
import type {
|
|
||||||
AniListCurrentUserWatchList,
|
|
||||||
AniListGetSingleAnime
|
|
||||||
} from "./anilist/types/AniListCurrentUserWatchListType.js";
|
|
||||||
import {writable} from 'svelte/store'
|
|
||||||
import type {SimklUser, SimklWatchList} from "./simkl/types/simklTypes";
|
|
||||||
import {type AniListUser, MediaListSort} from "./anilist/types/AniListTypes";
|
|
||||||
import type {MyAnimeListUser} from "./mal/types/MALTypes";
|
|
||||||
|
|
||||||
export let aniListAnime: AniListGetSingleAnime
|
|
||||||
export let title = writable("")
|
|
||||||
export let anilistModal = writable(false);
|
|
||||||
export let aniListLoggedIn = writable(false)
|
|
||||||
export let simklLoggedIn = writable(false)
|
|
||||||
export let malLoggedIn = writable(false)
|
|
||||||
export let simklWatchList = writable({} as SimklWatchList)
|
|
||||||
export let aniListPrimary = writable(true)
|
|
||||||
export let simklUser = writable({} as SimklUser)
|
|
||||||
export let aniListUser = writable({} as AniListUser)
|
|
||||||
export let malUser = writable({} as MyAnimeListUser)
|
|
||||||
export let aniListWatchlist = writable({} as AniListCurrentUserWatchList)
|
|
||||||
|
|
||||||
export let watchListPage = writable(1)
|
|
||||||
export let animePerPage = writable(20)
|
|
||||||
|
|
||||||
let isAniListPrimary: boolean
|
|
||||||
let page: number
|
|
||||||
let perPage: number
|
|
||||||
let aniWatchlist: AniListCurrentUserWatchList
|
|
||||||
|
|
||||||
aniListPrimary.subscribe(value => isAniListPrimary = value)
|
|
||||||
watchListPage.subscribe(value => page = value)
|
|
||||||
animePerPage.subscribe(value => perPage = value)
|
|
||||||
aniListWatchlist.subscribe(value => aniWatchlist = value)
|
|
||||||
|
|
||||||
export function GetAniListSingleItemAndOpenModal(aniId: number, login: boolean): void {
|
|
||||||
GetAniListItem(aniId, login).then(result => {
|
|
||||||
aniListAnime = result
|
|
||||||
title.set(aniListAnime.data.MediaList.media.title.english === "" ?
|
|
||||||
aniListAnime.data.MediaList.media.title.romaji :
|
|
||||||
aniListAnime.data.MediaList.media.title.english)
|
|
||||||
anilistModal.set(true)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function loginToSimkl(): void {
|
|
||||||
GetSimklLoggedInUser().then(result => {
|
|
||||||
simklUser.set(result)
|
|
||||||
simklLoggedIn.set(true)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function loginToAniList(): void {
|
|
||||||
GetAniListLoggedInUser().then(result => {
|
|
||||||
aniListUser.set(result)
|
|
||||||
if (isAniListPrimary) {
|
|
||||||
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
|
||||||
aniListWatchlist.set(result)
|
|
||||||
aniListLoggedIn.set(true)
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
aniListLoggedIn.set(true)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function loginToMAL(): void {
|
|
||||||
GetMyAnimeListLoggedInUser().then(result => {
|
|
||||||
malUser.set(result)
|
|
||||||
malLoggedIn.set(true)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function logoutOfAniList(): void {
|
|
||||||
LogoutAniList().then(result => {
|
|
||||||
console.log(result)
|
|
||||||
if (Object.keys(aniWatchlist).length !== 0) {
|
|
||||||
aniListWatchlist.set({} as AniListCurrentUserWatchList)
|
|
||||||
}
|
|
||||||
aniListUser.set({} as AniListUser)
|
|
||||||
aniListLoggedIn.set(false)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function logoutOfMAL(): void {
|
|
||||||
LogoutMyAnimeList().then(result => {
|
|
||||||
console.log(result)
|
|
||||||
malUser.set({} as MyAnimeListUser)
|
|
||||||
malLoggedIn.set(false)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export function logoutOfSimkl(): void {
|
|
||||||
LogoutSimkl().then(result => {
|
|
||||||
console.log(result)
|
|
||||||
simklUser.set({} as SimklUser)
|
|
||||||
simklLoggedIn.set(false)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
|
@ -1,98 +0,0 @@
|
|||||||
<script lang="ts">
|
|
||||||
import logo from "./assets/images/AniTrackLogo.svg"
|
|
||||||
import Search from "./Search.svelte"
|
|
||||||
import {
|
|
||||||
aniListLoggedIn,
|
|
||||||
aniListUser,
|
|
||||||
loginToAniList,
|
|
||||||
loginToMAL,
|
|
||||||
loginToSimkl,
|
|
||||||
malLoggedIn,
|
|
||||||
malUser,
|
|
||||||
simklLoggedIn,
|
|
||||||
simklUser
|
|
||||||
} from "./GlobalVariablesAndHelperFunctions.svelte"
|
|
||||||
import type {AniListUser} from "./anilist/types/AniListTypes";
|
|
||||||
import type {SimklUser} from "./simkl/types/simklTypes";
|
|
||||||
import type {MyAnimeListUser} from "./mal/types/MALTypes";
|
|
||||||
import AvatarMenu from "./AvatarMenu.svelte";
|
|
||||||
|
|
||||||
let isAniListLoggedIn: boolean
|
|
||||||
let isSimklLoggedIn: boolean
|
|
||||||
let isMALLoggedIn: boolean
|
|
||||||
let currentAniListUser: AniListUser
|
|
||||||
let currentSimklUser: SimklUser
|
|
||||||
let currentMALUser: MyAnimeListUser
|
|
||||||
|
|
||||||
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
|
||||||
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
|
|
||||||
malLoggedIn.subscribe((value) => isMALLoggedIn = value)
|
|
||||||
aniListUser.subscribe((value) => currentAniListUser = value)
|
|
||||||
simklUser.subscribe((value) => currentSimklUser = value)
|
|
||||||
malUser.subscribe((value) => currentMALUser = value)
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<header class="mb-2">
|
|
||||||
<nav class="bg-white border-gray-200 px-4 lg:px-6 py-2.5 dark:bg-gray-800">
|
|
||||||
<div class="flex justify-between items-center mx-auto max-w-screen-lg">
|
|
||||||
<img src={logo} class="mr-3 h-6 sm:h-9" alt="AniTrack Logo"/>
|
|
||||||
|
|
||||||
<div class="flex space-x-4 items-center">
|
|
||||||
|
|
||||||
<button data-collapse-toggle="mobile-menu-2" type="button"
|
|
||||||
class="inline-flex items-center p-2 ml-1 text-sm text-gray-500 rounded-lg lg:hidden hover:bg-gray-100 focus:outline-none focus:ring-2 focus:ring-gray-200 dark:text-gray-400 dark:hover:bg-gray-700 dark:focus:ring-gray-600"
|
|
||||||
aria-controls="mobile-menu-2" aria-expanded="false">
|
|
||||||
<span class="sr-only">Open main menu</span>
|
|
||||||
<svg class="w-6 h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path fill-rule="evenodd"
|
|
||||||
d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z"
|
|
||||||
clip-rule="evenodd"></path>
|
|
||||||
</svg>
|
|
||||||
<svg class="hidden w-6 h-6" fill="currentColor" viewBox="0 0 20 20"
|
|
||||||
xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path fill-rule="evenodd"
|
|
||||||
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
|
|
||||||
clip-rule="evenodd"></path>
|
|
||||||
</svg>
|
|
||||||
</button>
|
|
||||||
<div class="hidden justify-between items-center w-full lg:flex md:space-x-20 lg:mx-auto lg:max-w-screen-xl"
|
|
||||||
id="mobile-menu-2">
|
|
||||||
<ul class="flex flex-col mt-4 font-medium md:flex-row md:space-x-2 md:mt-0">
|
|
||||||
<li>
|
|
||||||
{#if isAniListLoggedIn}
|
|
||||||
<span class="bg-green-100 text-green-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-green-800 dark:text-green-200 cursor-default">AniList: {currentAniListUser.data.Viewer.name}</span>
|
|
||||||
{:else}
|
|
||||||
<button on:click={loginToAniList}
|
|
||||||
class="bg-blue-100 hover:bg-blue-200 text-blue-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-gray-700 dark:text-blue-400 border border-blue-400 inline-flex items-center justify-center">
|
|
||||||
AniList
|
|
||||||
</button>
|
|
||||||
{/if}
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
{#if isMALLoggedIn}
|
|
||||||
<span class="bg-blue-100 text-blue-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-blue-800 dark:text-blue-200 cursor-default">MAL: {currentMALUser.name}</span>
|
|
||||||
{:else}
|
|
||||||
<button on:click={loginToMAL}
|
|
||||||
class="bg-blue-100 hover:bg-blue-200 text-blue-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-gray-700 dark:text-blue-400 border border-blue-400 inline-flex items-center justify-center">
|
|
||||||
MAL
|
|
||||||
</button>
|
|
||||||
{/if}
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
{#if isSimklLoggedIn}
|
|
||||||
<span class="bg-indigo-100 text-indigo-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-indigo-800 dark:text-indigo-200 cursor-default">Simkl: {currentSimklUser.user.name}</span>
|
|
||||||
{:else}
|
|
||||||
<button on:click={loginToSimkl}
|
|
||||||
class="bg-blue-100 hover:bg-blue-200 text-blue-800 text-sm font-medium me-2 px-2.5 py-0.5 rounded dark:bg-gray-700 dark:text-blue-400 border border-blue-400 inline-flex items-center justify-center">
|
|
||||||
Simkl
|
|
||||||
</button>
|
|
||||||
{/if}
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<Search/>
|
|
||||||
</div>
|
|
||||||
<AvatarMenu />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
</header>
|
|
@ -81,3 +81,26 @@ export enum MediaListSort {
|
|||||||
MediaPopularity = "MEDIA_POPULARITY",
|
MediaPopularity = "MEDIA_POPULARITY",
|
||||||
MediaPopularityDesc = "MEDIA_POPULARITY_DESC"
|
MediaPopularityDesc = "MEDIA_POPULARITY_DESC"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface StartedAt {
|
||||||
|
year: number
|
||||||
|
month: number
|
||||||
|
day: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CompletedAt {
|
||||||
|
year: number
|
||||||
|
month: number
|
||||||
|
day: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface AniListUpdateVariables {
|
||||||
|
mediaId: number
|
||||||
|
progress: number
|
||||||
|
status: string
|
||||||
|
score: number
|
||||||
|
repeat: number
|
||||||
|
notes: string
|
||||||
|
startedAt: StartedAt
|
||||||
|
completedAt: CompletedAt
|
||||||
|
}
|
BIN
frontend/src/assets/fonts/MapleMono-Bold.woff2
Normal file
BIN
frontend/src/assets/fonts/MapleMono-Bold.woff2
Normal file
Binary file not shown.
BIN
frontend/src/assets/images/favicon.ico
Normal file
BIN
frontend/src/assets/images/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
765
frontend/src/helperComponents/Anime.svelte
Normal file
765
frontend/src/helperComponents/Anime.svelte
Normal file
@ -0,0 +1,765 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import {
|
||||||
|
aniListAnime,
|
||||||
|
aniListLoggedIn,
|
||||||
|
malAnime,
|
||||||
|
malLoggedIn,
|
||||||
|
simklAnime,
|
||||||
|
simklLoggedIn,
|
||||||
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
|
import { push } from "svelte-spa-router";
|
||||||
|
import { Button } from "flowbite-svelte";
|
||||||
|
import type { AniListGetSingleAnime } from "../anilist/types/AniListCurrentUserWatchListType";
|
||||||
|
import Rating from "./Rating.svelte";
|
||||||
|
import {
|
||||||
|
convertAniListDateToString,
|
||||||
|
convertAniListDateToDate,
|
||||||
|
} from "../helperFunctions/convertAniListDateIn";
|
||||||
|
import AnimeTable from "./AnimeTable.svelte";
|
||||||
|
import type {
|
||||||
|
MALAnime,
|
||||||
|
MalListStatus,
|
||||||
|
MALUploadStatus,
|
||||||
|
} from "../mal/types/MALTypes";
|
||||||
|
import type { SimklAnime } from "../simkl/types/simklTypes";
|
||||||
|
import { writable } from "svelte/store";
|
||||||
|
import type {
|
||||||
|
StatusOption,
|
||||||
|
StatusOptions,
|
||||||
|
} from "../helperTypes/StatusTypes";
|
||||||
|
import type { AniListUpdateVariables } from "../anilist/types/AniListTypes";
|
||||||
|
import {
|
||||||
|
convertDateStringToAniList,
|
||||||
|
convertDateToAniList,
|
||||||
|
} from "../helperFunctions/convertDateToAniList";
|
||||||
|
import {
|
||||||
|
AniListDeleteEntry,
|
||||||
|
AniListUpdateEntry,
|
||||||
|
DeleteMyAnimeListEntry,
|
||||||
|
MyAnimeListUpdate,
|
||||||
|
SimklSyncEpisodes,
|
||||||
|
SimklSyncRating,
|
||||||
|
SimklSyncRemove,
|
||||||
|
SimklSyncStatus,
|
||||||
|
} from "../../wailsjs/go/main/App";
|
||||||
|
import { AddAnimeServiceToTable } from "../helperModules/AddAnimeServiceToTable.svelte";
|
||||||
|
import { CheckIfAniListLoggedInAndLoadWatchList } from "../helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
|
||||||
|
import Datepicker from "./Datepicker.svelte";
|
||||||
|
const re = /^([0-9]{4})-([0-9]{2})-([0-9]{2})/;
|
||||||
|
|
||||||
|
let isAniListLoggedIn: boolean;
|
||||||
|
let isMalLoggedIn: boolean;
|
||||||
|
let isSimklLoggedIn: boolean;
|
||||||
|
let currentAniListAnime: AniListGetSingleAnime;
|
||||||
|
let currentMalAnime: MALAnime;
|
||||||
|
let currentSimklAnime: SimklAnime;
|
||||||
|
let submitting = writable(false);
|
||||||
|
let isSubmitting: boolean;
|
||||||
|
let submitSuccess = writable(false);
|
||||||
|
|
||||||
|
aniListLoggedIn.subscribe((value) => (isAniListLoggedIn = value));
|
||||||
|
malLoggedIn.subscribe((value) => (isMalLoggedIn = value));
|
||||||
|
simklLoggedIn.subscribe((value) => (isSimklLoggedIn = value));
|
||||||
|
aniListAnime.subscribe((value) => (currentAniListAnime = value));
|
||||||
|
malAnime.subscribe((value) => (currentMalAnime = value));
|
||||||
|
simklAnime.subscribe((value) => (currentSimklAnime = value));
|
||||||
|
submitting.subscribe((value) => (isSubmitting = value));
|
||||||
|
|
||||||
|
const title =
|
||||||
|
currentAniListAnime.data.MediaList.media.title.english !== ""
|
||||||
|
? currentAniListAnime.data.MediaList.media.title.english
|
||||||
|
: currentAniListAnime.data.MediaList.media.title.romaji;
|
||||||
|
const statusOptions: StatusOptions = [
|
||||||
|
{ id: 0, aniList: "CURRENT", mal: "watching", simkl: "watching" },
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
aniList: "PLANNING",
|
||||||
|
mal: "plan_to_watch",
|
||||||
|
simkl: "plantowatch",
|
||||||
|
},
|
||||||
|
{ id: 2, aniList: "COMPLETED", mal: "completed", simkl: "completed" },
|
||||||
|
{ id: 3, aniList: "DROPPED", mal: "dropped", simkl: "dropped" },
|
||||||
|
{ id: 4, aniList: "PAUSED", mal: "on_hold", simkl: "hold" },
|
||||||
|
{ id: 5, aniList: "REPEATING", mal: "rewatching", simkl: "watching" },
|
||||||
|
];
|
||||||
|
let startingAnilistStatusOption: StatusOption = statusOptions.filter(
|
||||||
|
(option) =>
|
||||||
|
currentAniListAnime.data.MediaList.status === option.aniList,
|
||||||
|
)[0];
|
||||||
|
let startedAtDate: Date | null = convertAniListDateToDate(
|
||||||
|
currentAniListAnime.data.MediaList.startedAt,
|
||||||
|
);
|
||||||
|
let completedAtDate: Date | null = convertAniListDateToDate(
|
||||||
|
currentAniListAnime.data.MediaList.completedAt,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (isAniListLoggedIn)
|
||||||
|
AddAnimeServiceToTable({
|
||||||
|
id: `a-${currentAniListAnime.data.MediaList.mediaId}`,
|
||||||
|
title,
|
||||||
|
service: "AniList",
|
||||||
|
progress: currentAniListAnime.data.MediaList.progress,
|
||||||
|
status: currentAniListAnime.data.MediaList.status,
|
||||||
|
startedAt: convertAniListDateToString(
|
||||||
|
currentAniListAnime.data.MediaList.startedAt,
|
||||||
|
),
|
||||||
|
completedAt: convertAniListDateToString(
|
||||||
|
currentAniListAnime.data.MediaList.completedAt,
|
||||||
|
),
|
||||||
|
score: currentAniListAnime.data.MediaList.score,
|
||||||
|
repeat: currentAniListAnime.data.MediaList.repeat,
|
||||||
|
notes: currentAniListAnime.data.MediaList.notes,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (isMalLoggedIn) {
|
||||||
|
let startDate = "";
|
||||||
|
let finishDate = "";
|
||||||
|
if (currentMalAnime.my_list_status.start_date !== "") {
|
||||||
|
const startArray = re.exec(
|
||||||
|
currentMalAnime.my_list_status.start_date,
|
||||||
|
);
|
||||||
|
startDate = `${startArray[2]}-${startArray[3]}-${startArray[1]}`;
|
||||||
|
}
|
||||||
|
if (currentMalAnime.my_list_status.finish_date !== "") {
|
||||||
|
const finishArray = re.exec(
|
||||||
|
currentMalAnime.my_list_status.finish_date,
|
||||||
|
);
|
||||||
|
finishDate = `${finishArray[2]}-${finishArray[3]}-${finishArray[1]}`;
|
||||||
|
}
|
||||||
|
AddAnimeServiceToTable({
|
||||||
|
id: `m-${currentMalAnime.id}`,
|
||||||
|
title: currentMalAnime.title,
|
||||||
|
service: "MyAnimeList",
|
||||||
|
progress: currentMalAnime.my_list_status.num_episodes_watched,
|
||||||
|
status: currentMalAnime.my_list_status.status,
|
||||||
|
startedAt: startDate,
|
||||||
|
completedAt: finishDate,
|
||||||
|
score: currentMalAnime.my_list_status.score,
|
||||||
|
repeat: currentMalAnime.my_list_status.num_times_rewatched,
|
||||||
|
notes: currentMalAnime.my_list_status.comments,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSimklLoggedIn && Object.keys(currentSimklAnime).length > 0)
|
||||||
|
AddAnimeServiceToTable({
|
||||||
|
id: `s-${currentSimklAnime.show.ids.simkl}`,
|
||||||
|
title: currentSimklAnime.show.title,
|
||||||
|
service: "Simkl",
|
||||||
|
progress: currentSimklAnime.watched_episodes_count,
|
||||||
|
status: currentSimklAnime.status,
|
||||||
|
startedAt: "",
|
||||||
|
completedAt: "",
|
||||||
|
score: currentSimklAnime.user_rating,
|
||||||
|
repeat: 0,
|
||||||
|
notes: "",
|
||||||
|
});
|
||||||
|
|
||||||
|
const handleSubmit = async (e: any) => {
|
||||||
|
submitting.set(true);
|
||||||
|
let submitData: {
|
||||||
|
rating: number;
|
||||||
|
episodes: number;
|
||||||
|
status: StatusOption;
|
||||||
|
startedAt: Date | null;
|
||||||
|
completedAt: Date | null;
|
||||||
|
repeat: number;
|
||||||
|
notes: string;
|
||||||
|
} = {
|
||||||
|
rating: 0,
|
||||||
|
episodes: 0,
|
||||||
|
status: {
|
||||||
|
id: 0,
|
||||||
|
aniList: "",
|
||||||
|
mal: "",
|
||||||
|
simkl: "",
|
||||||
|
},
|
||||||
|
startedAt: null,
|
||||||
|
completedAt: null,
|
||||||
|
repeat: 0,
|
||||||
|
notes: "",
|
||||||
|
};
|
||||||
|
const formData = new FormData(e.target);
|
||||||
|
for (let field of formData) {
|
||||||
|
const [key, value] = field;
|
||||||
|
if (key === "rating") {
|
||||||
|
submitData.rating = Number(value) * 2;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (key === "episodes") {
|
||||||
|
submitData.episodes = Number(value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (key === "repeat") {
|
||||||
|
submitData.repeat = Number(value);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (key === "status") {
|
||||||
|
submitData.status = startingAnilistStatusOption;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
submitData[key] = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
isAniListLoggedIn &&
|
||||||
|
currentAniListAnime.data.MediaList.mediaId !== 0
|
||||||
|
) {
|
||||||
|
let body: AniListUpdateVariables = {
|
||||||
|
mediaId: currentAniListAnime.data.MediaList.mediaId,
|
||||||
|
progress: submitData.episodes,
|
||||||
|
status: submitData.status.aniList,
|
||||||
|
score: submitData.rating,
|
||||||
|
repeat: submitData.repeat,
|
||||||
|
notes: submitData.notes,
|
||||||
|
startedAt: convertDateToAniList(startedAtDate),
|
||||||
|
completedAt: convertDateToAniList(completedAtDate),
|
||||||
|
};
|
||||||
|
await AniListUpdateEntry(body).then(
|
||||||
|
(value: AniListGetSingleAnime) => {
|
||||||
|
/* TODO in future when you inevitably add tags to typescript, until Anilist fixes the api bug
|
||||||
|
where tags break the SaveMediaListEntry return, you'll want to use this delete line
|
||||||
|
delete value.data.MediaList.media.tags */
|
||||||
|
aniListAnime.update((newValue) => {
|
||||||
|
newValue = value;
|
||||||
|
return newValue;
|
||||||
|
});
|
||||||
|
AddAnimeServiceToTable({
|
||||||
|
id: `a-${currentAniListAnime.data.MediaList.mediaId}`,
|
||||||
|
title,
|
||||||
|
service: "AniList",
|
||||||
|
progress: currentAniListAnime.data.MediaList.progress,
|
||||||
|
status: currentAniListAnime.data.MediaList.status,
|
||||||
|
startedAt: convertAniListDateToString(
|
||||||
|
currentAniListAnime.data.MediaList.startedAt,
|
||||||
|
),
|
||||||
|
completedAt: convertAniListDateToString(
|
||||||
|
currentAniListAnime.data.MediaList.completedAt,
|
||||||
|
),
|
||||||
|
score: currentAniListAnime.data.MediaList.score,
|
||||||
|
repeat: currentAniListAnime.data.MediaList.repeat,
|
||||||
|
notes: currentAniListAnime.data.MediaList.notes,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (malLoggedIn && currentMalAnime.id !== 0) {
|
||||||
|
let body: MALUploadStatus = {
|
||||||
|
status: submitData.status.mal,
|
||||||
|
is_rewatching: submitData.repeat > 0,
|
||||||
|
score: submitData.rating,
|
||||||
|
num_watched_episodes: submitData.episodes,
|
||||||
|
num_times_rewatched: submitData.repeat,
|
||||||
|
comments: submitData.notes,
|
||||||
|
};
|
||||||
|
|
||||||
|
await MyAnimeListUpdate(currentMalAnime, body).then(
|
||||||
|
(malAnimeReturn: MalListStatus) => {
|
||||||
|
malAnime.update((value) => {
|
||||||
|
value.my_list_status.status = malAnimeReturn.status;
|
||||||
|
value.my_list_status.is_rewatching =
|
||||||
|
malAnimeReturn.is_rewatching;
|
||||||
|
value.my_list_status.score = malAnimeReturn.score;
|
||||||
|
value.my_list_status.num_episodes_watched =
|
||||||
|
malAnimeReturn.num_episodes_watched;
|
||||||
|
value.my_list_status.num_times_rewatched =
|
||||||
|
malAnimeReturn.num_times_rewatched;
|
||||||
|
value.my_list_status.comments = malAnimeReturn.comments;
|
||||||
|
return value;
|
||||||
|
});
|
||||||
|
let startDate = "";
|
||||||
|
let finishDate = "";
|
||||||
|
if (currentMalAnime.my_list_status.start_date !== "") {
|
||||||
|
const startArray = re.exec(
|
||||||
|
currentMalAnime.my_list_status.start_date,
|
||||||
|
);
|
||||||
|
startDate = `${startArray[2]}-${startArray[3]}-${startArray[1]}`;
|
||||||
|
}
|
||||||
|
if (currentMalAnime.my_list_status.finish_date !== "") {
|
||||||
|
const finishArray = re.exec(
|
||||||
|
currentMalAnime.my_list_status.finish_date,
|
||||||
|
);
|
||||||
|
finishDate = `${finishArray[2]}-${finishArray[3]}-${finishArray[1]}`;
|
||||||
|
}
|
||||||
|
AddAnimeServiceToTable({
|
||||||
|
id: `m-${currentMalAnime.id}`,
|
||||||
|
title: currentMalAnime.title,
|
||||||
|
service: "MyAnimeList",
|
||||||
|
progress:
|
||||||
|
currentMalAnime.my_list_status.num_episodes_watched,
|
||||||
|
status: currentMalAnime.my_list_status.status,
|
||||||
|
startedAt: startDate,
|
||||||
|
completedAt: finishDate,
|
||||||
|
score: currentMalAnime.my_list_status.score,
|
||||||
|
repeat: currentMalAnime.my_list_status
|
||||||
|
.num_times_rewatched,
|
||||||
|
notes: currentMalAnime.my_list_status.comments,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (simklLoggedIn && currentSimklAnime.show.ids.simkl !== 0) {
|
||||||
|
if (
|
||||||
|
currentSimklAnime.watched_episodes_count !== submitData.episodes
|
||||||
|
) {
|
||||||
|
await SimklSyncEpisodes(
|
||||||
|
currentSimklAnime,
|
||||||
|
submitData.episodes,
|
||||||
|
).then((value: SimklAnime) => {
|
||||||
|
AddAnimeServiceToTable({
|
||||||
|
id: `s-${value.show.ids.simkl}`,
|
||||||
|
title: value.show.title,
|
||||||
|
service: "Simkl",
|
||||||
|
progress: value.watched_episodes_count,
|
||||||
|
status: value.status,
|
||||||
|
startedAt: "",
|
||||||
|
completedAt: "",
|
||||||
|
score: value.user_rating,
|
||||||
|
repeat: 0,
|
||||||
|
notes: "",
|
||||||
|
});
|
||||||
|
simklAnime.update((newValue) => {
|
||||||
|
newValue = value;
|
||||||
|
return newValue;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentSimklAnime.user_rating !== submitData.rating) {
|
||||||
|
await SimklSyncRating(
|
||||||
|
currentSimklAnime,
|
||||||
|
submitData.rating,
|
||||||
|
).then((value) => {
|
||||||
|
AddAnimeServiceToTable({
|
||||||
|
id: `s-${value.show.ids.simkl}`,
|
||||||
|
title: value.show.title,
|
||||||
|
service: "Simkl",
|
||||||
|
progress: value.watched_episodes_count,
|
||||||
|
status: value.status,
|
||||||
|
startedAt: "",
|
||||||
|
completedAt: "",
|
||||||
|
score: value.user_rating,
|
||||||
|
repeat: 0,
|
||||||
|
notes: "",
|
||||||
|
});
|
||||||
|
simklAnime.update((newValue) => {
|
||||||
|
newValue = value;
|
||||||
|
return newValue;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentSimklAnime.status !== submitData.status.simkl) {
|
||||||
|
await SimklSyncStatus(
|
||||||
|
currentSimklAnime,
|
||||||
|
submitData.status.simkl,
|
||||||
|
).then((value) => {
|
||||||
|
AddAnimeServiceToTable({
|
||||||
|
id: `s-${value.show.ids.simkl}`,
|
||||||
|
title: value.show.title,
|
||||||
|
service: "Simkl",
|
||||||
|
progress: value.watched_episodes_count,
|
||||||
|
status: value.status,
|
||||||
|
startedAt: "",
|
||||||
|
completedAt: "",
|
||||||
|
score: value.user_rating,
|
||||||
|
repeat: 0,
|
||||||
|
notes: "",
|
||||||
|
});
|
||||||
|
simklAnime.update((newValue) => {
|
||||||
|
newValue = value;
|
||||||
|
return newValue;
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
submitting.set(false);
|
||||||
|
submitSuccess.set(true);
|
||||||
|
setTimeout(() => submitSuccess.set(false), 2000);
|
||||||
|
};
|
||||||
|
|
||||||
|
const deleteEntries = async () => {
|
||||||
|
submitting.set(true);
|
||||||
|
if (
|
||||||
|
isAniListLoggedIn &&
|
||||||
|
currentAniListAnime.data.MediaList.mediaId !== 0
|
||||||
|
) {
|
||||||
|
await AniListDeleteEntry(currentAniListAnime.data.MediaList.id);
|
||||||
|
AddAnimeServiceToTable({
|
||||||
|
id: `a-${currentAniListAnime.data.MediaList.mediaId}`,
|
||||||
|
title,
|
||||||
|
service: "AniList",
|
||||||
|
progress: 0,
|
||||||
|
status: "",
|
||||||
|
startedAt: "",
|
||||||
|
completedAt: "",
|
||||||
|
score: 0,
|
||||||
|
repeat: 0,
|
||||||
|
notes: "",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (malLoggedIn && currentMalAnime.id !== 0) {
|
||||||
|
await DeleteMyAnimeListEntry(currentMalAnime.id);
|
||||||
|
AddAnimeServiceToTable({
|
||||||
|
id: `m-${currentMalAnime.id}`,
|
||||||
|
title: currentMalAnime.title,
|
||||||
|
service: "MyAnimeList",
|
||||||
|
progress: 0,
|
||||||
|
status: "",
|
||||||
|
startedAt: "",
|
||||||
|
completedAt: "",
|
||||||
|
score: 0,
|
||||||
|
repeat: 0,
|
||||||
|
notes: "",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (simklLoggedIn && currentSimklAnime.show.ids.simkl !== 0) {
|
||||||
|
await SimklSyncRemove(currentSimklAnime);
|
||||||
|
AddAnimeServiceToTable({
|
||||||
|
id: `s-${currentSimklAnime.show.ids.simkl}`,
|
||||||
|
title: currentSimklAnime.show.title,
|
||||||
|
service: "Simkl",
|
||||||
|
progress: 0,
|
||||||
|
status: "",
|
||||||
|
startedAt: "",
|
||||||
|
completedAt: "",
|
||||||
|
score: 0,
|
||||||
|
repeat: 0,
|
||||||
|
notes: "",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
submitting.set(false);
|
||||||
|
submitSuccess.set(true);
|
||||||
|
setTimeout(() => submitSuccess.set(false), 2000);
|
||||||
|
};
|
||||||
|
|
||||||
|
let max = 999;
|
||||||
|
|
||||||
|
if (currentAniListAnime.data.MediaList.media.episodes !== 0) {
|
||||||
|
max = currentAniListAnime.data.MediaList.media.episodes;
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
currentAniListAnime.data.MediaList.media.episodes === 0 &&
|
||||||
|
currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode !== 0
|
||||||
|
) {
|
||||||
|
max =
|
||||||
|
currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode -
|
||||||
|
1;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<form on:submit|preventDefault={handleSubmit} class="container pt-3 pb-10">
|
||||||
|
<h1 class="text-white font-bold text-left text-xl pb-3">
|
||||||
|
{title}
|
||||||
|
</h1>
|
||||||
|
<div class="grid grid-cols-1 md:grid-cols-10 grid-flow-col gap-4">
|
||||||
|
<div class="md:col-span-2 space-y-3">
|
||||||
|
<img
|
||||||
|
class="rounded-lg"
|
||||||
|
src={currentAniListAnime.data.MediaList.media.coverImage.large}
|
||||||
|
alt="{title} Cover Image"
|
||||||
|
/>
|
||||||
|
<Rating bind:score={currentAniListAnime.data.MediaList.score} />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="md:col-span-8">
|
||||||
|
<div
|
||||||
|
class="flex flex-col md:flex-row md:pl-10 md:pr-10 pt-5 pb-5 justify-center md:gap-x-24 lg:gap-x-56"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<label
|
||||||
|
for="episodes"
|
||||||
|
class="text-left block mb-2 text-sm font-medium text-white"
|
||||||
|
>Episode Progress</label
|
||||||
|
>
|
||||||
|
<div class="relative flex items-center max-w-[8rem]">
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
id="decrement-button"
|
||||||
|
data-input-counter-decrement="quantity-input"
|
||||||
|
on:click={() =>
|
||||||
|
(currentAniListAnime.data.MediaList.progress -= 1)}
|
||||||
|
class="bg-gray-100 dark:bg-gray-700 dark:hover:bg-gray-600 dark:border-gray-600 hover:bg-gray-200 border border-gray-300 rounded-s-lg p-3 h-11 focus:ring-gray-100 dark:focus:ring-gray-700 focus:ring-2 focus:outline-none"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="w-3 h-3 text-gray-900 dark:text-white"
|
||||||
|
aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 18 2"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2"
|
||||||
|
d="M1 1h16"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
name="episodes"
|
||||||
|
min="0"
|
||||||
|
{max}
|
||||||
|
id="episodes"
|
||||||
|
class="border border-x-0 p-2.5 h-11 text-center text-sm block w-full placeholder-gray-400 [appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none
|
||||||
|
{currentAniListAnime.data.MediaList.progress < 0 ||
|
||||||
|
(currentAniListAnime.data.MediaList.media.episodes >
|
||||||
|
0 &&
|
||||||
|
currentAniListAnime.data.MediaList.progress >
|
||||||
|
currentAniListAnime.data.MediaList.media
|
||||||
|
.episodes) ||
|
||||||
|
(currentAniListAnime.data.MediaList.media
|
||||||
|
.nextAiringEpisode.episode > 0 &&
|
||||||
|
currentAniListAnime.data.MediaList.progress >
|
||||||
|
currentAniListAnime.data.MediaList.media
|
||||||
|
.nextAiringEpisode.episode -
|
||||||
|
1)
|
||||||
|
? 'border-red-500 border-[2px] text-rose-300 focus:ring-red-500 focus:border-red-500'
|
||||||
|
: 'bg-gray-700 hover:bg-gray-600 border-gray-600 text-white focus:ring-blue-500 focus:border-blue-500'} w-24"
|
||||||
|
bind:value={
|
||||||
|
currentAniListAnime.data.MediaList.progress
|
||||||
|
}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
id="increment-button"
|
||||||
|
data-input-counter-increment="quantity-input"
|
||||||
|
on:click={() =>
|
||||||
|
(currentAniListAnime.data.MediaList.progress += 1)}
|
||||||
|
class="bg-gray-100 dark:bg-gray-700 dark:hover:bg-gray-600 dark:border-gray-600 hover:bg-gray-200 border border-gray-300 rounded-e-lg p-3 h-11 focus:ring-gray-100 dark:focus:ring-gray-700 focus:ring-2 focus:outline-none"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="w-3 h-3 text-gray-900 dark:text-white"
|
||||||
|
aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 18 18"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2"
|
||||||
|
d="M9 1v16M1 9h16"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
/ {currentAniListAnime.data.MediaList.media
|
||||||
|
.nextAiringEpisode.episode !== 0
|
||||||
|
? currentAniListAnime.data.MediaList.media
|
||||||
|
.nextAiringEpisode.episode - 1
|
||||||
|
: currentAniListAnime.data.MediaList.media.episodes}
|
||||||
|
</div>
|
||||||
|
{#if currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode !== 0}
|
||||||
|
<div>
|
||||||
|
of {currentAniListAnime.data.MediaList.media
|
||||||
|
.episodes}
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label
|
||||||
|
for="status"
|
||||||
|
class="text-left block mb-2 text-sm font-medium text-gray-900 dark:text-white"
|
||||||
|
>Status</label
|
||||||
|
>
|
||||||
|
<select
|
||||||
|
id="status"
|
||||||
|
name="status"
|
||||||
|
class="border text-sm rounded-lg
|
||||||
|
block p-2.5 bg-gray-700 border-gray-600 placeholder-gray-400
|
||||||
|
text-white focus:ring-blue-500 focus:border-blue-500"
|
||||||
|
bind:value={startingAnilistStatusOption}
|
||||||
|
>
|
||||||
|
{#each statusOptions as option}
|
||||||
|
<option value={option}>{option.aniList}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="flex flex-col md:flex-row md:pl-10 md:pr-10 pt-5 pb-5 justify-center md:gap-x-16 lg:gap-x-36"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<label
|
||||||
|
for="startedAt"
|
||||||
|
class="text-left block mb-2 text-sm font-medium text-white"
|
||||||
|
>Date Started</label
|
||||||
|
>
|
||||||
|
<Datepicker
|
||||||
|
bind:value={startedAtDate}
|
||||||
|
color="slate"
|
||||||
|
dateFormat={{
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
}}
|
||||||
|
showActionButtons
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label
|
||||||
|
for="completedAt"
|
||||||
|
class="text-left block mb-2 text-sm font-medium text-white"
|
||||||
|
>Date Completed</label
|
||||||
|
>
|
||||||
|
<Datepicker
|
||||||
|
bind:value={completedAtDate}
|
||||||
|
color="slate"
|
||||||
|
dateFormat={{
|
||||||
|
year: "numeric",
|
||||||
|
month: "2-digit",
|
||||||
|
day: "2-digit",
|
||||||
|
}}
|
||||||
|
showActionButtons
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label
|
||||||
|
for="repeat"
|
||||||
|
class="text-left block mb-2 text-sm font-medium text-white"
|
||||||
|
>Rewatched</label
|
||||||
|
>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
name="repeat"
|
||||||
|
min="0"
|
||||||
|
id="repeat"
|
||||||
|
class="border {currentAniListAnime.data.MediaList
|
||||||
|
.repeat < 0
|
||||||
|
? 'border-red-500 border-[2px] text-rose-300 focus:ring-red-500 focus:border-red-500'
|
||||||
|
: 'border-gray-500 text-white focus:ring-blue-500 focus:border-blue-500'} text-sm rounded-lg block w-24 p-2.5 bg-gray-600 placeholder-gray-400 text-white"
|
||||||
|
bind:value={currentAniListAnime.data.MediaList.repeat}
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="flex flex-col md:flex-row md:pl-10 md:pr-10 pt-5 pb-5 justify-center"
|
||||||
|
>
|
||||||
|
<div class="w-full">
|
||||||
|
<label
|
||||||
|
for="notes"
|
||||||
|
class="text-left block mb-2 text-sm font-medium text-white"
|
||||||
|
>Your notes</label
|
||||||
|
>
|
||||||
|
<textarea
|
||||||
|
id="notes"
|
||||||
|
rows="3"
|
||||||
|
name="notes"
|
||||||
|
class="block p-2.5 w-full text-sm rounded-lg border bg-gray-700 border-gray-600 placeholder-gray-400 text-white focus:ring-blue-500 focus:border-blue-500"
|
||||||
|
placeholder="Write your thoughts here..."
|
||||||
|
bind:value={currentAniListAnime.data.MediaList.notes}
|
||||||
|
></textarea>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="external-data">
|
||||||
|
<div
|
||||||
|
id="anilist-data"
|
||||||
|
class="flex flex-col md:flex-row md:pl-10 md:pr-10 pt-5 pb-5 justify-center md:gap-x-16 lg:gap-x-36 group"
|
||||||
|
>
|
||||||
|
<h2 class="text-left mb-1 text-base font-semibold text-white">
|
||||||
|
AniList
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<AnimeTable />
|
||||||
|
|
||||||
|
<div class="flex rounded-lg shadow max-w-4-4 bg-gray-800">
|
||||||
|
<div
|
||||||
|
class="w-full mx-auto max-w-screen-xl p-4 md:flex md:items-center md:justify-start"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
disabled={isSubmitting}
|
||||||
|
id="delete-button"
|
||||||
|
class="text-white bg-red-700 {$submitSuccess
|
||||||
|
? 'bg-green-600 dark:bg-green-600 hover:bg-green-700 dark:hover:bg-green-700 focus:ring-4 focus:ring-green-800 dark:focus:ring-green-800'
|
||||||
|
: 'bg-red-600 dark:bg-red-600 hover:bg-red-700 dark:hover:bg-red-700 focus:ring-4 focus:ring-red-800 dark:focus:ring-red-800'} font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 focus:outline-none"
|
||||||
|
on:click={deleteEntries}
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
id="submit-loader"
|
||||||
|
aria-hidden="true"
|
||||||
|
role="status"
|
||||||
|
class="{isSubmitting
|
||||||
|
? 'inline'
|
||||||
|
: 'hidden'} w-4 h-4 me-3 text-white animate-spin"
|
||||||
|
viewBox="0 0 100 101"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||||
|
fill="#E5E7EB"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
Delete Entries
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="w-full mx-auto max-w-screen-xl p-4 md:flex md:items-center md:justify-end"
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
disabled={isSubmitting}
|
||||||
|
id="sync-button"
|
||||||
|
class="text-white {$submitSuccess
|
||||||
|
? 'bg-green-600 dark:bg-green-600 hover:bg-green-700 dark:hover:bg-green-700 focus:ring-4 focus:ring-green-800 dark:focus:ring-green-800'
|
||||||
|
: 'bg-blue-600 dark:bg-blue-600 hover:bg-blue-700 dark:hover:bg-blue-700 focus:ring-4 focus:ring-blue-800 dark:focus:ring-blue-800'} font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 focus:outline-none"
|
||||||
|
type="submit"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
id="submit-loader"
|
||||||
|
aria-hidden="true"
|
||||||
|
role="status"
|
||||||
|
class="{isSubmitting
|
||||||
|
? 'inline'
|
||||||
|
: 'hidden'} w-4 h-4 me-3 text-white animate-spin"
|
||||||
|
viewBox="0 0 100 101"
|
||||||
|
fill="none"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||||
|
fill="#E5E7EB"
|
||||||
|
/>
|
||||||
|
<path
|
||||||
|
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||||
|
fill="currentColor"
|
||||||
|
/>
|
||||||
|
</svg>
|
||||||
|
Sync Changes
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
class="text-white bg-gray-800 border border-gray-600 focus:outline-none hover:bg-gray-700 focus:ring-4
|
||||||
|
focus:ring-gray-700 font-medium rounded-lg text-sm px-5 py-2.5 me-2 mb-2 dark:bg-gray-800 dark:text-white
|
||||||
|
dark:border-gray-600 dark:hover:bg-gray-700 dark:hover:border-gray-600 dark:focus:ring-gray-700"
|
||||||
|
on:click={async () => {
|
||||||
|
await CheckIfAniListLoggedInAndLoadWatchList();
|
||||||
|
return push("/");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Go Home
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3 class="text-2xl">Summary</h3>
|
||||||
|
<p>{@html currentAniListAnime.data.MediaList.media.description}</p>
|
||||||
|
</div>
|
||||||
|
</form>
|
119
frontend/src/helperComponents/AnimeTable.svelte
Normal file
119
frontend/src/helperComponents/AnimeTable.svelte
Normal file
@ -0,0 +1,119 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import {
|
||||||
|
createRender,
|
||||||
|
createTable,
|
||||||
|
Render,
|
||||||
|
Subscribe,
|
||||||
|
} from "svelte-headless-table"
|
||||||
|
// @ts-ignore
|
||||||
|
import { addSortBy } from "svelte-headless-table/plugins"
|
||||||
|
import { tableItems } from "../helperModules/GlobalVariablesAndHelperFunctions.svelte"
|
||||||
|
import WebsiteLink from "./WebsiteLink.svelte"
|
||||||
|
|
||||||
|
//when adding sort here is code { sort: addSortBy() }
|
||||||
|
const table = createTable(tableItems, { sort: addSortBy() })
|
||||||
|
|
||||||
|
const columns = table.createColumns([
|
||||||
|
table.column({
|
||||||
|
header: "Service Id",
|
||||||
|
cell: ({ value }) => createRender(WebsiteLink, {id: value}),
|
||||||
|
accessor: "id",
|
||||||
|
}),
|
||||||
|
table.column({
|
||||||
|
header: "Anime Title",
|
||||||
|
accessor: "title",
|
||||||
|
}),
|
||||||
|
table.column({
|
||||||
|
header: "Service",
|
||||||
|
accessor: "service",
|
||||||
|
}),
|
||||||
|
table.column({
|
||||||
|
header: "Episode Progress",
|
||||||
|
accessor: "progress",
|
||||||
|
}),
|
||||||
|
table.column({
|
||||||
|
header: "Status",
|
||||||
|
accessor: "status",
|
||||||
|
}),
|
||||||
|
table.column({
|
||||||
|
header: "Started At",
|
||||||
|
accessor: "startedAt",
|
||||||
|
}),
|
||||||
|
table.column({
|
||||||
|
header: "Completed At",
|
||||||
|
accessor: "completedAt",
|
||||||
|
}),
|
||||||
|
table.column({
|
||||||
|
header: "Rating",
|
||||||
|
accessor: "score",
|
||||||
|
}),
|
||||||
|
table.column({
|
||||||
|
header: "Repeat",
|
||||||
|
accessor: "repeat",
|
||||||
|
}),
|
||||||
|
table.column({
|
||||||
|
header: "Notes",
|
||||||
|
accessor: "notes",
|
||||||
|
}),
|
||||||
|
])
|
||||||
|
|
||||||
|
//add pluginStates when add sort back
|
||||||
|
const { headerRows, rows, tableAttrs, tableBodyAttrs } =
|
||||||
|
table.createViewModel(columns)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="relative overflow-x-auto rounded-lg mb-5">
|
||||||
|
<table
|
||||||
|
class="w-full text-sm text-left rtl:text-right text-gray-400"
|
||||||
|
{...$tableAttrs}
|
||||||
|
>
|
||||||
|
<thead class="text-xs uppercase bg-gray-700 text-gray-400">
|
||||||
|
{#each $headerRows as headerRow (headerRow.id)}
|
||||||
|
<Subscribe attrs={headerRow.attrs()} let:attrs>
|
||||||
|
<tr {...attrs}>
|
||||||
|
{#each headerRow.cells as cell (cell.id)}
|
||||||
|
<Subscribe
|
||||||
|
attrs={cell.attrs()}
|
||||||
|
let:attrs
|
||||||
|
props={cell.props()}
|
||||||
|
let:props
|
||||||
|
>
|
||||||
|
<th
|
||||||
|
{...attrs}
|
||||||
|
on:click={props.sort.toggle}
|
||||||
|
class:sorted={props.sort.order !==
|
||||||
|
undefined}
|
||||||
|
class="px-6 py-3"
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<Render of={cell.render()} />
|
||||||
|
{#if props.sort.order === "asc"}
|
||||||
|
⬇️
|
||||||
|
{:else if props.sort.order === "desc"}
|
||||||
|
⬆️
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</th>
|
||||||
|
</Subscribe>
|
||||||
|
{/each}
|
||||||
|
</tr>
|
||||||
|
</Subscribe>
|
||||||
|
{/each}
|
||||||
|
</thead>
|
||||||
|
<tbody {...$tableBodyAttrs}>
|
||||||
|
{#each $rows as row (row.id)}
|
||||||
|
<Subscribe attrs={row.attrs()} let:attrs>
|
||||||
|
<tr {...attrs} class="bg-gray-800 border-gray-700">
|
||||||
|
{#each row.cells as cell (cell.id)}
|
||||||
|
<Subscribe attrs={cell.attrs()} let:attrs>
|
||||||
|
<td {...attrs} class="px-6 py-4">
|
||||||
|
<Render of={cell.render()} />
|
||||||
|
</td>
|
||||||
|
</Subscribe>
|
||||||
|
{/each}
|
||||||
|
</tr>
|
||||||
|
</Subscribe>
|
||||||
|
{/each}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
130
frontend/src/helperComponents/AvatarMenu.svelte
Normal file
130
frontend/src/helperComponents/AvatarMenu.svelte
Normal file
@ -0,0 +1,130 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { Avatar } from "flowbite-svelte";
|
||||||
|
import type { AniListUser } from "../anilist/types/AniListTypes";
|
||||||
|
import {
|
||||||
|
aniListLoggedIn,
|
||||||
|
aniListUser,
|
||||||
|
malUser,
|
||||||
|
simklUser,
|
||||||
|
malLoggedIn,
|
||||||
|
simklLoggedIn,
|
||||||
|
loginToAniList,
|
||||||
|
loginToMAL,
|
||||||
|
loginToSimkl,
|
||||||
|
logoutOfAniList,
|
||||||
|
logoutOfMAL,
|
||||||
|
logoutOfSimkl,
|
||||||
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
|
import * as runtime from "../../wailsjs/runtime";
|
||||||
|
import type {MyAnimeListUser} from "../mal/types/MALTypes";
|
||||||
|
import type {SimklUser} from "../simkl/types/simklTypes";
|
||||||
|
|
||||||
|
let currentAniListUser: AniListUser;
|
||||||
|
let currentMALUser: MyAnimeListUser;
|
||||||
|
let currentSimklUser: SimklUser;
|
||||||
|
let isAniListLoggedIn: boolean;
|
||||||
|
let isSimklLoggedIn: boolean;
|
||||||
|
let isMALLoggedIn: boolean;
|
||||||
|
|
||||||
|
aniListUser.subscribe((value) => (currentAniListUser = value));
|
||||||
|
malUser.subscribe((value) => (currentMALUser = value))
|
||||||
|
simklUser.subscribe(value => currentSimklUser = value)
|
||||||
|
aniListLoggedIn.subscribe((value) => (isAniListLoggedIn = value));
|
||||||
|
simklLoggedIn.subscribe((value) => (isSimklLoggedIn = value));
|
||||||
|
malLoggedIn.subscribe((value) => (isMALLoggedIn = value));
|
||||||
|
|
||||||
|
function dropdownUser(): void {
|
||||||
|
let dropdown = document.querySelector("#userDropdown");
|
||||||
|
dropdown.classList.toggle("hidden");
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="relative">
|
||||||
|
<button id="userDropdownButton" on:click={dropdownUser}>
|
||||||
|
{#if isAniListLoggedIn}
|
||||||
|
<Avatar
|
||||||
|
src={currentAniListUser.data.Viewer.avatar.medium}
|
||||||
|
class="cursor-pointer"
|
||||||
|
dot={{ color: "green" }}
|
||||||
|
/>
|
||||||
|
{:else}
|
||||||
|
<Avatar class="cursor-pointer" dot={{ color: "red" }} />
|
||||||
|
{/if}
|
||||||
|
</button>
|
||||||
|
<div
|
||||||
|
id="userDropdown"
|
||||||
|
class="absolute hidden right-0 2xl:left-1/2 2xl:-translate-x-1/2 z-10 divide-y rounded-lg shadow w-44 bg-gray-700 divide-gray-600"
|
||||||
|
>
|
||||||
|
<div class="px-4 py-3 text-sm text-white">
|
||||||
|
{#if isAniListLoggedIn}
|
||||||
|
<div>{currentAniListUser.data.Viewer.name}</div>
|
||||||
|
{:else}
|
||||||
|
<div>You are not logged into AniList</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
<ul
|
||||||
|
class="py-2 text-sm text-gray-200"
|
||||||
|
aria-labelledby="dropdownUserAvatarButton"
|
||||||
|
>
|
||||||
|
{#if isAniListLoggedIn}
|
||||||
|
<li>
|
||||||
|
<button
|
||||||
|
on:click={logoutOfAniList}
|
||||||
|
class="block px-4 py-2 w-full hover:bg-gray-600 truncate bg-green-800 hover:text-white"
|
||||||
|
>
|
||||||
|
<span class="maple-font text-lg text-green-200 mr-4">A</span>Logout {currentAniListUser.data.Viewer.name}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{:else}
|
||||||
|
<li>
|
||||||
|
<button on:click={loginToAniList}
|
||||||
|
class="block px-4 py-2 w-full hover:bg-gray-600 truncate hover:text-white">
|
||||||
|
<span class="maple-font text-lg mr-4">A</span>Login to AniList
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
|
{#if isMALLoggedIn}
|
||||||
|
<li>
|
||||||
|
<button
|
||||||
|
on:click={logoutOfMAL}
|
||||||
|
class="block px-4 py-2 w-full hover:bg-gray-600 truncate bg-blue-800 hover:text-white"
|
||||||
|
>
|
||||||
|
<span class="maple-font text-lg text-blue-200 mr-4">M</span>Logout {currentMALUser.name}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{:else}
|
||||||
|
<li>
|
||||||
|
<button on:click={loginToMAL}
|
||||||
|
class="block px-4 py-2 w-full hover:bg-gray-600 truncate hover:text-white">
|
||||||
|
<span class="maple-font text-lg mr-4">M</span>Login to MyAnimeList
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
|
{#if isSimklLoggedIn}
|
||||||
|
<li>
|
||||||
|
<button
|
||||||
|
on:click={logoutOfSimkl}
|
||||||
|
class="block px-4 py-2 w-full hover:bg-gray-600 truncate bg-indigo-800 hover:text-white"
|
||||||
|
>
|
||||||
|
<span class="maple-font text-lg text-indigo-200 mr-4">S</span>Logout {currentSimklUser.user.name}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{:else}
|
||||||
|
<li>
|
||||||
|
<button on:click={loginToSimkl}
|
||||||
|
class="block px-4 py-2 w-full hover:bg-gray-600 truncate hover:text-white">
|
||||||
|
<span class="maple-font text-lg mr-4">S</span>Login to Simkl
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
|
</ul>
|
||||||
|
<div class="py-2">
|
||||||
|
<button
|
||||||
|
on:click={() => runtime.Quit()}
|
||||||
|
class="block px-4 py-2 w-full text-sm hover:bg-gray-600 text-gray-200 over:text-white"
|
||||||
|
>
|
||||||
|
Exit Application
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
481
frontend/src/helperComponents/Datepicker.svelte
Normal file
481
frontend/src/helperComponents/Datepicker.svelte
Normal file
@ -0,0 +1,481 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { createEventDispatcher, onMount } from "svelte";
|
||||||
|
import { fade } from "svelte/transition";
|
||||||
|
import { Button } from "flowbite-svelte";
|
||||||
|
|
||||||
|
export let value: Date | null = null;
|
||||||
|
export let defaultDate: Date | null = null;
|
||||||
|
export let range: boolean = false;
|
||||||
|
export let rangeFrom: Date | null = null;
|
||||||
|
export let rangeTo: Date | null = null;
|
||||||
|
export let locale: string = "default";
|
||||||
|
export let firstDayOfWeek: number = 0; // 0 = Monday, 6 = Sunday
|
||||||
|
export let dateFormat: Intl.DateTimeFormatOptions = {
|
||||||
|
year: "numeric",
|
||||||
|
month: "long",
|
||||||
|
day: "numeric",
|
||||||
|
};
|
||||||
|
export let placeholder: string = "Select date";
|
||||||
|
export let disabled: boolean = false;
|
||||||
|
export let required: boolean = false;
|
||||||
|
export let inputClass: string = "";
|
||||||
|
export let color: Button["color"] = "primary";
|
||||||
|
export let inline: boolean = false;
|
||||||
|
export let autohide: boolean = true;
|
||||||
|
export let showActionButtons: boolean = false;
|
||||||
|
export let title: string = "";
|
||||||
|
|
||||||
|
// Internal state
|
||||||
|
const dispatch = createEventDispatcher();
|
||||||
|
let isOpen: boolean = inline;
|
||||||
|
let inputElement: HTMLInputElement;
|
||||||
|
let datepickerContainerElement: HTMLDivElement;
|
||||||
|
let currentMonth: Date = value || defaultDate || new Date();
|
||||||
|
let focusedDate: Date | null = null;
|
||||||
|
let calendarRef: HTMLDivElement;
|
||||||
|
|
||||||
|
$: daysInMonth = getDaysInMonth(currentMonth);
|
||||||
|
$: weekdays = getWeekdays();
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
if (!inline) {
|
||||||
|
document.addEventListener("click", handleClickOutside);
|
||||||
|
return () => {
|
||||||
|
document.removeEventListener("click", handleClickOutside);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Color handling functions
|
||||||
|
function getFocusRingClass(color: Button["color"]): string {
|
||||||
|
switch (color) {
|
||||||
|
case "primary":
|
||||||
|
return "focus:ring-2 focus:ring-primary-500 dark:focus:ring-primary-400";
|
||||||
|
case "blue":
|
||||||
|
return "focus:ring-2 focus:ring-blue-500 dark:focus:ring-blue-400";
|
||||||
|
case "red":
|
||||||
|
return "focus:ring-2 focus:ring-red-500 dark:focus:ring-red-400";
|
||||||
|
case "green":
|
||||||
|
return "focus:ring-2 focus:ring-green-500 dark:focus:ring-green-400";
|
||||||
|
case "yellow":
|
||||||
|
return "focus:ring-2 focus:ring-yellow-500 dark:focus:ring-yellow-400";
|
||||||
|
case "purple":
|
||||||
|
return "focus:ring-2 focus:ring-purple-500 dark:focus:ring-purple-400";
|
||||||
|
case "slate":
|
||||||
|
return "focus:ring-2 focus:ring-slate-500 dark:focus:ring-slate-400";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getRangeBackgroundClass(color: Button["color"]): string {
|
||||||
|
switch (color) {
|
||||||
|
case "primary":
|
||||||
|
return "bg-primary-100 dark:bg-primary-900";
|
||||||
|
case "blue":
|
||||||
|
return "bg-blue-100 dark:bg-blue-900";
|
||||||
|
case "red":
|
||||||
|
return "bg-red-100 dark:bg-red-900";
|
||||||
|
case "green":
|
||||||
|
return "bg-green-100 dark:bg-green-900";
|
||||||
|
case "yellow":
|
||||||
|
return "bg-yellow-100 dark:bg-yellow-900";
|
||||||
|
case "purple":
|
||||||
|
return "bg-purple-100 dark:bg-purple-900";
|
||||||
|
case "slate":
|
||||||
|
return "bg-slate-100 dark:bg-slate-900";
|
||||||
|
default:
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function getDaysInMonth(date: Date): Date[] {
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = date.getMonth();
|
||||||
|
const firstDay = new Date(year, month, 0);
|
||||||
|
const lastDay = new Date(year, month + 1, 0);
|
||||||
|
const daysArray: Date[] = [];
|
||||||
|
|
||||||
|
// Add days from previous month to fill the first week
|
||||||
|
let start = firstDay.getDay() - firstDayOfWeek;
|
||||||
|
if (start < 0) start += 7;
|
||||||
|
for (let i = 0; i < start; i++) {
|
||||||
|
daysArray.unshift(new Date(year, month, -i));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add days of the current month
|
||||||
|
for (let i = 1; i <= lastDay.getDate(); i++) {
|
||||||
|
daysArray.push(new Date(year, month, i));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add days from next month to fill the last week
|
||||||
|
const remainingDays = 7 - (daysArray.length % 7);
|
||||||
|
if (remainingDays < 7) {
|
||||||
|
for (let i = 1; i <= remainingDays; i++) {
|
||||||
|
daysArray.push(new Date(year, month + 1, i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return daysArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getWeekdays(): string[] {
|
||||||
|
const weekdays = [];
|
||||||
|
for (let i = 0; i < 7; i++) {
|
||||||
|
const day = new Date(2021, 5, i + firstDayOfWeek);
|
||||||
|
weekdays.push(day.toLocaleString(locale, { weekday: "short" }));
|
||||||
|
}
|
||||||
|
return weekdays;
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeMonth(increment: number) {
|
||||||
|
currentMonth = new Date(
|
||||||
|
currentMonth.getFullYear(),
|
||||||
|
currentMonth.getMonth() + increment,
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleDaySelect(day: Date) {
|
||||||
|
if (range) {
|
||||||
|
if (!rangeFrom || (rangeFrom && rangeTo)) {
|
||||||
|
rangeFrom = day;
|
||||||
|
rangeTo = null;
|
||||||
|
} else if (day < rangeFrom) {
|
||||||
|
rangeTo = rangeFrom;
|
||||||
|
rangeFrom = day;
|
||||||
|
} else {
|
||||||
|
rangeTo = day;
|
||||||
|
}
|
||||||
|
dispatch("select", { from: rangeFrom, to: rangeTo });
|
||||||
|
} else {
|
||||||
|
value = day;
|
||||||
|
dispatch("select", value);
|
||||||
|
if (autohide && !inline) isOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleInputChange() {
|
||||||
|
const date = new Date(inputElement.value);
|
||||||
|
if (!isNaN(date.getTime())) {
|
||||||
|
handleDaySelect(date);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClickOutside(event: MouseEvent) {
|
||||||
|
if (
|
||||||
|
isOpen &&
|
||||||
|
datepickerContainerElement &&
|
||||||
|
!datepickerContainerElement.contains(event.target as Node)
|
||||||
|
) {
|
||||||
|
isOpen = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(date: Date | null): string {
|
||||||
|
if (!date) return "";
|
||||||
|
return date.toLocaleDateString(locale, dateFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSameDate(date1: Date | null, date2: Date | null): boolean {
|
||||||
|
if (!date1 || !date2) return false;
|
||||||
|
return date1.toDateString() === date2.toDateString();
|
||||||
|
}
|
||||||
|
|
||||||
|
$: isSelected = (day: Date): boolean => {
|
||||||
|
if (range) {
|
||||||
|
return isSameDate(day, rangeFrom) || isSameDate(day, rangeTo);
|
||||||
|
}
|
||||||
|
return isSameDate(day, value);
|
||||||
|
};
|
||||||
|
|
||||||
|
function isInRange(day: Date): boolean {
|
||||||
|
if (!range || !rangeFrom || !rangeTo) return false;
|
||||||
|
return day > rangeFrom && day < rangeTo;
|
||||||
|
}
|
||||||
|
|
||||||
|
function isToday(day: Date): boolean {
|
||||||
|
const today = new Date();
|
||||||
|
return day.toDateString() === today.toDateString();
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleCalendarKeydown(event: KeyboardEvent) {
|
||||||
|
if (!isOpen) return;
|
||||||
|
|
||||||
|
if (!focusedDate) {
|
||||||
|
focusedDate = value || new Date();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (event.key) {
|
||||||
|
case "ArrowLeft":
|
||||||
|
focusedDate = new Date(
|
||||||
|
focusedDate.getFullYear(),
|
||||||
|
focusedDate.getMonth(),
|
||||||
|
focusedDate.getDate() - 1,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "ArrowRight":
|
||||||
|
focusedDate = new Date(
|
||||||
|
focusedDate.getFullYear(),
|
||||||
|
focusedDate.getMonth(),
|
||||||
|
focusedDate.getDate() + 1,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "ArrowUp":
|
||||||
|
focusedDate = new Date(
|
||||||
|
focusedDate.getFullYear(),
|
||||||
|
focusedDate.getMonth(),
|
||||||
|
focusedDate.getDate() - 7,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "ArrowDown":
|
||||||
|
focusedDate = new Date(
|
||||||
|
focusedDate.getFullYear(),
|
||||||
|
focusedDate.getMonth(),
|
||||||
|
focusedDate.getDate() + 7,
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
case "Enter":
|
||||||
|
handleDaySelect(focusedDate);
|
||||||
|
break;
|
||||||
|
case "Escape":
|
||||||
|
isOpen = false;
|
||||||
|
inputElement.focus();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.preventDefault();
|
||||||
|
if (focusedDate.getMonth() !== currentMonth.getMonth()) {
|
||||||
|
currentMonth = new Date(
|
||||||
|
focusedDate.getFullYear(),
|
||||||
|
focusedDate.getMonth(),
|
||||||
|
1,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Focus the button for the focused date
|
||||||
|
setTimeout(() => {
|
||||||
|
const focusedButton = calendarRef.querySelector(
|
||||||
|
`button[aria-label="${focusedDate!.toLocaleDateString(locale, { weekday: "long", year: "numeric", month: "long", day: "numeric" })}"]`,
|
||||||
|
) as HTMLButtonElement | null;
|
||||||
|
focusedButton?.focus();
|
||||||
|
}, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleInputKeydown(event: KeyboardEvent) {
|
||||||
|
if (event.key === "Enter" || event.key === " ") {
|
||||||
|
event.preventDefault();
|
||||||
|
isOpen = !isOpen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleToday() {
|
||||||
|
handleDaySelect(new Date());
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleClear() {
|
||||||
|
value = null;
|
||||||
|
rangeFrom = null;
|
||||||
|
rangeTo = null;
|
||||||
|
dispatch("clear");
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleApply() {
|
||||||
|
dispatch("apply", range ? { from: rangeFrom, to: rangeTo } : value);
|
||||||
|
if (!inline) isOpen = false;
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div
|
||||||
|
bind:this={datepickerContainerElement}
|
||||||
|
class="relative {inline ? 'inline-block' : ''}"
|
||||||
|
>
|
||||||
|
{#if !inline}
|
||||||
|
<div class="relative">
|
||||||
|
<input
|
||||||
|
bind:this={inputElement}
|
||||||
|
type="text"
|
||||||
|
class="w-full px-4 py-3 text-sm border rounded-md focus:outline-none dark:bg-gray-700 dark:text-white dark:border-gray-600 {getFocusRingClass(
|
||||||
|
color,
|
||||||
|
)} {inputClass}"
|
||||||
|
{placeholder}
|
||||||
|
value={range
|
||||||
|
? `${formatDate(rangeFrom)} - ${formatDate(rangeTo)}`
|
||||||
|
: formatDate(value)}
|
||||||
|
on:focus={() => (isOpen = true)}
|
||||||
|
on:input={handleInputChange}
|
||||||
|
on:keydown={handleInputKeydown}
|
||||||
|
{disabled}
|
||||||
|
{required}
|
||||||
|
aria-haspopup="dialog"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="absolute inset-y-0 right-0 flex items-center px-3 text-gray-500 dark:text-gray-400 focus:outline-none"
|
||||||
|
on:click={() => (isOpen = !isOpen)}
|
||||||
|
{disabled}
|
||||||
|
aria-label={isOpen ? "Close date picker" : "Open date picker"}
|
||||||
|
>
|
||||||
|
<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>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if isOpen || inline}
|
||||||
|
<div
|
||||||
|
bind:this={calendarRef}
|
||||||
|
id="datepicker-dropdown"
|
||||||
|
class="
|
||||||
|
{inline ? '' : 'absolute z-10 mt-1'}
|
||||||
|
bg-white dark:bg-gray-800 rounded-md shadow-lg"
|
||||||
|
transition:fade={{ duration: 100 }}
|
||||||
|
role="dialog"
|
||||||
|
aria-label="Calendar"
|
||||||
|
>
|
||||||
|
<div class="p-4" role="application">
|
||||||
|
{#if title}
|
||||||
|
<h2 class="text-lg font-semibold mb-4 dark:text-white">
|
||||||
|
{title}
|
||||||
|
</h2>
|
||||||
|
{/if}
|
||||||
|
<div class="flex items-center justify-between mb-4">
|
||||||
|
<Button
|
||||||
|
on:click={() => changeMonth(-1)}
|
||||||
|
{color}
|
||||||
|
size="sm"
|
||||||
|
aria-label="Previous month"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="w-3 h-3 rtl:rotate-180 text-white dark:text-white"
|
||||||
|
aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 14 10"
|
||||||
|
><path
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2"
|
||||||
|
d="M13 5H1m0 0 4 4M1 5l4-4"
|
||||||
|
></path></svg
|
||||||
|
>
|
||||||
|
</Button>
|
||||||
|
<h3
|
||||||
|
class="text-lg font-semibold dark:text-white"
|
||||||
|
aria-live="polite"
|
||||||
|
>
|
||||||
|
{currentMonth.toLocaleString(locale, {
|
||||||
|
month: "long",
|
||||||
|
year: "numeric",
|
||||||
|
})}
|
||||||
|
</h3>
|
||||||
|
<Button
|
||||||
|
on:click={() => changeMonth(1)}
|
||||||
|
{color}
|
||||||
|
size="sm"
|
||||||
|
aria-label="Next month"
|
||||||
|
>
|
||||||
|
<svg
|
||||||
|
class="w-3 h-3 rtl:rotate-180 text-white dark:text-white"
|
||||||
|
aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
|
fill="none"
|
||||||
|
viewBox="0 0 14 10"
|
||||||
|
><path
|
||||||
|
stroke="currentColor"
|
||||||
|
stroke-linecap="round"
|
||||||
|
stroke-linejoin="round"
|
||||||
|
stroke-width="2"
|
||||||
|
d="M1 5h12m0 0L9 1m4 4L9 9"
|
||||||
|
></path></svg
|
||||||
|
>
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
<div class="grid grid-cols-7 gap-1" role="grid">
|
||||||
|
{#each weekdays as day}
|
||||||
|
<div
|
||||||
|
class="text-center text-sm font-medium text-gray-500 dark:text-gray-400"
|
||||||
|
role="columnheader"
|
||||||
|
>
|
||||||
|
{day}
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
{#each daysInMonth as day}
|
||||||
|
<Button
|
||||||
|
color={isSelected(day) ? color : "alternative"}
|
||||||
|
size="sm"
|
||||||
|
class="w-full h-8 {day.getMonth() !==
|
||||||
|
currentMonth.getMonth()
|
||||||
|
? 'text-gray-300 dark:text-gray-600'
|
||||||
|
: ''} {isToday(day)
|
||||||
|
? 'font-bold'
|
||||||
|
: ''} {isInRange(day)
|
||||||
|
? getRangeBackgroundClass(color)
|
||||||
|
: ''}"
|
||||||
|
on:click={() => handleDaySelect(day)}
|
||||||
|
on:keydown={handleCalendarKeydown}
|
||||||
|
aria-label={day.toLocaleDateString(locale, {
|
||||||
|
weekday: "long",
|
||||||
|
year: "numeric",
|
||||||
|
month: "long",
|
||||||
|
day: "numeric",
|
||||||
|
})}
|
||||||
|
aria-selected={isSelected(day)}
|
||||||
|
role="gridcell"
|
||||||
|
>
|
||||||
|
{day.getDate()}
|
||||||
|
</Button>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
{#if showActionButtons}
|
||||||
|
<div class="mt-4 flex justify-between">
|
||||||
|
<Button on:click={handleToday} {color} size="sm"
|
||||||
|
>Today</Button
|
||||||
|
>
|
||||||
|
<Button on:click={handleClear} color="red" size="sm"
|
||||||
|
>Clear</Button
|
||||||
|
>
|
||||||
|
<Button on:click={handleApply} {color} size="sm"
|
||||||
|
>Apply</Button
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
@component
|
||||||
|
[Go to docs](https://flowbite-svelte.com/)
|
||||||
|
## Props
|
||||||
|
@prop export let value: Date | null = null;
|
||||||
|
@prop export let defaultDate: Date | null = null;
|
||||||
|
@prop export let range: boolean = false;
|
||||||
|
@prop export let rangeFrom: Date | null = null;
|
||||||
|
@prop export let rangeTo: Date | null = null;
|
||||||
|
@prop export let locale: string = 'default';
|
||||||
|
@prop export let firstDayOfWeek: number = 0;
|
||||||
|
@prop export let dateFormat: Intl.DateTimeFormatOptions = { year: 'numeric', month: 'long', day: 'numeric' };
|
||||||
|
@prop export let placeholder: string = 'Select date';
|
||||||
|
@prop export let disabled: boolean = false;
|
||||||
|
@prop export let required: boolean = false;
|
||||||
|
@prop export let inputClass: string = '';
|
||||||
|
@prop export let color: Button['color'] = 'primary';
|
||||||
|
@prop export let inline: boolean = false;
|
||||||
|
@prop export let autohide: boolean = true;
|
||||||
|
@prop export let showActionButtons: boolean = false;
|
||||||
|
@prop export let title: string = '';
|
||||||
|
-->
|
77
frontend/src/helperComponents/Header.svelte
Normal file
77
frontend/src/helperComponents/Header.svelte
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import Search from "./Search.svelte"
|
||||||
|
import {
|
||||||
|
aniListLoggedIn,
|
||||||
|
loginToAniList,
|
||||||
|
loginToMAL,
|
||||||
|
loginToSimkl,
|
||||||
|
malLoggedIn,
|
||||||
|
simklLoggedIn,
|
||||||
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte"
|
||||||
|
import AvatarMenu from "./AvatarMenu.svelte";
|
||||||
|
import logo from "../assets/images/AniTrackLogo.svg"
|
||||||
|
|
||||||
|
let isAniListLoggedIn: boolean
|
||||||
|
let isSimklLoggedIn: boolean
|
||||||
|
let isMALLoggedIn: boolean
|
||||||
|
|
||||||
|
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
||||||
|
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
|
||||||
|
malLoggedIn.subscribe((value) => isMALLoggedIn = value)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<nav class="border-gray-200 bg-gray-900">
|
||||||
|
<div class="max-w-screen-xl flex flex-wrap items-center justify-between mx-auto p-4">
|
||||||
|
<div class="flex items-center space-x-3 rtl:space-x-reverse">
|
||||||
|
<a href="/"><img src={logo} class="h-8" alt="AniTrack Logo"/></a>
|
||||||
|
</div>
|
||||||
|
<div class="flex items-center min-[950px]:order-2 space-x-3 min-[950px]:space-x-0 rtl:space-x-reverse">
|
||||||
|
<div class="min-[950px]:block min-[950px]:mr-4">
|
||||||
|
<Search />
|
||||||
|
</div>
|
||||||
|
<AvatarMenu/>
|
||||||
|
<button on:click={() => {
|
||||||
|
let menu = document.querySelector("#navbar-user")
|
||||||
|
menu.classList.toggle("hidden")
|
||||||
|
}} type="button"
|
||||||
|
class="inline-flex items-center p-2 w-10 h-10 justify-center text-sm rounded-lg min-[950px]:hidden focus:outline-none focus:ring-2 text-gray-400 hover:bg-gray-700 focus:ring-gray-600"
|
||||||
|
aria-controls="navbar-user" aria-expanded="false">
|
||||||
|
<span class="sr-only">Open main menu</span>
|
||||||
|
<svg class="w-5 h-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
||||||
|
viewBox="0 0 17 14">
|
||||||
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
|
d="M1 1h15M1 7h15M1 13h15"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="hidden items-center justify-between w-full pb-4 min-[950px]:pb-0 min-[950px]:flex min-[950px]:w-auto min-[950px]:order-1 border border-gray-700 min-[950px]:border-0 bg-gray-800 min-[950px]:bg-transparent rounded-lg" id="navbar-user">
|
||||||
|
<ul class="flex flex-col font-medium pb-6 min-[950px]:p-0 mt-4 min-[950px]:space-x-8 rtl:space-x-reverse min-[950px]:flex-row min-[950px]:mt-0">
|
||||||
|
<li>
|
||||||
|
{#if !isAniListLoggedIn}
|
||||||
|
<button on:click={loginToAniList}>
|
||||||
|
<!-- class="block py-2 px-3 w-full min-[950px]:w-auto rounded text-gray-300 min-[950px]:hover:text-blue-500 hover:bg-gray-700 hover:text-white min-[950px]:hover:bg-transparent border-gray-700">-->
|
||||||
|
AniList Login
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
{#if !isMALLoggedIn}
|
||||||
|
<button on:click={loginToMAL}>
|
||||||
|
<!-- class="block py-2 px-3 w-full min-[950px]:w-auto rounded min-[950px]:p-0 text-gray-300 min-[950px]:hover:text-blue-500 hover:bg-gray-700 hover:text-white min-[950px]:hover:bg-transparent border-gray-700">-->
|
||||||
|
MyAnimeList Login
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
{#if !isSimklLoggedIn}
|
||||||
|
<button on:click={loginToSimkl}>
|
||||||
|
<!-- class="block py-2 px-3 w-full min-[950px]:w-auto rounded min-[950px]:p-0 text-gray-300 min-[950px]:hover:text-blue-500 hover:bg-gray-700 hover:text-white min-[950px]:hover:bg-transparent border-gray-700">-->
|
||||||
|
Simkl Login
|
||||||
|
</button>
|
||||||
|
{/if}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="flex justify-center min-[950px]:hidden">
|
||||||
|
<Search/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</nav>
|
145
frontend/src/helperComponents/Pagination.svelte
Normal file
145
frontend/src/helperComponents/Pagination.svelte
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import {
|
||||||
|
aniListLoggedIn,
|
||||||
|
aniListWatchlist,
|
||||||
|
animePerPage,
|
||||||
|
watchListPage,
|
||||||
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
|
|
||||||
|
import type {AniListCurrentUserWatchList} from "../anilist/types/AniListCurrentUserWatchListType"
|
||||||
|
import {GetAniListUserWatchingList} from "../../wailsjs/go/main/App";
|
||||||
|
import {MediaListSort} from "../anilist/types/AniListTypes";
|
||||||
|
|
||||||
|
let aniListWatchListLoaded: AniListCurrentUserWatchList
|
||||||
|
let page: number
|
||||||
|
let perPage: number
|
||||||
|
|
||||||
|
watchListPage.subscribe(value => page = value)
|
||||||
|
animePerPage.subscribe(value => perPage = value)
|
||||||
|
aniListWatchlist.subscribe((value) => aniListWatchListLoaded = value)
|
||||||
|
|
||||||
|
const perPageOptions = [10, 20, 50]
|
||||||
|
|
||||||
|
function ChangeWatchListPage(newPage: number) {
|
||||||
|
GetAniListUserWatchingList(newPage, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
||||||
|
watchListPage.set(newPage)
|
||||||
|
aniListWatchlist.set(result)
|
||||||
|
aniListLoggedIn.set(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function changePage(e): void {
|
||||||
|
if ((e.key === "Enter" || e.key === "Tab") && Number(e.target.value) !== page) ChangeWatchListPage(Number(e.target.value))
|
||||||
|
}
|
||||||
|
|
||||||
|
function changeCountPerPage(e): void {
|
||||||
|
GetAniListUserWatchingList(1, Number(e.target.value), MediaListSort.UpdatedTimeDesc).then((result) => {
|
||||||
|
animePerPage.set(Number(e.target.value))
|
||||||
|
watchListPage.set(1)
|
||||||
|
aniListWatchlist.set(result)
|
||||||
|
aniListLoggedIn.set(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div class="mb-8">
|
||||||
|
{#if aniListWatchListLoaded.data.Page.pageInfo.lastPage <= 12}
|
||||||
|
<nav aria-label="Page navigation" class="hidden md:block">
|
||||||
|
<ul class="inline-flex -space-x-px text-base h-10">
|
||||||
|
{#if page === 1}
|
||||||
|
<li>
|
||||||
|
<button disabled
|
||||||
|
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight border border-e-0 rounded-s-lg border-gray-700 text-gray-400 cursor-default">
|
||||||
|
Previous
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{:else}
|
||||||
|
<li>
|
||||||
|
<button on:click={() => ChangeWatchListPage(page-1)}
|
||||||
|
class="flex items-center justify-center px-4 h-10 ms-0 leading-tight border border-e-0 rounded-s-lg border-gray-700 text-gray-400 hover:bg-gray-700 hover:text-white">
|
||||||
|
Previous
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
|
{#each {length: aniListWatchListLoaded.data.Page.pageInfo.lastPage} as _, i}
|
||||||
|
{#if i + 1 === page}
|
||||||
|
<li>
|
||||||
|
<button on:click={() => ChangeWatchListPage(i+1)}
|
||||||
|
class="flex items-center justify-center px-4 h-10 leading-tight border bg-gray-100 border-gray-700 bg-gray-700 text-white">{i + 1}</button>
|
||||||
|
</li>
|
||||||
|
{:else}
|
||||||
|
<li>
|
||||||
|
<button on:click={() => ChangeWatchListPage(i+1)}
|
||||||
|
class="flex items-center justify-center px-4 h-10 leading-tight border dark border-gray-700 text-gray-400 hover:bg-gray-700 hover:text-white">{i + 1}</button>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
{#if page === aniListWatchListLoaded.data.Page.pageInfo.lastPage}
|
||||||
|
<li>
|
||||||
|
<button disabled
|
||||||
|
class="flex items-center justify-center px-4 h-10 leading-tight border rounded-e-lg dark border-gray-700 text-gray-400 cursor-default">
|
||||||
|
Next
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{:else}
|
||||||
|
<li>
|
||||||
|
<button on:click={() => ChangeWatchListPage(page+1)}
|
||||||
|
class="flex items-center justify-center px-4 h-10 leading-tight border rounded-e-lg dark border-gray-700 text-gray-400 hover:bg-gray-700 hover:text-white">
|
||||||
|
Next
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
{/if}
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
{/if}
|
||||||
|
<div class="flex mt-5">
|
||||||
|
<div class="w-20 mx-auto">
|
||||||
|
<select bind:value={perPage} on:change={(e) => changeCountPerPage(e)} id="countPerPage"
|
||||||
|
class="border text-sm rounded-lg block w-full p-2.5 bg-gray-700 border-gray-600 placeholder-gray-400 text-white focus:ring-blue-500 focus:border-blue-500">
|
||||||
|
{#each perPageOptions as option}
|
||||||
|
<option value={option}>
|
||||||
|
{option}
|
||||||
|
</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<div>Total Anime: {aniListWatchListLoaded.data.Page.pageInfo.total}</div>
|
||||||
|
{#if aniListWatchListLoaded.data.Page.pageInfo.lastPage <= 12}
|
||||||
|
<div class="md:hidden">Page: {page} of {aniListWatchListLoaded.data.Page.pageInfo.lastPage}</div>
|
||||||
|
{:else}
|
||||||
|
<div>Page: {page} of {aniListWatchListLoaded.data.Page.pageInfo.lastPage}</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="max-w-xs mx-auto">
|
||||||
|
<div class="relative flex items-center max-w-[11rem]">
|
||||||
|
<button type="button" id="decrement-button" on:click={() => ChangeWatchListPage(page-1)}
|
||||||
|
class="bg-gray-700 hover:bg-gray-600 border-gray-600 border rounded-s-lg p-3 h-11 focus:ring-gray-700 focus:ring-2 focus:outline-none">
|
||||||
|
<svg class="w-3 h-3 text-white" aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 2">
|
||||||
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
|
d="M1 1h16"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
<input type="number" min="1" max="{aniListWatchListLoaded.data.Page.pageInfo.lastPage}"
|
||||||
|
on:keydown={changePage} id="page-counter"
|
||||||
|
class="[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none border-x-0 h-11 font-medium text-center text-sm block w-full pb-6 bg-gray-700 border-gray-600 placeholder-gray-400 text-white focus:ring-blue-500 focus:border-blue-500"
|
||||||
|
value={page} required/>
|
||||||
|
<div class="absolute bottom-1 start-1/2 -translate-x-1/2 rtl:translate-x-1/2 flex items-center text-xs text-gray-400 space-x-1 rtl:space-x-reverse">
|
||||||
|
<span>Page #</span>
|
||||||
|
</div>
|
||||||
|
<button type="button" id="increment-button" on:click={() => ChangeWatchListPage(page+1)}
|
||||||
|
class="hover:bg-gray-600 border-gray-600 border rounded-e-lg p-3 h-11 focus:ring-gray-700 focus:ring-2 focus:outline-none">
|
||||||
|
<svg class="w-3 h-3 text-white" aria-hidden="true"
|
||||||
|
xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 18 18">
|
||||||
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
|
d="M9 1v16M1 9h16"/>
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
50
frontend/src/helperComponents/Rating.svelte
Normal file
50
frontend/src/helperComponents/Rating.svelte
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import StarRatting from "../star-rating/Stars.svelte";
|
||||||
|
|
||||||
|
export let score
|
||||||
|
|
||||||
|
let config = {
|
||||||
|
readOnly: false,
|
||||||
|
countStars: 5,
|
||||||
|
range: {
|
||||||
|
min: 0,
|
||||||
|
max: 5,
|
||||||
|
step: 0.5
|
||||||
|
},
|
||||||
|
score: score / 2,
|
||||||
|
showScore: false,
|
||||||
|
name: "rating",
|
||||||
|
scoreFormat: function(){ return `(${this.score.toFixed(0)}/${this.countStars})` },
|
||||||
|
starConfig: {
|
||||||
|
size: 32,
|
||||||
|
fillColor: '#F9ED4F',
|
||||||
|
strokeColor: "#e2c714",
|
||||||
|
unfilledColor: '#FFF',
|
||||||
|
strokeUnfilledColor: '#000'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const ratingInWords = {
|
||||||
|
0: "Not Reviewed",
|
||||||
|
1: "Appalling",
|
||||||
|
2: "Horrible",
|
||||||
|
3: "Very Bad",
|
||||||
|
4: "Bad",
|
||||||
|
5: "Average",
|
||||||
|
6: "Fine",
|
||||||
|
7: "Good",
|
||||||
|
8: "Very Good",
|
||||||
|
9: "Great",
|
||||||
|
10: "Masterpiece",
|
||||||
|
}
|
||||||
|
|
||||||
|
const changeRating = (e: any) => {
|
||||||
|
score = e.target.valueAsNumber * 2
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<StarRatting bind:config on:change={changeRating}/>
|
||||||
|
<p>Rating: {config.score * 2}</p>
|
||||||
|
<p>{ratingInWords[config.score * 2]}</p>
|
||||||
|
</div>
|
@ -1,8 +1,8 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
import {AniListSearch} from "../wailsjs/go/main/App";
|
import {AniListSearch} from "../../wailsjs/go/main/App";
|
||||||
import type {AniSearchList} from "./anilist/types/AniListTypes";
|
import type {AniSearchList} from "../anilist/types/AniListTypes";
|
||||||
import {GetAniListSingleItemAndOpenModal} from "./GlobalVariablesAndHelperFunctions.svelte";
|
import {push} from "svelte-spa-router";
|
||||||
|
|
||||||
let aniSearch = ""
|
let aniSearch = ""
|
||||||
let aniListSearch: AniSearchList
|
let aniListSearch: AniSearchList
|
||||||
@ -10,7 +10,6 @@
|
|||||||
|
|
||||||
function runAniListSearch(): void {
|
function runAniListSearch(): void {
|
||||||
AniListSearch(aniSearch).then(result => {
|
AniListSearch(aniSearch).then(result => {
|
||||||
console.log(result.data.Page.media[5])
|
|
||||||
aniListSearch = result
|
aniListSearch = result
|
||||||
aniListSearchActive = true
|
aniListSearchActive = true
|
||||||
})
|
})
|
||||||
@ -24,16 +23,23 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
<div id="searchDropdown" class="relative">
|
<div id="searchDropdown" class="relative w-64 md:w-48">
|
||||||
<div class="flex">
|
<div class="flex">
|
||||||
<label for="anime-search" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Find
|
<label for="anime-search" class="mb-2 text-sm font-medium sr-only text-white">Find
|
||||||
Anime</label>
|
Anime</label>
|
||||||
<div class="relative w-full">
|
<div class="relative w-full">
|
||||||
<input type="search" id="anime-search" bind:value={aniSearch}
|
<input type="search" id="anime-search" bind:value={aniSearch}
|
||||||
class="rounded-s-lg block p-2.5 w-full z-20 text-sm text-gray-900 bg-gray-50 rounded-e-lg border-s-gray-50 border-s-2 border border-gray-300 focus:ring-blue-500 focus:border-blue-500 dark:bg-gray-700 dark:border-s-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:border-blue-500"
|
class="rounded-s-lg block p-2.5 w-full z-20 text-sm rounded-e-lg bg-gray-700 border-s-gray-700 border-gray-600 placeholder-gray-400 text-white focus:border-blue-500"
|
||||||
placeholder="Search for Anime" required/>
|
placeholder="Search for Anime"
|
||||||
|
on:keypress={(e) => {
|
||||||
|
if (e.key === "Enter") {
|
||||||
|
searchDropdown()
|
||||||
|
if(aniSearch.length > 0) runAniListSearch()
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
required/>
|
||||||
<button id="aniListSearchButton"
|
<button id="aniListSearchButton"
|
||||||
class="absolute top-0 end-0 h-full p-2.5 text-sm font-medium text-white bg-blue-700 rounded-e-lg border border-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 dark:bg-blue-600 dark:hover:bg-blue-700 dark:focus:ring-blue-800"
|
class="absolute top-0 end-0 h-full p-2.5 text-sm font-medium rounded-e-lg border focus:ring-4 focus:outline-none bg-blue-600 hover:bg-blue-700 focus:ring-blue-800"
|
||||||
on:click={() => {
|
on:click={() => {
|
||||||
searchDropdown()
|
searchDropdown()
|
||||||
if(aniSearch.length > 0) runAniListSearch()
|
if(aniSearch.length > 0) runAniListSearch()
|
||||||
@ -54,16 +60,18 @@
|
|||||||
aria-labelledby="aniListSearchButton">
|
aria-labelledby="aniListSearchButton">
|
||||||
{#each aniListSearch.data.Page.media as media}
|
{#each aniListSearch.data.Page.media as media}
|
||||||
<li class="w-full">
|
<li class="w-full">
|
||||||
<div class="flex w-full items-start p-1 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white rounded-lg">
|
<div class="flex w-full items-start p-1 hover:bg-gray-600 hover:text-white rounded-lg">
|
||||||
<button on:click={() => {
|
<button on:click={() => {
|
||||||
GetAniListSingleItemAndOpenModal(media.id, false)
|
searchDropdown()
|
||||||
|
push(`#/anime/${media.id}`)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<img class="rounded-bl-lg rounded-tl-lg max-w-24 max-h-24" src={media.coverImage.large}
|
<img class="rounded-bl-lg rounded-tl-lg max-w-24 max-h-24" src={media.coverImage.large}
|
||||||
alt="{media.title.english === '' || media.title.english === null ? media.title.romaji : media.title.english} Cover">
|
alt="{media.title.english === '' || media.title.english === null ? media.title.romaji : media.title.english} Cover">
|
||||||
</button>
|
</button>
|
||||||
<button class="rounded-bl-lg rounded-tl-lg w-full h-24" on:click={() => {
|
<button class="rounded-bl-lg rounded-tl-lg w-full h-24" on:click={() => {
|
||||||
GetAniListSingleItemAndOpenModal(media.id, false)
|
searchDropdown()
|
||||||
|
push(`#/anime/${media.id}`)
|
||||||
}} >{media.title.english === '' || media.title.english === null ? media.title.romaji : media.title.english }</button>
|
}} >{media.title.english === '' || media.title.english === null ? media.title.romaji : media.title.english }</button>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
11
frontend/src/helperComponents/Spinner.svelte
Normal file
11
frontend/src/helperComponents/Spinner.svelte
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
<div id="spinner" role="status" class="fixed -translate-x-1/2 -translate-y-1/2 top-2/4 left-1/2">
|
||||||
|
<svg aria-hidden="true"
|
||||||
|
class="inline w-16 h-16 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
|
||||||
|
viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||||
|
<path d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
||||||
|
fill="currentColor"/>
|
||||||
|
<path d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
||||||
|
fill="currentFill"/>
|
||||||
|
</svg>
|
||||||
|
<span class="sr-only">Loading...</span>
|
||||||
|
</div>
|
68
frontend/src/helperComponents/WatchList.svelte
Normal file
68
frontend/src/helperComponents/WatchList.svelte
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import {
|
||||||
|
aniListLoggedIn,
|
||||||
|
aniListWatchlist,
|
||||||
|
GetAnimeSingleItem,
|
||||||
|
loading,
|
||||||
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
|
import {push} from "svelte-spa-router";
|
||||||
|
import type {AniListCurrentUserWatchList} from "../anilist/types/AniListCurrentUserWatchListType"
|
||||||
|
import {Rating} from "flowbite-svelte";
|
||||||
|
import loader from '../helperFunctions/loader'
|
||||||
|
|
||||||
|
|
||||||
|
let isAniListLoggedIn: boolean
|
||||||
|
let aniListWatchListLoaded: AniListCurrentUserWatchList
|
||||||
|
|
||||||
|
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
||||||
|
aniListWatchlist.subscribe((value) => aniListWatchListLoaded = value)
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
{#if isAniListLoggedIn}
|
||||||
|
<div class="mx-auto max-w-2xl p-4 sm:p-6 lg:max-w-7xl lg:px-8 relative items-center">
|
||||||
|
<h1 class="text-left text-xl font-bold mb-4">Your AniList WatchList</h1>
|
||||||
|
|
||||||
|
<div class="grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 xl:gap-x-8">
|
||||||
|
{#each aniListWatchListLoaded.data.Page.mediaList as media}
|
||||||
|
<div use:loader={loading} class="aspect-h-1 aspect-w-1 w-full overflow-hidden rounded-lg xl:aspect-h-8 xl:aspect-w-7">
|
||||||
|
<div class="flex flex-col items-center group">
|
||||||
|
<button on:click={() => {
|
||||||
|
push(`#/anime/${media.media.id}`)
|
||||||
|
// loading.set(true)
|
||||||
|
// GetAniListSingleItem(media.media.id, true).then(() => {
|
||||||
|
// loading.set(false)
|
||||||
|
//
|
||||||
|
// })
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<img class="rounded-lg" src={media.media.coverImage.large} alt={
|
||||||
|
media.media.title.english === "" ?
|
||||||
|
media.media.title.romaji :
|
||||||
|
media.media.title.english
|
||||||
|
}/>
|
||||||
|
</button>
|
||||||
|
<Rating id="anime-rating" total={5} size={35} rating={media.score/2.0}/>
|
||||||
|
<button class="mt-4 text-md font-semibold text-white-700"
|
||||||
|
on:click={() => GetAnimeSingleItem(media.media.id, true)}>
|
||||||
|
{
|
||||||
|
media.media.title.english === "" ?
|
||||||
|
media.media.title.romaji :
|
||||||
|
media.media.title.english
|
||||||
|
}
|
||||||
|
</button>
|
||||||
|
<p class="mt-1 text-lg font-medium text-white-900">{media.progress}
|
||||||
|
/ {media.media.nextAiringEpisode.episode !== 0 ?
|
||||||
|
media.media.nextAiringEpisode.episode - 1 : media.media.episodes}</p>
|
||||||
|
{#if media.media.episodes > 0}
|
||||||
|
<p class="mt-1 text-lg font-medium text-white-900">Total
|
||||||
|
Episodes: {media.media.episodes}</p>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
28
frontend/src/helperComponents/WebsiteLink.svelte
Normal file
28
frontend/src/helperComponents/WebsiteLink.svelte
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import {BrowserOpenURL} from "../../wailsjs/runtime"
|
||||||
|
|
||||||
|
export let id: string
|
||||||
|
let url = ""
|
||||||
|
let isAniList = false
|
||||||
|
let isMAL = false
|
||||||
|
let isSimkl = false
|
||||||
|
let newId = id
|
||||||
|
let re = /[ams]?-?(.*)/
|
||||||
|
if (id !== undefined && id.length > 0) {
|
||||||
|
isAniList = id.includes("a-")
|
||||||
|
isMAL = id.includes("m-")
|
||||||
|
isSimkl = id.includes("s-")
|
||||||
|
newId = id.match(re)[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (isAniList) url = `https://anilist.co/anime/${newId}`
|
||||||
|
if (isMAL) url = `https://myanimelist.net/anime/${newId}`
|
||||||
|
if (isSimkl) url = `https://simkl.com/anime/${newId}`
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if url.length > 0}
|
||||||
|
<button class="underline underline-offset-2 px-4 py-1" on:click={() => BrowserOpenURL(url)}>{newId}</button>
|
||||||
|
{:else}
|
||||||
|
{id}
|
||||||
|
{/if}
|
65
frontend/src/helperDefaults/AniListGetSingleAnime.ts
Normal file
65
frontend/src/helperDefaults/AniListGetSingleAnime.ts
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
import type {AniListGetSingleAnime} from "../anilist/types/AniListCurrentUserWatchListType";
|
||||||
|
|
||||||
|
export const AniListGetSingleAnimeDefaultData: AniListGetSingleAnime = {
|
||||||
|
data: {
|
||||||
|
MediaList: {
|
||||||
|
id: 0,
|
||||||
|
mediaId: 0,
|
||||||
|
userId: 0,
|
||||||
|
media: {
|
||||||
|
id: 0,
|
||||||
|
idMal: 0,
|
||||||
|
title: {
|
||||||
|
romaji: "",
|
||||||
|
english: "",
|
||||||
|
native: "",
|
||||||
|
},
|
||||||
|
description: "",
|
||||||
|
coverImage: {
|
||||||
|
large: "",
|
||||||
|
},
|
||||||
|
season: "",
|
||||||
|
seasonYear: 0,
|
||||||
|
status: "",
|
||||||
|
episodes: 0,
|
||||||
|
nextAiringEpisode: {
|
||||||
|
airingAt: 0,
|
||||||
|
timeUntilAiring: 0,
|
||||||
|
episode: 0,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
status: "",
|
||||||
|
startedAt: {
|
||||||
|
year: 0,
|
||||||
|
month: 0,
|
||||||
|
day: 0,
|
||||||
|
},
|
||||||
|
completedAt: {
|
||||||
|
year: 0,
|
||||||
|
month: 0,
|
||||||
|
day: 0,
|
||||||
|
},
|
||||||
|
notes: "",
|
||||||
|
progress: 0,
|
||||||
|
score: 0,
|
||||||
|
repeat: 0,
|
||||||
|
user: {
|
||||||
|
id: 0,
|
||||||
|
name: "",
|
||||||
|
avatar: {
|
||||||
|
large: "",
|
||||||
|
medium: "",
|
||||||
|
},
|
||||||
|
statistics: {
|
||||||
|
anime: {
|
||||||
|
count: 0,
|
||||||
|
statuses: [{
|
||||||
|
status: "",
|
||||||
|
count: 0,
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
37
frontend/src/helperFunctions/convertAniListDateIn.ts
Normal file
37
frontend/src/helperFunctions/convertAniListDateIn.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import moment from "moment";
|
||||||
|
|
||||||
|
const convertAniListDateToString = (date: {
|
||||||
|
year?: number;
|
||||||
|
month?: number;
|
||||||
|
day?: number;
|
||||||
|
}): string => {
|
||||||
|
if (
|
||||||
|
date.year === undefined ||
|
||||||
|
(date.year === 0 && date.month === undefined) ||
|
||||||
|
(date.month === 0 && date.day === undefined) ||
|
||||||
|
date.day === 0
|
||||||
|
) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
const newISODate = new Date(date.year, date.month - 1, date.day);
|
||||||
|
const newMoment = moment(newISODate);
|
||||||
|
return newMoment.format("MM-DD-YYYY");
|
||||||
|
};
|
||||||
|
|
||||||
|
const convertAniListDateToDate = (date: {
|
||||||
|
year?: number;
|
||||||
|
month?: number;
|
||||||
|
day?: number;
|
||||||
|
}): Date | null => {
|
||||||
|
if (
|
||||||
|
date.year === undefined ||
|
||||||
|
(date.year === 0 && date.month === undefined) ||
|
||||||
|
(date.month === 0 && date.day === undefined) ||
|
||||||
|
date.day === 0
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new Date(date.year, date.month - 1, date.day);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { convertAniListDateToString, convertAniListDateToDate };
|
39
frontend/src/helperFunctions/convertDateToAniList.ts
Normal file
39
frontend/src/helperFunctions/convertDateToAniList.ts
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
type AnilistDate = {
|
||||||
|
year: number;
|
||||||
|
month: number;
|
||||||
|
day: number;
|
||||||
|
};
|
||||||
|
|
||||||
|
const convertDateStringToAniList = (date: string): AnilistDate => {
|
||||||
|
if (date === "") {
|
||||||
|
return {
|
||||||
|
year: 0,
|
||||||
|
month: 0,
|
||||||
|
day: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
const re = /^([0-9]{4})-([0-9]{2})-([0-9]{2})/;
|
||||||
|
const newDate = re.exec(date);
|
||||||
|
return {
|
||||||
|
year: Number(newDate[1]),
|
||||||
|
month: Number(newDate[2]),
|
||||||
|
day: Number(newDate[3]),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const convertDateToAniList = (date: Date | null): AnilistDate => {
|
||||||
|
if (date === null) {
|
||||||
|
return {
|
||||||
|
year: 0,
|
||||||
|
month: 0,
|
||||||
|
day: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
year: Number(date.getFullYear()),
|
||||||
|
month: Number(date.getMonth()) + 1,
|
||||||
|
day: Number(date.getDate()),
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
export { convertDateStringToAniList, convertDateToAniList };
|
18
frontend/src/helperFunctions/loader.ts
Normal file
18
frontend/src/helperFunctions/loader.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import Spinner from '../helperComponents/Spinner.svelte';
|
||||||
|
|
||||||
|
export default (node: any, loading: any) => {
|
||||||
|
let Spin: any
|
||||||
|
loading.subscribe((loading: any) => {
|
||||||
|
if(loading){
|
||||||
|
Spin = new Spinner({
|
||||||
|
target: node,
|
||||||
|
intro: true
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
if(Spin){
|
||||||
|
Spin?.$destroy?.()
|
||||||
|
Spin = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
21
frontend/src/helperModules/AddAnimeServiceToTable.svelte
Normal file
21
frontend/src/helperModules/AddAnimeServiceToTable.svelte
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
import type {TableItem} from "../helperTypes/TableTypes";
|
||||||
|
import { tableItems } from "./GlobalVariablesAndHelperFunctions.svelte"
|
||||||
|
|
||||||
|
export function AddAnimeServiceToTable(animeItem: TableItem) {
|
||||||
|
tableItems.update((table) => {
|
||||||
|
if (table.length === 0) {
|
||||||
|
table.push(animeItem)
|
||||||
|
} else {
|
||||||
|
for (const [index, tableItem] of table.entries()) {
|
||||||
|
if(tableItem.service === animeItem.service) {
|
||||||
|
table[index] = animeItem
|
||||||
|
return table
|
||||||
|
}
|
||||||
|
}
|
||||||
|
table.push(animeItem)
|
||||||
|
}
|
||||||
|
return table
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,34 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
import {CheckIfAniListLoggedIn, GetAniListLoggedInUser, GetAniListUserWatchingList} from "../../wailsjs/go/main/App";
|
||||||
|
import {MediaListSort} from "../anilist/types/AniListTypes";
|
||||||
|
import { aniListUser, watchListPage, animePerPage, aniListPrimary, aniListLoggedIn, aniListWatchlist } from "./GlobalVariablesAndHelperFunctions.svelte"
|
||||||
|
|
||||||
|
let isAniListPrimary: boolean
|
||||||
|
let page: number
|
||||||
|
let perPage: number
|
||||||
|
|
||||||
|
aniListPrimary.subscribe(value => isAniListPrimary = value)
|
||||||
|
watchListPage.subscribe(value => page = value)
|
||||||
|
animePerPage.subscribe(value => perPage = value)
|
||||||
|
|
||||||
|
export const LoadAniListUser = async () => {
|
||||||
|
await GetAniListLoggedInUser().then(user => {
|
||||||
|
aniListUser.set(user)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const LoadAniListWatchList = async () => {
|
||||||
|
await GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((watchList) => {
|
||||||
|
aniListWatchlist.set(watchList)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export const CheckIfAniListLoggedInAndLoadWatchList = async () => {
|
||||||
|
const loggedIn = await CheckIfAniListLoggedIn()
|
||||||
|
if (loggedIn) {
|
||||||
|
await LoadAniListUser()
|
||||||
|
if (isAniListPrimary) await LoadAniListWatchList()
|
||||||
|
}
|
||||||
|
aniListLoggedIn.set(loggedIn)
|
||||||
|
}
|
||||||
|
</script>
|
25
frontend/src/helperModules/CheckIfMyAnimeListLoggedIn.svelte
Normal file
25
frontend/src/helperModules/CheckIfMyAnimeListLoggedIn.svelte
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
import {CheckIfMyAnimeListLoggedIn, GetMyAnimeList, GetMyAnimeListLoggedInUser} from "../../wailsjs/go/main/App";
|
||||||
|
import {malUser, malPrimary, malWatchList, malLoggedIn} from "./GlobalVariablesAndHelperFunctions.svelte"
|
||||||
|
|
||||||
|
let isMalPrimary: boolean
|
||||||
|
malPrimary.subscribe(value => isMalPrimary = value)
|
||||||
|
|
||||||
|
export const CheckIfMALLoggedInAndSetUser = async () => {
|
||||||
|
await CheckIfMyAnimeListLoggedIn().then(loggedIn => {
|
||||||
|
if (loggedIn) {
|
||||||
|
GetMyAnimeListLoggedInUser().then(user => {
|
||||||
|
malUser.set(user)
|
||||||
|
if (isMalPrimary) {
|
||||||
|
GetMyAnimeList(1000).then(watchList => {
|
||||||
|
malWatchList.set(watchList)
|
||||||
|
malLoggedIn.set(loggedIn)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
malLoggedIn.set(loggedIn)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
29
frontend/src/helperModules/CheckIsSimklLoggedIn.svelte
Normal file
29
frontend/src/helperModules/CheckIsSimklLoggedIn.svelte
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
import {CheckIfSimklLoggedIn, GetSimklLoggedInUser, SimklGetUserWatchlist} from "../../wailsjs/go/main/App";
|
||||||
|
import { simklLoggedIn, simklUser, simklPrimary, simklWatchList } from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||||
|
|
||||||
|
let isSimklPrimary: boolean
|
||||||
|
simklPrimary.subscribe(value => isSimklPrimary = value)
|
||||||
|
|
||||||
|
export const CheckIfSimklLoggedInAndSetUser = async () => {
|
||||||
|
await CheckIfSimklLoggedIn().then(loggedIn => {
|
||||||
|
if (loggedIn) {
|
||||||
|
GetSimklLoggedInUser().then(user => {
|
||||||
|
if (Object.keys(user).length === 0) {
|
||||||
|
simklLoggedIn.set(false)
|
||||||
|
} else {
|
||||||
|
simklUser.set(user)
|
||||||
|
if (isSimklPrimary) {
|
||||||
|
SimklGetUserWatchlist().then(result => {
|
||||||
|
simklWatchList.set(result)
|
||||||
|
simklLoggedIn.set(loggedIn)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
simklLoggedIn.set(loggedIn)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
@ -0,0 +1,162 @@
|
|||||||
|
<script lang="ts" context="module">
|
||||||
|
import {
|
||||||
|
GetAniListItem,
|
||||||
|
GetAniListLoggedInUser,
|
||||||
|
GetAniListUserWatchingList,
|
||||||
|
GetMyAnimeListAnime,
|
||||||
|
GetMyAnimeListLoggedInUser,
|
||||||
|
GetSimklLoggedInUser,
|
||||||
|
LogoutAniList,
|
||||||
|
LogoutMyAnimeList,
|
||||||
|
LogoutSimkl,
|
||||||
|
SimklGetUserWatchlist,
|
||||||
|
SimklSearch
|
||||||
|
} from "../../wailsjs/go/main/App";
|
||||||
|
import type {
|
||||||
|
AniListCurrentUserWatchList,
|
||||||
|
AniListGetSingleAnime
|
||||||
|
} from "../anilist/types/AniListCurrentUserWatchListType.js";
|
||||||
|
import {writable} from 'svelte/store'
|
||||||
|
import type {SimklAnime, SimklUser, SimklWatchList} from "../simkl/types/simklTypes";
|
||||||
|
import {type AniListUser, MediaListSort} from "../anilist/types/AniListTypes";
|
||||||
|
import type {MALAnime, MALWatchlist, MyAnimeListUser} from "../mal/types/MALTypes";
|
||||||
|
import type {TableItems} from "../helperTypes/TableTypes";
|
||||||
|
import {AniListGetSingleAnimeDefaultData} from "../helperDefaults/AniListGetSingleAnime";
|
||||||
|
|
||||||
|
export let aniListAnime = writable(AniListGetSingleAnimeDefaultData)
|
||||||
|
export let title = writable("")
|
||||||
|
export let aniListLoggedIn = writable(false)
|
||||||
|
export let simklLoggedIn = writable(false)
|
||||||
|
export let malLoggedIn = writable(false)
|
||||||
|
export let simklWatchList = writable({} as SimklWatchList)
|
||||||
|
export let aniListPrimary = writable(true)
|
||||||
|
export let simklPrimary = writable(false)
|
||||||
|
export let malPrimary = writable(false)
|
||||||
|
export let simklUser = writable({} as SimklUser)
|
||||||
|
export let aniListUser = writable({} as AniListUser)
|
||||||
|
export let malUser = writable({} as MyAnimeListUser)
|
||||||
|
export let aniListWatchlist = writable({} as AniListCurrentUserWatchList)
|
||||||
|
export let malWatchList = writable({} as MALWatchlist)
|
||||||
|
export let malAnime = writable({} as MALAnime)
|
||||||
|
export let simklAnime = writable({} as SimklAnime)
|
||||||
|
export let loading = writable(false)
|
||||||
|
export let tableItems = writable([] as TableItems)
|
||||||
|
|
||||||
|
export let watchListPage = writable(1)
|
||||||
|
export let animePerPage = writable(20)
|
||||||
|
|
||||||
|
let isAniListPrimary: boolean
|
||||||
|
let page: number
|
||||||
|
let perPage: number
|
||||||
|
let aniWatchlist: AniListCurrentUserWatchList
|
||||||
|
let currentAniListAnime: AniListGetSingleAnime
|
||||||
|
|
||||||
|
let isMalLoggedIn: boolean
|
||||||
|
let isSimklLoggedIn: boolean
|
||||||
|
|
||||||
|
aniListPrimary.subscribe(value => isAniListPrimary = value)
|
||||||
|
watchListPage.subscribe(value => page = value)
|
||||||
|
animePerPage.subscribe(value => perPage = value)
|
||||||
|
aniListWatchlist.subscribe(value => aniWatchlist = value)
|
||||||
|
malLoggedIn.subscribe(value => isMalLoggedIn = value)
|
||||||
|
simklLoggedIn.subscribe(value => isSimklLoggedIn = value)
|
||||||
|
aniListAnime.subscribe(value => currentAniListAnime = value)
|
||||||
|
|
||||||
|
|
||||||
|
export async function GetAnimeSingleItem(aniId: number, login: boolean): Promise<""> {
|
||||||
|
await GetAniListItem(aniId, login).then(aniListResult => {
|
||||||
|
let finalResult: AniListGetSingleAnime
|
||||||
|
finalResult = aniListResult
|
||||||
|
if (login === false) {
|
||||||
|
finalResult.data.MediaList.status = ""
|
||||||
|
finalResult.data.MediaList.score = 0
|
||||||
|
finalResult.data.MediaList.progress = 0
|
||||||
|
finalResult.data.MediaList.notes = ""
|
||||||
|
finalResult.data.MediaList.repeat = 0
|
||||||
|
finalResult.data.MediaList.startedAt.day = 0
|
||||||
|
finalResult.data.MediaList.startedAt.month = 0
|
||||||
|
finalResult.data.MediaList.startedAt.year = 0
|
||||||
|
finalResult.data.MediaList.completedAt.day = 0
|
||||||
|
finalResult.data.MediaList.completedAt.month = 0
|
||||||
|
finalResult.data.MediaList.completedAt.year = 0
|
||||||
|
}
|
||||||
|
aniListAnime.set(finalResult)
|
||||||
|
title.set(currentAniListAnime.data.MediaList.media.title.english === "" ?
|
||||||
|
currentAniListAnime.data.MediaList.media.title.romaji :
|
||||||
|
currentAniListAnime.data.MediaList.media.title.english)
|
||||||
|
})
|
||||||
|
if (isMalLoggedIn) {
|
||||||
|
await GetMyAnimeListAnime(currentAniListAnime.data.MediaList.media.idMal).then(malResult => {
|
||||||
|
malAnime.set(malResult)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
if (isSimklLoggedIn) {
|
||||||
|
await SimklSearch(currentAniListAnime.data.MediaList).then((value: SimklAnime) => {
|
||||||
|
simklAnime.set(value)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loginToSimkl(): void {
|
||||||
|
GetSimklLoggedInUser().then(user => {
|
||||||
|
if (Object.keys(user).length === 0) {
|
||||||
|
simklLoggedIn.set(false)
|
||||||
|
} else {
|
||||||
|
simklUser.set(user)
|
||||||
|
SimklGetUserWatchlist().then(result => {
|
||||||
|
simklWatchList.set(result)
|
||||||
|
simklLoggedIn.set(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loginToAniList(): void {
|
||||||
|
GetAniListLoggedInUser().then(result => {
|
||||||
|
aniListUser.set(result)
|
||||||
|
if (isAniListPrimary) {
|
||||||
|
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
||||||
|
aniListWatchlist.set(result)
|
||||||
|
aniListLoggedIn.set(true)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
aniListLoggedIn.set(true)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function loginToMAL(): void {
|
||||||
|
GetMyAnimeListLoggedInUser().then(result => {
|
||||||
|
malUser.set(result)
|
||||||
|
malLoggedIn.set(true)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function logoutOfAniList(): void {
|
||||||
|
LogoutAniList().then(result => {
|
||||||
|
console.log(result)
|
||||||
|
if (Object.keys(aniWatchlist).length !== 0) {
|
||||||
|
aniListWatchlist.set({} as AniListCurrentUserWatchList)
|
||||||
|
}
|
||||||
|
aniListUser.set({} as AniListUser)
|
||||||
|
aniListLoggedIn.set(false)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function logoutOfMAL(): void {
|
||||||
|
LogoutMyAnimeList().then(result => {
|
||||||
|
console.log(result)
|
||||||
|
malUser.set({} as MyAnimeListUser)
|
||||||
|
malLoggedIn.set(false)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function logoutOfSimkl(): void {
|
||||||
|
LogoutSimkl().then(result => {
|
||||||
|
console.log(result)
|
||||||
|
simklUser.set({} as SimklUser)
|
||||||
|
simklLoggedIn.set(false)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</script>
|
8
frontend/src/helperTypes/StatusTypes.ts
Normal file
8
frontend/src/helperTypes/StatusTypes.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
export type StatusOptions = StatusOption[]
|
||||||
|
|
||||||
|
export type StatusOption = {
|
||||||
|
id: number,
|
||||||
|
aniList: string,
|
||||||
|
mal: string,
|
||||||
|
simkl: string,
|
||||||
|
}
|
14
frontend/src/helperTypes/TableTypes.ts
Normal file
14
frontend/src/helperTypes/TableTypes.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
export type TableItems = TableItem[]
|
||||||
|
|
||||||
|
export type TableItem = {
|
||||||
|
id: string
|
||||||
|
title: string
|
||||||
|
service: string
|
||||||
|
progress: number
|
||||||
|
status: string
|
||||||
|
startedAt: string
|
||||||
|
completedAt: string
|
||||||
|
score: number
|
||||||
|
repeat: number
|
||||||
|
notes: string
|
||||||
|
}
|
@ -29,3 +29,136 @@ export interface AnimeStatistics {
|
|||||||
numTimesRewatched: number
|
numTimesRewatched: number
|
||||||
meanScore: number
|
meanScore: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MALWatchlist {
|
||||||
|
data: [MALAnimeFromList]
|
||||||
|
paging: Paging
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MALAnimeFromList {
|
||||||
|
node: Node
|
||||||
|
listStatus: ListStatus | MalListStatus
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Node {
|
||||||
|
id: number
|
||||||
|
title: string
|
||||||
|
mainPicture: MainPicture
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MainPicture {
|
||||||
|
medium: string
|
||||||
|
large: string
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export interface Paging {
|
||||||
|
previous: string
|
||||||
|
next: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MALAnime {
|
||||||
|
id: number;
|
||||||
|
title: string;
|
||||||
|
main_picture: {
|
||||||
|
large: string;
|
||||||
|
medium: string;
|
||||||
|
};
|
||||||
|
alternative_titles: {
|
||||||
|
synonyms: string[];
|
||||||
|
en: string;
|
||||||
|
ja: string;
|
||||||
|
};
|
||||||
|
start_date: string;
|
||||||
|
end_date: string;
|
||||||
|
synopsis: string;
|
||||||
|
mean: number;
|
||||||
|
rank: number;
|
||||||
|
popularity: number;
|
||||||
|
num_list_users: number;
|
||||||
|
num_scoring_users: number;
|
||||||
|
nsfw: string;
|
||||||
|
genres: {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}[];
|
||||||
|
created_at: string;
|
||||||
|
updated_at: string;
|
||||||
|
media_type: string;
|
||||||
|
status: string;
|
||||||
|
my_list_status: MalListStatus;
|
||||||
|
num_episodes: number;
|
||||||
|
start_season: {
|
||||||
|
year: number;
|
||||||
|
season: string;
|
||||||
|
};
|
||||||
|
broadcast: {
|
||||||
|
day_of_the_week: string;
|
||||||
|
start_time: string;
|
||||||
|
};
|
||||||
|
source: string;
|
||||||
|
average_episode_duration: number;
|
||||||
|
rating: string;
|
||||||
|
studios: {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}[];
|
||||||
|
pictures: {
|
||||||
|
large: string;
|
||||||
|
medium: string;
|
||||||
|
}[];
|
||||||
|
background: string;
|
||||||
|
related_anime: {
|
||||||
|
node: MALAnime;
|
||||||
|
relation_type: string;
|
||||||
|
relation_type_formatted: string;
|
||||||
|
}[];
|
||||||
|
recommendations: {
|
||||||
|
node: MALAnime;
|
||||||
|
num_recommendations: number;
|
||||||
|
}[];
|
||||||
|
Statistics: {
|
||||||
|
num_list_users: number;
|
||||||
|
Status: {
|
||||||
|
watching: string;
|
||||||
|
completed: string;
|
||||||
|
on_hold: string;
|
||||||
|
dropped: string;
|
||||||
|
plan_to_watch: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MalListStatus {
|
||||||
|
status: string;
|
||||||
|
score: number;
|
||||||
|
num_episodes_watched: number;
|
||||||
|
is_rewatching: boolean;
|
||||||
|
start_date: string;
|
||||||
|
finish_date: string;
|
||||||
|
priority: number;
|
||||||
|
num_times_rewatched: number;
|
||||||
|
rewatch_value: number;
|
||||||
|
tags: string[];
|
||||||
|
comments: string;
|
||||||
|
updated_at: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface MALUploadStatus {
|
||||||
|
status: string
|
||||||
|
is_rewatching: boolean
|
||||||
|
score: number
|
||||||
|
num_watched_episodes: number
|
||||||
|
num_times_rewatched: number
|
||||||
|
comments: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ListStatus {
|
||||||
|
status: string
|
||||||
|
score: number
|
||||||
|
numEpisodesWatched: number
|
||||||
|
isRewatching: boolean
|
||||||
|
updated_at: string
|
||||||
|
startDate: string
|
||||||
|
finishDate: string
|
||||||
|
}
|
@ -1,155 +0,0 @@
|
|||||||
<script>import { twMerge } from "tailwind-merge";
|
|
||||||
import { Frame } from "flowbite-svelte";
|
|
||||||
import { createEventDispatcher } from "svelte";
|
|
||||||
import {CloseButton} from "flowbite-svelte";
|
|
||||||
import focusTrap from "../../node_modules/flowbite-svelte/dist/utils/focusTrap.js";
|
|
||||||
export let open = false;
|
|
||||||
export let title = "";
|
|
||||||
export let size = "md";
|
|
||||||
export let color = "default";
|
|
||||||
export let placement = "center";
|
|
||||||
export let autoclose = false;
|
|
||||||
export let outsideclose = false;
|
|
||||||
export let dismissable = true;
|
|
||||||
export let backdropClass = "fixed inset-0 z-20 bg-gray-900 bg-opacity-50 dark:bg-opacity-80";
|
|
||||||
export let classBackdrop = void 0;
|
|
||||||
export let dialogClass = "fixed top-0 start-0 end-0 h-modal md:inset-0 md:h-full z-30 w-full p-4 flex";
|
|
||||||
export let classDialog = void 0;
|
|
||||||
export let defaultClass = "relative flex flex-col mx-auto";
|
|
||||||
export let headerClass = "flex justify-between items-center p-4 md:p-5 rounded-t-lg";
|
|
||||||
export let classHeader = void 0;
|
|
||||||
export let bodyClass = "p-4 md:p-5 space-y-4 flex-1 overflow-y-auto overscroll-contain";
|
|
||||||
export let classBody = void 0;
|
|
||||||
export let footerClass = "flex items-center p-4 md:p-5 space-x-3 rtl:space-x-reverse rounded-b-lg";
|
|
||||||
export let classFooter = void 0;
|
|
||||||
const dispatch = createEventDispatcher();
|
|
||||||
$: dispatch(open ? "open" : "close");
|
|
||||||
function prepareFocus(node) {
|
|
||||||
const walker = document.createTreeWalker(node, NodeFilter.SHOW_ELEMENT);
|
|
||||||
let n;
|
|
||||||
while (n = walker.nextNode()) {
|
|
||||||
if (n instanceof HTMLElement) {
|
|
||||||
const el = n;
|
|
||||||
const [x, y] = isScrollable(el);
|
|
||||||
if (x || y) el.tabIndex = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
node.focus();
|
|
||||||
}
|
|
||||||
const getPlacementClasses = (placement2) => {
|
|
||||||
switch (placement2) {
|
|
||||||
case "top-left":
|
|
||||||
return ["justify-start", "items-start"];
|
|
||||||
case "top-center":
|
|
||||||
return ["justify-center", "items-start"];
|
|
||||||
case "top-right":
|
|
||||||
return ["justify-end", "items-start"];
|
|
||||||
case "center-left":
|
|
||||||
return ["justify-start", "items-center"];
|
|
||||||
case "center":
|
|
||||||
return ["justify-center", "items-center"];
|
|
||||||
case "center-right":
|
|
||||||
return ["justify-end", "items-center"];
|
|
||||||
case "bottom-left":
|
|
||||||
return ["justify-start", "items-end"];
|
|
||||||
case "bottom-center":
|
|
||||||
return ["justify-center", "items-end"];
|
|
||||||
case "bottom-right":
|
|
||||||
return ["justify-end", "items-end"];
|
|
||||||
default:
|
|
||||||
return ["justify-center", "items-center"];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const sizes = {
|
|
||||||
xs: "max-w-md",
|
|
||||||
sm: "max-w-lg",
|
|
||||||
md: "max-w-2xl",
|
|
||||||
lg: "max-w-4xl",
|
|
||||||
xl: "max-w-6xl"
|
|
||||||
};
|
|
||||||
const onAutoClose = (e) => {
|
|
||||||
const target = e.target;
|
|
||||||
if (autoclose && target?.tagName === "BUTTON") hide(e);
|
|
||||||
};
|
|
||||||
const onOutsideClose = (e) => {
|
|
||||||
const target = e.target;
|
|
||||||
if (outsideclose && target === e.currentTarget) hide(e);
|
|
||||||
};
|
|
||||||
const hide = (e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
open = false;
|
|
||||||
};
|
|
||||||
const isScrollable = (e) => [e.scrollWidth > e.clientWidth && ["scroll", "auto"].indexOf(getComputedStyle(e).overflowX) >= 0, e.scrollHeight > e.clientHeight && ["scroll", "auto"].indexOf(getComputedStyle(e).overflowY) >= 0];
|
|
||||||
function handleKeys(e) {
|
|
||||||
if (e.key === "Escape" && dismissable) return hide(e);
|
|
||||||
}
|
|
||||||
$: backdropCls = twMerge(backdropClass, classBackdrop);
|
|
||||||
$: dialogCls = twMerge(dialogClass, classDialog, getPlacementClasses(placement));
|
|
||||||
$: frameCls = twMerge(defaultClass, "w-full divide-y", $$props.class);
|
|
||||||
$: headerCls = twMerge(headerClass, classHeader);
|
|
||||||
$: bodyCls = twMerge(bodyClass, classBody);
|
|
||||||
$: footerCls = twMerge(footerClass, classFooter);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#if open}
|
|
||||||
<!-- backdrop -->
|
|
||||||
<div class={backdropCls}></div>
|
|
||||||
<!-- dialog -->
|
|
||||||
<!-- svelte-ignore a11y-no-noninteractive-element-interactions -->
|
|
||||||
<div on:keydown={handleKeys} on:wheel|preventDefault|nonpassive use:prepareFocus use:focusTrap on:click={onAutoClose} on:mousedown={onOutsideClose} class={dialogCls} tabindex="-1" aria-modal="true" role="dialog">
|
|
||||||
<div class="flex relative {sizes[size]} w-full max-h-full">
|
|
||||||
<!-- Modal content -->
|
|
||||||
<Frame rounded shadow {...$$restProps} class={frameCls} {color}>
|
|
||||||
<!-- Modal header -->
|
|
||||||
{#if $$slots.header || title}
|
|
||||||
<Frame class={headerCls} {color}>
|
|
||||||
<slot name="header">
|
|
||||||
<h3 class="text-xl font-semibold {color === 'default' ? '' : 'text-gray-900 dark:text-white'} p-0">
|
|
||||||
{title}
|
|
||||||
</h3>
|
|
||||||
</slot>
|
|
||||||
{#if dismissable}<CloseButton name="Close modal" {color} on:click={hide} />{/if}
|
|
||||||
</Frame>
|
|
||||||
{/if}
|
|
||||||
<!-- Modal body -->
|
|
||||||
<div class={bodyCls} role="document" on:keydown|stopPropagation={handleKeys} on:wheel|stopPropagation|passive>
|
|
||||||
{#if dismissable && !$$slots.header && !title}
|
|
||||||
<CloseButton name="Close modal" class="absolute top-3 end-2.5" {color} on:click={hide} />
|
|
||||||
{/if}
|
|
||||||
<slot></slot>
|
|
||||||
</div>
|
|
||||||
<!-- Modal footer -->
|
|
||||||
{#if $$slots.footer}
|
|
||||||
<Frame class={footerCls} {color}>
|
|
||||||
<slot name="footer"></slot>
|
|
||||||
</Frame>
|
|
||||||
{/if}
|
|
||||||
</Frame>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<!--
|
|
||||||
@component
|
|
||||||
[Go to docs](https://flowbite-svelte.com/)
|
|
||||||
## Props
|
|
||||||
@prop export let open: boolean = false;
|
|
||||||
@prop export let title: string = '';
|
|
||||||
@prop export let size: SizeType = 'md';
|
|
||||||
@prop export let color: ComponentProps<Frame>['color'] = 'default';
|
|
||||||
@prop export let placement: ModalPlacementType = 'center';
|
|
||||||
@prop export let autoclose: boolean = false;
|
|
||||||
@prop export let outsideclose: boolean = false;
|
|
||||||
@prop export let dismissable: boolean = true;
|
|
||||||
@prop export let backdropClass: string = 'fixed inset-0 z-40 bg-gray-900 bg-opacity-50 dark:bg-opacity-80';
|
|
||||||
@prop export let classBackdrop: string | undefined = undefined;
|
|
||||||
@prop export let dialogClass: string = 'fixed top-0 start-0 end-0 h-modal md:inset-0 md:h-full z-50 w-full p-4 flex';
|
|
||||||
@prop export let classDialog: string | undefined = undefined;
|
|
||||||
@prop export let defaultClass: string = 'relative flex flex-col mx-auto';
|
|
||||||
@prop export let headerClass: string = 'flex justify-between items-center p-4 md:p-5 rounded-t-lg';
|
|
||||||
@prop export let classHeader: string | undefined = undefined;
|
|
||||||
@prop export let bodyClass: string = 'p-4 md:p-5 space-y-4 flex-1 overflow-y-auto overscroll-contain';
|
|
||||||
@prop export let classBody: string | undefined = undefined;
|
|
||||||
@prop export let footerClass: string = 'flex items-center p-4 md:p-5 space-x-3 rtl:space-x-reverse rounded-b-lg';
|
|
||||||
@prop export let classFooter: string | undefined = undefined;
|
|
||||||
-->
|
|
77
frontend/src/modal/Modal.svelte.d.ts
vendored
77
frontend/src/modal/Modal.svelte.d.ts
vendored
@ -1,77 +0,0 @@
|
|||||||
import { SvelteComponentTyped } from "svelte";
|
|
||||||
import type { Dismissable, SizeType } from '../types';
|
|
||||||
import type { ModalPlacementType } from '../types';
|
|
||||||
declare const __propDef: {
|
|
||||||
props: import("svelte/elements").HTMLAnchorAttributes & {
|
|
||||||
tag?: string;
|
|
||||||
color?: import("../utils/Frame.svelte").FrameColor;
|
|
||||||
rounded?: boolean;
|
|
||||||
border?: boolean;
|
|
||||||
shadow?: boolean;
|
|
||||||
node?: HTMLElement | undefined;
|
|
||||||
use?: import("svelte/action").Action<HTMLElement, any>;
|
|
||||||
options?: object;
|
|
||||||
class?: string;
|
|
||||||
role?: string;
|
|
||||||
open?: boolean;
|
|
||||||
transition?: (node: HTMLElement, params: any) => import("svelte/transition").TransitionConfig;
|
|
||||||
params?: any;
|
|
||||||
} & Dismissable & {
|
|
||||||
open?: boolean;
|
|
||||||
title?: string;
|
|
||||||
size?: SizeType;
|
|
||||||
placement?: ModalPlacementType;
|
|
||||||
autoclose?: boolean;
|
|
||||||
outsideclose?: boolean;
|
|
||||||
backdropClass?: string;
|
|
||||||
classBackdrop?: string;
|
|
||||||
dialogClass?: string;
|
|
||||||
classDialog?: string;
|
|
||||||
defaultClass?: string;
|
|
||||||
headerClass?: string;
|
|
||||||
classHeader?: string;
|
|
||||||
bodyClass?: string;
|
|
||||||
classBody?: string;
|
|
||||||
footerClass?: string;
|
|
||||||
classFooter?: string;
|
|
||||||
};
|
|
||||||
events: {
|
|
||||||
wheel: WheelEvent;
|
|
||||||
} & {
|
|
||||||
[evt: string]: CustomEvent<any>;
|
|
||||||
};
|
|
||||||
slots: {
|
|
||||||
header: {};
|
|
||||||
default: {};
|
|
||||||
footer: {};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
export type ModalProps = typeof __propDef.props;
|
|
||||||
export type ModalEvents = typeof __propDef.events;
|
|
||||||
export type ModalSlots = typeof __propDef.slots;
|
|
||||||
/**
|
|
||||||
* [Go to docs](https://flowbite-svelte.com/)
|
|
||||||
* ## Props
|
|
||||||
* @prop export let open: boolean = false;
|
|
||||||
* @prop export let title: string = '';
|
|
||||||
* @prop export let size: SizeType = 'md';
|
|
||||||
* @prop export let color: ComponentProps<Frame>['color'] = 'default';
|
|
||||||
* @prop export let placement: ModalPlacementType = 'center';
|
|
||||||
* @prop export let autoclose: boolean = false;
|
|
||||||
* @prop export let outsideclose: boolean = false;
|
|
||||||
* @prop export let dismissable: boolean = true;
|
|
||||||
* @prop export let backdropClass: string = 'fixed inset-0 z-40 bg-gray-900 bg-opacity-50 dark:bg-opacity-80';
|
|
||||||
* @prop export let classBackdrop: string | undefined = undefined;
|
|
||||||
* @prop export let dialogClass: string = 'fixed top-0 start-0 end-0 h-modal md:inset-0 md:h-full z-50 w-full p-4 flex';
|
|
||||||
* @prop export let classDialog: string | undefined = undefined;
|
|
||||||
* @prop export let defaultClass: string = 'relative flex flex-col mx-auto';
|
|
||||||
* @prop export let headerClass: string = 'flex justify-between items-center p-4 md:p-5 rounded-t-lg';
|
|
||||||
* @prop export let classHeader: string | undefined = undefined;
|
|
||||||
* @prop export let bodyClass: string = 'p-4 md:p-5 space-y-4 flex-1 overflow-y-auto overscroll-contain';
|
|
||||||
* @prop export let classBody: string | undefined = undefined;
|
|
||||||
* @prop export let footerClass: string = 'flex items-center p-4 md:p-5 space-x-3 rtl:space-x-reverse rounded-b-lg';
|
|
||||||
* @prop export let classFooter: string | undefined = undefined;
|
|
||||||
*/
|
|
||||||
export default class Modal extends SvelteComponentTyped<ModalProps, ModalEvents, ModalSlots> {
|
|
||||||
}
|
|
||||||
export {};
|
|
9
frontend/src/routes/AnimeRoutePage.svelte
Normal file
9
frontend/src/routes/AnimeRoutePage.svelte
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import Anime from "../helperComponents/Anime.svelte"
|
||||||
|
|
||||||
|
export let params: Record<string, string>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#key params.id}
|
||||||
|
<Anime />
|
||||||
|
{/key}
|
25
frontend/src/routes/Home.svelte
Normal file
25
frontend/src/routes/Home.svelte
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import Pagination from "../helperComponents/Pagination.svelte";
|
||||||
|
import WatchList from "../helperComponents/WatchList.svelte";
|
||||||
|
import {
|
||||||
|
aniListLoggedIn,
|
||||||
|
aniListPrimary,
|
||||||
|
loading,
|
||||||
|
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||||
|
import loader from '../helperFunctions/loader'
|
||||||
|
|
||||||
|
let isAniListPrimary: boolean
|
||||||
|
let isAniListLoggedIn: boolean
|
||||||
|
|
||||||
|
aniListPrimary.subscribe((value) => isAniListPrimary = value)
|
||||||
|
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
||||||
|
</script>
|
||||||
|
{#if isAniListLoggedIn && isAniListPrimary}
|
||||||
|
<div class="container py-10">
|
||||||
|
<Pagination />
|
||||||
|
<WatchList />
|
||||||
|
<Pagination />
|
||||||
|
</div>
|
||||||
|
{:else}
|
||||||
|
<div use:loader={loading}></div>
|
||||||
|
{/if}
|
@ -20,6 +20,7 @@ export type SimklUser = {
|
|||||||
|
|
||||||
export type SimklWatchList = {
|
export type SimklWatchList = {
|
||||||
anime: [SimklAnime]
|
anime: [SimklAnime]
|
||||||
|
currentIndex: number
|
||||||
}
|
}
|
||||||
|
|
||||||
export type SimklAnime = {
|
export type SimklAnime = {
|
||||||
@ -59,3 +60,17 @@ export type SimklAnime = {
|
|||||||
},
|
},
|
||||||
anime_type: string
|
anime_type: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type SimklSearchType = [{
|
||||||
|
type: string;
|
||||||
|
title: string;
|
||||||
|
poster: string;
|
||||||
|
year: number;
|
||||||
|
status: string;
|
||||||
|
ids: {
|
||||||
|
simkl: number;
|
||||||
|
slug: string;
|
||||||
|
};
|
||||||
|
totalEpisodes: number;
|
||||||
|
animeType: string;
|
||||||
|
}]
|
63
frontend/src/star-rating/Stars.svelte
Normal file
63
frontend/src/star-rating/Stars.svelte
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
<!-- Originally from @ernane/svelte-star-rating. Wanted to give credit but could not use from the library without causing program crash. -->
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Star from './components/Star.svelte';
|
||||||
|
export let config = {
|
||||||
|
readOnly: false,
|
||||||
|
countStars: 5,
|
||||||
|
range: { min: 0, max: 5, step: 0.001 },
|
||||||
|
score: 0.0,
|
||||||
|
showScore: true,
|
||||||
|
name: "stars",
|
||||||
|
scoreFormat: function(){ return `(${this.score.toFixed(0)}/${this.countStars})` },
|
||||||
|
starConfig: {
|
||||||
|
size: 30,
|
||||||
|
fillColor: '#F9ED4F',
|
||||||
|
strokeColor: "#BB8511",
|
||||||
|
unfilledColor: '#FFF',
|
||||||
|
strokeUnfilledColor: '#000'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<section class="stars-container">
|
||||||
|
<div class="range-stars">
|
||||||
|
<div class="stars">
|
||||||
|
{#each Array(config.countStars) as star, id}
|
||||||
|
{#if Math.floor(config.score) === id}
|
||||||
|
<Star id={config.name + id} readOnly={config.readOnly} starConfig={config.starConfig} fillPercentage={config.score - Math.floor(config.score)}/>
|
||||||
|
{:else if Math.floor(config.score) > id}
|
||||||
|
<Star id={config.name + id} readOnly={config.readOnly} starConfig={config.starConfig} fillPercentage={1}/>
|
||||||
|
{:else}
|
||||||
|
<Star id={config.name + id} readOnly={config.readOnly} starConfig={config.starConfig} fillPercentage={0}/>
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
</div>
|
||||||
|
<input name={config.name}
|
||||||
|
class="slider"
|
||||||
|
type="range"
|
||||||
|
min={config.readOnly ? config.score : config.range.min}
|
||||||
|
max={config.readOnly ? config.score : config.range.max}
|
||||||
|
step="{config.range.step}" bind:value={config.score}
|
||||||
|
on:change
|
||||||
|
on:click
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
{#if config.showScore}
|
||||||
|
<span class="show-score" style="font-size: {config.starConfig.size/2}px;">
|
||||||
|
{#if config.scoreFormat}
|
||||||
|
{config.scoreFormat()}
|
||||||
|
{:else}
|
||||||
|
({((config.score/config.countStars)*100).toFixed(2)}%)
|
||||||
|
{/if}
|
||||||
|
</span>
|
||||||
|
{/if}
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.stars-container{ position: relative; display: flex; align-items: center; justify-content: center; gap: .5rem; }
|
||||||
|
.range-stars{ position: relative; }
|
||||||
|
.stars{ display: flex; align-items: center; justify-content: center; gap: .5rem; }
|
||||||
|
.slider{ opacity: 0; cursor: pointer; position: absolute; top: 0; left: 0; right: 0; height: 100%; }
|
||||||
|
.show-score{ user-select: none; color: #888 }
|
||||||
|
</style>
|
21
frontend/src/star-rating/components/Star.svelte
Normal file
21
frontend/src/star-rating/components/Star.svelte
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<script>
|
||||||
|
export let id, readOnly, fillPercentage, starConfig;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="{starConfig.size}" viewBox="0 -10 187.673 179.503" height="{starConfig.size}" >
|
||||||
|
{#if fillPercentage < 1 && fillPercentage > 0}
|
||||||
|
<defs>
|
||||||
|
<linearGradient id="linear-gradient-{id}" x1="0%" y1="0%" x2="100%" y2="0%">
|
||||||
|
<stop offset="0%" style="stop-color:{starConfig.fillColor};stop-opacity:1" />
|
||||||
|
<stop offset="{fillPercentage * 100}%" style="stop-color:{starConfig.fillColor};stop-opacity:1"/>
|
||||||
|
<stop offset="{fillPercentage * 100}%" style="stop-color:{starConfig.unfilledColor};stop-opacity:1" />
|
||||||
|
</linearGradient>
|
||||||
|
</defs>
|
||||||
|
{/if}
|
||||||
|
<path
|
||||||
|
opacity="{readOnly ? .7 : 1}"
|
||||||
|
stroke={fillPercentage > 0 ? starConfig.strokeColor : starConfig.strokeUnfilledColor}
|
||||||
|
fill={fillPercentage === 1 ? starConfig.fillColor : fillPercentage === 0 ? starConfig.unfilledColor : `url(#linear-gradient-${id})`}
|
||||||
|
d="M187.183 57.47a9.955 9.955 0 00-8.587-6.86l-54.167-4.918-21.42-50.134a9.978 9.978 0 00-9.172-6.052 9.972 9.972 0 00-9.172 6.061l-21.42 50.125L9.07 50.611a9.973 9.973 0 00-8.578 6.858 9.964 9.964 0 002.917 10.596l40.944 35.908-12.073 53.184a9.97 9.97 0 003.878 10.298A9.953 9.953 0 0042 169.357a9.937 9.937 0 005.114-1.424l46.724-27.925 46.707 27.925a9.936 9.936 0 0010.964-.478 9.979 9.979 0 003.88-10.298l-12.074-53.184 40.944-35.9a9.98 9.98 0 002.925-10.604zm0 0"
|
||||||
|
/>
|
||||||
|
</svg>
|
@ -16,6 +16,12 @@ body {
|
|||||||
sans-serif;
|
sans-serif;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.maple-font {
|
||||||
|
font-family: "Maple Mono NF", -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto",
|
||||||
|
"Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue",
|
||||||
|
sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
@font-face {
|
@font-face {
|
||||||
font-family: "Nunito";
|
font-family: "Nunito";
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
@ -24,6 +30,14 @@ body {
|
|||||||
url("assets/fonts/nunito-v16-latin-regular.woff2") format("woff2");
|
url("assets/fonts/nunito-v16-latin-regular.woff2") format("woff2");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@font-face {
|
||||||
|
font-family: "Maple Mono NF";
|
||||||
|
font-style: normal;
|
||||||
|
font-weight: 800;
|
||||||
|
src: local(""),
|
||||||
|
url("assets/fonts/MapleMono-Bold.woff2") format("woff2");
|
||||||
|
}
|
||||||
|
|
||||||
#app {
|
#app {
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import flowbitePlugin from 'flowbite/plugin'
|
||||||
/** @type {import('tailwindcss').Config} */
|
/** @type {import('tailwindcss').Config} */
|
||||||
export default {
|
export default {
|
||||||
content: [
|
content: [
|
||||||
@ -6,17 +7,36 @@ export default {
|
|||||||
"./node_modules/flowbite/**/*.{html,js,svelte,ts}",
|
"./node_modules/flowbite/**/*.{html,js,svelte,ts}",
|
||||||
"./node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}",
|
"./node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}",
|
||||||
],
|
],
|
||||||
plugins: [
|
plugins: [ flowbitePlugin ],
|
||||||
require('flowbite/plugin')
|
|
||||||
],
|
|
||||||
|
|
||||||
darkMode: 'media',
|
darkMode: 'media',
|
||||||
|
|
||||||
theme: {
|
theme: {
|
||||||
|
container: {
|
||||||
|
center: true,
|
||||||
|
padding: {
|
||||||
|
DEFAULT: '1rem',
|
||||||
|
sm: '2rem',
|
||||||
|
lg: '4rem',
|
||||||
|
xl: '5rem',
|
||||||
|
'2xl': '6rem',
|
||||||
|
},
|
||||||
|
},
|
||||||
extend: {
|
extend: {
|
||||||
colors: {
|
colors: {
|
||||||
// flowbite-svelte
|
// flowbite-svelte
|
||||||
primary: { 50: '#FFF5F2', 100: '#FFF1EE', 200: '#FFE4DE', 300: '#FFD5CC', 400: '#FFBCAD', 500: '#FE795D', 600: '#EF562F', 700: '#EB4F27', 800: '#CC4522', 900: '#A5371B'},
|
primary: {
|
||||||
|
50: '#FFF5F2',
|
||||||
|
100: '#FFF1EE',
|
||||||
|
200: '#FFE4DE',
|
||||||
|
300: '#FFD5CC',
|
||||||
|
400: '#FFBCAD',
|
||||||
|
500: '#FE795D',
|
||||||
|
600: '#EF562F',
|
||||||
|
700: '#EB4F27',
|
||||||
|
800: '#CC4522',
|
||||||
|
900: '#A5371B'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,10 @@
|
|||||||
|
// vite.config.ts
|
||||||
|
import { defineConfig } from "file:///home/nymusicman/Code/AniTrack/frontend/node_modules/vite/dist/node/index.js";
|
||||||
|
import { svelte } from "file:///home/nymusicman/Code/AniTrack/frontend/node_modules/@sveltejs/vite-plugin-svelte/src/index.js";
|
||||||
|
var vite_config_default = defineConfig({
|
||||||
|
plugins: [svelte()]
|
||||||
|
});
|
||||||
|
export {
|
||||||
|
vite_config_default as default
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcudHMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvaG9tZS9ueW11c2ljbWFuL0NvZGUvQW5pVHJhY2svZnJvbnRlbmRcIjtjb25zdCBfX3ZpdGVfaW5qZWN0ZWRfb3JpZ2luYWxfZmlsZW5hbWUgPSBcIi9ob21lL255bXVzaWNtYW4vQ29kZS9BbmlUcmFjay9mcm9udGVuZC92aXRlLmNvbmZpZy50c1wiO2NvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9pbXBvcnRfbWV0YV91cmwgPSBcImZpbGU6Ly8vaG9tZS9ueW11c2ljbWFuL0NvZGUvQW5pVHJhY2svZnJvbnRlbmQvdml0ZS5jb25maWcudHNcIjtpbXBvcnQge2RlZmluZUNvbmZpZ30gZnJvbSAndml0ZSdcbmltcG9ydCB7c3ZlbHRlfSBmcm9tICdAc3ZlbHRlanMvdml0ZS1wbHVnaW4tc3ZlbHRlJ1xuXG4vLyBodHRwczovL3ZpdGVqcy5kZXYvY29uZmlnL1xuZXhwb3J0IGRlZmF1bHQgZGVmaW5lQ29uZmlnKHtcbiAgcGx1Z2luczogW3N2ZWx0ZSgpXVxufSlcbiJdLAogICJtYXBwaW5ncyI6ICI7QUFBdVMsU0FBUSxvQkFBbUI7QUFDbFUsU0FBUSxjQUFhO0FBR3JCLElBQU8sc0JBQVEsYUFBYTtBQUFBLEVBQzFCLFNBQVMsQ0FBQyxPQUFPLENBQUM7QUFDcEIsQ0FBQzsiLAogICJuYW1lcyI6IFtdCn0K
|
30
frontend/wailsjs/go/main/App.d.ts
vendored
30
frontend/wailsjs/go/main/App.d.ts
vendored
@ -2,11 +2,13 @@
|
|||||||
// This file is automatically generated. DO NOT EDIT
|
// This file is automatically generated. DO NOT EDIT
|
||||||
import {main} from '../models';
|
import {main} from '../models';
|
||||||
|
|
||||||
|
export function AniListDeleteEntry(arg1:number):Promise<main.DeleteAniListReturn>;
|
||||||
|
|
||||||
export function AniListLogin():Promise<void>;
|
export function AniListLogin():Promise<void>;
|
||||||
|
|
||||||
export function AniListSearch(arg1:string):Promise<any>;
|
export function AniListSearch(arg1:string):Promise<any>;
|
||||||
|
|
||||||
export function AniListUpdateEntry(arg1:number,arg2:number,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:main.AniListUpdateVariables):Promise<main.AniListGetSingleAnime>;
|
||||||
|
|
||||||
export function CheckIfAniListLoggedIn():Promise<boolean>;
|
export function CheckIfAniListLoggedIn():Promise<boolean>;
|
||||||
|
|
||||||
@ -14,24 +16,42 @@ export function CheckIfMyAnimeListLoggedIn():Promise<boolean>;
|
|||||||
|
|
||||||
export function CheckIfSimklLoggedIn():Promise<boolean>;
|
export function CheckIfSimklLoggedIn():Promise<boolean>;
|
||||||
|
|
||||||
|
export function DeleteMyAnimeListEntry(arg1:number):Promise<boolean>;
|
||||||
|
|
||||||
export function GetAniListItem(arg1:number,arg2:boolean):Promise<main.AniListGetSingleAnime>;
|
export function GetAniListItem(arg1:number,arg2:boolean):Promise<main.AniListGetSingleAnime>;
|
||||||
|
|
||||||
export function GetAniListLoggedInUser():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 GetMyAnimeList(arg1:number):Promise<main.MALWatchlist>;
|
||||||
|
|
||||||
|
export function GetMyAnimeListAnime(arg1:number):Promise<main.MALAnime>;
|
||||||
|
|
||||||
export function GetMyAnimeListLoggedInUser():Promise<main.MyAnimeListUser>;
|
export function GetMyAnimeListLoggedInUser():Promise<main.MyAnimeListUser>;
|
||||||
|
|
||||||
export function GetSimklLoggedInUser():Promise<main.SimklUser>;
|
export function GetSimklLoggedInUser():Promise<main.SimklUser>;
|
||||||
|
|
||||||
|
export function LogoutAniList():Promise<string>;
|
||||||
|
|
||||||
|
export function LogoutMyAnimeList():Promise<string>;
|
||||||
|
|
||||||
|
export function LogoutSimkl():Promise<string>;
|
||||||
|
|
||||||
export function MyAnimeListLogin():Promise<void>;
|
export function MyAnimeListLogin():Promise<void>;
|
||||||
|
|
||||||
export function SimklGetUserWatchlist():Promise<main.SimklWatchList>;
|
export function MyAnimeListUpdate(arg1:main.MALAnime,arg2:main.MALUploadStatus):Promise<main.MalListStatus>;
|
||||||
|
|
||||||
|
export function SimklGetUserWatchlist():Promise<main.SimklWatchListType>;
|
||||||
|
|
||||||
export function SimklLogin():Promise<void>;
|
export function SimklLogin():Promise<void>;
|
||||||
|
|
||||||
export function SimklSyncEpisodes(arg1:main.Anime,arg2:number):Promise<any>;
|
export function SimklSearch(arg1:main.MediaList):Promise<main.SimklAnime>;
|
||||||
|
|
||||||
export function SimklSyncRating(arg1:main.Anime,arg2:number):Promise<any>;
|
export function SimklSyncEpisodes(arg1:main.SimklAnime,arg2:number):Promise<main.SimklAnime>;
|
||||||
|
|
||||||
export function SimklSyncStatus(arg1:main.Anime,arg2:string):Promise<any>;
|
export function SimklSyncRating(arg1:main.SimklAnime,arg2:number):Promise<main.SimklAnime>;
|
||||||
|
|
||||||
|
export function SimklSyncRemove(arg1:main.SimklAnime):Promise<boolean>;
|
||||||
|
|
||||||
|
export function SimklSyncStatus(arg1:main.SimklAnime,arg2:string):Promise<main.SimklAnime>;
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
|
||||||
// This file is automatically generated. DO NOT EDIT
|
// This file is automatically generated. DO NOT EDIT
|
||||||
|
|
||||||
|
export function AniListDeleteEntry(arg1) {
|
||||||
|
return window['go']['main']['App']['AniListDeleteEntry'](arg1);
|
||||||
|
}
|
||||||
|
|
||||||
export function AniListLogin() {
|
export function AniListLogin() {
|
||||||
return window['go']['main']['App']['AniListLogin']();
|
return window['go']['main']['App']['AniListLogin']();
|
||||||
}
|
}
|
||||||
@ -10,8 +14,8 @@ export function AniListSearch(arg1) {
|
|||||||
return window['go']['main']['App']['AniListSearch'](arg1);
|
return window['go']['main']['App']['AniListSearch'](arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function AniListUpdateEntry(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) {
|
export function AniListUpdateEntry(arg1) {
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CheckIfAniListLoggedIn() {
|
export function CheckIfAniListLoggedIn() {
|
||||||
@ -26,6 +30,10 @@ export function CheckIfSimklLoggedIn() {
|
|||||||
return window['go']['main']['App']['CheckIfSimklLoggedIn']();
|
return window['go']['main']['App']['CheckIfSimklLoggedIn']();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function DeleteMyAnimeListEntry(arg1) {
|
||||||
|
return window['go']['main']['App']['DeleteMyAnimeListEntry'](arg1);
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
@ -38,6 +46,14 @@ 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 GetMyAnimeList(arg1) {
|
||||||
|
return window['go']['main']['App']['GetMyAnimeList'](arg1);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function GetMyAnimeListAnime(arg1) {
|
||||||
|
return window['go']['main']['App']['GetMyAnimeListAnime'](arg1);
|
||||||
|
}
|
||||||
|
|
||||||
export function GetMyAnimeListLoggedInUser() {
|
export function GetMyAnimeListLoggedInUser() {
|
||||||
return window['go']['main']['App']['GetMyAnimeListLoggedInUser']();
|
return window['go']['main']['App']['GetMyAnimeListLoggedInUser']();
|
||||||
}
|
}
|
||||||
@ -46,10 +62,26 @@ export function GetSimklLoggedInUser() {
|
|||||||
return window['go']['main']['App']['GetSimklLoggedInUser']();
|
return window['go']['main']['App']['GetSimklLoggedInUser']();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function LogoutAniList() {
|
||||||
|
return window['go']['main']['App']['LogoutAniList']();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function LogoutMyAnimeList() {
|
||||||
|
return window['go']['main']['App']['LogoutMyAnimeList']();
|
||||||
|
}
|
||||||
|
|
||||||
|
export function LogoutSimkl() {
|
||||||
|
return window['go']['main']['App']['LogoutSimkl']();
|
||||||
|
}
|
||||||
|
|
||||||
export function MyAnimeListLogin() {
|
export function MyAnimeListLogin() {
|
||||||
return window['go']['main']['App']['MyAnimeListLogin']();
|
return window['go']['main']['App']['MyAnimeListLogin']();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function MyAnimeListUpdate(arg1, arg2) {
|
||||||
|
return window['go']['main']['App']['MyAnimeListUpdate'](arg1, arg2);
|
||||||
|
}
|
||||||
|
|
||||||
export function SimklGetUserWatchlist() {
|
export function SimklGetUserWatchlist() {
|
||||||
return window['go']['main']['App']['SimklGetUserWatchlist']();
|
return window['go']['main']['App']['SimklGetUserWatchlist']();
|
||||||
}
|
}
|
||||||
@ -58,6 +90,10 @@ export function SimklLogin() {
|
|||||||
return window['go']['main']['App']['SimklLogin']();
|
return window['go']['main']['App']['SimklLogin']();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function SimklSearch(arg1) {
|
||||||
|
return window['go']['main']['App']['SimklSearch'](arg1);
|
||||||
|
}
|
||||||
|
|
||||||
export function SimklSyncEpisodes(arg1, arg2) {
|
export function SimklSyncEpisodes(arg1, arg2) {
|
||||||
return window['go']['main']['App']['SimklSyncEpisodes'](arg1, arg2);
|
return window['go']['main']['App']['SimklSyncEpisodes'](arg1, arg2);
|
||||||
}
|
}
|
||||||
@ -66,6 +102,10 @@ export function SimklSyncRating(arg1, arg2) {
|
|||||||
return window['go']['main']['App']['SimklSyncRating'](arg1, arg2);
|
return window['go']['main']['App']['SimklSyncRating'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function SimklSyncRemove(arg1) {
|
||||||
|
return window['go']['main']['App']['SimklSyncRemove'](arg1);
|
||||||
|
}
|
||||||
|
|
||||||
export function SimklSyncStatus(arg1, arg2) {
|
export function SimklSyncStatus(arg1, arg2) {
|
||||||
return window['go']['main']['App']['SimklSyncStatus'](arg1, arg2);
|
return window['go']['main']['App']['SimklSyncStatus'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
@ -60,6 +60,82 @@ export namespace main {
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export class CompletedAt {
|
||||||
|
year: number;
|
||||||
|
month: number;
|
||||||
|
day: number;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new CompletedAt(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.year = source["year"];
|
||||||
|
this.month = source["month"];
|
||||||
|
this.day = source["day"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class StartedAt {
|
||||||
|
year: number;
|
||||||
|
month: number;
|
||||||
|
day: number;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new StartedAt(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.year = source["year"];
|
||||||
|
this.month = source["month"];
|
||||||
|
this.day = source["day"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class AniListUpdateVariables {
|
||||||
|
mediaId: number;
|
||||||
|
progress: number;
|
||||||
|
status: string;
|
||||||
|
score: number;
|
||||||
|
repeat: number;
|
||||||
|
notes: string;
|
||||||
|
startedAt: StartedAt;
|
||||||
|
completedAt: CompletedAt;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new AniListUpdateVariables(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.mediaId = source["mediaId"];
|
||||||
|
this.progress = source["progress"];
|
||||||
|
this.status = source["status"];
|
||||||
|
this.score = source["score"];
|
||||||
|
this.repeat = source["repeat"];
|
||||||
|
this.notes = source["notes"];
|
||||||
|
this.startedAt = this.convertValues(source["startedAt"], StartedAt);
|
||||||
|
this.completedAt = this.convertValues(source["completedAt"], CompletedAt);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
export class AniListUser {
|
export class AniListUser {
|
||||||
// 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\"" }
|
// 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;
|
||||||
@ -91,34 +167,197 @@ export namespace main {
|
|||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class Anime {
|
|
||||||
last_watched_at: last_watched_at;
|
export class DeleteAniListReturn {
|
||||||
status: status;
|
// Go type: struct { DeleteMediaListEntry struct { Deleted bool "json:\"deleted\"" } "json:\"DeleteMediaListEntry\"" }
|
||||||
user_rating: user_rating;
|
data: any;
|
||||||
last_watched: last_watched;
|
|
||||||
next_to_watch: next_to_watch;
|
|
||||||
watched_episodes_count: watched_episodes_count;
|
|
||||||
total_episodes_count: total_episodes_count;
|
|
||||||
not_aired_episodes_count: not_aired_episodes_count;
|
|
||||||
show: show;
|
|
||||||
anime_type: anime_type;
|
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
static createFrom(source: any = {}) {
|
||||||
return new Anime(source);
|
return new DeleteAniListReturn(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(source: any = {}) {
|
constructor(source: any = {}) {
|
||||||
if ('string' === typeof source) source = JSON.parse(source);
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
this.last_watched_at = source["last_watched_at"];
|
this.data = this.convertValues(source["data"], Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class MALAnime {
|
||||||
|
id: id;
|
||||||
|
title: title;
|
||||||
|
main_picture: mainPicture;
|
||||||
|
alternative_titles: alternativeTitles;
|
||||||
|
start_date: startDate;
|
||||||
|
end_date: endDate;
|
||||||
|
synopsis: synopsis;
|
||||||
|
mean: mean;
|
||||||
|
rank: rank;
|
||||||
|
popularity: popularity;
|
||||||
|
num_list_users: numListUsers;
|
||||||
|
num_scoring_users: numScoringUsers;
|
||||||
|
nsfw: nsfw;
|
||||||
|
genres: genres;
|
||||||
|
created_at: createdAt;
|
||||||
|
updated_at: updatedAt;
|
||||||
|
media_type: mediaType;
|
||||||
|
status: status;
|
||||||
|
my_list_status: MalListStatus;
|
||||||
|
num_episodes: numEpisodes;
|
||||||
|
start_season: startSeason;
|
||||||
|
broadcast: broadcast;
|
||||||
|
source: source;
|
||||||
|
average_episode_duration: averageEpisodeDuration;
|
||||||
|
rating: rating;
|
||||||
|
studios: studios;
|
||||||
|
pictures: pictures;
|
||||||
|
background: background;
|
||||||
|
related_anime: relatedAnime;
|
||||||
|
recommendations: recommendations;
|
||||||
|
// Go type: struct { NumListUsers int "json:\"num_list_users\" ts_type:\"numListUsers\""; Status struct { Watching string "json:\"watching\" ts_type:\"watching\""; Completed string "json:\"completed\" ts_type:\"completed\""; OnHold string "json:\"on_hold\" ts_type:\"onHold\""; Dropped string "json:\"dropped\" ts_type:\"dropped\""; PlanToWatch string "json:\"plan_to_watch\" ts_type:\"planToWatch\"" } }
|
||||||
|
Statistics: any;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new MALAnime(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.id = source["id"];
|
||||||
|
this.title = source["title"];
|
||||||
|
this.main_picture = source["main_picture"];
|
||||||
|
this.alternative_titles = source["alternative_titles"];
|
||||||
|
this.start_date = source["start_date"];
|
||||||
|
this.end_date = source["end_date"];
|
||||||
|
this.synopsis = source["synopsis"];
|
||||||
|
this.mean = source["mean"];
|
||||||
|
this.rank = source["rank"];
|
||||||
|
this.popularity = source["popularity"];
|
||||||
|
this.num_list_users = source["num_list_users"];
|
||||||
|
this.num_scoring_users = source["num_scoring_users"];
|
||||||
|
this.nsfw = source["nsfw"];
|
||||||
|
this.genres = source["genres"];
|
||||||
|
this.created_at = source["created_at"];
|
||||||
|
this.updated_at = source["updated_at"];
|
||||||
|
this.media_type = source["media_type"];
|
||||||
this.status = source["status"];
|
this.status = source["status"];
|
||||||
this.user_rating = source["user_rating"];
|
this.my_list_status = source["my_list_status"];
|
||||||
this.last_watched = source["last_watched"];
|
this.num_episodes = source["num_episodes"];
|
||||||
this.next_to_watch = source["next_to_watch"];
|
this.start_season = source["start_season"];
|
||||||
this.watched_episodes_count = source["watched_episodes_count"];
|
this.broadcast = source["broadcast"];
|
||||||
this.total_episodes_count = source["total_episodes_count"];
|
this.source = source["source"];
|
||||||
this.not_aired_episodes_count = source["not_aired_episodes_count"];
|
this.average_episode_duration = source["average_episode_duration"];
|
||||||
this.show = source["show"];
|
this.rating = source["rating"];
|
||||||
this.anime_type = source["anime_type"];
|
this.studios = source["studios"];
|
||||||
|
this.pictures = source["pictures"];
|
||||||
|
this.background = source["background"];
|
||||||
|
this.related_anime = source["related_anime"];
|
||||||
|
this.recommendations = source["recommendations"];
|
||||||
|
this.Statistics = this.convertValues(source["Statistics"], Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class MALUploadStatus {
|
||||||
|
status: string;
|
||||||
|
is_rewatching: boolean;
|
||||||
|
score: number;
|
||||||
|
num_watched_episodes: number;
|
||||||
|
num_times_rewatched: number;
|
||||||
|
comments: string;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new MALUploadStatus(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.status = source["status"];
|
||||||
|
this.is_rewatching = source["is_rewatching"];
|
||||||
|
this.score = source["score"];
|
||||||
|
this.num_watched_episodes = source["num_watched_episodes"];
|
||||||
|
this.num_times_rewatched = source["num_times_rewatched"];
|
||||||
|
this.comments = source["comments"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class MALWatchlist {
|
||||||
|
data: data;
|
||||||
|
paging: paging;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new MALWatchlist(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.data = source["data"];
|
||||||
|
this.paging = source["paging"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class MalListStatus {
|
||||||
|
status: status;
|
||||||
|
score: score;
|
||||||
|
num_episodes_watched: numEpisodesWatched;
|
||||||
|
is_rewatching: isRewatching;
|
||||||
|
start_date: startDate;
|
||||||
|
finish_date: finishDate;
|
||||||
|
priority: priority;
|
||||||
|
num_times_rewatched: numTimesRewatched;
|
||||||
|
rewatch_value: rewatchValue;
|
||||||
|
tags: tags;
|
||||||
|
comments: comments;
|
||||||
|
updated_at: updatedAt;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new MalListStatus(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.status = source["status"];
|
||||||
|
this.score = source["score"];
|
||||||
|
this.num_episodes_watched = source["num_episodes_watched"];
|
||||||
|
this.is_rewatching = source["is_rewatching"];
|
||||||
|
this.start_date = source["start_date"];
|
||||||
|
this.finish_date = source["finish_date"];
|
||||||
|
this.priority = source["priority"];
|
||||||
|
this.num_times_rewatched = source["num_times_rewatched"];
|
||||||
|
this.rewatch_value = source["rewatch_value"];
|
||||||
|
this.tags = source["tags"];
|
||||||
|
this.comments = source["comments"];
|
||||||
|
this.updated_at = source["updated_at"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class MediaList {
|
export class MediaList {
|
||||||
@ -235,6 +474,36 @@ export namespace main {
|
|||||||
this.is_supporter = source["is_supporter"];
|
this.is_supporter = source["is_supporter"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
export class SimklAnime {
|
||||||
|
last_watched_at: last_watched_at;
|
||||||
|
status: status;
|
||||||
|
user_rating: user_rating;
|
||||||
|
last_watched: last_watched;
|
||||||
|
next_to_watch: next_to_watch;
|
||||||
|
watched_episodes_count: watched_episodes_count;
|
||||||
|
total_episodes_count: total_episodes_count;
|
||||||
|
not_aired_episodes_count: not_aired_episodes_count;
|
||||||
|
show: show;
|
||||||
|
anime_type: anime_type;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new SimklAnime(source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.last_watched_at = source["last_watched_at"];
|
||||||
|
this.status = source["status"];
|
||||||
|
this.user_rating = source["user_rating"];
|
||||||
|
this.last_watched = source["last_watched"];
|
||||||
|
this.next_to_watch = source["next_to_watch"];
|
||||||
|
this.watched_episodes_count = source["watched_episodes_count"];
|
||||||
|
this.total_episodes_count = source["total_episodes_count"];
|
||||||
|
this.not_aired_episodes_count = source["not_aired_episodes_count"];
|
||||||
|
this.show = source["show"];
|
||||||
|
this.anime_type = source["anime_type"];
|
||||||
|
}
|
||||||
|
}
|
||||||
export class SimklUser {
|
export class SimklUser {
|
||||||
user: user;
|
user: user;
|
||||||
account: account;
|
account: account;
|
||||||
@ -251,11 +520,11 @@ export namespace main {
|
|||||||
this.connections = source["connections"];
|
this.connections = source["connections"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
export class SimklWatchList {
|
export class SimklWatchListType {
|
||||||
anime: anime;
|
anime: anime;
|
||||||
|
|
||||||
static createFrom(source: any = {}) {
|
static createFrom(source: any = {}) {
|
||||||
return new SimklWatchList(source);
|
return new SimklWatchListType(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(source: any = {}) {
|
constructor(source: any = {}) {
|
||||||
@ -301,3 +570,86 @@ export namespace struct { MediaList main {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export namespace struct { Node main {
|
||||||
|
|
||||||
|
export class {
|
||||||
|
node: node;
|
||||||
|
num_recommendations: numRecommendations;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new (source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.node = source["node"];
|
||||||
|
this.num_recommendations = source["num_recommendations"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export class {
|
||||||
|
node: node;
|
||||||
|
relation_type: relationType;
|
||||||
|
relation_type_formatted: relationTypeFormatted;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new (source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.node = source["node"];
|
||||||
|
this.relation_type = source["relation_type"];
|
||||||
|
this.relation_type_formatted = source["relation_type_formatted"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace struct { Node struct { Id int "json:\"id\" ts_type:\"id\""; Title string "json:\"title\" ts_type:\"title\""; MainPicture struct { Medium string "json:\"medium\" ts_type:\"medium\""; Large string "json:\"large\" ts_type:\"large\"" } "json:\"main_picture\" ts_type:\"mainPicture\"" } "json:\"node\" ts_type:\"node\""; ListStatus struct { Status string "json:\"status\" ts_type:\"status\""; Score int "json:\"score\" ts_type:\"score\""; NumEpisodesWatched int "json:\"num_episodes_watched\" ts_type:\"numEpisodesWatched\""; IsRewatching bool "json:\"is_rewatching\" ts_type:\"isRewatching\""; UpdatedAt time {
|
||||||
|
|
||||||
|
export class {
|
||||||
|
node: node;
|
||||||
|
list_status: listStatus;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new (source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.node = source["node"];
|
||||||
|
this.list_status = source["list_status"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace struct { Status string "json:\"status\" ts_type:\"status\""; Score int "json:\"score\" ts_type:\"score\""; NumEpisodesWatched int "json:\"num_episodes_watched\" ts_type:\"numEpisodesWatched\""; IsRewatching bool "json:\"is_rewatching\" ts_type:\"isRewatching\""; UpdatedAt time {
|
||||||
|
|
||||||
|
export class {
|
||||||
|
status: status;
|
||||||
|
score: score;
|
||||||
|
num_episodes_watched: numEpisodesWatched;
|
||||||
|
is_rewatching: isRewatching;
|
||||||
|
updated_at: updatedAt;
|
||||||
|
start_date: startDate;
|
||||||
|
finish_date: finishDate;
|
||||||
|
|
||||||
|
static createFrom(source: any = {}) {
|
||||||
|
return new (source);
|
||||||
|
}
|
||||||
|
|
||||||
|
constructor(source: any = {}) {
|
||||||
|
if ('string' === typeof source) source = JSON.parse(source);
|
||||||
|
this.status = source["status"];
|
||||||
|
this.score = source["score"];
|
||||||
|
this.num_episodes_watched = source["num_episodes_watched"];
|
||||||
|
this.is_rewatching = source["is_rewatching"];
|
||||||
|
this.updated_at = source["updated_at"];
|
||||||
|
this.start_date = source["start_date"];
|
||||||
|
this.finish_date = source["finish_date"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
36
go.mod
36
go.mod
@ -1,49 +1,49 @@
|
|||||||
module AniTrack
|
module AniTrack
|
||||||
|
|
||||||
go 1.21
|
go 1.23
|
||||||
|
|
||||||
toolchain go1.21.11
|
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/99designs/keyring v1.2.2
|
github.com/99designs/keyring v1.2.2
|
||||||
github.com/joho/godotenv v1.5.1
|
github.com/tidwall/gjson v1.18.0
|
||||||
github.com/wailsapp/wails/v2 v2.9.1
|
github.com/wailsapp/wails/v2 v2.9.2
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
||||||
github.com/bep/debounce v1.2.1 // indirect
|
github.com/bep/debounce v1.2.1 // indirect
|
||||||
github.com/danieljoos/wincred v1.1.2 // indirect
|
github.com/danieljoos/wincred v1.2.2 // indirect
|
||||||
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
|
github.com/dvsekhvalnov/jose2go v1.8.0 // indirect
|
||||||
github.com/go-ole/go-ole v1.3.0 // indirect
|
github.com/go-ole/go-ole v1.3.0 // indirect
|
||||||
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
|
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect
|
||||||
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
github.com/godbus/dbus/v5 v5.1.0 // indirect
|
||||||
github.com/google/uuid v1.6.0 // indirect
|
github.com/google/uuid v1.6.0 // indirect
|
||||||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
|
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c // indirect
|
||||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
|
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e // indirect
|
||||||
github.com/labstack/echo/v4 v4.12.0 // indirect
|
github.com/labstack/echo/v4 v4.13.3 // indirect
|
||||||
github.com/labstack/gommon v0.4.2 // indirect
|
github.com/labstack/gommon v0.4.2 // indirect
|
||||||
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
|
github.com/leaanthony/go-ansi-parser v1.6.1 // indirect
|
||||||
github.com/leaanthony/gosod v1.0.4 // indirect
|
github.com/leaanthony/gosod v1.0.4 // indirect
|
||||||
github.com/leaanthony/slicer v1.6.0 // indirect
|
github.com/leaanthony/slicer v1.6.0 // indirect
|
||||||
github.com/leaanthony/u v1.1.1 // indirect
|
github.com/leaanthony/u v1.1.1 // indirect
|
||||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
github.com/mattn/go-colorable v0.1.14 // indirect
|
||||||
github.com/mattn/go-isatty v0.0.20 // indirect
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
github.com/mtibben/percent v0.2.1 // indirect
|
github.com/mtibben/percent v0.2.1 // indirect
|
||||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 // indirect
|
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/rivo/uniseg v0.4.7 // indirect
|
github.com/rivo/uniseg v0.4.7 // indirect
|
||||||
github.com/samber/lo v1.46.0 // indirect
|
github.com/samber/lo v1.47.0 // indirect
|
||||||
github.com/tkrajina/go-reflector v0.5.6 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
|
github.com/tidwall/pretty v1.2.1 // indirect
|
||||||
|
github.com/tkrajina/go-reflector v0.5.8 // indirect
|
||||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||||
github.com/valyala/fasttemplate v1.2.2 // indirect
|
github.com/valyala/fasttemplate v1.2.2 // indirect
|
||||||
github.com/wailsapp/go-webview2 v1.0.10 // indirect
|
github.com/wailsapp/go-webview2 v1.0.19 // indirect
|
||||||
github.com/wailsapp/mimetype v1.4.1 // indirect
|
github.com/wailsapp/mimetype v1.4.1 // indirect
|
||||||
golang.org/x/crypto v0.25.0 // indirect
|
golang.org/x/crypto v0.32.0 // indirect
|
||||||
golang.org/x/net v0.27.0 // indirect
|
golang.org/x/net v0.34.0 // indirect
|
||||||
golang.org/x/sys v0.22.0 // indirect
|
golang.org/x/sys v0.29.0 // indirect
|
||||||
golang.org/x/term v0.22.0 // indirect
|
golang.org/x/term v0.28.0 // indirect
|
||||||
golang.org/x/text v0.16.0 // indirect
|
golang.org/x/text v0.21.0 // indirect
|
||||||
)
|
)
|
||||||
|
|
||||||
// replace github.com/wailsapp/wails/v2 v2.9.1 => /home/nymusicman/go/pkg/mod
|
// replace github.com/wailsapp/wails/v2 v2.9.1 => /home/nymusicman/go/pkg/mod
|
||||||
|
82
go.sum
82
go.sum
@ -4,13 +4,12 @@ github.com/99designs/keyring v1.2.2 h1:pZd3neh/EmUzWONb35LxQfvuY7kiSXAq3HQd97+XB
|
|||||||
github.com/99designs/keyring v1.2.2/go.mod h1:wes/FrByc8j7lFOAGLGSNEg8f/PaI3cgTBqhFkHUrPk=
|
github.com/99designs/keyring v1.2.2/go.mod h1:wes/FrByc8j7lFOAGLGSNEg8f/PaI3cgTBqhFkHUrPk=
|
||||||
github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY=
|
github.com/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY=
|
||||||
github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
|
github.com/bep/debounce v1.2.1/go.mod h1:H8yggRPQKLUhUoqrJC1bO2xNya7vanpDl7xR3ISbCJ0=
|
||||||
github.com/danieljoos/wincred v1.1.2 h1:QLdCxFs1/Yl4zduvBdcHB8goaYk9RARS2SgLLRuAyr0=
|
github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0=
|
||||||
github.com/danieljoos/wincred v1.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
|
github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
|
||||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM=
|
github.com/dvsekhvalnov/jose2go v1.8.0 h1:LqkkVKAlHFfH9LOEl5fe4p/zL02OhWE7pCufMBG2jLA=
|
||||||
github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
|
github.com/dvsekhvalnov/jose2go v1.8.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
|
||||||
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
github.com/go-ole/go-ole v1.3.0 h1:Dt6ye7+vXGIKZ7Xtk4s6/xVdGDQynvom7xCFEdWr6uE=
|
||||||
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
github.com/go-ole/go-ole v1.3.0/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||||
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0=
|
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0=
|
||||||
@ -23,13 +22,11 @@ github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c h1:6rhixN/i8
|
|||||||
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
|
github.com/gsterjov/go-libsecret v0.0.0-20161001094733-a6f4afe4910c/go.mod h1:NMPJylDgVpX0MLRlPy15sqSwOFv/U1GZ2m21JhFfek0=
|
||||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
|
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e h1:Q3+PugElBCf4PFpxhErSzU3/PY5sFL5Z6rfv4AbGAck=
|
||||||
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
|
github.com/jchv/go-winloader v0.0.0-20210711035445-715c2860da7e/go.mod h1:alcuEEnZsY1WQsagKhZDsoPCRoOijYqhZvPwLG0kzVs=
|
||||||
github.com/joho/godotenv v1.5.1 h1:7eLL/+HRGLY0ldzfGMeQkb7vMd0as4CfYvUVzLqw0N0=
|
|
||||||
github.com/joho/godotenv v1.5.1/go.mod h1:f4LDr5Voq0i2e/R5DDNOoa2zzDfwtkZa6DnEwAbqwq4=
|
|
||||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0=
|
github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY=
|
||||||
github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM=
|
github.com/labstack/echo/v4 v4.13.3/go.mod h1:o90YNEeQWjDozo584l7AwhJMHN0bOC4tAfg+Xox9q5g=
|
||||||
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0=
|
||||||
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
||||||
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
|
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
|
||||||
@ -45,17 +42,16 @@ github.com/leaanthony/u v1.1.1/go.mod h1:9+o6hejoRljvZ3BzdYlVL0JYCwtnAsVuN9pVTQc
|
|||||||
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
github.com/matryer/is v1.4.0/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||||
github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ=
|
github.com/matryer/is v1.4.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ=
|
||||||
github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
github.com/matryer/is v1.4.1/go.mod h1:8I/i5uYgLzgsgEloJE1U6xx5HkBQpAZvepWuujKwMRU=
|
||||||
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||||
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
|
||||||
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs=
|
github.com/mtibben/percent v0.2.1 h1:5gssi8Nqo8QU/r2pynCm+hBQHpkB/uNK7BJCFogWdzs=
|
||||||
github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns=
|
github.com/mtibben/percent v0.2.1/go.mod h1:KG9uO+SZkUp+VkRHsCdYQV3XSZrrSpR3O9ibNBTZrns=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
|
||||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
|
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
|
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU=
|
||||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
@ -63,51 +59,51 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
|
|||||||
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||||
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
|
||||||
github.com/samber/lo v1.46.0 h1:w8G+oaCPgz1PoCJztqymCFaKwXt+5cCXn51uPxExFfQ=
|
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
|
||||||
github.com/samber/lo v1.46.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
|
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||||
github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As=
|
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||||
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||||
github.com/tkrajina/go-reflector v0.5.6 h1:hKQ0gyocG7vgMD2M3dRlYN6WBBOmdoOzJ6njQSepKdE=
|
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||||
github.com/tkrajina/go-reflector v0.5.6/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4=
|
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||||
|
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
|
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||||
|
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||||
|
github.com/tkrajina/go-reflector v0.5.8 h1:yPADHrwmUbMq4RGEyaOUpz2H90sRsETNVpjzo3DLVQQ=
|
||||||
|
github.com/tkrajina/go-reflector v0.5.8/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4=
|
||||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||||
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo=
|
||||||
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=
|
||||||
github.com/wailsapp/go-webview2 v1.0.10 h1:PP5Hug6pnQEAhfRzLCoOh2jJaPdrqeRgJKZhyYyDV/w=
|
github.com/wailsapp/go-webview2 v1.0.19 h1:7U3QcDj1PrBPaxJNCui2k1SkWml+Q5kvFUFyTImA6NU=
|
||||||
github.com/wailsapp/go-webview2 v1.0.10/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
github.com/wailsapp/go-webview2 v1.0.19/go.mod h1:qJmWAmAmaniuKGZPWwne+uor3AHMB5PFhqiK0Bbj8kc=
|
||||||
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
github.com/wailsapp/mimetype v1.4.1 h1:pQN9ycO7uo4vsUUuPeHEYoUkLVkaRntMnHJxVwYhwHs=
|
||||||
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
github.com/wailsapp/mimetype v1.4.1/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||||
github.com/wailsapp/wails/v2 v2.9.1 h1:irsXnoQrCpeKzKTYZ2SUVlRRyeMR6I0vCO9Q1cvlEdc=
|
github.com/wailsapp/wails/v2 v2.9.2 h1:Xb5YRTos1w5N7DTMyYegWaGukCP2fIaX9WF21kPPF2k=
|
||||||
github.com/wailsapp/wails/v2 v2.9.1/go.mod h1:7maJV2h+Egl11Ak8QZN/jlGLj2wg05bsQS+ywJPT0gI=
|
github.com/wailsapp/wails/v2 v2.9.2/go.mod h1:uehvlCwJSFcBq7rMCGfk4rxca67QQGsbg5Nm4m9UnBs=
|
||||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
golang.org/x/crypto v0.32.0 h1:euUpcYgM8WcP71gNpTqQCn6rC2t6ULUPiOzfWaXVVfc=
|
||||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
golang.org/x/crypto v0.32.0/go.mod h1:ZnnJkOaASj8g0AjIduWNlq2NRxL0PlBrbKVyZ6V/Ugc=
|
||||||
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
golang.org/x/net v0.0.0-20210505024714-0287a6fb4125/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
golang.org/x/net v0.34.0 h1:Mb7Mrk043xzHgnRM88suvJFwzVrRfHEHJEl5/71CKw0=
|
||||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
golang.org/x/net v0.34.0/go.mod h1:di0qlW3YNM5oh6GqDGQr92MyTozJPmybPK4Ev/Gm31k=
|
||||||
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200810151505-1b9f1253b3ed/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20210819135213-f52c844e1c1c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|
||||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
|
||||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk=
|
golang.org/x/term v0.28.0 h1:/Ts8HFuMR2E6IP/jlo7QVLZHggjKQbhu/7H0LJFr3Gg=
|
||||||
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
|
golang.org/x/term v0.28.0/go.mod h1:Sw/lC2IAUZ92udQNf3WodGtn4k/XoLyZoh8v/8uiwek=
|
||||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo=
|
||||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
|
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b h1:QRR6H1YWRnHb4Y/HeNFCTJLFVxaq6wH4YuVdsUOr75U=
|
||||||
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v1.0.0-20200902074654-038fdea0a05b/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
22
main.go
22
main.go
@ -2,20 +2,13 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"embed"
|
"embed"
|
||||||
"github.com/joho/godotenv"
|
|
||||||
"github.com/wailsapp/wails/v2"
|
"github.com/wailsapp/wails/v2"
|
||||||
"github.com/wailsapp/wails/v2/pkg/options"
|
"github.com/wailsapp/wails/v2/pkg/options"
|
||||||
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
|
||||||
"log"
|
"github.com/wailsapp/wails/v2/pkg/options/linux"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
err := godotenv.Load()
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("Error loading .env file")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//go:embed all:frontend/dist
|
//go:embed all:frontend/dist
|
||||||
var assets embed.FS
|
var assets embed.FS
|
||||||
|
|
||||||
@ -33,11 +26,20 @@ func main() {
|
|||||||
},
|
},
|
||||||
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
|
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
|
||||||
OnStartup: app.startup,
|
OnStartup: app.startup,
|
||||||
|
SingleInstanceLock: &options.SingleInstanceLock{
|
||||||
|
UniqueId: "49c93b6d-663d-4b7a-9cb0-8a469ea9182b",
|
||||||
|
OnSecondInstanceLaunch: app.onSecondInstanceLaunch,
|
||||||
|
},
|
||||||
Bind: []interface{}{
|
Bind: []interface{}{
|
||||||
app,
|
app,
|
||||||
},
|
},
|
||||||
|
Linux: &linux.Options{
|
||||||
|
Icon: []byte("./build/AniTrack.png"),
|
||||||
|
WindowIsTranslucent: false,
|
||||||
|
WebviewGpuPolicy: linux.WebviewGpuPolicyNever,
|
||||||
|
ProgramName: "AniTrack",
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
println("Error:", err.Error())
|
println("Error:", err.Error())
|
||||||
}
|
}
|
||||||
|
@ -9,5 +9,9 @@
|
|||||||
"author": {
|
"author": {
|
||||||
"name": "John O'Keefe",
|
"name": "John O'Keefe",
|
||||||
"email": "jokeefe@fastmail.com"
|
"email": "jokeefe@fastmail.com"
|
||||||
|
},
|
||||||
|
"info": {
|
||||||
|
"productName": "AniTrack",
|
||||||
|
"productVersion": "0.1.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user