Compare commits
206 Commits
d1258c54d3
...
0.7.0
| Author | SHA1 | Date | |
|---|---|---|---|
| a3b4857175 | |||
| 6e4b9c041a | |||
| ae54fd20dd | |||
| 2c7e2d0eff | |||
| 9a9f055c38 | |||
| bc497521e7 | |||
| 48a6005725 | |||
| 93a94d0797 | |||
| a2576b044c | |||
| 2ee2d85e9e | |||
| 1090f112f3 | |||
| 58c9f449e0 | |||
| f016c90353 | |||
| 6bbe0f0f48 | |||
| d841fee1e7 | |||
| f29d8f378e | |||
| 35e93c0ca9 | |||
| 8c169d549a | |||
| b2a8a504f3 | |||
| c85a53a278 | |||
| 2cf3844e76 | |||
| 6ed5fe8b71 | |||
| 8a8baf7f8f | |||
| ca8c8beaf3 | |||
| 3e7f7d1c95 | |||
| b0ca864dfe | |||
| 5ed6dedeab | |||
| 3271af445a | |||
| e7e9e5b826 | |||
| 5337758dee | |||
| 426793e56a | |||
| a794b77654 | |||
| c510c2a138 | |||
| 8cbf5cb20c | |||
| 54a8924384 | |||
| d70153064f | |||
| 7960f8e26d | |||
| 2e5a4a4493 | |||
| 874b3952ee | |||
| 60eac10545 | |||
| 6d66d711ff | |||
| cd62e6c658 | |||
| 063c5016f3 | |||
| 5c4caf68e6 | |||
| c10e853564 | |||
| cd043d093f | |||
| 6db01f7f9f | |||
| 8460d56d55 | |||
| 8fedbe4607 | |||
| e069c47242 | |||
| aba0f2d1d5 | |||
| af6cb7f08a | |||
| 487e5ee5a8 | |||
| 631bd8b885 | |||
| b35be6926a | |||
| 5a9f4391dc | |||
| 72004c98b4 | |||
| 3db25bc33a | |||
| f3a1536953 | |||
| dc01aa314c | |||
| baed9a4a67 | |||
| 0e00120778 | |||
| 697692c277 | |||
| 3e82677c2c | |||
| b81549e5a6 | |||
| fd806df0a9 | |||
| 26f85dd412 | |||
| 4d9c54a116 | |||
| 068e568ec6 | |||
| 4e6f910e74 | |||
| b39f19f03a | |||
| 1a083deb54 | |||
| 61f8f5dd84 | |||
| 4509e479bc | |||
| ee8dd2e866 | |||
| 0c6a8a40c3 | |||
| 45845c2a69 | |||
| 3ec5eb1a03 | |||
| a2aa90edec | |||
| d08283bd2d | |||
| 73d349ee1a | |||
| c9c6650829 | |||
| 896c6640e2 | |||
| 18c744c1cf | |||
| 0475d39c6c | |||
| 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 | |||
| 90b68b717a | |||
| 0ae1e4cb7d | |||
| 4a60d45089 | |||
| 12706426f4 | |||
| 5050cb92d9 | |||
| adad8418a9 | |||
| c2bf45313d | |||
| 0f647e85cb | |||
| a0e193e343 | |||
| 03413cd11a | |||
| fa3304db92 | |||
| 43a054ac92 | |||
| 15d61290be | |||
| d573b871ae | |||
| 8daf3af5f9 | |||
| d644758253 | |||
| 1b08918d8e | |||
| a6b26171d4 | |||
| b11395a617 | |||
| 8a6b3bd2b7 | |||
| aaf0f421f2 | |||
| 49e461d0ff | |||
| 6c4fdabb79 | |||
| 77289052e9 | |||
| 1dcf7ba5bd | |||
| 46e2a9156f | |||
| 1e90f68e70 | |||
| 8fc2b8b508 | |||
| ce52ae20f5 | |||
| 94c0f97e95 | |||
| 79ed79c25e | |||
| 091ca82f69 | |||
| eeb4a62f26 | |||
| a0b00de615 | |||
| 6e9c2cf46e | |||
| 53b7368daf | |||
| c95b658131 | |||
| de38d0335b | |||
| d2ef265807 | |||
| 7af14ad7f3 | |||
| 2f272fe7af | |||
| 54d5932d8a | |||
| 8c61c5e96b | |||
| 7044dc1d90 |
7
.gitignore
vendored
@@ -29,3 +29,10 @@ package.json.md5
|
||||
package-lock.json
|
||||
.idea
|
||||
.env
|
||||
environment.go
|
||||
|
||||
# REST (http files)
|
||||
http-client.private.env.json
|
||||
|
||||
# Build artifacts
|
||||
build/*.tar.gz
|
||||
|
||||
@@ -18,31 +18,29 @@ func AniListQuery(body interface{}, login bool) (json.RawMessage, string) {
|
||||
if login && (AniListJWT{}) != aniListJwt {
|
||||
response.Header.Add("Authorization", "Bearer "+aniListJwt.AccessToken)
|
||||
} 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("Accept", "application/json")
|
||||
|
||||
client := &http.Client{}
|
||||
res, reserr := client.Do(response)
|
||||
if reserr != nil {
|
||||
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 {
|
||||
return nil, "Could not read the returned body."
|
||||
}
|
||||
|
||||
return returnedBody, ""
|
||||
return returnedBody, res.Status
|
||||
}
|
||||
|
||||
func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
|
||||
var user = a.GetAniListLoggedInUserId()
|
||||
// type Variables struct {
|
||||
// UserId int `json:"userId"`
|
||||
// MediaId int `json:"mediaId"`
|
||||
// ListType string `json:"listType"`
|
||||
// }
|
||||
user := a.GetAniListLoggedInUser()
|
||||
|
||||
var neededVariables interface{}
|
||||
|
||||
@@ -96,6 +94,16 @@ func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
|
||||
timeUntilAiring
|
||||
episode
|
||||
}
|
||||
genres
|
||||
tags{
|
||||
id
|
||||
name
|
||||
description
|
||||
rank
|
||||
isMediaSpoiler
|
||||
isAdult
|
||||
}
|
||||
isAdult
|
||||
}
|
||||
status
|
||||
startedAt{
|
||||
@@ -135,18 +143,48 @@ func (a *App) GetAniListItem(aniId int, login bool) AniListGetSingleAnime {
|
||||
Variables: neededVariables,
|
||||
}
|
||||
|
||||
returnedBody, _ := AniListQuery(body, false)
|
||||
|
||||
returnedBody, status := AniListQuery(body, login)
|
||||
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)
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
|
||||
func (a *App) AniListSearch(query string) any {
|
||||
func (a *App) AniListSearch(query string) (interface{}, error) {
|
||||
type Variables struct {
|
||||
Search string `json:"search"`
|
||||
ListType string `json:"listType"`
|
||||
@@ -186,6 +224,16 @@ func (a *App) AniListSearch(query string) any {
|
||||
timeUntilAiring
|
||||
episode
|
||||
}
|
||||
genres
|
||||
tags{
|
||||
id
|
||||
name
|
||||
description
|
||||
rank
|
||||
isMediaSpoiler
|
||||
isAdult
|
||||
}
|
||||
isAdult
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -195,19 +243,21 @@ func (a *App) AniListSearch(query string) any {
|
||||
ListType: "ANIME",
|
||||
},
|
||||
}
|
||||
returnedBody, _ := AniListQuery(body, false)
|
||||
|
||||
returnedBody, status := AniListQuery(body, false)
|
||||
if status != "200 OK" {
|
||||
return nil, fmt.Errorf("API search failed with status: %s", status)
|
||||
}
|
||||
var post interface{}
|
||||
err := json.Unmarshal(returnedBody, &post)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
return nil, fmt.Errorf("Failed to parse search results")
|
||||
}
|
||||
|
||||
return post
|
||||
return post, nil
|
||||
}
|
||||
|
||||
func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) AniListCurrentUserWatchList {
|
||||
var user = a.GetAniListLoggedInUserId()
|
||||
func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) (AniListCurrentUserWatchList, error) {
|
||||
user := a.GetAniListLoggedInUser()
|
||||
type Variables struct {
|
||||
Page int `json:"page"`
|
||||
PerPage int `json:"perPage"`
|
||||
@@ -262,6 +312,16 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani
|
||||
timeUntilAiring
|
||||
episode
|
||||
}
|
||||
genres
|
||||
tags{
|
||||
id
|
||||
name
|
||||
description
|
||||
rank
|
||||
isMediaSpoiler
|
||||
isAdult
|
||||
}
|
||||
isAdult
|
||||
}
|
||||
status
|
||||
startedAt {
|
||||
@@ -309,72 +369,61 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani
|
||||
},
|
||||
}
|
||||
|
||||
returnedBody, _ := AniListQuery(body, true)
|
||||
|
||||
fmt.Println("ReturnedBody: ", string(returnedBody))
|
||||
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
|
||||
err := json.Unmarshal(returnedBody, &post)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
}
|
||||
|
||||
// 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
|
||||
var total int
|
||||
for _, status := range statuses {
|
||||
if status.Status == "CURRENT" {
|
||||
total = status.Count
|
||||
if status == "200 OK" {
|
||||
err := json.Unmarshal(returnedBody, &post)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
}
|
||||
// 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
|
||||
var total int
|
||||
for _, status := range statuses {
|
||||
if status.Status == "CURRENT" {
|
||||
total = status.Count
|
||||
}
|
||||
}
|
||||
|
||||
lastPage := total / perPage
|
||||
|
||||
post.Data.Page.PageInfo.Total = total
|
||||
post.Data.Page.PageInfo.LastPage = lastPage
|
||||
}
|
||||
|
||||
lastPage := total / perPage
|
||||
if status == "403 Forbidden" {
|
||||
err := json.Unmarshal(returnedBody, &badPost)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
return post, fmt.Errorf("API authentication error")
|
||||
}
|
||||
return post, fmt.Errorf("AniList API error: %s", badPost.Errors[0].Message)
|
||||
}
|
||||
if status != "200 OK" {
|
||||
return post, fmt.Errorf("API request failed with status: %s", status)
|
||||
}
|
||||
|
||||
post.Data.Page.PageInfo.Total = total
|
||||
post.Data.Page.PageInfo.LastPage = lastPage
|
||||
|
||||
return post
|
||||
return post, nil
|
||||
}
|
||||
|
||||
func (a *App) AniListUpdateEntry(
|
||||
mediaId int,
|
||||
progress string,
|
||||
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 string `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"`
|
||||
}
|
||||
func (a *App) AniListUpdateEntry(updateBody AniListUpdateVariables) AniListGetSingleAnime {
|
||||
body := struct {
|
||||
Mutation string `json:"mutation"`
|
||||
Variables Variables `json:"variables"`
|
||||
Query string `json:"query"`
|
||||
Variables AniListUpdateVariables `json:"variables"`
|
||||
}{
|
||||
Mutation: `
|
||||
Query: `
|
||||
mutation(
|
||||
$mediaId:Int,
|
||||
$progress:Int,
|
||||
@@ -395,12 +444,33 @@ func (a *App) AniListUpdateEntry(
|
||||
startedAt:$startedAt
|
||||
completedAt:$completedAt
|
||||
){
|
||||
id
|
||||
mediaId
|
||||
progress
|
||||
userId
|
||||
media {
|
||||
id
|
||||
idMal
|
||||
title {
|
||||
romaji
|
||||
english
|
||||
native
|
||||
}
|
||||
description
|
||||
coverImage {
|
||||
large
|
||||
}
|
||||
season
|
||||
seasonYear
|
||||
status
|
||||
episodes
|
||||
nextAiringEpisode {
|
||||
airingAt
|
||||
timeUntilAiring
|
||||
episode
|
||||
}
|
||||
isAdult
|
||||
}
|
||||
status
|
||||
score
|
||||
repeat
|
||||
notes
|
||||
startedAt{
|
||||
year
|
||||
month
|
||||
@@ -411,31 +481,76 @@ func (a *App) AniListUpdateEntry(
|
||||
month
|
||||
day
|
||||
}
|
||||
notes
|
||||
progress
|
||||
score
|
||||
repeat
|
||||
user {
|
||||
id
|
||||
name
|
||||
avatar{
|
||||
large
|
||||
medium
|
||||
}
|
||||
statistics{
|
||||
anime{
|
||||
count
|
||||
statuses{
|
||||
status
|
||||
count
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
Variables: Variables{
|
||||
MediaId: mediaId,
|
||||
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,
|
||||
},
|
||||
}}
|
||||
Variables: updateBody,
|
||||
}
|
||||
|
||||
returnedBody, _ := AniListQuery(body, true)
|
||||
|
||||
var post interface{}
|
||||
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{
|
||||
Id: mediaListId,
|
||||
},
|
||||
}
|
||||
|
||||
returnedBody, _ := AniListQuery(body, true)
|
||||
|
||||
var post DeleteAniListReturn
|
||||
err := json.Unmarshal(returnedBody, &post)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
|
||||
187
AniListTypes.go
@@ -10,8 +10,14 @@ type AniListJWT struct {
|
||||
type AniListUser struct {
|
||||
Data struct {
|
||||
Viewer struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Avatar struct {
|
||||
Large string `json:"large"`
|
||||
Medium string `json:"medium"`
|
||||
} `json:"avatar"`
|
||||
BannerImage string `json:"bannerImage"`
|
||||
SiteUrl string `json:"siteUrl"`
|
||||
} `json:"Viewer"`
|
||||
} `json:"data"`
|
||||
}
|
||||
@@ -37,6 +43,12 @@ type AniListGetSingleAnime struct {
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type AniListUpdateReturn struct {
|
||||
Data struct {
|
||||
SaveMediaListEntry MediaList `json:"SaveMediaListEntry"`
|
||||
}
|
||||
}
|
||||
|
||||
type MediaList struct {
|
||||
ID int `json:"id"`
|
||||
MediaID int `json:"mediaId"`
|
||||
@@ -62,6 +74,16 @@ type MediaList struct {
|
||||
TimeUntilAiring int `json:"timeUntilAiring"`
|
||||
Episode int `json:"episode"`
|
||||
} `json:"nextAiringEpisode"`
|
||||
Genres []string `json:"genres"`
|
||||
Tags []struct {
|
||||
Id int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Rank int `json:"rank"`
|
||||
IsMediaSpoiler bool `json:"isMediaSpoiler"`
|
||||
IsAdult bool `json:"isAdult"`
|
||||
} `json:"tags"`
|
||||
IsAdult bool `json:"isAdult"`
|
||||
} `json:"media"`
|
||||
Status string `json:"status"`
|
||||
StartedAt struct {
|
||||
@@ -74,10 +96,10 @@ type MediaList struct {
|
||||
Month int `json:"month"`
|
||||
Day int `json:"day"`
|
||||
} `json:"completedAt"`
|
||||
Notes string `json:"notes"`
|
||||
Progress int `json:"progress"`
|
||||
Score int `json:"score"`
|
||||
Repeat int `json:"repeat"`
|
||||
Notes string `json:"notes"`
|
||||
Progress int `json:"progress"`
|
||||
Score float64 `json:"score"`
|
||||
Repeat int `json:"repeat"`
|
||||
User struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
@@ -97,66 +119,95 @@ type MediaList struct {
|
||||
} `json:"user"`
|
||||
}
|
||||
|
||||
var MediaListSort = struct {
|
||||
MediaId string
|
||||
MediaIdDesc string
|
||||
Score string
|
||||
ScoreDesc string
|
||||
Status string
|
||||
StatusDesc string
|
||||
Progress string
|
||||
ProgressDesc string
|
||||
ProgressVolumes string
|
||||
ProgressVolumesDesc string
|
||||
Repeat string
|
||||
RepeatDesc string
|
||||
Priority string
|
||||
PriorityDesc string
|
||||
StartedOn string
|
||||
StartedOnDesc string
|
||||
FinishedOn string
|
||||
FinishedOnDesc string
|
||||
AddedTime string
|
||||
AddedTimeDesc string
|
||||
UpdatedTime string
|
||||
UpdatedTimeDesc string
|
||||
MediaTitleRomaji string
|
||||
MediaTitleRomajiDesc string
|
||||
MediaTitleEnglish string
|
||||
MediaTitleEnglishDesc string
|
||||
MediaTitleNative string
|
||||
MediaTitleNativeDesc string
|
||||
MediaPopularity string
|
||||
MediaPopularityDesc string
|
||||
}{
|
||||
MediaId: "MEDIA_ID",
|
||||
MediaIdDesc: "MEDIA_ID_DESC",
|
||||
Score: "SCORE",
|
||||
ScoreDesc: "SCORE_DESC",
|
||||
Status: "STATUS",
|
||||
StatusDesc: "STATUS_DESC",
|
||||
Progress: "PROGRESS",
|
||||
ProgressDesc: "PROGRESS_DESC",
|
||||
ProgressVolumes: "PROGRESS_VOLUMES",
|
||||
ProgressVolumesDesc: "PROGRESS_VOLUMES_DESC",
|
||||
Repeat: "REPEAT",
|
||||
RepeatDesc: "REPEAT_DESC",
|
||||
Priority: "PRIORITY",
|
||||
PriorityDesc: "PRIORITY_DESC",
|
||||
StartedOn: "STARTED_ON",
|
||||
StartedOnDesc: "STARTED_ON_DESC",
|
||||
FinishedOn: "FINISHED_ON",
|
||||
FinishedOnDesc: "FINISHED_ON_DESC",
|
||||
AddedTime: "ADDED_TIME",
|
||||
AddedTimeDesc: "ADDED_TIME_DESC",
|
||||
UpdatedTime: "UPDATED_TIME",
|
||||
UpdatedTimeDesc: "UPDATED_TIME_DESC",
|
||||
MediaTitleRomaji: "MEDIA_TITLE_ROMAJI",
|
||||
MediaTitleRomajiDesc: "MEDIA_TITLE_ROMAJI_DESC",
|
||||
MediaTitleEnglish: "MEDIA_TITLE_ENGLISH",
|
||||
MediaTitleEnglishDesc: "MEDIA_TITLE_ENGLISH_DESC",
|
||||
MediaTitleNative: "MEDIA_TITLE_NATIVE",
|
||||
MediaTitleNativeDesc: "MEDIA_TITLE_NATIVE_DESC",
|
||||
MediaPopularity: "MEDIA_POPULARITY",
|
||||
MediaPopularityDesc: "MEDIA_POPULARITY_DESC",
|
||||
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 {
|
||||
// MediaId string
|
||||
// MediaIdDesc string
|
||||
// Score string
|
||||
// ScoreDesc string
|
||||
// Status string
|
||||
// StatusDesc string
|
||||
// Progress string
|
||||
// ProgressDesc string
|
||||
// ProgressVolumes string
|
||||
// ProgressVolumesDesc string
|
||||
// Repeat string
|
||||
// RepeatDesc string
|
||||
// Priority string
|
||||
// PriorityDesc string
|
||||
// StartedOn string
|
||||
// StartedOnDesc string
|
||||
// FinishedOn string
|
||||
// FinishedOnDesc string
|
||||
// AddedTime string
|
||||
// AddedTimeDesc string
|
||||
// UpdatedTime string
|
||||
// UpdatedTimeDesc string
|
||||
// MediaTitleRomaji string
|
||||
// MediaTitleRomajiDesc string
|
||||
// MediaTitleEnglish string
|
||||
// MediaTitleEnglishDesc string
|
||||
// MediaTitleNative string
|
||||
// MediaTitleNativeDesc string
|
||||
// MediaPopularity string
|
||||
// MediaPopularityDesc string
|
||||
//}{
|
||||
// MediaId: "MEDIA_ID",
|
||||
// MediaIdDesc: "MEDIA_ID_DESC",
|
||||
// Score: "SCORE",
|
||||
// ScoreDesc: "SCORE_DESC",
|
||||
// Status: "STATUS",
|
||||
// StatusDesc: "STATUS_DESC",
|
||||
// Progress: "PROGRESS",
|
||||
// ProgressDesc: "PROGRESS_DESC",
|
||||
// ProgressVolumes: "PROGRESS_VOLUMES",
|
||||
// ProgressVolumesDesc: "PROGRESS_VOLUMES_DESC",
|
||||
// Repeat: "REPEAT",
|
||||
// RepeatDesc: "REPEAT_DESC",
|
||||
// Priority: "PRIORITY",
|
||||
// PriorityDesc: "PRIORITY_DESC",
|
||||
// StartedOn: "STARTED_ON",
|
||||
// StartedOnDesc: "STARTED_ON_DESC",
|
||||
// FinishedOn: "FINISHED_ON",
|
||||
// FinishedOnDesc: "FINISHED_ON_DESC",
|
||||
// AddedTime: "ADDED_TIME",
|
||||
// AddedTimeDesc: "ADDED_TIME_DESC",
|
||||
// UpdatedTime: "UPDATED_TIME",
|
||||
// UpdatedTimeDesc: "UPDATED_TIME_DESC",
|
||||
// MediaTitleRomaji: "MEDIA_TITLE_ROMAJI",
|
||||
// MediaTitleRomajiDesc: "MEDIA_TITLE_ROMAJI_DESC",
|
||||
// MediaTitleEnglish: "MEDIA_TITLE_ENGLISH",
|
||||
// MediaTitleEnglishDesc: "MEDIA_TITLE_ENGLISH_DESC",
|
||||
// MediaTitleNative: "MEDIA_TITLE_NATIVE",
|
||||
// MediaTitleNativeDesc: "MEDIA_TITLE_NATIVE_DESC",
|
||||
// MediaPopularity: "MEDIA_POPULARITY",
|
||||
// MediaPopularityDesc: "MEDIA_POPULARITY_DESC",
|
||||
//}
|
||||
|
||||
@@ -3,12 +3,12 @@ package main
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -20,38 +20,62 @@ import (
|
||||
var aniListJwt AniListJWT
|
||||
|
||||
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())
|
||||
|
||||
func (a *App) CheckIfAniListLoggedIn() bool {
|
||||
if (AniListJWT{} == aniListJwt) {
|
||||
tokenType, tokenErr := aniRing.Get("anilistTokenType")
|
||||
expiresIn, expiresInErr := aniRing.Get("anilistTokenExpiresIn")
|
||||
refreshToken, refreshTokenErr := aniRing.Get("anilistRefreshToken")
|
||||
accessToken, accessTokenErr := aniRing.Get("anilistAccessToken")
|
||||
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
||||
return false
|
||||
} else {
|
||||
aniListJwt.TokenType = string(tokenType.Data)
|
||||
aniListJwt.AccessToken = string(accessToken.Data)
|
||||
aniListJwt.RefreshToken = string(refreshToken.Data)
|
||||
aniListJwt.ExpiresIn, _ = strconv.Atoi(string(expiresIn.Data))
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) AniListLogin() {
|
||||
if (AniListJWT{}) == aniListJwt {
|
||||
tokenType, err := aniRing.Get("anilistTokenType")
|
||||
expiresIn, err := aniRing.Get("anilistTokenExpiresIn")
|
||||
accessToken, err := aniRing.Get("anilistAccessToken")
|
||||
refreshToken, err := aniRing.Get("anilistRefreshToken")
|
||||
if err != nil {
|
||||
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"
|
||||
runtime.BrowserOpenURL(a.ctx, getAniListCodeUrl)
|
||||
if (AniListJWT{} == aniListJwt) {
|
||||
tokenType, tokenErr := aniRing.Get("anilistTokenType")
|
||||
expiresIn, expiresInErr := aniRing.Get("anilistTokenExpiresIn")
|
||||
refreshToken, refreshTokenErr := aniRing.Get("anilistRefreshToken")
|
||||
accessToken, accessTokenErr := aniRing.Get("anilistAccessToken")
|
||||
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
||||
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(*wailsContext, getAniListCodeUrl)
|
||||
|
||||
serverDone := &sync.WaitGroup{}
|
||||
serverDone.Add(1)
|
||||
handleAniListCallback(serverDone)
|
||||
a.handleAniListCallback(serverDone)
|
||||
serverDone.Wait()
|
||||
} else {
|
||||
aniListJwt.TokenType = string(tokenType.Data)
|
||||
aniListJwt.AccessToken = string(accessToken.Data)
|
||||
aniListJwt.RefreshToken = string(refreshToken.Data)
|
||||
expiresInString := string(expiresIn.Data)
|
||||
aniListJwt.ExpiresIn, _ = strconv.Atoi(expiresInString)
|
||||
aniListJwt.ExpiresIn, _ = strconv.Atoi(string(expiresIn.Data))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func handleAniListCallback(wg *sync.WaitGroup) {
|
||||
srv := &http.Server{Addr: ":6734"}
|
||||
http.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) {
|
||||
func (a *App) handleAniListCallback(wg *sync.WaitGroup) {
|
||||
mux := http.NewServeMux()
|
||||
srv := &http.Server{Addr: ":6734", Handler: mux}
|
||||
mux.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) {
|
||||
select {
|
||||
case <-aniCtxShutdown.Done():
|
||||
fmt.Println("Shutting down...")
|
||||
@@ -59,7 +83,6 @@ func handleAniListCallback(wg *sync.WaitGroup) {
|
||||
default:
|
||||
}
|
||||
content := r.FormValue("code")
|
||||
|
||||
if content != "" {
|
||||
aniListJwt = getAniListAuthorizationToken(content)
|
||||
_ = aniRing.Set(keyring.Item{
|
||||
@@ -68,7 +91,7 @@ func handleAniListCallback(wg *sync.WaitGroup) {
|
||||
})
|
||||
_ = aniRing.Set(keyring.Item{
|
||||
Key: "anilistTokenExpiresIn",
|
||||
Data: []byte(string(aniListJwt.ExpiresIn)),
|
||||
Data: []byte(strconv.Itoa(aniListJwt.ExpiresIn)),
|
||||
})
|
||||
_ = aniRing.Set(keyring.Item{
|
||||
Key: "anilistAccessToken",
|
||||
@@ -78,9 +101,16 @@ func handleAniListCallback(wg *sync.WaitGroup) {
|
||||
Key: "anilistRefreshToken",
|
||||
Data: []byte(aniListJwt.RefreshToken),
|
||||
})
|
||||
_, err := runtime.MessageDialog(*wailsContext, runtime.MessageDialogOptions{
|
||||
Title: "AniList Authorization",
|
||||
Message: "It is now safe to close your browser tab",
|
||||
})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
fmt.Println("Shutting down...")
|
||||
aniCancel()
|
||||
err := srv.Shutdown(context.Background())
|
||||
err = srv.Shutdown(context.Background())
|
||||
if err != nil {
|
||||
log.Println("server.Shutdown:", err)
|
||||
}
|
||||
@@ -94,7 +124,7 @@ func handleAniListCallback(wg *sync.WaitGroup) {
|
||||
|
||||
go func() {
|
||||
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)
|
||||
}
|
||||
fmt.Println("Shutting down...")
|
||||
@@ -106,9 +136,9 @@ func getAniListAuthorizationToken(content string) AniListJWT {
|
||||
resource := "/api/v2/oauth/token"
|
||||
data := url.Values{}
|
||||
data.Set("grant_type", "authorization_code")
|
||||
data.Set("client_id", os.Getenv("ANILIST_APP_ID"))
|
||||
data.Set("client_secret", os.Getenv("ANILIST_SECRET_TOKEN"))
|
||||
data.Set("redirect_uri", os.Getenv("ANILIST_CALLBACK_URI"))
|
||||
data.Set("client_id", Environment.ANILIST_APP_ID)
|
||||
data.Set("client_secret", Environment.ANILIST_SECRET_TOKEN)
|
||||
data.Set("redirect_uri", Environment.ANILIST_CALLBACK_URI)
|
||||
data.Set("code", content)
|
||||
|
||||
u, _ := url.ParseRequestURI(apiUrl)
|
||||
@@ -119,19 +149,21 @@ func getAniListAuthorizationToken(content string) AniListJWT {
|
||||
if err != nil {
|
||||
log.Printf("Failed at response, %s\n", err)
|
||||
}
|
||||
response.Header.Add("content-type", "application/x-www-form-urlencoded")
|
||||
response.Header.Add("Content-Type", "application/json")
|
||||
response.Header.Add("Content-type", "application/x-www-form-urlencoded")
|
||||
response.Header.Add("Accept", "application/json")
|
||||
|
||||
client := &http.Client{}
|
||||
res, reserr := client.Do(response)
|
||||
if reserr != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
var post AniListJWT
|
||||
err = json.Unmarshal(returnedBody, &post)
|
||||
@@ -142,7 +174,7 @@ func getAniListAuthorizationToken(content string) AniListJWT {
|
||||
return post
|
||||
}
|
||||
|
||||
func (a *App) GetAniListLoggedInUserId() AniListUser {
|
||||
func (a *App) GetAniListLoggedInUser() AniListUser {
|
||||
a.AniListLogin()
|
||||
body := struct {
|
||||
Query string `json:"query"`
|
||||
@@ -152,6 +184,12 @@ func (a *App) GetAniListLoggedInUserId() AniListUser {
|
||||
Viewer {
|
||||
id
|
||||
name
|
||||
avatar {
|
||||
large
|
||||
medium
|
||||
}
|
||||
bannerImage
|
||||
siteUrl
|
||||
}
|
||||
}
|
||||
`,
|
||||
@@ -167,3 +205,18 @@ func (a *App) GetAniListLoggedInUserId() AniListUser {
|
||||
|
||||
return post
|
||||
}
|
||||
|
||||
func (a *App) LogoutAniList() string {
|
||||
if (AniListJWT{} != aniListJwt) {
|
||||
typeErr := aniRing.Remove("anilistTokenType")
|
||||
expiresInErr := aniRing.Remove("anilistTokenExpiresIn")
|
||||
accessTokenErr := aniRing.Remove("anilistAccessToken")
|
||||
refreshTokenErr := aniRing.Remove("anilistRefreshToken")
|
||||
if typeErr != nil || expiresInErr != nil || accessTokenErr != nil || refreshTokenErr != nil {
|
||||
fmt.Println("AniList Logout Failed")
|
||||
}
|
||||
aniListJwt = AniListJWT{}
|
||||
}
|
||||
|
||||
return "AniList Logged Out Successfully"
|
||||
}
|
||||
|
||||
148
MALFunctions.go
Normal file
@@ -0,0 +1,148 @@
|
||||
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, error) {
|
||||
client := &http.Client{}
|
||||
|
||||
req, err := http.NewRequest(method, malUrl, strings.NewReader(body.Encode()))
|
||||
|
||||
if err != nil {
|
||||
message, _ := json.Marshal(struct {
|
||||
Message string `json:"message"`
|
||||
}{
|
||||
Message: "Failed to create request: " + err.Error(),
|
||||
})
|
||||
return message, "", fmt.Errorf("failed to create request: %w", err)
|
||||
}
|
||||
|
||||
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 {
|
||||
message, _ := json.Marshal(struct {
|
||||
Message string `json:"message"`
|
||||
}{
|
||||
Message: "Network error: " + err.Error(),
|
||||
})
|
||||
return message, "", fmt.Errorf("network error: %w", err)
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
respBody, err := io.ReadAll(resp.Body)
|
||||
|
||||
if err != nil {
|
||||
return nil, resp.Status, fmt.Errorf("failed to read response: %w", err)
|
||||
}
|
||||
|
||||
if resp.Status == "401 Unauthorized" {
|
||||
refreshMyAnimeListAuthorizationToken()
|
||||
return MALHelper(method, malUrl, body)
|
||||
}
|
||||
|
||||
if resp.Status != "200 OK" && resp.Status != "201 Created" && resp.Status != "202 Accepted" {
|
||||
return respBody, resp.Status, fmt.Errorf("API returned status: %s", resp.Status)
|
||||
}
|
||||
return respBody, resp.Status, nil
|
||||
}
|
||||
|
||||
func (a *App) GetMyAnimeList(count int) (MALWatchlist, error) {
|
||||
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, err := MALHelper("GET", malUrl, nil)
|
||||
|
||||
if err != nil {
|
||||
return malList, fmt.Errorf("failed to get MAL watchlist: %w", err)
|
||||
}
|
||||
|
||||
if resStatus == "200 OK" {
|
||||
err := json.Unmarshal(respBody, &malList)
|
||||
if err != nil {
|
||||
log.Printf("Failed to unmarshal json response, %s\n", err)
|
||||
return malList, fmt.Errorf("failed to parse response: %w", err)
|
||||
}
|
||||
}
|
||||
|
||||
return malList, nil
|
||||
}
|
||||
|
||||
func (a *App) MyAnimeListUpdate(anime MALAnime, update MALUploadStatus) (MalListStatus, error) {
|
||||
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, err := MALHelper("PATCH", malUrl, body)
|
||||
|
||||
if err != nil {
|
||||
return status, fmt.Errorf("failed to update MAL entry: %w", err)
|
||||
}
|
||||
|
||||
if respStatus == "200 OK" {
|
||||
err := json.Unmarshal(respBody, &status)
|
||||
if err != nil {
|
||||
log.Printf("Failed to unmarshal json response, %s\n", err)
|
||||
return status, fmt.Errorf("failed to parse response: %w", err)
|
||||
}
|
||||
}
|
||||
return status, nil
|
||||
}
|
||||
|
||||
func (a *App) GetMyAnimeListAnime(id int) (MALAnime, error) {
|
||||
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"
|
||||
var malAnime MALAnime
|
||||
respBody, respStatus, err := MALHelper("GET", malUrl, nil)
|
||||
|
||||
if err != nil {
|
||||
return malAnime, fmt.Errorf("failed to get MAL anime: %w", err)
|
||||
}
|
||||
|
||||
if respStatus == "200 OK" {
|
||||
err := json.Unmarshal(respBody, &malAnime)
|
||||
if err != nil {
|
||||
log.Printf("Failed to unmarshal json response, %s\n", err)
|
||||
return malAnime, fmt.Errorf("failed to parse response: %w", err)
|
||||
}
|
||||
}
|
||||
return malAnime, nil
|
||||
}
|
||||
|
||||
func (a *App) DeleteMyAnimeListEntry(id int) (bool, error) {
|
||||
malUrl := "https://api.myanimelist.net/v2/anime/" + strconv.Itoa(id) + "/my_list_status"
|
||||
_, respStatus, err := MALHelper("DELETE", malUrl, nil)
|
||||
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("failed to delete MAL entry: %w", err)
|
||||
}
|
||||
|
||||
if respStatus == "200 OK" {
|
||||
return true, nil
|
||||
} else {
|
||||
return false, fmt.Errorf("delete failed with status: %s", respStatus)
|
||||
}
|
||||
}
|
||||
163
MALTypes.go
Normal file
@@ -0,0 +1,163 @@
|
||||
package main
|
||||
|
||||
import "time"
|
||||
|
||||
type MyAnimeListJWT struct {
|
||||
TokenType string `json:"token_type"`
|
||||
ExpiresIn int `json:"expires_in"`
|
||||
AccessToken string `json:"access_token"`
|
||||
RefreshToken string `json:"refresh_token"`
|
||||
}
|
||||
|
||||
type MyAnimeListUser struct {
|
||||
Id int32 `json:"id" ts_type:"id"`
|
||||
Name string `json:"name" ts_type:"name"`
|
||||
Picture string `json:"picture" ts_type:"picture"`
|
||||
Gender string `json:"gender" ts_type:"gender"`
|
||||
Birthday string `json:"birthday" ts_type:"birthday"`
|
||||
Location string `json:"location" ts_type:"location"`
|
||||
JoinedAt string `json:"joined_at" ts_type:"joinedAt"`
|
||||
AnimeStatistics `json:"anime_statistics" ts_type:"AnimeStatistics"`
|
||||
TimeZone string `json:"time_zone" ts_type:"timeZone"`
|
||||
IsSupporter bool `json:"is_supporter" ts_type:"isSupporter"`
|
||||
}
|
||||
|
||||
type AnimeStatistics struct {
|
||||
NumItemsWatching int `json:"num_items_watching" ts_type:"numItemsWatching"`
|
||||
NumItemsCompleted int `json:"num_items_completed" ts_type:"numItemsCompleted"`
|
||||
NumItemsOnHold int `json:"num_items_on_hold" ts_type:"numItemsOnHold"`
|
||||
NumItemsDropped int `json:"num_items_dropped" ts_type:"numItemsDropped"`
|
||||
NumItemsPlanToWatch int `json:"num_items_plan_to_watch" ts_type:"numItemsPlanToWatch"`
|
||||
NumItems int `json:"num_items" ts_type:"numItems"`
|
||||
NumDaysWatched float64 `json:"num_days_watched" ts_type:"numDaysWatched"`
|
||||
NumDaysWatching float64 `json:"num_days_watching" ts_type:"numDaysWatching"`
|
||||
NumDaysCompleted float64 `json:"num_days_completed" ts_type:"numDaysCompleted"`
|
||||
NumDaysOnHold float64 `json:"num_days_on_hold" ts_type:"numDaysOnHold"`
|
||||
NumDaysDropped float64 `json:"num_days_dropped" ts_type:"numDaysDropped"`
|
||||
NumDays float64 `json:"num_days" ts_type:"numDays"`
|
||||
NumEpisodes int `json:"num_episodes" ts_type:"numEpisodes"`
|
||||
NumTimesRewatched int `json:"num_times_rewatched" ts_type:"numTimesRewatched"`
|
||||
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"`
|
||||
}
|
||||
363
MALUserFunctions.go
Normal file
@@ -0,0 +1,363 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/sha256"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/99designs/keyring"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
)
|
||||
|
||||
var myAnimeListJwt MyAnimeListJWT
|
||||
|
||||
var myAnimeListRing, _ = keyring.Open(keyring.Config{
|
||||
ServiceName: "AniTrack",
|
||||
KeychainName: "AniTrack",
|
||||
KeychainSynchronizable: false,
|
||||
KeychainTrustApplication: true,
|
||||
KeychainAccessibleWhenUnlocked: true,
|
||||
})
|
||||
|
||||
var myAnimeListCtxShutdown, myAnimeListCancel = context.WithCancel(context.Background())
|
||||
|
||||
type CodeVerifier struct {
|
||||
Value string
|
||||
}
|
||||
|
||||
const (
|
||||
length = 32
|
||||
)
|
||||
|
||||
func base64URLEncode(str []byte) string {
|
||||
encoded := base64.StdEncoding.EncodeToString(str)
|
||||
encoded = strings.Replace(encoded, "+", "-", -1)
|
||||
encoded = strings.Replace(encoded, "/", "_", -1)
|
||||
encoded = strings.Replace(encoded, "=", "", -1)
|
||||
return encoded
|
||||
}
|
||||
|
||||
func verifier() (*CodeVerifier, error) {
|
||||
r := rand.New(rand.NewSource(time.Now().UnixNano()))
|
||||
b := make([]byte, length)
|
||||
for i := 0; i < length; i++ {
|
||||
b[i] = byte(r.Intn(255))
|
||||
}
|
||||
return CreateCodeVerifierFromBytes(b)
|
||||
}
|
||||
|
||||
func CreateCodeVerifierFromBytes(b []byte) (*CodeVerifier, error) {
|
||||
return &CodeVerifier{
|
||||
Value: base64URLEncode(b),
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (v *CodeVerifier) CodeChallengeS256() string {
|
||||
h := sha256.New()
|
||||
h.Write([]byte(v.Value))
|
||||
return base64URLEncode(h.Sum(nil))
|
||||
}
|
||||
|
||||
func (a *App) CheckIfMyAnimeListLoggedIn() bool {
|
||||
if (MyAnimeListJWT{} == myAnimeListJwt) {
|
||||
tokenType, tokenErr := myAnimeListRing.Get("MyAnimeListTokenType")
|
||||
expiresIn, expiresInErr := myAnimeListRing.Get("MyAnimeListExpiresIn")
|
||||
refreshToken, refreshTokenErr := myAnimeListRing.Get("MyAnimeListAccessToken")
|
||||
accessToken, accessTokenErr := myAnimeListRing.Get("MyAnimeListRefreshToken")
|
||||
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
||||
return false
|
||||
} else {
|
||||
var expiresInConvertErr error
|
||||
myAnimeListJwt.TokenType = string(tokenType.Data)
|
||||
myAnimeListJwt.ExpiresIn, expiresInConvertErr = strconv.Atoi(string(expiresIn.Data))
|
||||
if expiresInConvertErr != nil {
|
||||
fmt.Println("unable to convert string to int")
|
||||
}
|
||||
myAnimeListJwt.AccessToken = string(accessToken.Data)
|
||||
myAnimeListJwt.RefreshToken = string(refreshToken.Data)
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) MyAnimeListLogin() {
|
||||
if !a.CheckIfMyAnimeListLoggedIn() {
|
||||
fmt.Println("check logged in function failed")
|
||||
tokenType, tokenErr := myAnimeListRing.Get("MyAnimeListTokenType")
|
||||
expiresIn, expiresInErr := myAnimeListRing.Get("MyAnimeListExpiresIn")
|
||||
refreshToken, refreshTokenErr := myAnimeListRing.Get("MyAnimeListAccessToken")
|
||||
accessToken, accessTokenErr := myAnimeListRing.Get("MyAnimeListRefreshToken")
|
||||
if (tokenErr != nil || expiresInErr != nil || refreshTokenErr != nil || accessTokenErr != nil) || len(accessToken.Data) == 0 {
|
||||
verifier, _ := verifier()
|
||||
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(*wailsContext, getMyAnimeListCodeUrl)
|
||||
serverDone := &sync.WaitGroup{}
|
||||
serverDone.Add(1)
|
||||
a.handleMyAnimeListCallback(serverDone, verifier)
|
||||
serverDone.Wait()
|
||||
} else {
|
||||
var expiresInConvertErr error
|
||||
myAnimeListJwt.TokenType = string(tokenType.Data)
|
||||
myAnimeListJwt.ExpiresIn, expiresInConvertErr = strconv.Atoi(string(expiresIn.Data))
|
||||
if expiresInConvertErr != nil {
|
||||
fmt.Println("unable to convert string to int in Login function")
|
||||
}
|
||||
myAnimeListJwt.AccessToken = string(accessToken.Data)
|
||||
myAnimeListJwt.RefreshToken = string(refreshToken.Data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) handleMyAnimeListCallback(wg *sync.WaitGroup, verifier *CodeVerifier) {
|
||||
mux := http.NewServeMux()
|
||||
srv := &http.Server{Addr: ":6734", Handler: mux}
|
||||
mux.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) {
|
||||
select {
|
||||
case <-myAnimeListCtxShutdown.Done():
|
||||
fmt.Println("Shutting down...")
|
||||
return
|
||||
default:
|
||||
}
|
||||
content := r.FormValue("code")
|
||||
|
||||
if content != "" {
|
||||
myAnimeListJwt = getMyAnimeListAuthorizationToken(content, verifier)
|
||||
_ = 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 {
|
||||
log.Println(err)
|
||||
}
|
||||
fmt.Println("Shutting down...")
|
||||
myAnimeListCancel()
|
||||
err = srv.Shutdown(context.Background())
|
||||
if err != nil {
|
||||
log.Println("server.Shutdown:", err)
|
||||
}
|
||||
} else {
|
||||
_, err := fmt.Fprintf(w, "Getting code failed.")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Printf("Server error: %s\n", err)
|
||||
}
|
||||
fmt.Println("Shutting down...")
|
||||
}()
|
||||
}
|
||||
|
||||
func getMyAnimeListAuthorizationToken(content string, verifier *CodeVerifier) MyAnimeListJWT {
|
||||
dataForURLs := struct {
|
||||
GrantType string `json:"grant_type"`
|
||||
ClientID string `json:"client_id"`
|
||||
ClientSecret string `json:"client_secret"`
|
||||
RedirectURI string `json:"redirect_uri"`
|
||||
Code string `json:"code"`
|
||||
CodeVerifier *CodeVerifier `json:"code_verifier"`
|
||||
}{
|
||||
GrantType: "authorization_code",
|
||||
ClientID: Environment.MAL_CLIENT_ID,
|
||||
ClientSecret: Environment.MAL_CLIENT_SECRET,
|
||||
RedirectURI: Environment.MAL_CALLBACK_URI,
|
||||
Code: content,
|
||||
CodeVerifier: verifier,
|
||||
}
|
||||
|
||||
data := url.Values{}
|
||||
data.Set("grant_type", dataForURLs.GrantType)
|
||||
data.Set("client_id", dataForURLs.ClientID)
|
||||
data.Set("client_secret", dataForURLs.ClientSecret)
|
||||
data.Set("redirect_uri", dataForURLs.RedirectURI)
|
||||
data.Set("code", dataForURLs.Code)
|
||||
data.Set("code_verifier", dataForURLs.CodeVerifier.Value)
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
var post MyAnimeListJWT
|
||||
err = json.Unmarshal(returnedBody, &post)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
}
|
||||
|
||||
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 {
|
||||
a.MyAnimeListLogin()
|
||||
user := createUser()
|
||||
if user.Name == "" {
|
||||
refreshMyAnimeListAuthorizationToken()
|
||||
user = createUser()
|
||||
}
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
func createUser() MyAnimeListUser {
|
||||
client := &http.Client{}
|
||||
|
||||
req, _ := http.NewRequest("GET", "https://api.myanimelist.net/v2/users/@me?fields=anime_statistics", nil)
|
||||
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
req.Header.Add("Authorization", "Bearer "+myAnimeListJwt.AccessToken)
|
||||
req.Header.Add("myAnimeList-api-key", Environment.MAL_CLIENT_ID)
|
||||
|
||||
response, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Printf("Failed at request, %s\n", err)
|
||||
return MyAnimeListUser{}
|
||||
}
|
||||
|
||||
defer response.Body.Close()
|
||||
|
||||
var user MyAnimeListUser
|
||||
|
||||
respBody, _ := io.ReadAll(response.Body)
|
||||
|
||||
err = json.Unmarshal(respBody, &user)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
}
|
||||
|
||||
return user
|
||||
|
||||
}
|
||||
|
||||
func (a *App) LogoutMyAnimeList() string {
|
||||
if (MyAnimeListJWT{} != myAnimeListJwt) {
|
||||
typeErr := myAnimeListRing.Remove("MyAnimeListTokenType")
|
||||
expiresInErr := myAnimeListRing.Remove("MyAnimeListExpiresIn")
|
||||
accessTokenErr := myAnimeListRing.Remove("MyAnimeListAccessToken")
|
||||
refreshTokenErr := myAnimeListRing.Remove("MyAnimeListRefreshToken")
|
||||
if typeErr != nil || expiresInErr != nil || accessTokenErr != nil || refreshTokenErr != nil {
|
||||
fmt.Println("MAL Logout Failed")
|
||||
}
|
||||
myAnimeListJwt = MyAnimeListJWT{}
|
||||
}
|
||||
|
||||
return "MAL Logged Out Successfully"
|
||||
}
|
||||
29
README.md
@@ -2,10 +2,35 @@
|
||||
|
||||
## 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.
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
To build a redistributable, production mode package, use `wails build`.
|
||||
To build a redistributable, production mode package, use `wails build --clean`.
|
||||
|
||||
166
RELEASE_NOTES_v0.7.0.md
Normal file
@@ -0,0 +1,166 @@
|
||||
# 🎉 AniTrack v0.7.0 Release Notes
|
||||
|
||||
## 🚨 Major Feature: Comprehensive Error Handling
|
||||
|
||||
This release brings **massive improvements** to application stability and user experience. The app will **no longer crash** when API services are down or experiencing errors!
|
||||
|
||||
---
|
||||
|
||||
## ✨ What's New
|
||||
|
||||
### 🛡️ Graceful API Error Handling
|
||||
- **Application Stability**: App now remains running even when AniList, MAL, or Simkl APIs are down
|
||||
- **Visual Error Feedback**: Beautiful modal dialogs display error details instead of silent crashes
|
||||
- **Manual Retry**: Users can retry failed API connections with a single button click
|
||||
- **Continue Using App**: Dismiss error messages and continue with limited functionality
|
||||
|
||||
### 🔧 Backend Improvements
|
||||
|
||||
#### AniList Integration
|
||||
- Replaced all `log.Fatal()` calls with proper error returns
|
||||
- Added error handling for API failures, network issues, and authentication errors
|
||||
- `AniListSearch` now returns detailed error messages
|
||||
- `GetAniListUserWatchingList` gracefully handles 403/404 responses
|
||||
|
||||
#### MyAnimeList Integration
|
||||
- Updated `MALHelper` to return structured errors
|
||||
- All MAL API functions now return errors instead of crashing:
|
||||
- `GetMyAnimeList`
|
||||
- `MyAnimeListUpdate`
|
||||
- `GetMyAnimeListAnime`
|
||||
- `DeleteMyAnimeListEntry`
|
||||
- Fixed OAuth callback server to prevent shutdown on errors
|
||||
|
||||
#### Simkl Integration
|
||||
- Updated `SimklHelper` with status code validation (200-299 range)
|
||||
- All Simkl API functions now return errors:
|
||||
- `SimklGetUserWatchlist`
|
||||
- `SimklSyncEpisodes`
|
||||
- `SimklSyncRating`
|
||||
- `SimklSyncStatus`
|
||||
- `SimklSearch`
|
||||
- `SimklSyncRemove`
|
||||
- Replaced `log.Fatal()` with proper error logging
|
||||
|
||||
### 💻 Frontend Improvements
|
||||
|
||||
#### New Error Management System
|
||||
- **Centralized Error State**: New reactive stores for API errors
|
||||
- `apiError` - Tracks current error with service, message, and status
|
||||
- `isApiDown` - Quick flag for API availability
|
||||
- **Error Helper Functions**:
|
||||
- `setApiError()` - Set error state from any component
|
||||
- `clearApiError()` - Reset error state
|
||||
|
||||
#### New Error Modal Component
|
||||
- Auto-displays when API errors occur
|
||||
- Shows service name, error message, and HTTP status code
|
||||
- **"Retry Connection"** button - Attempts to reconnect to the failed service
|
||||
- **"Dismiss"** button - Close modal and continue using the app
|
||||
- Beautiful red-themed styling with Tailwind CSS
|
||||
- Supports all three services (AniList, MAL, Simkl)
|
||||
|
||||
#### Updated User Interface
|
||||
- Home page now displays "API Unavailable" state when services are down
|
||||
- Helpful warning messages guide users during outages
|
||||
- App structure remains visible and functional during errors
|
||||
|
||||
---
|
||||
|
||||
## 🐛 Bug Fixes
|
||||
|
||||
- **Critical**: Fixed app crashes when AniList API returns 403 Forbidden errors
|
||||
- **Critical**: Fixed app crashes when AniList API is down or unreachable
|
||||
- **Critical**: Fixed MAL OAuth server crashing on connection errors
|
||||
- **Critical**: Fixed Simkl JSON marshaling errors crashing the app
|
||||
- **Improved**: Better error messages for all API failures
|
||||
|
||||
---
|
||||
|
||||
## 📊 Technical Details
|
||||
|
||||
### Go Backend Changes
|
||||
- **AniListFunctions.go**: Updated 3 functions with error handling
|
||||
- **MALFunctions.go**: Updated 5 functions with error handling
|
||||
- **MALUserFunctions.go**: Fixed server error handling
|
||||
- **SimklFunctions.go**: Updated 7 functions with error handling
|
||||
- **SimklUserFunctions.go**: Fixed 2 critical error handling issues
|
||||
|
||||
### Frontend Changes
|
||||
- **ErrorModal.svelte**: New component (73 lines)
|
||||
- **GlobalVariablesAndHelperFunctions.svelte**: Added error state system (27 lines)
|
||||
- **App.svelte**: Integrated ErrorModal into main layout
|
||||
- **CheckIfAniListLoggedInAndLoadWatchList.svelte**: Added error handling
|
||||
- **Home.svelte**: Added API down state display
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Impact
|
||||
|
||||
### Before (v0.6.5)
|
||||
- ❌ App crashes to desktop when AniList API is down
|
||||
- ❌ Users see only console error messages
|
||||
- ❌ Must restart app after API failures
|
||||
- ❌ No way to retry failed connections
|
||||
|
||||
### After (v0.7.0)
|
||||
- ✅ App stays open during any API failures
|
||||
- ✅ Beautiful modal dialogs explain what went wrong
|
||||
- ✅ One-click retry to reconnect services
|
||||
- ✅ Continue using app with limited functionality
|
||||
|
||||
---
|
||||
|
||||
## 🔄 Upgrading
|
||||
|
||||
No migration needed! This release is fully backward compatible.
|
||||
|
||||
Simply run:
|
||||
```bash
|
||||
git pull
|
||||
wails build
|
||||
```
|
||||
|
||||
Or download the latest release from the releases page.
|
||||
|
||||
---
|
||||
|
||||
## 🙏 Acknowledgments
|
||||
|
||||
This release addresses a critical stability issue that was affecting users during API service outages. Special thanks to the community for reporting these crashes and providing detailed error logs.
|
||||
|
||||
---
|
||||
|
||||
## 📝 Full Changelog
|
||||
|
||||
### Added
|
||||
- Error modal component with retry/dismiss functionality
|
||||
- Centralized error state management system
|
||||
- API availability status tracking
|
||||
- Visual feedback for all API failures
|
||||
- Manual retry functionality for all services
|
||||
|
||||
### Changed
|
||||
- AniList API functions to return errors instead of crashing
|
||||
- MAL API functions to return errors instead of crashing
|
||||
- Simkl API functions to return errors instead of crashing
|
||||
- Error handling from console-only to UI modal dialogs
|
||||
- App behavior from crash-on-error to graceful-degradation
|
||||
|
||||
### Fixed
|
||||
- App crashes on AniList 403 errors
|
||||
- App crashes on network failures
|
||||
- MAL OAuth server shutdown on errors
|
||||
- Simkl JSON marshaling crashes
|
||||
- All `log.Fatal()` calls that terminated the app
|
||||
|
||||
### Removed
|
||||
- `alert()` calls in favor of modal system
|
||||
- Vite timestamp file (cleanup)
|
||||
|
||||
---
|
||||
|
||||
**Version**: 0.7.0
|
||||
**Release Date**: March 2026
|
||||
**Upgrade Difficulty**: ⭐ Easy (backward compatible)
|
||||
**Recommended**: ⭐⭐⭐⭐⭐ Highly recommended for all users
|
||||
@@ -3,34 +3,388 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"reflect"
|
||||
"slices"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
func SimklQuery(body interface{}, login bool) (json.RawMessage, string) {
|
||||
reader, _ := json.Marshal(body)
|
||||
response, err := http.NewRequest("POST", "https://graphql.anilist.co", bytes.NewBuffer(reader))
|
||||
var SimklWatchList SimklWatchListType
|
||||
|
||||
func SimklHelper(method string, url string, body interface{}) (json.RawMessage, error) {
|
||||
reader, err := json.Marshal(body)
|
||||
if err != nil {
|
||||
log.Printf("Failed at response, %s\n", err)
|
||||
return nil, fmt.Errorf("failed to marshal body: %w", err)
|
||||
}
|
||||
if login && (SimklJWT{}) != simklJwt {
|
||||
response.Header.Add("Authorization", "Bearer "+simklJwt.AccessToken)
|
||||
} else if login {
|
||||
return nil, "Please login to anilist to make this request"
|
||||
}
|
||||
response.Header.Add("Content-Type", "application/json")
|
||||
response.Header.Add("Accept", "application/json")
|
||||
|
||||
var req *http.Request
|
||||
|
||||
client := &http.Client{}
|
||||
res, reserr := client.Do(response)
|
||||
if reserr != nil {
|
||||
log.Printf("Failed at res, %s\n", err)
|
||||
|
||||
if body != nil {
|
||||
req, err = http.NewRequest(method, url, bytes.NewBuffer(reader))
|
||||
} else {
|
||||
req, err = http.NewRequest(method, url, nil)
|
||||
}
|
||||
|
||||
defer res.Body.Close()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create request: %w", err)
|
||||
}
|
||||
|
||||
returnedBody, err := io.ReadAll(res.Body)
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
req.Header.Add("Authorization", "Bearer "+simklJwt.AccessToken)
|
||||
req.Header.Add("simkl-api-key", Environment.SIMKL_CLIENT_ID)
|
||||
|
||||
return returnedBody, ""
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("network error: %w", err)
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
respBody, err := io.ReadAll(resp.Body)
|
||||
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read response: %w", err)
|
||||
}
|
||||
if resp.StatusCode < 200 || resp.StatusCode >= 300 {
|
||||
return respBody, fmt.Errorf("API returned status: %d", resp.StatusCode)
|
||||
}
|
||||
return respBody, nil
|
||||
}
|
||||
|
||||
func (a *App) SimklGetUserWatchlist() (SimklWatchListType, error) {
|
||||
method := "GET"
|
||||
url := "https://api.simkl.com/sync/all-items/anime"
|
||||
|
||||
respBody, err := SimklHelper(method, url, nil)
|
||||
|
||||
if err != nil {
|
||||
return SimklWatchListType{}, fmt.Errorf("failed to get Simkl watchlist: %w", err)
|
||||
}
|
||||
|
||||
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)
|
||||
return SimklWatchListType{}, fmt.Errorf("failed to parse error response: %w", err)
|
||||
}
|
||||
|
||||
if errCheck.Error != "" {
|
||||
a.LogoutSimkl()
|
||||
return SimklWatchListType{}, fmt.Errorf("Simkl API error: %s", errCheck.Message)
|
||||
}
|
||||
|
||||
var watchlist SimklWatchListType
|
||||
|
||||
err = json.Unmarshal(respBody, &watchlist)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
return SimklWatchListType{}, fmt.Errorf("failed to parse watchlist: %w", err)
|
||||
}
|
||||
|
||||
SimklWatchList = watchlist
|
||||
|
||||
return watchlist, nil
|
||||
}
|
||||
|
||||
func (a *App) SimklSyncEpisodes(anime SimklAnime, progress int) (SimklAnime, error) {
|
||||
var episodes []Episode
|
||||
var url string
|
||||
var shows []SimklPostShow
|
||||
|
||||
if progress >= anime.WatchedEpisodesCount {
|
||||
for i := 1; i <= progress; i++ {
|
||||
episodes = append(episodes, Episode{Number: i})
|
||||
}
|
||||
url = "https://api.simkl.com/sync/history"
|
||||
} else {
|
||||
for i := anime.WatchedEpisodesCount; i > progress; i-- {
|
||||
episodes = append(episodes, Episode{Number: i})
|
||||
}
|
||||
url = "https://api.simkl.com/sync/history/remove"
|
||||
}
|
||||
|
||||
formattedShow := SimklPostShow{
|
||||
Title: anime.Show.Title,
|
||||
Ids: Ids{
|
||||
Simkl: anime.Show.Ids.Simkl,
|
||||
Mal: anime.Show.Ids.Mal,
|
||||
Anilist: anime.Show.Ids.AniList,
|
||||
},
|
||||
Episodes: episodes,
|
||||
}
|
||||
|
||||
shows = append(shows, formattedShow)
|
||||
|
||||
simklSync := SimklSyncHistoryType{shows}
|
||||
|
||||
respBody, err := SimklHelper("POST", url, simklSync)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Failed to sync episodes: %s\n", err)
|
||||
return anime, fmt.Errorf("failed to sync episodes: %w", err)
|
||||
}
|
||||
|
||||
var success interface{}
|
||||
|
||||
err = json.Unmarshal(respBody, &success)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
return anime, fmt.Errorf("failed to parse response: %w", err)
|
||||
}
|
||||
|
||||
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, nil
|
||||
}
|
||||
|
||||
func (a *App) SimklSyncRating(anime SimklAnime, rating int) (SimklAnime, error) {
|
||||
var url string
|
||||
showWithRating := ShowWithRating{
|
||||
Title: anime.Show.Title,
|
||||
Ids: Ids{
|
||||
Simkl: anime.Show.Ids.Simkl,
|
||||
Mal: anime.Show.Ids.Mal,
|
||||
Anilist: anime.Show.Ids.AniList,
|
||||
},
|
||||
Rating: rating,
|
||||
}
|
||||
|
||||
showWithoutRating := ShowWithoutRating{
|
||||
Title: anime.Show.Title,
|
||||
Ids: Ids{
|
||||
Simkl: anime.Show.Ids.Simkl,
|
||||
Mal: anime.Show.Ids.Mal,
|
||||
Anilist: anime.Show.Ids.AniList,
|
||||
},
|
||||
}
|
||||
|
||||
var shows []interface{}
|
||||
|
||||
if rating > 0 {
|
||||
shows = append(shows, showWithRating)
|
||||
url = "https://api.simkl.com/sync/ratings"
|
||||
} else {
|
||||
shows = append(shows, showWithoutRating)
|
||||
url = "https://api.simkl.com/sync/ratings/remove"
|
||||
}
|
||||
|
||||
simklSync := struct {
|
||||
Shows []interface{} `json:"shows" ts_type:"shows"`
|
||||
}{shows}
|
||||
|
||||
respBody, err := SimklHelper("POST", url, simklSync)
|
||||
if err != nil {
|
||||
log.Printf("Failed to sync rating: %s\n", err)
|
||||
return anime, fmt.Errorf("failed to sync rating: %w", err)
|
||||
}
|
||||
var success interface{}
|
||||
|
||||
err = json.Unmarshal(respBody, &success)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
return anime, fmt.Errorf("failed to parse response: %w", err)
|
||||
}
|
||||
|
||||
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, nil
|
||||
}
|
||||
|
||||
func (a *App) SimklSyncStatus(anime SimklAnime, status string) (SimklAnime, error) {
|
||||
url := "https://api.simkl.com/sync/add-to-list"
|
||||
show := SimklShowStatus{
|
||||
Title: anime.Show.Title,
|
||||
Ids: Ids{
|
||||
Simkl: anime.Show.Ids.Simkl,
|
||||
Mal: anime.Show.Ids.Mal,
|
||||
Anilist: anime.Show.Ids.AniList,
|
||||
},
|
||||
To: status,
|
||||
}
|
||||
|
||||
var shows []SimklShowStatus
|
||||
|
||||
shows = append(shows, show)
|
||||
|
||||
simklSync := struct {
|
||||
Shows []SimklShowStatus `json:"shows" ts_type:"shows"`
|
||||
}{shows}
|
||||
|
||||
respBody, err := SimklHelper("POST", url, simklSync)
|
||||
if err != nil {
|
||||
log.Printf("Failed to sync status: %s\n", err)
|
||||
return anime, fmt.Errorf("failed to sync status: %w", err)
|
||||
}
|
||||
var success interface{}
|
||||
|
||||
err = json.Unmarshal(respBody, &success)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
return anime, fmt.Errorf("failed to parse response: %w", err)
|
||||
}
|
||||
|
||||
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, nil
|
||||
}
|
||||
|
||||
func (a *App) SimklSearch(aniListAnime MediaList) (SimklAnime, error) {
|
||||
var result SimklAnime
|
||||
|
||||
if reflect.DeepEqual(SimklWatchList, SimklWatchListType{}) {
|
||||
fmt.Println("Watchlist empty. Calling...")
|
||||
watchlist, err := a.SimklGetUserWatchlist()
|
||||
if err != nil {
|
||||
log.Printf("Failed to get watchlist: %s\n", err)
|
||||
return result, fmt.Errorf("failed to load watchlist for search: %w", err)
|
||||
}
|
||||
SimklWatchList = watchlist
|
||||
}
|
||||
|
||||
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, err := SimklHelper("GET", url, nil)
|
||||
if err != nil {
|
||||
log.Printf("Failed to search Simkl: %s\n", err)
|
||||
return result, fmt.Errorf("failed to search Simkl by AniList ID: %w", err)
|
||||
}
|
||||
err = json.Unmarshal(respBody, &anime)
|
||||
|
||||
if len(anime) == 0 {
|
||||
url = "https://api.simkl.com/search/id?mal=" + strconv.Itoa(aniListAnime.Media.IDMal)
|
||||
respBody, err = SimklHelper("GET", url, nil)
|
||||
if err != nil {
|
||||
log.Printf("Failed to search Simkl by MAL ID: %s\n", err)
|
||||
return result, fmt.Errorf("failed to search by MAL ID: %w", err)
|
||||
}
|
||||
err = json.Unmarshal(respBody, &anime)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
return result, fmt.Errorf("failed to parse search results: %w", err)
|
||||
}
|
||||
|
||||
if len(anime) == 0 {
|
||||
return result, nil
|
||||
}
|
||||
|
||||
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, nil
|
||||
}
|
||||
|
||||
func (a *App) SimklSyncRemove(anime SimklAnime) (bool, error) {
|
||||
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, err := SimklHelper("POST", url, show)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Failed to sync remove: %s\n", err)
|
||||
return false, fmt.Errorf("failed to sync remove: %w", err)
|
||||
}
|
||||
var success SimklDeleteType
|
||||
err = json.Unmarshal(respBody, &success)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
return false, fmt.Errorf("failed to parse response: %w", 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, nil
|
||||
}
|
||||
|
||||
return false, fmt.Errorf("no shows were deleted")
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
||||
129
SimklTypes.go
@@ -7,10 +7,127 @@ type SimklJWT struct {
|
||||
}
|
||||
|
||||
type SimklUser struct {
|
||||
Data struct {
|
||||
Viewer struct {
|
||||
ID int `json:"id"`
|
||||
Name string `json:"name"`
|
||||
} `json:"Viewer"`
|
||||
} `json:"data"`
|
||||
User struct {
|
||||
Name string `json:"name" ts_type:"name"`
|
||||
JoinedAt string `json:"joined_at" ts_type:"joined_at"`
|
||||
Gender string `json:"gender" ts_type:"gender"`
|
||||
Avatar string `json:"avatar" ts_type:"avatar"`
|
||||
Bio string `json:"bio" ts_type:"bio"`
|
||||
Loc string `json:"loc" ts_type:"loc"`
|
||||
Age string `json:"age" ts_type:"age"`
|
||||
} `json:"user" ts_type:"user"`
|
||||
Account struct {
|
||||
Id int `json:"id" ts_type:"id"`
|
||||
Timezone string `json:"timezone" ts_type:"timezone"`
|
||||
Type string `json:"type" ts_type:"type"`
|
||||
} `json:"account" ts_type:"account"`
|
||||
Connections struct {
|
||||
Facebook bool `json:"facebook" ts_type:"facebook"`
|
||||
} `json:"connections" ts_type:"connections"`
|
||||
}
|
||||
|
||||
type SimklWatchListType struct {
|
||||
Anime []SimklAnime `json:"anime" ts_type:"anime"`
|
||||
}
|
||||
|
||||
type SimklAnime struct {
|
||||
LastWatchedAt string `json:"last_watched_at" ts_type:"last_watched_at"`
|
||||
Status string `json:"status" ts_type:"status"`
|
||||
UserRating int `json:"user_rating" ts_type:"user_rating"`
|
||||
LastWatched string `json:"last_watched" ts_type:"last_watched"`
|
||||
NextToWatch string `json:"next_to_watch" ts_type:"next_to_watch"`
|
||||
WatchedEpisodesCount int `json:"watched_episodes_count" ts_type:"watched_episodes_count"`
|
||||
TotalEpisodesCount int `json:"total_episodes_count" ts_type:"total_episodes_count"`
|
||||
NotAiredEpisodesCount int `json:"not_aired_episodes_count" ts_type:"not_aired_episodes_count"`
|
||||
Show struct {
|
||||
Title string `json:"title" ts_type:"title"`
|
||||
Poster string `json:"poster" ts_type:"poster"`
|
||||
Ids struct {
|
||||
Simkl int `json:"simkl" ts_type:"simkl"`
|
||||
Slug string `json:"slug" ts_type:"slug"`
|
||||
OffJp string `json:"offjp" ts_type:"offjp"`
|
||||
TW string `json:"tw" ts_type:"tw"`
|
||||
ANN string `json:"ann" ts_type:"ann"`
|
||||
Mal string `json:"mal" ts_type:"mal"`
|
||||
Wikien string `json:"wikien" ts_type:"wikien"`
|
||||
WikiJp string `json:"wikijp" ts_type:"wikijp"`
|
||||
AllCin string `json:"allcin" ts_type:"allcin"`
|
||||
IMDB string `json:"imdb" ts_type:"imdb"`
|
||||
TMDB string `json:"tmdb" ts_type:"tmdb"`
|
||||
Offen string `json:"offen" ts_type:"offen"`
|
||||
Crunchyroll string `json:"crunchyroll" ts_type:"crunchyroll"`
|
||||
TVDBSlug string `json:"tvdbslug" ts_type:"tvdbslug"`
|
||||
AniList string `json:"anilist" ts_type:"anilist"`
|
||||
AnimePlanet string `json:"animeplanet" ts_type:"animeplanet"`
|
||||
AniSearch string `json:"anisearch" ts_type:"anisearch"`
|
||||
Kitsu string `json:"kitsu" ts_type:"kitsu"`
|
||||
LiveChart string `json:"livechart" ts_type:"livechart"`
|
||||
TraktSlug string `json:"traktslug" ts_type:"traktslug"`
|
||||
AniDB string `json:"anidb" ts_type:"anidb"`
|
||||
} `json:"ids" ts_type:"ids"`
|
||||
} `json:"show" ts_type:"show"`
|
||||
AnimeType string `json:"anime_type" ts_type:"anime_type"`
|
||||
}
|
||||
|
||||
type SimklSyncHistoryType struct {
|
||||
Shows []SimklPostShow `json:"shows" ts_type:"shows"`
|
||||
}
|
||||
|
||||
type SimklPostShow struct {
|
||||
Title string `json:"title" ts_type:"title"`
|
||||
Ids `json:"ids" ts_type:"ids"`
|
||||
Episodes []Episode `json:"episodes" ts_type:"episodes"`
|
||||
}
|
||||
|
||||
type Episode struct {
|
||||
Number int `json:"number" ts_type:"number"`
|
||||
}
|
||||
|
||||
type Ids struct {
|
||||
Simkl int `json:"simkl" ts_type:"simkl"`
|
||||
Mal string `json:"mal" ts_type:"mal"`
|
||||
Anilist string `json:"anilist" ts_type:"anilist"`
|
||||
}
|
||||
|
||||
type ShowWithRating struct {
|
||||
Title string `json:"title" ts_type:"title"`
|
||||
Ids `json:"ids" ts_type:"ids"`
|
||||
Rating int `json:"rating" ts_type:"rating"`
|
||||
}
|
||||
|
||||
type ShowWithoutRating struct {
|
||||
Title string `json:"title" ts_type:"title"`
|
||||
Ids `json:"ids" ts_type:"ids"`
|
||||
}
|
||||
|
||||
type SimklShowStatus struct {
|
||||
Title string `json:"title" ts_type:"title"`
|
||||
Ids `json:"ids" ts_type:"ids"`
|
||||
To string `json:"to" ts_type:"to"`
|
||||
}
|
||||
|
||||
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"
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
"sync"
|
||||
|
||||
"github.com/99designs/keyring"
|
||||
@@ -18,23 +18,45 @@ import (
|
||||
var simklJwt SimklJWT
|
||||
|
||||
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())
|
||||
|
||||
func (a *App) CheckIfSimklLoggedIn() bool {
|
||||
if (SimklJWT{} == simklJwt) {
|
||||
tokenType, tokenTypeErr := simklRing.Get("SimklTokenType")
|
||||
accessToken, accessTokenErr := simklRing.Get("SimklAccessToken")
|
||||
scope, scopeErr := simklRing.Get("SimklScope")
|
||||
if (tokenTypeErr != nil || accessTokenErr != nil || scopeErr != nil) || len(accessToken.Data) == 0 {
|
||||
return false
|
||||
} else {
|
||||
simklJwt.TokenType = string(tokenType.Data)
|
||||
simklJwt.AccessToken = string(accessToken.Data)
|
||||
simklJwt.Scope = string(scope.Data)
|
||||
return true
|
||||
}
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) SimklLogin() {
|
||||
if (SimklJWT{}) == simklJwt {
|
||||
tokenType, err := simklRing.Get("SimklTokenType")
|
||||
accessToken, err := simklRing.Get("SimklAccessToken")
|
||||
scope, err := simklRing.Get("SimklScope")
|
||||
if err != nil {
|
||||
getSimklCodeUrl := "https://simkl.com/oauth/authorize?response_type=code&client_id=" + os.Getenv("SIMKL_CLIENT_ID") + "&redirect_uri=" + os.Getenv("SIMKL_CALLBACK_URI")
|
||||
runtime.BrowserOpenURL(a.ctx, getSimklCodeUrl)
|
||||
if !a.CheckIfSimklLoggedIn() {
|
||||
tokenType, tokenTypeErr := simklRing.Get("SimklTokenType")
|
||||
accessToken, accessTokenErr := simklRing.Get("SimklAccessToken")
|
||||
scope, scopeErr := simklRing.Get("SimklScope")
|
||||
if (tokenTypeErr != nil || accessTokenErr != nil || scopeErr != nil) || len(accessToken.Data) == 0 {
|
||||
getSimklCodeUrl := "https://simkl.com/oauth/authorize?response_type=code&client_id=" + Environment.SIMKL_CLIENT_ID + "&redirect_uri=" + Environment.SIMKL_CALLBACK_URI
|
||||
runtime.BrowserOpenURL(*wailsContext, getSimklCodeUrl)
|
||||
|
||||
serverDone := &sync.WaitGroup{}
|
||||
serverDone.Add(1)
|
||||
handleSimklCallback(serverDone)
|
||||
a.handleSimklCallback(serverDone)
|
||||
serverDone.Wait()
|
||||
} else {
|
||||
simklJwt.TokenType = string(tokenType.Data)
|
||||
@@ -44,9 +66,10 @@ func (a *App) SimklLogin() {
|
||||
}
|
||||
}
|
||||
|
||||
func handleSimklCallback(wg *sync.WaitGroup) {
|
||||
srv := &http.Server{Addr: ":6734"}
|
||||
http.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) {
|
||||
func (a *App) handleSimklCallback(wg *sync.WaitGroup) {
|
||||
mux := http.NewServeMux()
|
||||
srv := &http.Server{Addr: ":6734", Handler: mux}
|
||||
mux.HandleFunc("/callback", func(w http.ResponseWriter, r *http.Request) {
|
||||
select {
|
||||
case <-simklCtxShutdown.Done():
|
||||
fmt.Println("Shutting down...")
|
||||
@@ -69,9 +92,16 @@ func handleSimklCallback(wg *sync.WaitGroup) {
|
||||
Key: "SimklScope",
|
||||
Data: []byte(simklJwt.Scope),
|
||||
})
|
||||
_, err := runtime.MessageDialog(*wailsContext, runtime.MessageDialogOptions{
|
||||
Title: "Simkl Authorization",
|
||||
Message: "It is now safe to close your browser tab",
|
||||
})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
fmt.Println("Shutting down...")
|
||||
simklCancel()
|
||||
err := srv.Shutdown(context.Background())
|
||||
err = srv.Shutdown(context.Background())
|
||||
if err != nil {
|
||||
log.Println("server.Shutdown:", err)
|
||||
}
|
||||
@@ -85,8 +115,8 @@ func handleSimklCallback(wg *sync.WaitGroup) {
|
||||
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
if err := srv.ListenAndServe(); err != nil && err != http.ErrServerClosed {
|
||||
log.Fatalf("listen: %s\n", err)
|
||||
if err := srv.ListenAndServe(); err != nil && !errors.Is(err, http.ErrServerClosed) {
|
||||
log.Printf("Server error: %s\n", err)
|
||||
}
|
||||
fmt.Println("Shutting down...")
|
||||
}()
|
||||
@@ -101,14 +131,15 @@ func getSimklAuthorizationToken(content string) SimklJWT {
|
||||
Code string `json:"code"`
|
||||
}{
|
||||
GrantType: "authorization_code",
|
||||
ClientID: os.Getenv("SIMKL_CLIENT_ID"),
|
||||
ClientSecret: os.Getenv("SIMKL_CLIENT_SECRET"),
|
||||
RedirectURI: os.Getenv("SIMKL_CALLBACK_URI"),
|
||||
ClientID: Environment.SIMKL_CLIENT_ID,
|
||||
ClientSecret: Environment.SIMKL_CLIENT_SECRET,
|
||||
RedirectURI: Environment.SIMKL_CALLBACK_URI,
|
||||
Code: content,
|
||||
}
|
||||
jsonData, err := json.Marshal(data)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
log.Printf("Failed to marshal data: %s\n", err)
|
||||
return SimklJWT{}
|
||||
}
|
||||
|
||||
response, err := http.NewRequest("POST", "https://api.simkl.com/oauth/token", bytes.NewBuffer(jsonData))
|
||||
@@ -118,14 +149,17 @@ func getSimklAuthorizationToken(content string) SimklJWT {
|
||||
response.Header.Add("Content-Type", "application/json")
|
||||
|
||||
client := &http.Client{}
|
||||
res, reserr := client.Do(response)
|
||||
if reserr != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
var post SimklJWT
|
||||
err = json.Unmarshal(returnedBody, &post)
|
||||
@@ -136,28 +170,63 @@ func getSimklAuthorizationToken(content string) SimklJWT {
|
||||
return post
|
||||
}
|
||||
|
||||
func (a *App) GetSimklLoggedInUserId() SimklUser {
|
||||
func (a *App) GetSimklLoggedInUser() SimklUser {
|
||||
a.SimklLogin()
|
||||
body := struct {
|
||||
Query string `json:"query"`
|
||||
}{
|
||||
Query: `
|
||||
query {
|
||||
Viewer {
|
||||
id
|
||||
name
|
||||
}
|
||||
}
|
||||
`,
|
||||
|
||||
client := &http.Client{}
|
||||
|
||||
req, _ := http.NewRequest("POST", "https://api.simkl.com/users/settings", nil)
|
||||
|
||||
req.Header.Add("Content-Type", "application/json")
|
||||
req.Header.Add("Authorization", "Bearer "+simklJwt.AccessToken)
|
||||
req.Header.Add("simkl-api-key", Environment.SIMKL_CLIENT_ID)
|
||||
|
||||
response, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Printf("Failed at request, %s\n", err)
|
||||
return SimklUser{}
|
||||
}
|
||||
|
||||
user, _ := SimklQuery(body, true)
|
||||
defer response.Body.Close()
|
||||
|
||||
var post SimklUser
|
||||
err := json.Unmarshal(user, &post)
|
||||
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)
|
||||
}
|
||||
|
||||
return post
|
||||
if errCheck.Error != "" {
|
||||
a.LogoutSimkl()
|
||||
return SimklUser{}
|
||||
}
|
||||
|
||||
var user SimklUser
|
||||
|
||||
err = json.Unmarshal(respBody, &user)
|
||||
if err != nil {
|
||||
log.Printf("Failed at unmarshal, %s\n", err)
|
||||
}
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
func (a *App) LogoutSimkl() string {
|
||||
if (SimklJWT{} != simklJwt) {
|
||||
tokenTypeErr := simklRing.Remove("SimklTokenType")
|
||||
accessTokenErr := simklRing.Remove("SimklAccessToken")
|
||||
scopeErr := simklRing.Remove("SimklScope")
|
||||
|
||||
if tokenTypeErr != nil || accessTokenErr != nil || scopeErr != nil {
|
||||
fmt.Println("Simkl Logout Failed")
|
||||
}
|
||||
simklJwt = SimklJWT{}
|
||||
}
|
||||
|
||||
return "Simkl Logged Out Successfully"
|
||||
}
|
||||
|
||||
41
app.go
@@ -2,9 +2,21 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
_ "embed"
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"github.com/wailsapp/wails/v2/pkg/runtime"
|
||||
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
//go:embed wails.json
|
||||
var wailsJSON string
|
||||
|
||||
var wailsContext *context.Context
|
||||
|
||||
// App struct
|
||||
type App struct {
|
||||
ctx context.Context
|
||||
@@ -18,10 +30,29 @@ func NewApp() *App {
|
||||
// startup is called when the app starts. The context is saved
|
||||
// so we can call the runtime methods
|
||||
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)
|
||||
}
|
||||
|
||||
// Greet returns a greeting for the given name
|
||||
func (a *App) Greet(name string) string {
|
||||
return fmt.Sprintf("Hello %s, It's show time!", name)
|
||||
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)
|
||||
}
|
||||
|
||||
func (a *App) ShowVersion() {
|
||||
version := gjson.Get(wailsJSON, "info.productVersion")
|
||||
_, err := runtime.MessageDialog(*wailsContext, runtime.MessageDialogOptions{
|
||||
Title: "Version",
|
||||
Message: "AniTrack Version: " + version.String(),
|
||||
})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
Content-Type: "application/json"
|
||||
Accept: "application/json"
|
||||
Authorization: Bearer {{ANILIST_ACCESS_TOKEN}}
|
||||
}
|
||||
|
||||
body:graphql {
|
||||
@@ -24,6 +25,15 @@ body:graphql {
|
||||
media {
|
||||
id
|
||||
idMal
|
||||
genres
|
||||
tags {
|
||||
id
|
||||
name
|
||||
description
|
||||
rank
|
||||
isMediaSpoiler
|
||||
isAdult
|
||||
}
|
||||
title {
|
||||
romaji
|
||||
english
|
||||
@@ -42,6 +52,7 @@ body:graphql {
|
||||
timeUntilAiring
|
||||
episode
|
||||
}
|
||||
isAdult
|
||||
}
|
||||
status
|
||||
startedAt {
|
||||
@@ -83,7 +94,7 @@ body:graphql {
|
||||
body:graphql:vars {
|
||||
{
|
||||
"userId": 413504,
|
||||
"mediaId": 157371,
|
||||
"mediaId": 170998,
|
||||
"listType": "ANIME"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ body:graphql {
|
||||
english
|
||||
native
|
||||
}
|
||||
genre
|
||||
description
|
||||
coverImage {
|
||||
large
|
||||
@@ -53,7 +54,7 @@ body:graphql {
|
||||
|
||||
body:graphql:vars {
|
||||
{
|
||||
"search": "frieren",
|
||||
"search": "dan-da-dan",
|
||||
"listType": "ANIME"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ post {
|
||||
|
||||
headers {
|
||||
Accept: application/json
|
||||
Content-Type: application/json
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
}
|
||||
|
||||
body:form-urlencoded {
|
||||
@@ -20,7 +20,7 @@ body:form-urlencoded {
|
||||
client_id: {{ANILIST_APP_ID}}
|
||||
client_secret: {{ANILIST_SECRET_TOKEN}}
|
||||
redirect_uri: http://localhost:6734/callback
|
||||
code: {{code}}
|
||||
code: {{ANILIST_CODE}}
|
||||
}
|
||||
|
||||
body:multipart-form {
|
||||
|
||||
@@ -19,12 +19,33 @@ headers {
|
||||
body:graphql {
|
||||
mutation($mediaId:Int, $progress:Int, $status:MediaListStatus){
|
||||
SaveMediaListEntry(mediaId:$mediaId, progress:$progress, status:$status){
|
||||
id
|
||||
mediaId
|
||||
progress
|
||||
userId
|
||||
media {
|
||||
id
|
||||
idMal
|
||||
title {
|
||||
romaji
|
||||
english
|
||||
native
|
||||
}
|
||||
description
|
||||
coverImage {
|
||||
large
|
||||
}
|
||||
season
|
||||
seasonYear
|
||||
status
|
||||
episodes
|
||||
nextAiringEpisode {
|
||||
airingAt
|
||||
timeUntilAiring
|
||||
episode
|
||||
}
|
||||
isAdult
|
||||
}
|
||||
status
|
||||
score
|
||||
repeat
|
||||
notes
|
||||
startedAt{
|
||||
year
|
||||
month
|
||||
@@ -35,14 +56,35 @@ body:graphql {
|
||||
month
|
||||
day
|
||||
}
|
||||
notes
|
||||
progress
|
||||
score
|
||||
repeat
|
||||
user {
|
||||
id
|
||||
name
|
||||
avatar{
|
||||
large
|
||||
medium
|
||||
}
|
||||
statistics{
|
||||
anime{
|
||||
count
|
||||
statuses{
|
||||
status
|
||||
count
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
body:graphql:vars {
|
||||
{
|
||||
"mediaId": 1,
|
||||
"progress": 26,
|
||||
"mediaId": 169417,
|
||||
"progress": 12,
|
||||
"status":"COMPLETED"
|
||||
}
|
||||
}
|
||||
|
||||
79
bruno/AniTrack/AniList/Set Items/Change Episode Count.bru
Normal file
@@ -0,0 +1,79 @@
|
||||
meta {
|
||||
name: Change Episode Count
|
||||
type: graphql
|
||||
seq: 3
|
||||
}
|
||||
|
||||
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(
|
||||
$mediaId:Int,
|
||||
$progress:Int,
|
||||
$status:MediaListStatus,
|
||||
$score:Float,
|
||||
$repeat:Int,
|
||||
$notes:String,
|
||||
$startedAt:FuzzyDateInput,
|
||||
$completedAt:FuzzyDateInput,
|
||||
){
|
||||
SaveMediaListEntry(
|
||||
mediaId:$mediaId,
|
||||
progress:$progress,
|
||||
status:$status,
|
||||
score:$score,
|
||||
repeat:$repeat,
|
||||
notes:$notes,
|
||||
startedAt:$startedAt
|
||||
completedAt:$completedAt
|
||||
){
|
||||
mediaId
|
||||
progress
|
||||
status
|
||||
score
|
||||
repeat
|
||||
notes
|
||||
startedAt{
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
completedAt{
|
||||
year
|
||||
month
|
||||
day
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
body:graphql:vars {
|
||||
{
|
||||
"mediaId":170998,
|
||||
"progress":5,
|
||||
"status":"CURRENT",
|
||||
"score":9.0,
|
||||
"repeat":0,
|
||||
"notes":",malSync::eyJ1IjoiaHR0cHM6Ly93d3cuY3J1bmNoeXJvbGwuY29tL3Nlcmllcy9HVkRIWDg1Wk4vI3NlYXNvbj1HNjNWQzJHUUsiLCJwIjoiIn0=::",
|
||||
"startedAt":{
|
||||
"year":2024,
|
||||
"month":7,
|
||||
"day":10
|
||||
},
|
||||
"completedAt":{
|
||||
"year": 0,
|
||||
"month":0,
|
||||
"day":0
|
||||
}
|
||||
}
|
||||
}
|
||||
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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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}}
|
||||
}
|
||||
17
bruno/AniTrack/Simkl/Get Items/GetUser WatchList.bru
Normal file
@@ -0,0 +1,17 @@
|
||||
meta {
|
||||
name: GetUser WatchList
|
||||
type: http
|
||||
seq: 2
|
||||
}
|
||||
|
||||
get {
|
||||
url: https://api.simkl.com/sync/all-items/anime/
|
||||
body: none
|
||||
auth: none
|
||||
}
|
||||
|
||||
headers {
|
||||
Authorization: Bearer {{SIMKL_AUTH_TOKEN}}
|
||||
Content-Type: application/json
|
||||
simkl-api-key: {{SIMKL_CLIENT_ID}}
|
||||
}
|
||||
@@ -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}}&mal=52991
|
||||
body: none
|
||||
auth: none
|
||||
}
|
||||
|
||||
params:query {
|
||||
client_id: {{SIMKL_CLIENT_ID}}
|
||||
mal: 52991
|
||||
}
|
||||
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
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
52
bruno/AniTrack/Simkl/Post Items/Update Episode.bru
Normal file
@@ -0,0 +1,52 @@
|
||||
meta {
|
||||
name: Update Episode
|
||||
type: http
|
||||
seq: 1
|
||||
}
|
||||
|
||||
post {
|
||||
url: https://api.simkl.com/sync/history
|
||||
body: json
|
||||
auth: none
|
||||
}
|
||||
|
||||
headers {
|
||||
Authorization: Bearer {{SIMKL_AUTH_TOKEN}}
|
||||
Content-Type: application/json
|
||||
simkl-api-key: {{SIMKL_CLIENT_ID}}
|
||||
}
|
||||
|
||||
body:json {
|
||||
{
|
||||
"shows": [
|
||||
{
|
||||
"title": "Ramen Aka Neko",
|
||||
"ids": {
|
||||
"simkl": 2307708,
|
||||
"mal": "57325",
|
||||
"anilist": "170998"
|
||||
},
|
||||
"episodes": [
|
||||
{
|
||||
"number": 1
|
||||
},
|
||||
{
|
||||
"number": 2
|
||||
},
|
||||
{
|
||||
"number": 3
|
||||
},
|
||||
{
|
||||
"number": 4
|
||||
},
|
||||
{
|
||||
"number": 5
|
||||
},
|
||||
{
|
||||
"number": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,16 @@ vars {
|
||||
ANILIST_SECRET_TOKEN: {{process.env.ANILIST_SECRET_TOKEN}}
|
||||
SIMKL_CLIENT_ID: {{process.env.SIMKL_CLIENT_ID}}
|
||||
SIMKL_CLIENT_SECRET: {{process.env.SIMKL_CLIENT_SECRET}}
|
||||
MAL_CLIENT_ID: {{process.env.MAL_CLIENT_ID}}
|
||||
MAL_CLIENT_SECRET: {{process.env.MAL_CLIENT_SECRET}}
|
||||
MAL_CALLBACK_URI: {{process.env.MAL_CALLBACK_URI}}
|
||||
}
|
||||
vars:secret [
|
||||
code
|
||||
ANILIST_ACCESS_TOKEN,
|
||||
ANILIST_CODE,
|
||||
SIMKL_AUTH_TOKEN,
|
||||
MAL_CODE,
|
||||
MAL_VERIFIER,
|
||||
MAL_USER,
|
||||
~MAL_ACCESS_TOKEN
|
||||
]
|
||||
|
||||
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=
|
||||
|
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">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>NSAppTransportSecurity</key>
|
||||
<dict>
|
||||
<key>NSAllowsLocalNetworking</key>
|
||||
<true />
|
||||
</dict>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleName</key>
|
||||
|
||||
BIN
build/icon/128/AniTrack.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
build/icon/32/AniTrack.png
Normal file
|
After Width: | Height: | Size: 2.8 KiB |
BIN
build/icon/48/AniTrack.png
Normal file
|
After Width: | Height: | Size: 3.3 KiB |
BIN
build/icon/64/AniTrack.png
Normal file
|
After Width: | Height: | Size: 3.9 KiB |
26
build/install_linux.sh
Executable file
@@ -0,0 +1,26 @@
|
||||
#!/bin/bash
|
||||
|
||||
# copy desktop file
|
||||
if [ -e "~/.local/share/applications/AniTrack.desktop" ]; then
|
||||
if [ -d "~/.local/share/applications/" ]; then
|
||||
cp ./AniTrack.desktop ~/.local/share/applications/
|
||||
else
|
||||
mkdir -p ~/.local/share/applications/
|
||||
cp ./AniTrack.desktop ~/.local/share/applications/
|
||||
fi
|
||||
fi
|
||||
|
||||
# copy icons to xdg folders
|
||||
for size in 32 48 64 128; do
|
||||
xdg-icon-resource install --novendor --context apps --size $size ./icon/$size/AniTrack.png AniTrack
|
||||
done
|
||||
|
||||
# copy AniTrack Binary to $HOME/Applications/
|
||||
if ! [ -d "~/Applications" ]; then
|
||||
mkdir -p ~/Applications
|
||||
cp ./bin/AniTrack ~/Applications/
|
||||
elif ! [[ -e ~/Applications/AniTrack ]]; then
|
||||
cp ./bin/AniTrack ~/Applications/
|
||||
fi
|
||||
|
||||
echo "AniTrack has been successfully installed."
|
||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 15 KiB |
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 = {}
|
||||
5
frontend/.vscode/extensions.json
vendored
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"recommendations": [
|
||||
"svelte.svelte-vscode"
|
||||
]
|
||||
}
|
||||
@@ -1,13 +1,16 @@
|
||||
<!DOCTYPE html>
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8"/>
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport"/>
|
||||
<title>AniTrack</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="./src/main.ts" type="module"></script>
|
||||
<script src="./node_modules/flowbite/dist/flowbite.js"></script>
|
||||
</body>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
||||
<title>AniTrack</title>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script src="./src/main.ts" type="module"></script>
|
||||
<script
|
||||
src="./node_modules/flowbite/dist/flowbite.js"
|
||||
type="module"
|
||||
></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
@@ -10,23 +10,25 @@
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/vite-plugin-svelte": "^1.0.1",
|
||||
"@tsconfig/svelte": "^3.0.0",
|
||||
"autoprefixer": "^10.4.19",
|
||||
"postcss": "^8.4.39",
|
||||
"svelte": "^3.49.0",
|
||||
"svelte-check": "^2.8.0",
|
||||
"svelte-preprocess": "^4.10.7",
|
||||
"tailwind-merge": "^2.4.0",
|
||||
"tailwindcss": "^3.4.6",
|
||||
"tslib": "^2.4.0",
|
||||
"typescript": "^4.6.4",
|
||||
"vite": "^3.0.7"
|
||||
"@sveltejs/vite-plugin-svelte": "^2.4.1",
|
||||
"@tsconfig/svelte": "^4.0.1",
|
||||
"autoprefixer": "^10.4.20",
|
||||
"postcss": "^8.4.45",
|
||||
"svelte": "^4.0.0",
|
||||
"svelte-check": "^3.4.3",
|
||||
"svelte-headless-table": "^0.18.3",
|
||||
"svelte-preprocess": "^5.0.3",
|
||||
"svelte-spa-router": "^4.0.1",
|
||||
"tailwind-merge": "^2.5.2",
|
||||
"tailwindcss": "^3.4.10",
|
||||
"tslib": "^2.7.0",
|
||||
"typescript": "^5.0.0",
|
||||
"vite": "^4.5.5"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ernane/svelte-star-rating": "^1.1.7",
|
||||
"@popperjs/core": "^2.11.8",
|
||||
"flowbite": "^2.4.1",
|
||||
"flowbite-svelte": "^0.46.15"
|
||||
"flowbite": "^2.5.1",
|
||||
"flowbite-svelte": "^0.46.16",
|
||||
"moment": "^2.30.1"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,145 +1,72 @@
|
||||
<script lang="ts">
|
||||
import {anilistModal, GetAniListSingleItemAndOpenModal, title} from "./GetAniListSingleItemAndOpenModal.svelte";
|
||||
import {GetAniListUserWatchingList, SimklLogin} from "../wailsjs/go/main/App";
|
||||
import {MediaListSort} from "./anilist/types/AniListTypes";
|
||||
import type {AniListCurrentUserWatchList} from "./anilist/types/AniListCurrentUserWatchListType"
|
||||
import Header from "./Header.svelte";
|
||||
import StarRatting from '@ernane/svelte-star-rating'
|
||||
import {Modal} from "flowbite-svelte";
|
||||
import {
|
||||
aniListLoggedIn,
|
||||
malLoggedIn,
|
||||
simklLoggedIn,
|
||||
watchlistNeedsRefresh,
|
||||
aniListPrimary,
|
||||
malPrimary,
|
||||
simklPrimary,
|
||||
malWatchList,
|
||||
simklWatchList,
|
||||
} from "./helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||
import { onMount } from "svelte";
|
||||
import Router from "svelte-spa-router";
|
||||
import Home from "./routes/Home.svelte";
|
||||
import { wrap } from "svelte-spa-router/wrap";
|
||||
import Spinner from "./helperComponents/Spinner.svelte";
|
||||
import Header from "./helperComponents/Header.svelte";
|
||||
import { CheckIfAniListLoggedInAndLoadWatchList } from "./helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
|
||||
import { CheckIfMALLoggedInAndSetUser } from "./helperModules/CheckIfMyAnimeListLoggedIn.svelte";
|
||||
import { CheckIfSimklLoggedInAndSetUser } from "./helperModules/CheckIsSimklLoggedIn.svelte";
|
||||
import {
|
||||
CheckIfAniListLoggedIn,
|
||||
GetMyAnimeList,
|
||||
SimklGetUserWatchlist,
|
||||
} from "../wailsjs/go/main/App";
|
||||
import { loc } from "svelte-spa-router";
|
||||
import ErrorModal from "./helperComponents/ErrorModal.svelte";
|
||||
|
||||
import ChangeDataDialogue from "./ChangeDataDialogue.svelte";
|
||||
onMount(async () => {
|
||||
let isAniListLoggedIn: boolean;
|
||||
let isMALLoggedIn: boolean;
|
||||
let isSimklLoggedIn: boolean;
|
||||
aniListLoggedIn.subscribe((value) => (isAniListLoggedIn = value));
|
||||
malLoggedIn.subscribe((value) => (isMALLoggedIn = value));
|
||||
simklLoggedIn.subscribe((value) => (isSimklLoggedIn = value));
|
||||
|
||||
const config = {
|
||||
readOnly: false,
|
||||
countStars: 5,
|
||||
range: {
|
||||
min: 0,
|
||||
max: 5,
|
||||
step: 0.5
|
||||
},
|
||||
score: 0.0,
|
||||
showScore: true,
|
||||
scoreFormat: function(){ return `(${this.score.toFixed(1)}/${this.countStars})` },
|
||||
name: "",
|
||||
starConfig: {
|
||||
size: 20,
|
||||
fillColor: '#F9ED4F',
|
||||
strokeColor: "#e2c714",
|
||||
unfilledColor: '#FFF',
|
||||
strokeUnfilledColor: '#000'
|
||||
}
|
||||
}
|
||||
|
||||
let aniListLoggedIn = false
|
||||
let aniListWatchlist: AniListCurrentUserWatchList
|
||||
let page = 1
|
||||
let perPage = 20
|
||||
const size = "xl"
|
||||
|
||||
function anilistGetUserWatchlist(): void {
|
||||
GetAniListUserWatchingList(page, perPage, MediaListSort.UpdatedTimeDesc).then((result) => {
|
||||
aniListWatchlist = result
|
||||
aniListLoggedIn = true
|
||||
})
|
||||
}
|
||||
|
||||
let count = 1;
|
||||
|
||||
const decrement = () => {
|
||||
if (count > 0) {
|
||||
count--
|
||||
}
|
||||
}
|
||||
|
||||
const increment = () => {
|
||||
count++
|
||||
}
|
||||
!isAniListLoggedIn && (await CheckIfAniListLoggedInAndLoadWatchList());
|
||||
!isMALLoggedIn && (await CheckIfMALLoggedInAndSetUser());
|
||||
!isSimklLoggedIn && (await CheckIfSimklLoggedInAndSetUser());
|
||||
});
|
||||
|
||||
$: if ($loc?.location === "/" && $watchlistNeedsRefresh) {
|
||||
(async () => {
|
||||
if ($aniListLoggedIn && $aniListPrimary) {
|
||||
await CheckIfAniListLoggedInAndLoadWatchList();
|
||||
}
|
||||
if ($malLoggedIn && $malPrimary) {
|
||||
await GetMyAnimeList(1000).then((w) => malWatchList.set(w));
|
||||
}
|
||||
if ($simklLoggedIn && $simklPrimary) {
|
||||
await SimklGetUserWatchlist().then((w) => simklWatchList.set(w));
|
||||
}
|
||||
|
||||
watchlistNeedsRefresh.set(false);
|
||||
})();
|
||||
}
|
||||
</script>
|
||||
|
||||
<Header/>
|
||||
|
||||
<main>
|
||||
|
||||
|
||||
<button class="btn" on:click={anilistGetUserWatchlist}>Login to AniList</button>
|
||||
<button class="btn" on:click={SimklLogin}>Login to Simkl</button>
|
||||
{#if aniListLoggedIn}
|
||||
<div>You are logged in {aniListWatchlist.data.Page.mediaList[0].user.name}!</div>
|
||||
{/if}
|
||||
|
||||
{#if aniListLoggedIn}
|
||||
<div class="mx-auto max-w-2xl px-4 py-16 sm:px-6 sm:py-24 lg:max-w-7xl lg:px-8">
|
||||
<h1>Your Watching List</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 aniListWatchlist.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">
|
||||
<button on:click={() => GetAniListSingleItemAndOpenModal(media.media.id, true)} class="group">
|
||||
<div class="flex flex-col items-center">
|
||||
<img class="rounded-lg" src={media.media.coverImage.large} alt={
|
||||
media.media.title.english === "" ?
|
||||
media.media.title.romaji :
|
||||
media.media.title.english
|
||||
}/>
|
||||
{config.score = media.score / 2.0}
|
||||
<StarRatting {config}/>
|
||||
<h3 class="mt-4 text-sm text-white-700">{
|
||||
media.media.title.english === "" ?
|
||||
media.media.title.romaji :
|
||||
media.media.title.english
|
||||
}</h3>
|
||||
<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>
|
||||
</button>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="flex items-center justify-center">
|
||||
<button on:click={decrement}
|
||||
class="flex justify-center items-center w-10 h-10 rounded-full text-white focus:outline-none bg-gray-400 hover:bg-gray-500">
|
||||
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M20 12H4"></path>
|
||||
</svg>
|
||||
</button>
|
||||
<input bind:value={count} class="text-2xl font-bold mx-4" />
|
||||
<button on:click={increment}
|
||||
class="flex justify-center items-center w-10 h-10 rounded-full text-white focus:outline-none bg-indigo-500 hover:bg-indigo-600">
|
||||
<svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6v12M6 12h12"></path>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<!-- <div class="relative max-w-sm">-->
|
||||
<!-- <div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">-->
|
||||
<!-- <svg class="w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">-->
|
||||
<!-- <path d="M20 4a2 2 0 0 0-2-2h-2V1a1 1 0 0 0-2 0v1h-3V1a1 1 0 0 0-2 0v1H6V1a1 1 0 0 0-2 0v1H2a2 2 0 0 0-2 2v2h20V4ZM0 18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8H0v10Zm5-8h10a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z"/>-->
|
||||
<!-- </svg>-->
|
||||
<!-- </div>-->
|
||||
<!-- <input-->
|
||||
<!-- datepicker-->
|
||||
<!-- datepicker-buttons-->
|
||||
<!-- datepicker-autoselect-today-->
|
||||
<!-- datepicker-autohide-->
|
||||
<!-- datepicker-title="Started At"-->
|
||||
<!-- id="startedAt"-->
|
||||
<!-- type="text"-->
|
||||
<!-- class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500-->
|
||||
<!-- focus:border-blue-500 block w-full ps-10 p-2.5 dark:bg-gray-700 dark:border-gray-600-->
|
||||
<!-- dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"-->
|
||||
<!-- placeholder="Select date">-->
|
||||
<!-- </div>-->
|
||||
<Modal title={$title} bind:open={$anilistModal} {size} autoclose={false}>
|
||||
<ChangeDataDialogue/>
|
||||
</Modal>
|
||||
</main>
|
||||
<Header />
|
||||
<ErrorModal />
|
||||
<Router
|
||||
routes={{
|
||||
"/": Home,
|
||||
"/anime/:id": wrap({
|
||||
asyncComponent: () => import("./routes/AnimeRoutePage.svelte"),
|
||||
conditions: [async () => await CheckIfAniListLoggedIn()],
|
||||
loadingComponent: Spinner,
|
||||
}),
|
||||
// '*': "Not Found"
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
<script lang="ts">
|
||||
import {anime} from "./GetAniListSingleItemAndOpenModal.svelte";
|
||||
import {Button} from "flowbite-svelte";
|
||||
import StarRatting from "@ernane/svelte-star-rating"
|
||||
|
||||
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 title = anime.data.MediaList.media.title.english !== "" ?
|
||||
anime.data.MediaList.media.title.english :
|
||||
anime.data.MediaList.media.title.romaji
|
||||
|
||||
let config = {
|
||||
readOnly: false,
|
||||
countStars: 5,
|
||||
range: {
|
||||
min: 0,
|
||||
max: 5,
|
||||
step: 0.5
|
||||
},
|
||||
score: anime.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: anime.data.MediaList.progress,
|
||||
status: anime.data.MediaList.status,
|
||||
startedAt: {
|
||||
year: anime.data.MediaList.startedAt.year,
|
||||
month: anime.data.MediaList.startedAt.month,
|
||||
day: anime.data.MediaList.startedAt.day
|
||||
},
|
||||
completedAt: {
|
||||
year: anime.data.MediaList.completedAt.year,
|
||||
month: anime.data.MediaList.completedAt.month,
|
||||
day: anime.data.MediaList.completedAt.day
|
||||
},
|
||||
repeat: anime.data.MediaList.repeat,
|
||||
score: anime.data.MediaList.score,
|
||||
notes: anime.data.MediaList.notes
|
||||
}
|
||||
|
||||
const changeRating = (e) => {
|
||||
config.score = e.target.valueAsNumber
|
||||
values.score = e.target.valueAsNumber * 2
|
||||
}
|
||||
|
||||
let count = 1;
|
||||
|
||||
const decrement = () => {
|
||||
if (count > 0) {
|
||||
count--
|
||||
}
|
||||
}
|
||||
|
||||
const increment = () => {
|
||||
count++
|
||||
}
|
||||
|
||||
let startedAtDate = `${values.startedAt.year}-${values.startedAt.month}-${values.startedAt.day}`
|
||||
|
||||
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])
|
||||
}
|
||||
|
||||
console.log(startedAtDate)
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<div class="grid grid-rows-2 grid-cols-10 grid-flow-col gap-4 mt-10">
|
||||
<div class="row-span-2 col-span-2 space-y-3">
|
||||
<img class="rounded-lg" src={anime.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="col-span-8 z-30">
|
||||
<div class="flex flex-row p-10 justify-center gap-x-56">
|
||||
|
||||
|
||||
<div class="mr-4">
|
||||
<label for="episodes" class="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-full 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="block mb-2 text-sm font-medium text-gray-900 dark:text-white">Select
|
||||
your
|
||||
country</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"
|
||||
>
|
||||
|
||||
<option>CURRENT</option>
|
||||
<option>PLANNING</option>
|
||||
<option>COMPLETED</option>
|
||||
<option>DROPPED</option>
|
||||
<option>PAUSED</option>
|
||||
<option>REPEATING</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row p-10 justify-center">
|
||||
|
||||
<div class="relative z-40 max-w-sm">
|
||||
<div class="absolute inset-y-0 start-0 flex items-center ps-3.5 pointer-events-none">
|
||||
<svg class="w-4 h-4 text-gray-500 dark:text-gray-400" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
|
||||
<path d="M20 4a2 2 0 0 0-2-2h-2V1a1 1 0 0 0-2 0v1h-3V1a1 1 0 0 0-2 0v1H6V1a1 1 0 0 0-2 0v1H2a2 2 0 0 0-2 2v2h20V4ZM0 18a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8H0v10Zm5-8h10a1 1 0 0 1 0 2H5a1 1 0 0 1 0-2Z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<!-- <input-->
|
||||
<!-- datepicker-->
|
||||
<!-- datepicker-buttons-->
|
||||
<!-- datepicker-autoselect-today-->
|
||||
<!-- datepicker-autohide-->
|
||||
<!-- datepicker-title="Started At"-->
|
||||
<!-- id="startedAt"-->
|
||||
<!-- type="text"-->
|
||||
<!-- name="startedAt"-->
|
||||
<!-- class="z-50 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={`${values.startedAt.year}-${values.startedAt.month}-${values.startedAt.day}`}-->
|
||||
<!-- on:change={transformStartedAtDate}-->
|
||||
<!-- >-->
|
||||
<input
|
||||
id="startedAt"
|
||||
type="date"
|
||||
name="startedAt"
|
||||
class="z-50 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}
|
||||
on:change={transformStartedAtDate}
|
||||
>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<footer class="bg-white rounded-lg shadow m-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={() => alert('Handle "success"')}>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">
|
||||
Cancel
|
||||
</Button>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
@@ -1,19 +0,0 @@
|
||||
<script lang="ts" context="module">
|
||||
import {GetAniListItem} from "../wailsjs/go/main/App";
|
||||
import type {AniListGetSingleAnime} from "./anilist/types/AniListCurrentUserWatchListType.js";
|
||||
import {writable} from 'svelte/store'
|
||||
|
||||
export let anime: AniListGetSingleAnime
|
||||
export let title = writable("")
|
||||
export let anilistModal = writable(false);
|
||||
|
||||
export function GetAniListSingleItemAndOpenModal(aniId: number, login: boolean): void {
|
||||
GetAniListItem(aniId, login).then(result => {
|
||||
anime = result
|
||||
title.set(anime.data.MediaList.media.title.english === "" ?
|
||||
anime.data.MediaList.media.title.romaji :
|
||||
anime.data.MediaList.media.title.english)
|
||||
anilistModal.set(true)
|
||||
})
|
||||
}
|
||||
</script>
|
||||
@@ -1,49 +0,0 @@
|
||||
<script lang="ts">
|
||||
import logo from "./assets/images/AniTrackLogo.svg"
|
||||
import Search from "./Search.svelte"
|
||||
import UserDialogue from "./UserHeaderDialogue.svelte";
|
||||
|
||||
</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 flex-wrap justify-between items-center mx-auto max-w-screen-xl">
|
||||
<a href="#" class="flex items-center">
|
||||
<img src={logo} class="mr-3 h-6 sm:h-9" alt="AniTrack Logo" />
|
||||
</a>
|
||||
<div class="flex space-x-4 items-center lg:order-2">
|
||||
|
||||
<Search />
|
||||
|
||||
<UserDialogue />
|
||||
<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>
|
||||
<div class="hidden justify-between items-center w-full lg:flex lg:w-auto lg:order-1" id="mobile-menu-2">
|
||||
<ul class="flex flex-col mt-4 font-medium lg:flex-row lg:space-x-8 lg:mt-0">
|
||||
<!-- <li>-->
|
||||
<!-- <a href="#" class="block py-2 pr-4 pl-3 text-white rounded bg-blue-700 lg:bg-transparent lg:text-blue-700 lg:p-0 dark:text-white" aria-current="page">Home</a>-->
|
||||
<!-- </li>-->
|
||||
<!-- <li>-->
|
||||
<!-- <a href="#" class="block py-2 pr-4 pl-3 text-gray-700 border-b border-gray-100 hover:bg-gray-50 lg:hover:bg-transparent lg:border-0 lg:hover:text-blue-700 lg:p-0 dark:text-gray-400 lg:dark:hover:text-white dark:hover:bg-gray-700 dark:hover:text-white lg:dark:hover:bg-transparent dark:border-gray-700">Company</a>-->
|
||||
<!-- </li>-->
|
||||
<!-- <li>-->
|
||||
<!-- <a href="#" class="block py-2 pr-4 pl-3 text-gray-700 border-b border-gray-100 hover:bg-gray-50 lg:hover:bg-transparent lg:border-0 lg:hover:text-blue-700 lg:p-0 dark:text-gray-400 lg:dark:hover:text-white dark:hover:bg-gray-700 dark:hover:text-white lg:dark:hover:bg-transparent dark:border-gray-700">Marketplace</a>-->
|
||||
<!-- </li>-->
|
||||
<!-- <li>-->
|
||||
<!-- <a href="#" class="block py-2 pr-4 pl-3 text-gray-700 border-b border-gray-100 hover:bg-gray-50 lg:hover:bg-transparent lg:border-0 lg:hover:text-blue-700 lg:p-0 dark:text-gray-400 lg:dark:hover:text-white dark:hover:bg-gray-700 dark:hover:text-white lg:dark:hover:bg-transparent dark:border-gray-700">Features</a>-->
|
||||
<!-- </li>-->
|
||||
<!-- <li>-->
|
||||
<!-- <a href="#" class="block py-2 pr-4 pl-3 text-gray-700 border-b border-gray-100 hover:bg-gray-50 lg:hover:bg-transparent lg:border-0 lg:hover:text-blue-700 lg:p-0 dark:text-gray-400 lg:dark:hover:text-white dark:hover:bg-gray-700 dark:hover:text-white lg:dark:hover:bg-transparent dark:border-gray-700">Team</a>-->
|
||||
<!-- </li>-->
|
||||
<!-- <li>-->
|
||||
<!-- <a href="#" class="block py-2 pr-4 pl-3 text-gray-700 border-b border-gray-100 hover:bg-gray-50 lg:hover:bg-transparent lg:border-0 lg:hover:text-blue-700 lg:p-0 dark:text-gray-400 lg:dark:hover:text-white dark:hover:bg-gray-700 dark:hover:text-white lg:dark:hover:bg-transparent dark:border-gray-700">Contact</a>-->
|
||||
<!-- </li>-->
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
@@ -1,77 +0,0 @@
|
||||
<script lang="ts">
|
||||
|
||||
import {AniListSearch} from "../wailsjs/go/main/App";
|
||||
import type {AniSearchList} from "./anilist/types/AniListTypes";
|
||||
import {GetAniListSingleItemAndOpenModal} from "./GetAniListSingleItemAndOpenModal.svelte";
|
||||
|
||||
let aniSearch = ""
|
||||
let aniListSearch: AniSearchList
|
||||
let aniListSearchActive = false
|
||||
|
||||
function runAniListSearch(): void {
|
||||
AniListSearch(aniSearch).then(result => {
|
||||
console.log(result.data.Page.media[5])
|
||||
aniListSearch = result
|
||||
aniListSearchActive = true
|
||||
})
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<div>
|
||||
<div class="max-w-md mx-auto">
|
||||
<div class="flex">
|
||||
<label for="anime-search" class="mb-2 text-sm font-medium text-gray-900 sr-only dark:text-white">Find
|
||||
Anime</label>
|
||||
<div class="relative w-full">
|
||||
<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"
|
||||
placeholder="Search for Anime" required/>
|
||||
<button id="aniListSearchButton" data-dropdown-toggle="aniListSearch"
|
||||
data-dropdown-offset-distance="0"
|
||||
data-dropdown-offset-skidding="-50"
|
||||
data-dropdown-placement="bottom"
|
||||
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"
|
||||
on:click={() => {if(aniSearch.length > 0) runAniListSearch()}}>
|
||||
<svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
||||
viewBox="0 0 20 20">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"/>
|
||||
</svg>
|
||||
<span class="sr-only">Search</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="aniListSearch" class="z-10 hidden bg-white rounded-lg shadow w-80 dark:bg-gray-700">
|
||||
{#if aniListSearchActive}
|
||||
<ul class="h-56 w-full py-2 overflow-y-auto text-gray-700 dark:text-gray-200"
|
||||
aria-labelledby="aniListSearchButton">
|
||||
{#each aniListSearch.data.Page.media as media}
|
||||
<li class="w-full">
|
||||
<button on:click={() => {
|
||||
GetAniListSingleItemAndOpenModal(media.id, false)
|
||||
}}
|
||||
class="flex w-full items-start p-1 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white rounded-lg">
|
||||
<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">
|
||||
<p class="bg-gray-800 text-left w-full h-24 p-2 rounded-tr-lg rounded-br-lg">{media.title.english === '' || media.title.english === null ? media.title.romaji : media.title.english }</p>
|
||||
</button>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{:else if aniSearch.length === 0}
|
||||
<div class="m-4">Please enter a search term...</div>
|
||||
{/if}
|
||||
<a href="#"
|
||||
class="flex items-center p-3 text-sm font-medium text-blue-600 border-t border-gray-200 rounded-b-lg bg-gray-50 dark:border-gray-600 hover:bg-gray-100 dark:bg-gray-700 dark:hover:bg-gray-600 dark:text-blue-500 hover:underline">
|
||||
<svg class="w-4 h-4 me-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor"
|
||||
viewBox="0 0 20 18">
|
||||
<path d="M6.5 9a4.5 4.5 0 1 0 0-9 4.5 4.5 0 0 0 0 9ZM8 10H5a5.006 5.006 0 0 0-5 5v2a1 1 0 0 0 1 1h11a1 1 0 0 0 1-1v-2a5.006 5.006 0 0 0-5-5Zm11-3h-2V5a1 1 0 0 0-2 0v2h-2a1 1 0 1 0 0 2h2v2a1 1 0 0 0 2 0V9h2a1 1 0 1 0 0-2Z"/>
|
||||
</svg>
|
||||
Add new user
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,34 +0,0 @@
|
||||
<script lang="ts">
|
||||
let loggedIn = false
|
||||
</script>
|
||||
|
||||
|
||||
<div id="avatarButton" type="button" data-dropdown-toggle="userDropdown" data-dropdown-placement="bottom-start" class="relative w-10 h-10 overflow-hidden bg-gray-100 rounded-full dark:bg-gray-600">
|
||||
{#if loggedIn}
|
||||
<img class="w-10 h-10 rounded-full cursor-pointer" src="/docs/images/people/profile-picture-5.jpg" alt="User dropdown">
|
||||
{:else}
|
||||
<svg class="absolute w-12 h-12 text-gray-400 -left-1" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M10 9a3 3 0 100-6 3 3 0 000 6zm-7 9a7 7 0 1114 0H3z" clip-rule="evenodd"></path></svg>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- Dropdown menu -->
|
||||
<div id="userDropdown" class="z-10 hidden 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">
|
||||
<div>Bonnie Green</div>
|
||||
<div class="font-medium truncate">name@flowbite.com</div>
|
||||
</div>
|
||||
<ul class="py-2 text-sm text-gray-700 dark:text-gray-200" aria-labelledby="avatarButton">
|
||||
<li>
|
||||
<a href="#" class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Dashboard</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Settings</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#" class="block px-4 py-2 hover:bg-gray-100 dark:hover:bg-gray-600 dark:hover:text-white">Earnings</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="py-1">
|
||||
<a href="#" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white">Sign out</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,80 +1,94 @@
|
||||
export interface AniListCurrentUserWatchList {
|
||||
data: {
|
||||
Page: {
|
||||
pageInfo: {
|
||||
total: number
|
||||
perPage: number
|
||||
currentPage: number
|
||||
lastPage: number
|
||||
hasNextPage: boolean
|
||||
},
|
||||
mediaList: MediaList[]
|
||||
}
|
||||
}
|
||||
data: {
|
||||
Page: {
|
||||
pageInfo: {
|
||||
total: number;
|
||||
perPage: number;
|
||||
currentPage: number;
|
||||
lastPage: number;
|
||||
hasNextPage: boolean;
|
||||
};
|
||||
mediaList: MediaList[];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
export interface AniListGetSingleAnime {
|
||||
data: {
|
||||
MediaList: MediaList
|
||||
}
|
||||
data: {
|
||||
MediaList: MediaList;
|
||||
};
|
||||
}
|
||||
|
||||
export interface MediaList {
|
||||
id: number
|
||||
mediaId: number
|
||||
userId: number
|
||||
media: {
|
||||
id: number
|
||||
idMal: number
|
||||
title: {
|
||||
romaji: string
|
||||
english?: string
|
||||
native: string
|
||||
}
|
||||
description: string
|
||||
coverImage: {
|
||||
large: string
|
||||
}
|
||||
season: string
|
||||
seasonYear: number
|
||||
status: string
|
||||
episodes?: number
|
||||
nextAiringEpisode?: {
|
||||
airingAt: number
|
||||
timeUntilAiring: number
|
||||
episode: number
|
||||
}
|
||||
}
|
||||
status: string
|
||||
startedAt: {
|
||||
year: number
|
||||
month: number
|
||||
day: number
|
||||
}
|
||||
completedAt: {
|
||||
year?: number
|
||||
month?: number
|
||||
day?: number
|
||||
}
|
||||
notes?: string
|
||||
progress: number
|
||||
score: number
|
||||
repeat: number
|
||||
user: {
|
||||
id: number
|
||||
name: string
|
||||
avatar: {
|
||||
large: string
|
||||
medium: string
|
||||
}
|
||||
statistics: {
|
||||
anime: {
|
||||
count: number
|
||||
statuses: [{
|
||||
status: string
|
||||
count: number
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
id: number;
|
||||
mediaId: number;
|
||||
userId: number;
|
||||
media: {
|
||||
id: number;
|
||||
idMal: number;
|
||||
title: {
|
||||
romaji: string;
|
||||
english?: string;
|
||||
native: string;
|
||||
};
|
||||
description: string;
|
||||
coverImage: {
|
||||
large: string;
|
||||
};
|
||||
season: string;
|
||||
seasonYear: number;
|
||||
status: string;
|
||||
episodes?: number;
|
||||
nextAiringEpisode?: {
|
||||
airingAt: number;
|
||||
timeUntilAiring: number;
|
||||
episode: number;
|
||||
};
|
||||
genres: string[];
|
||||
tags: [
|
||||
{
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
rank: number;
|
||||
isMediaSpoiler: boolean;
|
||||
isAdult: boolean;
|
||||
},
|
||||
];
|
||||
isAdult: boolean;
|
||||
};
|
||||
status: string;
|
||||
startedAt: {
|
||||
year: number;
|
||||
month: number;
|
||||
day: number;
|
||||
};
|
||||
completedAt: {
|
||||
year?: number;
|
||||
month?: number;
|
||||
day?: number;
|
||||
};
|
||||
notes?: string;
|
||||
progress: number;
|
||||
score: number;
|
||||
repeat: number;
|
||||
user: {
|
||||
id: number;
|
||||
name: string;
|
||||
avatar: {
|
||||
large: string;
|
||||
medium: string;
|
||||
};
|
||||
statistics: {
|
||||
anime: {
|
||||
count: number;
|
||||
statuses: [
|
||||
{
|
||||
status: string;
|
||||
count: number;
|
||||
},
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -39,6 +39,12 @@ export interface AniListUser {
|
||||
"Viewer": {
|
||||
id: number,
|
||||
name: string,
|
||||
avatar: {
|
||||
large: string,
|
||||
medium: string,
|
||||
},
|
||||
bannerImage: string,
|
||||
siteUrl: string,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -75,3 +81,26 @@ export enum MediaListSort {
|
||||
MediaPopularity = "MEDIA_POPULARITY",
|
||||
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/images/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
870
frontend/src/helperComponents/Anime.svelte
Normal file
@@ -0,0 +1,870 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
aniListAnime,
|
||||
aniListLoggedIn,
|
||||
malAnime,
|
||||
malLoggedIn,
|
||||
simklAnime,
|
||||
simklLoggedIn,
|
||||
watchlistNeedsRefresh,
|
||||
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||
import { push } from "svelte-spa-router";
|
||||
import WebsiteLink from "./WebsiteLink.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 { 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";
|
||||
import { Badge, Tooltip } from "flowbite-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;
|
||||
}
|
||||
|
||||
try {
|
||||
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) => {
|
||||
value.data.MediaList.media.tags =
|
||||
currentAniListAnime.data.MediaList.media.tags;
|
||||
value.data.MediaList.media.genres =
|
||||
currentAniListAnime.data.MediaList.media.genres;
|
||||
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;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error submitting changes:", error);
|
||||
} finally {
|
||||
submitting.set(false);
|
||||
submitSuccess.set(true);
|
||||
watchlistNeedsRefresh.set(true);
|
||||
setTimeout(() => submitSuccess.set(false), 2000);
|
||||
}
|
||||
};
|
||||
|
||||
const deleteEntries = async () => {
|
||||
submitting.set(true);
|
||||
try {
|
||||
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: "",
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Error deleting entries:", error);
|
||||
} finally {
|
||||
submitting.set(false);
|
||||
submitSuccess.set(true);
|
||||
watchlistNeedsRefresh.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;
|
||||
if (
|
||||
currentAniListAnime.data.MediaList.progress <
|
||||
currentAniListAnime.data.MediaList.media.episodes
|
||||
) {
|
||||
startingAnilistStatusOption = statusOptions[0];
|
||||
if (currentAniListAnime.data.MediaList.repeat === 0)
|
||||
completedAtDate = null;
|
||||
}
|
||||
}}
|
||||
disabled={currentAniListAnime.data.MediaList.progress <= 0}
|
||||
class={currentAniListAnime.data.MediaList.progress <= 0
|
||||
? "border-gray-600 border rounded-s-lg p-3 h-11 focus:ring-gray-700 focus:ring-2 focus:outline-none"
|
||||
: "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"
|
||||
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;
|
||||
if (
|
||||
currentAniListAnime.data.MediaList.media.episodes ===
|
||||
currentAniListAnime.data.MediaList.progress
|
||||
) {
|
||||
startingAnilistStatusOption = statusOptions[2];
|
||||
completedAtDate = new Date();
|
||||
}
|
||||
if (currentAniListAnime.data.MediaList.progress - 1 === 0) {
|
||||
startingAnilistStatusOption = statusOptions[0];
|
||||
if (startedAtDate === null) startedAtDate = new Date();
|
||||
}
|
||||
}}
|
||||
disabled={(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 -
|
||||
2)}
|
||||
class={(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 -
|
||||
2)
|
||||
? "border-gray-600 border rounded-e-lg p-3 h-11 focus:ring-gray-700 focus:ring-2 focus:outline-none"
|
||||
: "bg-gray-700 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>
|
||||
/ {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-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 class="flex mb-4 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-end"
|
||||
>
|
||||
<button
|
||||
disabled={isSubmitting}
|
||||
id="sync-button"
|
||||
class="text-white {$submitSuccess
|
||||
? 'bg-green-600 hover:bg-green-700 focus:ring-4 focus:ring-green-800'
|
||||
: 'bg-blue-600 hover:bg-blue-700 focus:ring-4 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
|
||||
type="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
|
||||
hover:border-gray-600"
|
||||
on:click={async () => {
|
||||
await CheckIfAniListLoggedInAndLoadWatchList();
|
||||
return push("/");
|
||||
}}
|
||||
>
|
||||
Go Home
|
||||
</button>
|
||||
</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 {$submitSuccess
|
||||
? 'bg-green-600 hover:bg-green-700 focus:ring-4 focus:ring-green-800'
|
||||
: 'bg-red-600 hover:bg-red-700 focus:ring-4 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 hover:bg-green-700 focus:ring-4 focus:ring-green-800'
|
||||
: 'bg-blue-600 hover:bg-blue-700 focus:ring-4 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
|
||||
hover:border-gray-600"
|
||||
on:click={async () => {
|
||||
await CheckIfAniListLoggedInAndLoadWatchList();
|
||||
return push("/");
|
||||
}}
|
||||
>
|
||||
Go Home
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex m-5">
|
||||
<div>
|
||||
<h3 class="text-2xl">Genres</h3>
|
||||
{#each currentAniListAnime.data.MediaList.media.genres || [] as genre}
|
||||
<div>
|
||||
<Badge large border color="blue" class="m-1 w-52">
|
||||
<div>
|
||||
<WebsiteLink
|
||||
id={genre}
|
||||
url="https://anilist.co/search/anime/{genre}"
|
||||
/>
|
||||
</div>
|
||||
</Badge>
|
||||
<Tooltip>{genre}</Tooltip>
|
||||
</div>
|
||||
{/each}
|
||||
<h3 class="text-2xl">Tags</h3>
|
||||
<div class="mt-2">
|
||||
{#each currentAniListAnime.data.MediaList.media.tags as tag}
|
||||
<div>
|
||||
<Badge large border color="blue" class="m-1 w-52">
|
||||
<div>
|
||||
<WebsiteLink
|
||||
id={tag.name}
|
||||
url="https://anilist.co/search/anime/?genres={tag.name}"
|
||||
/>
|
||||
<span class="text-xs">({tag.rank}%)</span>
|
||||
</div>
|
||||
</Badge>
|
||||
<Tooltip>{tag.description}</Tooltip>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="ml-5">
|
||||
<h3 class="text-2xl">Summary</h3>
|
||||
<p class="rounded border border-gray-700 p-2 mt-2">
|
||||
{@html currentAniListAnime.data.MediaList.media.description}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
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>
|
||||
177
frontend/src/helperComponents/AvatarMenu.svelte
Normal file
@@ -0,0 +1,177 @@
|
||||
<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";
|
||||
import { ShowVersion } from "../../wailsjs/go/main/App";
|
||||
|
||||
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");
|
||||
|
||||
if (!dropdown.classList.contains("hidden")) {
|
||||
document.addEventListener("click", clickOutside);
|
||||
}
|
||||
}
|
||||
|
||||
function clickOutside(event: Event): void {
|
||||
let dropdown = document.querySelector("#userDropdown");
|
||||
let toggleBtn = document.querySelector("#userDropdownButton");
|
||||
|
||||
if (
|
||||
!dropdown.contains(event.target as Node) &&
|
||||
!toggleBtn.contains(event.target as Node)
|
||||
) {
|
||||
dropdown.classList.add("hidden");
|
||||
document.removeEventListener("click", clickOutside);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="relative">
|
||||
<button id="userDropdownButton" on:click={dropdownUser}>
|
||||
{#if isAniListLoggedIn}
|
||||
<Avatar
|
||||
src={currentAniListUser.data.Viewer.avatar.medium}
|
||||
class="cursor-pointer"
|
||||
dot={isAniListLoggedIn && isMALLoggedIn && isSimklLoggedIn
|
||||
? { color: "green" }
|
||||
: { color: "yellow" }}
|
||||
/>
|
||||
{: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={() => {
|
||||
dropdownUser();
|
||||
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={() => {
|
||||
dropdownUser();
|
||||
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={() => {
|
||||
dropdownUser();
|
||||
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={() => {
|
||||
dropdownUser();
|
||||
ShowVersion();
|
||||
}}
|
||||
class="block px-4 py-2 w-full text-sm hover:bg-gray-600 text-gray-200 over:text-white"
|
||||
>
|
||||
Version
|
||||
</button>
|
||||
<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
@@ -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-400";
|
||||
case "blue":
|
||||
return "focus:ring-2 focus:ring-blue-400";
|
||||
case "red":
|
||||
return "focus:ring-2 focus:ring-red-400";
|
||||
case "green":
|
||||
return "focus:ring-2 focus:ring-green-400";
|
||||
case "yellow":
|
||||
return "focus:ring-2 focus:ring-yellow-400";
|
||||
case "purple":
|
||||
return "focus:ring-2 focus:ring-purple-400";
|
||||
case "slate":
|
||||
return "focus:ring-2 focus:ring-slate-400";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
function getRangeBackgroundClass(color: Button["color"]): string {
|
||||
switch (color) {
|
||||
case "primary":
|
||||
return "bg-primary-900";
|
||||
case "blue":
|
||||
return "bg-blue-900";
|
||||
case "red":
|
||||
return "bg-red-900";
|
||||
case "green":
|
||||
return "bg-green-900";
|
||||
case "yellow":
|
||||
return "bg-yellow-900";
|
||||
case "purple":
|
||||
return "bg-purple-900";
|
||||
case "slate":
|
||||
return "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 bg-gray-700 text-white 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-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-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-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 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"
|
||||
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 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"
|
||||
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-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-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 = '';
|
||||
-->
|
||||
73
frontend/src/helperComponents/ErrorModal.svelte
Normal file
@@ -0,0 +1,73 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
apiError,
|
||||
isApiDown,
|
||||
clearApiError,
|
||||
setApiError,
|
||||
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||
import { CheckIfAniListLoggedInAndLoadWatchList } from "../helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
|
||||
import { CheckIfMALLoggedInAndSetUser } from "../helperModules/CheckIfMyAnimeListLoggedIn.svelte";
|
||||
import { CheckIfSimklLoggedInAndSetUser } from "../helperModules/CheckIsSimklLoggedIn.svelte";
|
||||
import { Modal, Button } from "flowbite-svelte";
|
||||
let showModal = false;
|
||||
$: if ($apiError) {
|
||||
showModal = true;
|
||||
}
|
||||
async function handleRetry() {
|
||||
const service = $apiError?.service;
|
||||
clearApiError();
|
||||
|
||||
try {
|
||||
if (service === "anilist") {
|
||||
await CheckIfAniListLoggedInAndLoadWatchList();
|
||||
} else if (service === "mal") {
|
||||
await CheckIfMALLoggedInAndSetUser();
|
||||
} else if (service === "simkl") {
|
||||
await CheckIfSimklLoggedInAndSetUser();
|
||||
}
|
||||
} catch (err) {
|
||||
const errorMsg = err instanceof Error ? err.message : String(err);
|
||||
setApiError(
|
||||
service || "unknown",
|
||||
`Retry failed: ${errorMsg}`,
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
}
|
||||
}
|
||||
function handleDismiss() {
|
||||
clearApiError();
|
||||
showModal = false;
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if showModal && $apiError}
|
||||
<Modal
|
||||
open={showModal}
|
||||
title="{$apiError.service.toUpperCase()} API Error"
|
||||
size="md"
|
||||
>
|
||||
<div class="space-y-4">
|
||||
<div class="p-4 bg-red-50 border border-red-200 rounded-lg">
|
||||
<p class="text-red-800 font-medium">{$apiError.message}</p>
|
||||
{#if $apiError.statusCode}
|
||||
<p class="text-red-600 text-sm mt-2">
|
||||
Status: {$apiError.statusCode}
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
<p class="text-gray-600">
|
||||
The application will remain open. You can retry the connection or
|
||||
dismiss this message to continue with limited functionality.
|
||||
</p>
|
||||
</div>
|
||||
<div slot="footer" class="flex gap-3 justify-end">
|
||||
{#if $apiError.canRetry}
|
||||
<Button on:click={handleRetry} class="bg-blue-600 hover:bg-blue-700">
|
||||
Retry Connection
|
||||
</Button>
|
||||
{/if}
|
||||
<Button on:click={handleDismiss} color="alternative">Dismiss</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
{/if}
|
||||
103
frontend/src/helperComponents/Header.svelte
Normal file
@@ -0,0 +1,103 @@
|
||||
<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";
|
||||
import { link } from "svelte-spa-router";
|
||||
|
||||
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="/" use:link
|
||||
><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>
|
||||
220
frontend/src/helperComponents/Pagination.svelte
Normal file
@@ -0,0 +1,220 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
aniListLoggedIn,
|
||||
aniListSort,
|
||||
aniListWatchlist,
|
||||
animePerPage,
|
||||
watchListPage,
|
||||
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||
|
||||
import type { AniListCurrentUserWatchList } from "../anilist/types/AniListCurrentUserWatchListType";
|
||||
import { GetAniListUserWatchingList } from "../../wailsjs/go/main/App";
|
||||
|
||||
let aniListWatchListLoaded: AniListCurrentUserWatchList;
|
||||
let page: number;
|
||||
let perPage: number;
|
||||
let sort: string;
|
||||
|
||||
watchListPage.subscribe((value) => (page = value));
|
||||
animePerPage.subscribe((value) => (perPage = value));
|
||||
aniListWatchlist.subscribe((value) => (aniListWatchListLoaded = value));
|
||||
aniListSort.subscribe((value) => (sort = value));
|
||||
|
||||
const perPageOptions = [10, 20, 50];
|
||||
|
||||
function ChangeWatchListPage(newPage: number) {
|
||||
GetAniListUserWatchingList(newPage, perPage, sort).then((result) => {
|
||||
watchListPage.set(newPage);
|
||||
aniListWatchlist.set(result);
|
||||
aniListLoggedIn.set(true);
|
||||
});
|
||||
}
|
||||
|
||||
function changePage(
|
||||
e: KeyboardEvent & { currentTarget: HTMLInputElement },
|
||||
): void {
|
||||
if (
|
||||
(e.key === "Enter" || e.key === "Tab") &&
|
||||
Number(e.currentTarget.value) !== page
|
||||
)
|
||||
ChangeWatchListPage(Number(e.currentTarget.value));
|
||||
}
|
||||
|
||||
function changeCountPerPage(
|
||||
e: Event & { currentTarget: HTMLSelectElement },
|
||||
): void {
|
||||
GetAniListUserWatchingList(1, Number(e.currentTarget.value), sort).then(
|
||||
(result) => {
|
||||
animePerPage.set(Number(e.currentTarget.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 hover: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={page <= 1
|
||||
? "border-gray-600 border rounded-s-lg p-3 h-11 focus:ring-gray-700 focus:ring-2 focus:outline-none"
|
||||
: "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"}
|
||||
disabled={page <= 1}
|
||||
>
|
||||
<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={page >= aniListWatchListLoaded.data.Page.pageInfo.lastPage
|
||||
? "border-gray-600 border rounded-e-lg p-3 h-11 focus:ring-gray-700 focus:ring-2 focus:outline-none"
|
||||
: "bg-gray-700 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"}
|
||||
disabled={page >= aniListWatchListLoaded.data.Page.pageInfo.lastPage}
|
||||
>
|
||||
<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
@@ -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>
|
||||
84
frontend/src/helperComponents/Search.svelte
Normal file
@@ -0,0 +1,84 @@
|
||||
<script lang="ts">
|
||||
|
||||
import {AniListSearch} from "../../wailsjs/go/main/App";
|
||||
import type {AniSearchList} from "../anilist/types/AniListTypes";
|
||||
import {push} from "svelte-spa-router";
|
||||
|
||||
let aniSearch = ""
|
||||
let aniListSearch: AniSearchList
|
||||
let aniListSearchActive = false
|
||||
|
||||
function runAniListSearch(): void {
|
||||
AniListSearch(aniSearch).then(result => {
|
||||
aniListSearch = result
|
||||
aniListSearchActive = true
|
||||
})
|
||||
}
|
||||
|
||||
function searchDropdown(): void {
|
||||
let dropdown = document.querySelector("#aniListSearchDropdown")
|
||||
dropdown.classList.toggle("hidden")
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
<div id="searchDropdown" class="relative w-64 md:w-48">
|
||||
<div class="flex">
|
||||
<label for="anime-search" class="mb-2 text-sm font-medium sr-only text-white">Find
|
||||
Anime</label>
|
||||
<div class="relative w-full">
|
||||
<input type="search" id="anime-search" bind:value={aniSearch}
|
||||
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"
|
||||
on:keypress={(e) => {
|
||||
if (e.key === "Enter") {
|
||||
searchDropdown()
|
||||
if(aniSearch.length > 0) runAniListSearch()
|
||||
}
|
||||
}}
|
||||
required/>
|
||||
<button id="aniListSearchButton"
|
||||
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={() => {
|
||||
searchDropdown()
|
||||
if(aniSearch.length > 0) runAniListSearch()
|
||||
}}>
|
||||
<svg class="w-4 h-4" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
|
||||
viewBox="0 0 20 20">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="m19 19-4-4m0-7A7 7 0 1 1 1 8a7 7 0 0 1 14 0Z"/>
|
||||
</svg>
|
||||
<span class="sr-only">Search</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="aniListSearchDropdown" class="z-10 absolute left-0 hidden bg-white rounded-lg shadow w-60 2xl:w-80 dark:bg-gray-700">
|
||||
{#if aniListSearchActive}
|
||||
<ul class="h-56 w-full py-2 overflow-y-auto text-gray-700 dark:text-gray-200"
|
||||
aria-labelledby="aniListSearchButton">
|
||||
{#each aniListSearch.data.Page.media as media}
|
||||
<li class="w-full">
|
||||
<div class="flex w-full items-start p-1 hover:bg-gray-600 hover:text-white rounded-lg">
|
||||
<button on:click={() => {
|
||||
searchDropdown()
|
||||
push(`#/anime/${media.id}`)
|
||||
}}
|
||||
>
|
||||
<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">
|
||||
</button>
|
||||
<button class="rounded-bl-lg rounded-tl-lg w-full h-24" on:click={() => {
|
||||
searchDropdown()
|
||||
push(`#/anime/${media.id}`)
|
||||
}} >{media.title.english === '' || media.title.english === null ? media.title.romaji : media.title.english }</button>
|
||||
</div>
|
||||
</li>
|
||||
{/each}
|
||||
</ul>
|
||||
{:else if aniSearch.length === 0}
|
||||
<div class="m-4">Please enter a search term...</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
0
frontend/src/helperComponents/Sort.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>
|
||||
99
frontend/src/helperComponents/WatchList.svelte
Normal file
@@ -0,0 +1,99 @@
|
||||
<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";
|
||||
import { CheckIfAniListLoggedInAndLoadWatchList } from "../helperModules/CheckIfAniListLoggedInAndLoadWatchList.svelte";
|
||||
|
||||
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"
|
||||
>
|
||||
<div class="flex justify-between items-center mb-4">
|
||||
<h1 class="text-left text-xl font-bold">Your AniList WatchList</h1>
|
||||
<button
|
||||
type="button"
|
||||
class="py-2 px-4 bg-gray-700 rounded-lg"
|
||||
on:click={async () => {
|
||||
loading.set(true);
|
||||
await CheckIfAniListLoggedInAndLoadWatchList();
|
||||
loading.set(false);
|
||||
}}
|
||||
>
|
||||
Refresh WatchList
|
||||
</button>
|
||||
</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
|
||||
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 w-[230px] h-[330px] object-cover"
|
||||
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>
|
||||
32
frontend/src/helperComponents/WebsiteLink.svelte
Normal file
@@ -0,0 +1,32 @@
|
||||
<script lang="ts">
|
||||
import { BrowserOpenURL } from "../../wailsjs/runtime";
|
||||
|
||||
export let id: string;
|
||||
export 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-");
|
||||
if (isAniList || isMAL || isSimkl) newId = id.match(re)[1];
|
||||
else newId = id;
|
||||
}
|
||||
|
||||
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
|
||||
type="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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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,81 @@
|
||||
<script lang="ts" context="module">
|
||||
import {
|
||||
CheckIfAniListLoggedIn,
|
||||
GetAniListLoggedInUser,
|
||||
GetAniListUserWatchingList,
|
||||
} from "../../wailsjs/go/main/App";
|
||||
import {
|
||||
aniListUser,
|
||||
watchListPage,
|
||||
animePerPage,
|
||||
aniListPrimary,
|
||||
aniListLoggedIn,
|
||||
aniListWatchlist,
|
||||
aniListSort,
|
||||
clearApiError,
|
||||
setApiError,
|
||||
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||
|
||||
let isAniListPrimary: boolean;
|
||||
let page: number;
|
||||
let perPage: number;
|
||||
let sort: string;
|
||||
|
||||
aniListPrimary.subscribe((value) => (isAniListPrimary = value));
|
||||
watchListPage.subscribe((value) => (page = value));
|
||||
animePerPage.subscribe((value) => (perPage = value));
|
||||
aniListSort.subscribe((value) => (sort = value));
|
||||
|
||||
export const LoadAniListUser = async () => {
|
||||
try {
|
||||
await GetAniListLoggedInUser().then((user) => {
|
||||
aniListUser.set(user);
|
||||
});
|
||||
} catch (err) {
|
||||
const errorMsg = err instanceof Error ? err.message : String(err);
|
||||
setApiError(
|
||||
"anilist",
|
||||
`Failed to load user: ${errorMsg}`,
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
|
||||
export const LoadAniListWatchList = async () => {
|
||||
try {
|
||||
const watchList = await GetAniListUserWatchingList(page, perPage, sort);
|
||||
aniListWatchlist.set(watchList);
|
||||
clearApiError();
|
||||
} catch (err) {
|
||||
const errorMsg = err instanceof Error ? err.message : String(err);
|
||||
setApiError(
|
||||
"anilist",
|
||||
`Failed to load watch list: ${errorMsg}`,
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
export const CheckIfAniListLoggedInAndLoadWatchList = async () => {
|
||||
try {
|
||||
const loggedIn = await CheckIfAniListLoggedIn();
|
||||
if (loggedIn) {
|
||||
await LoadAniListUser();
|
||||
if (isAniListPrimary) await LoadAniListWatchList();
|
||||
}
|
||||
aniListLoggedIn.set(loggedIn);
|
||||
} catch (err) {
|
||||
const errorMsg = err instanceof Error ? err.message : String(err);
|
||||
setApiError(
|
||||
"anilist",
|
||||
`Authentication failed: ${errorMsg}`,
|
||||
undefined,
|
||||
true,
|
||||
);
|
||||
aniListLoggedIn.set(false);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
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
@@ -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,212 @@
|
||||
<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 watchlistNeedsRefresh = writable(false);
|
||||
export let aniListSort = writable(MediaListSort.UpdatedTimeDesc);
|
||||
|
||||
export let watchListPage = writable(1);
|
||||
export let animePerPage = writable(20);
|
||||
|
||||
let isAniListPrimary: boolean;
|
||||
let page: number;
|
||||
let perPage: number;
|
||||
let sort: string;
|
||||
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));
|
||||
aniListSort.subscribe((value) => (sort = value));
|
||||
|
||||
export interface ApiError {
|
||||
service: string;
|
||||
message: string;
|
||||
statusCode?: string;
|
||||
canRetry: boolean;
|
||||
}
|
||||
export const apiError = writable<ApiError | null>(null);
|
||||
export const isApiDown = writable(false);
|
||||
export function setApiError(
|
||||
service: string,
|
||||
message: string,
|
||||
statusCode?: string,
|
||||
canRetry: boolean = true,
|
||||
) {
|
||||
apiError.set({
|
||||
service,
|
||||
message,
|
||||
statusCode,
|
||||
canRetry,
|
||||
});
|
||||
isApiDown.set(true);
|
||||
}
|
||||
export function clearApiError() {
|
||||
apiError.set(null);
|
||||
isApiDown.set(false);
|
||||
}
|
||||
|
||||
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, sort).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
@@ -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
@@ -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
|
||||
}
|
||||
164
frontend/src/mal/types/MALTypes.ts
Normal file
@@ -0,0 +1,164 @@
|
||||
export interface MyAnimeListUser {
|
||||
id: number
|
||||
name: string
|
||||
picture: string
|
||||
gender: string
|
||||
birthday: string
|
||||
location: string
|
||||
joinedAt: string
|
||||
AnimeStatistics: AnimeStatistics
|
||||
timeZone: string
|
||||
isSupporter: boolean
|
||||
|
||||
}
|
||||
|
||||
export interface AnimeStatistics {
|
||||
numItemsWatching: number
|
||||
numItemsCompleted: number
|
||||
numItemsOnHold: number
|
||||
numItemsDropped: number
|
||||
numItemsPlanToWatch: number
|
||||
numItems: number
|
||||
numDaysWatched: number
|
||||
numDaysWatching: number
|
||||
numDaysCompleted: number
|
||||
numDaysOnHold: number
|
||||
numDaysDropped: number
|
||||
numDays: number
|
||||
numEpisodes: number
|
||||
numTimesRewatched: 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
|
||||
}
|
||||
23
frontend/src/routes/AnimeRoutePage.svelte
Normal file
@@ -0,0 +1,23 @@
|
||||
<script lang="ts">
|
||||
import { aniListAnime, GetAnimeSingleItem } from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
|
||||
import Anime from "../helperComponents/Anime.svelte"
|
||||
import { AniListGetSingleAnimeDefaultData } from "../helperDefaults/AniListGetSingleAnime";
|
||||
import Spinner from "../helperComponents/Spinner.svelte";
|
||||
|
||||
export let params: Record<string, string>
|
||||
let loadPromise = load(params.id)
|
||||
$: loadPromise = load(params.id)
|
||||
|
||||
async function load(id: string) {
|
||||
aniListAnime.update(() => AniListGetSingleAnimeDefaultData)
|
||||
await GetAnimeSingleItem(Number(id), true)
|
||||
}
|
||||
</script>
|
||||
|
||||
{#key params.id}
|
||||
{#await loadPromise}
|
||||
<Spinner />
|
||||
{:then _}
|
||||
<Anime />
|
||||
{/await}
|
||||
{/key}
|
||||
55
frontend/src/routes/Home.svelte
Normal file
@@ -0,0 +1,55 @@
|
||||
<script lang="ts">
|
||||
import Pagination from "../helperComponents/Pagination.svelte";
|
||||
import WatchList from "../helperComponents/WatchList.svelte";
|
||||
import {
|
||||
aniListLoggedIn,
|
||||
aniListPrimary,
|
||||
loading,
|
||||
isApiDown,
|
||||
apiError,
|
||||
} 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 $isApiDown}
|
||||
<div class="container py-10">
|
||||
<div
|
||||
class="bg-yellow-50 border border-yellow-200 rounded-lg p-6 text-center"
|
||||
>
|
||||
<svg
|
||||
class="mx-auto h-12 w-12 text-yellow-600 mb-4"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
stroke="currentColor"
|
||||
>
|
||||
<path
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="2"
|
||||
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"
|
||||
/>
|
||||
</svg>
|
||||
<h2 class="text-xl font-semibold text-yellow-900 mb-2">
|
||||
API Unavailable
|
||||
</h2>
|
||||
<p class="text-yellow-700 mb-4">
|
||||
The {$apiError?.service || "service"} is currently unavailable. The app will
|
||||
remain open, and you can retry when the service is back online.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{:else if isAniListLoggedIn && isAniListPrimary}
|
||||
<div class="container py-10">
|
||||
<Pagination />
|
||||
<WatchList />
|
||||
<Pagination />
|
||||
</div>
|
||||
{:else}
|
||||
<div use:loader={loading}></div>
|
||||
{/if}
|
||||
76
frontend/src/simkl/types/simklTypes.ts
Normal file
@@ -0,0 +1,76 @@
|
||||
export type SimklUser = {
|
||||
user: {
|
||||
name: string,
|
||||
joined_at: string,
|
||||
gender: string,
|
||||
avatar: string,
|
||||
bio: string,
|
||||
loc: string,
|
||||
age: string,
|
||||
},
|
||||
account: {
|
||||
id: number,
|
||||
timezone: string,
|
||||
type: string,
|
||||
},
|
||||
connections: {
|
||||
facebook: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export type SimklWatchList = {
|
||||
anime: [SimklAnime]
|
||||
currentIndex: number
|
||||
}
|
||||
|
||||
export type SimklAnime = {
|
||||
last_watched_at: string,
|
||||
status: string
|
||||
user_rating: number,
|
||||
last_watched: string,
|
||||
next_to_watch: string,
|
||||
watched_episodes_count: number,
|
||||
total_episodes_count: number,
|
||||
not_aired_episodes_count: number,
|
||||
show: {
|
||||
title: string,
|
||||
poster: string,
|
||||
ids: {
|
||||
simkl: number,
|
||||
slug: string,
|
||||
offjp: string,
|
||||
tw: string,
|
||||
ann: string,
|
||||
mal: string,
|
||||
wikien: string,
|
||||
wikijp: string,
|
||||
allcin: string,
|
||||
imdb: string,
|
||||
offen: string,
|
||||
crunchyroll: string,
|
||||
tvdbslug: string,
|
||||
anilist: string,
|
||||
animeplanet: string,
|
||||
anisearch: string,
|
||||
kitsu: string,
|
||||
livechart: string,
|
||||
traktslug: string,
|
||||
anidb: string,
|
||||
}
|
||||
},
|
||||
anime_type: string
|
||||
}
|
||||
|
||||
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
@@ -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
@@ -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;
|
||||
}
|
||||
|
||||
.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-family: "Nunito";
|
||||
font-style: normal;
|
||||
@@ -24,6 +30,14 @@ body {
|
||||
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 {
|
||||
height: 100vh;
|
||||
text-align: center;
|
||||
|
||||
@@ -1,24 +1,44 @@
|
||||
import flowbitePlugin from 'flowbite/plugin'
|
||||
/** @type {import('tailwindcss').Config} */
|
||||
export default {
|
||||
content: [
|
||||
"./index.html",
|
||||
"./src/**/*.{svelte,js,ts,jsx,tsx}",
|
||||
"./node_modules/flowbite/**/*.{html,js,svelte,ts}",
|
||||
"./node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}",
|
||||
],
|
||||
plugins: [
|
||||
require('flowbite/plugin')
|
||||
],
|
||||
content: [
|
||||
"./index.html",
|
||||
"./src/**/*.{svelte,js,ts,jsx,tsx}",
|
||||
"./node_modules/flowbite/**/*.{html,js,svelte,ts}",
|
||||
"./node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}",
|
||||
],
|
||||
plugins: [ flowbitePlugin ],
|
||||
|
||||
darkMode: 'media',
|
||||
darkMode: 'media',
|
||||
|
||||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
// flowbite-svelte
|
||||
primary: { 50: '#FFF5F2', 100: '#FFF1EE', 200: '#FFE4DE', 300: '#FFD5CC', 400: '#FFBCAD', 500: '#FE795D', 600: '#EF562F', 700: '#EB4F27', 800: '#CC4522', 900: '#A5371B'},
|
||||
}
|
||||
theme: {
|
||||
container: {
|
||||
center: true,
|
||||
padding: {
|
||||
DEFAULT: '1rem',
|
||||
sm: '2rem',
|
||||
lg: '4rem',
|
||||
xl: '5rem',
|
||||
'2xl': '6rem',
|
||||
},
|
||||
},
|
||||
extend: {
|
||||
colors: {
|
||||
// flowbite-svelte
|
||||
primary: {
|
||||
50: '#FFF5F2',
|
||||
100: '#FFF1EE',
|
||||
200: '#FFE4DE',
|
||||
300: '#FFD5CC',
|
||||
400: '#FFBCAD',
|
||||
500: '#FE795D',
|
||||
600: '#EF562F',
|
||||
700: '#EB4F27',
|
||||
800: '#CC4522',
|
||||
900: '#A5371B'
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
46
frontend/wailsjs/go/main/App.d.ts
vendored
@@ -2,20 +2,58 @@
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
import {main} from '../models';
|
||||
|
||||
export function AniListDeleteEntry(arg1:number):Promise<main.DeleteAniListReturn>;
|
||||
|
||||
export function AniListLogin():Promise<void>;
|
||||
|
||||
export function AniListSearch(arg1:string):Promise<any>;
|
||||
|
||||
export function AniListUpdateEntry(arg1:number,arg2:string,arg3:string,arg4:number,arg5:number,arg6:string,arg7:number,arg8:number,arg9:number,arg10:number,arg11:number,arg12:number):Promise<any>;
|
||||
export function AniListUpdateEntry(arg1:main.AniListUpdateVariables):Promise<main.AniListGetSingleAnime>;
|
||||
|
||||
export function CheckIfAniListLoggedIn():Promise<boolean>;
|
||||
|
||||
export function CheckIfMyAnimeListLoggedIn():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 GetAniListLoggedInUserId():Promise<main.AniListUser>;
|
||||
export function GetAniListLoggedInUser():Promise<main.AniListUser>;
|
||||
|
||||
export function GetAniListUserWatchingList(arg1:number,arg2:number,arg3:string):Promise<main.AniListCurrentUserWatchList>;
|
||||
|
||||
export function GetSimklLoggedInUserId():Promise<main.SimklUser>;
|
||||
export function GetMyAnimeList(arg1:number):Promise<main.MALWatchlist>;
|
||||
|
||||
export function Greet(arg1:string):Promise<string>;
|
||||
export function GetMyAnimeListAnime(arg1:number):Promise<main.MALAnime>;
|
||||
|
||||
export function GetMyAnimeListLoggedInUser():Promise<main.MyAnimeListUser>;
|
||||
|
||||
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 MyAnimeListUpdate(arg1:main.MALAnime,arg2:main.MALUploadStatus):Promise<main.MalListStatus>;
|
||||
|
||||
export function ShowVersion():Promise<void>;
|
||||
|
||||
export function SimklGetUserWatchlist():Promise<main.SimklWatchListType>;
|
||||
|
||||
export function SimklLogin():Promise<void>;
|
||||
|
||||
export function SimklSearch(arg1:main.MediaList):Promise<main.SimklAnime>;
|
||||
|
||||
export function SimklSyncEpisodes(arg1:main.SimklAnime,arg2:number):Promise<main.SimklAnime>;
|
||||
|
||||
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
|
||||
// This file is automatically generated. DO NOT EDIT
|
||||
|
||||
export function AniListDeleteEntry(arg1) {
|
||||
return window['go']['main']['App']['AniListDeleteEntry'](arg1);
|
||||
}
|
||||
|
||||
export function AniListLogin() {
|
||||
return window['go']['main']['App']['AniListLogin']();
|
||||
}
|
||||
@@ -10,30 +14,102 @@ export function AniListSearch(arg1) {
|
||||
return window['go']['main']['App']['AniListSearch'](arg1);
|
||||
}
|
||||
|
||||
export function AniListUpdateEntry(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12) {
|
||||
return window['go']['main']['App']['AniListUpdateEntry'](arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10, arg11, arg12);
|
||||
export function AniListUpdateEntry(arg1) {
|
||||
return window['go']['main']['App']['AniListUpdateEntry'](arg1);
|
||||
}
|
||||
|
||||
export function CheckIfAniListLoggedIn() {
|
||||
return window['go']['main']['App']['CheckIfAniListLoggedIn']();
|
||||
}
|
||||
|
||||
export function CheckIfMyAnimeListLoggedIn() {
|
||||
return window['go']['main']['App']['CheckIfMyAnimeListLoggedIn']();
|
||||
}
|
||||
|
||||
export function CheckIfSimklLoggedIn() {
|
||||
return window['go']['main']['App']['CheckIfSimklLoggedIn']();
|
||||
}
|
||||
|
||||
export function DeleteMyAnimeListEntry(arg1) {
|
||||
return window['go']['main']['App']['DeleteMyAnimeListEntry'](arg1);
|
||||
}
|
||||
|
||||
export function GetAniListItem(arg1, arg2) {
|
||||
return window['go']['main']['App']['GetAniListItem'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function GetAniListLoggedInUserId() {
|
||||
return window['go']['main']['App']['GetAniListLoggedInUserId']();
|
||||
export function GetAniListLoggedInUser() {
|
||||
return window['go']['main']['App']['GetAniListLoggedInUser']();
|
||||
}
|
||||
|
||||
export function GetAniListUserWatchingList(arg1, arg2, arg3) {
|
||||
return window['go']['main']['App']['GetAniListUserWatchingList'](arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
export function GetSimklLoggedInUserId() {
|
||||
return window['go']['main']['App']['GetSimklLoggedInUserId']();
|
||||
export function GetMyAnimeList(arg1) {
|
||||
return window['go']['main']['App']['GetMyAnimeList'](arg1);
|
||||
}
|
||||
|
||||
export function Greet(arg1) {
|
||||
return window['go']['main']['App']['Greet'](arg1);
|
||||
export function GetMyAnimeListAnime(arg1) {
|
||||
return window['go']['main']['App']['GetMyAnimeListAnime'](arg1);
|
||||
}
|
||||
|
||||
export function GetMyAnimeListLoggedInUser() {
|
||||
return window['go']['main']['App']['GetMyAnimeListLoggedInUser']();
|
||||
}
|
||||
|
||||
export function 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() {
|
||||
return window['go']['main']['App']['MyAnimeListLogin']();
|
||||
}
|
||||
|
||||
export function MyAnimeListUpdate(arg1, arg2) {
|
||||
return window['go']['main']['App']['MyAnimeListUpdate'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function ShowVersion() {
|
||||
return window['go']['main']['App']['ShowVersion']();
|
||||
}
|
||||
|
||||
export function SimklGetUserWatchlist() {
|
||||
return window['go']['main']['App']['SimklGetUserWatchlist']();
|
||||
}
|
||||
|
||||
export function SimklLogin() {
|
||||
return window['go']['main']['App']['SimklLogin']();
|
||||
}
|
||||
|
||||
export function SimklSearch(arg1) {
|
||||
return window['go']['main']['App']['SimklSearch'](arg1);
|
||||
}
|
||||
|
||||
export function SimklSyncEpisodes(arg1, arg2) {
|
||||
return window['go']['main']['App']['SimklSyncEpisodes'](arg1, arg2);
|
||||
}
|
||||
|
||||
export function 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) {
|
||||
return window['go']['main']['App']['SimklSyncStatus'](arg1, arg2);
|
||||
}
|
||||
|
||||
@@ -60,8 +60,84 @@ export namespace main {
|
||||
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 {
|
||||
// Go type: struct { Viewer struct { ID int "json:\"id\""; Name string "json:\"name\"" } "json:\"Viewer\"" }
|
||||
// Go type: struct { Viewer struct { ID int "json:\"id\""; Name string "json:\"name\""; Avatar struct { Large string "json:\"large\""; Medium string "json:\"medium\"" } "json:\"avatar\""; BannerImage string "json:\"bannerImage\""; SiteUrl string "json:\"siteUrl\"" } "json:\"Viewer\"" }
|
||||
data: any;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
@@ -91,11 +167,204 @@ export namespace main {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
|
||||
export class DeleteAniListReturn {
|
||||
// Go type: struct { DeleteMediaListEntry struct { Deleted bool "json:\"deleted\"" } "json:\"DeleteMediaListEntry\"" }
|
||||
data: any;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new DeleteAniListReturn(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
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.my_list_status = source["my_list_status"];
|
||||
this.num_episodes = source["num_episodes"];
|
||||
this.start_season = source["start_season"];
|
||||
this.broadcast = source["broadcast"];
|
||||
this.source = source["source"];
|
||||
this.average_episode_duration = source["average_episode_duration"];
|
||||
this.rating = source["rating"];
|
||||
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 {
|
||||
id: number;
|
||||
mediaId: number;
|
||||
userId: number;
|
||||
// Go type: struct { ID int "json:\"id\""; IDMal int "json:\"idMal\""; Title struct { Romaji string "json:\"romaji\""; English string "json:\"english\""; Native string "json:\"native\"" } "json:\"title\""; Description string "json:\"description\""; CoverImage struct { Large string "json:\"large\"" } "json:\"coverImage\""; Season string "json:\"season\""; SeasonYear int "json:\"seasonYear\""; Status string "json:\"status\""; Episodes int "json:\"episodes\""; NextAiringEpisode struct { AiringAt int "json:\"airingAt\""; TimeUntilAiring int "json:\"timeUntilAiring\""; Episode int "json:\"episode\"" } "json:\"nextAiringEpisode\"" }
|
||||
// Go type: struct { ID int "json:\"id\""; IDMal int "json:\"idMal\""; Title struct { Romaji string "json:\"romaji\""; English string "json:\"english\""; Native string "json:\"native\"" } "json:\"title\""; Description string "json:\"description\""; CoverImage struct { Large string "json:\"large\"" } "json:\"coverImage\""; Season string "json:\"season\""; SeasonYear int "json:\"seasonYear\""; Status string "json:\"status\""; Episodes int "json:\"episodes\""; NextAiringEpisode struct { AiringAt int "json:\"airingAt\""; TimeUntilAiring int "json:\"timeUntilAiring\""; Episode int "json:\"episode\"" } "json:\"nextAiringEpisode\""; Genres []string "json:\"genres\""; Tags []struct { Id int "json:\"id\""; Name string "json:\"name\""; Description string "json:\"description\""; Rank int "json:\"rank\""; IsMediaSpoiler bool "json:\"isMediaSpoiler\""; IsAdult bool "json:\"isAdult\"" } "json:\"tags\""; IsAdult bool "json:\"isAdult\"" }
|
||||
media: any;
|
||||
status: string;
|
||||
// Go type: struct { Year int "json:\"year\""; Month int "json:\"month\""; Day int "json:\"day\"" }
|
||||
@@ -147,9 +416,98 @@ export namespace main {
|
||||
return a;
|
||||
}
|
||||
}
|
||||
export class MyAnimeListUser {
|
||||
id: id;
|
||||
name: name;
|
||||
picture: picture;
|
||||
gender: gender;
|
||||
birthday: birthday;
|
||||
location: location;
|
||||
joined_at: joinedAt;
|
||||
num_items_watching: numItemsWatching;
|
||||
num_items_completed: numItemsCompleted;
|
||||
num_items_on_hold: numItemsOnHold;
|
||||
num_items_dropped: numItemsDropped;
|
||||
num_items_plan_to_watch: numItemsPlanToWatch;
|
||||
num_items: numItems;
|
||||
num_days_watched: numDaysWatched;
|
||||
num_days_watching: numDaysWatching;
|
||||
num_days_completed: numDaysCompleted;
|
||||
num_days_on_hold: numDaysOnHold;
|
||||
num_days_dropped: numDaysDropped;
|
||||
num_days: numDays;
|
||||
num_episodes: numEpisodes;
|
||||
num_times_rewatched: numTimesRewatched;
|
||||
mean_score: meanScore;
|
||||
time_zone: timeZone;
|
||||
is_supporter: isSupporter;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new MyAnimeListUser(source);
|
||||
}
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.id = source["id"];
|
||||
this.name = source["name"];
|
||||
this.picture = source["picture"];
|
||||
this.gender = source["gender"];
|
||||
this.birthday = source["birthday"];
|
||||
this.location = source["location"];
|
||||
this.joined_at = source["joined_at"];
|
||||
this.num_items_watching = source["num_items_watching"];
|
||||
this.num_items_completed = source["num_items_completed"];
|
||||
this.num_items_on_hold = source["num_items_on_hold"];
|
||||
this.num_items_dropped = source["num_items_dropped"];
|
||||
this.num_items_plan_to_watch = source["num_items_plan_to_watch"];
|
||||
this.num_items = source["num_items"];
|
||||
this.num_days_watched = source["num_days_watched"];
|
||||
this.num_days_watching = source["num_days_watching"];
|
||||
this.num_days_completed = source["num_days_completed"];
|
||||
this.num_days_on_hold = source["num_days_on_hold"];
|
||||
this.num_days_dropped = source["num_days_dropped"];
|
||||
this.num_days = source["num_days"];
|
||||
this.num_episodes = source["num_episodes"];
|
||||
this.num_times_rewatched = source["num_times_rewatched"];
|
||||
this.mean_score = source["mean_score"];
|
||||
this.time_zone = source["time_zone"];
|
||||
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 {
|
||||
// Go type: struct { Viewer struct { ID int "json:\"id\""; Name string "json:\"name\"" } "json:\"Viewer\"" }
|
||||
data: any;
|
||||
user: user;
|
||||
account: account;
|
||||
connections: connections;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new SimklUser(source);
|
||||
@@ -157,26 +515,22 @@ export namespace main {
|
||||
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.data = this.convertValues(source["data"], Object);
|
||||
this.user = source["user"];
|
||||
this.account = source["account"];
|
||||
this.connections = source["connections"];
|
||||
}
|
||||
}
|
||||
export class SimklWatchListType {
|
||||
anime: anime;
|
||||
|
||||
static createFrom(source: any = {}) {
|
||||
return new SimklWatchListType(source);
|
||||
}
|
||||
|
||||
convertValues(a: any, classs: any, asMap: boolean = false): any {
|
||||
if (!a) {
|
||||
return a;
|
||||
}
|
||||
if (a.slice && a.map) {
|
||||
return (a as any[]).map(elem => this.convertValues(elem, classs));
|
||||
} else if ("object" === typeof a) {
|
||||
if (asMap) {
|
||||
for (const key of Object.keys(a)) {
|
||||
a[key] = new classs(a[key]);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
return new classs(a);
|
||||
}
|
||||
return a;
|
||||
}
|
||||
constructor(source: any = {}) {
|
||||
if ('string' === typeof source) source = JSON.parse(source);
|
||||
this.anime = source["anime"];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -216,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"];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
2
frontend/wailsjs/runtime/runtime.d.ts
vendored
@@ -134,7 +134,7 @@ export function WindowIsFullscreen(): Promise<boolean>;
|
||||
|
||||
// [WindowSetSize](https://wails.io/docs/reference/runtime/window#windowsetsize)
|
||||
// Sets the width and height of the window.
|
||||
export function WindowSetSize(width: number, height: number): Promise<Size>;
|
||||
export function WindowSetSize(width: number, height: number): void;
|
||||
|
||||
// [WindowGetSize](https://wails.io/docs/reference/runtime/window#windowgetsize)
|
||||
// Gets the width and height of the window.
|
||||
|
||||
36
go.mod
@@ -1,49 +1,49 @@
|
||||
module AniTrack
|
||||
|
||||
go 1.21
|
||||
|
||||
toolchain go1.21.11
|
||||
go 1.24.0
|
||||
|
||||
require (
|
||||
github.com/99designs/keyring v1.2.2
|
||||
github.com/joho/godotenv v1.5.1
|
||||
github.com/wailsapp/wails/v2 v2.9.1
|
||||
github.com/tidwall/gjson v1.18.0
|
||||
github.com/wailsapp/wails/v2 v2.10.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/99designs/go-keychain v0.0.0-20191008050251-8e49817e8af4 // indirect
|
||||
github.com/bep/debounce v1.2.1 // indirect
|
||||
github.com/danieljoos/wincred v1.1.2 // indirect
|
||||
github.com/dvsekhvalnov/jose2go v1.5.0 // indirect
|
||||
github.com/danieljoos/wincred v1.2.2 // indirect
|
||||
github.com/dvsekhvalnov/jose2go v1.8.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/v5 v5.1.0 // indirect
|
||||
github.com/google/uuid v1.6.0 // 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/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/leaanthony/go-ansi-parser v1.6.1 // indirect
|
||||
github.com/leaanthony/gosod v1.0.4 // indirect
|
||||
github.com/leaanthony/slicer v1.6.0 // 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/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/rivo/uniseg v0.4.7 // indirect
|
||||
github.com/samber/lo v1.46.0 // indirect
|
||||
github.com/tkrajina/go-reflector v0.5.6 // indirect
|
||||
github.com/samber/lo v1.49.1 // 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/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
|
||||
golang.org/x/crypto v0.25.0 // indirect
|
||||
golang.org/x/net v0.27.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/term v0.22.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
golang.org/x/crypto v0.45.0 // indirect
|
||||
golang.org/x/net v0.47.0 // indirect
|
||||
golang.org/x/sys v0.38.0 // indirect
|
||||
golang.org/x/term v0.37.0 // indirect
|
||||
golang.org/x/text v0.31.0 // indirect
|
||||
)
|
||||
|
||||
// replace github.com/wailsapp/wails/v2 v2.9.1 => /home/nymusicman/go/pkg/mod
|
||||
|
||||
85
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/bep/debounce v1.2.1 h1:v67fRdBA9UQu2NhLFXrSg0Brw7CexQekrBwDMM8bzeY=
|
||||
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.1.2/go.mod h1:GijpziifJoIBfYh+S7BbkdUTU4LfM+QnGqR5Vl2tAx0=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/danieljoos/wincred v1.2.2 h1:774zMFJrqaeYCK2W57BgAem/MLi6mtSE47MB6BOJ0i0=
|
||||
github.com/danieljoos/wincred v1.2.2/go.mod h1:w7w4Utbrz8lqeMbDAK0lkNJUv5sAOkFi7nd/ogr0Uh8=
|
||||
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/dvsekhvalnov/jose2go v1.5.0 h1:3j8ya4Z4kMCwT5nXIKFSV84YS+HdqSSO0VsTQxaLAeM=
|
||||
github.com/dvsekhvalnov/jose2go v1.5.0/go.mod h1:QsHjhyTlD/lAVqn/NSbVZmSCGeDehTB/mPZadG+mhXU=
|
||||
github.com/dvsekhvalnov/jose2go v1.8.0 h1:LqkkVKAlHFfH9LOEl5fe4p/zL02OhWE7pCufMBG2jLA=
|
||||
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/go.mod h1:5LS6F96DhAwUc7C+1HLexzMXY1xGRSryjyPPKW6zv78=
|
||||
github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 h1:ZpnhV/YsD2/4cESfV5+Hoeu/iUR3ruzNvZ+yQfO03a0=
|
||||
@@ -23,13 +22,12 @@ 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/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/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/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
|
||||
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.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/labstack/echo/v4 v4.13.3 h1:pwhpCPrTl5qry5HRdM5FwdXnhXSLSY+WE+YQSeCaafY=
|
||||
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/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU=
|
||||
github.com/leaanthony/debme v1.2.1 h1:9Tgwf+kjcrbMQ4WnPcEIUcQuIZYqdWftzZkBr+i/oOc=
|
||||
@@ -45,17 +43,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.1 h1:55ehd8zaGABKLXQUe2awZ99BD/PTc2ls+KV/dXphgEQ=
|
||||
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.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-colorable v0.1.14 h1:9A9LHSqF/7dyVVX6g0U9cwm9pG3kP9gSzcuIPHPsaIE=
|
||||
github.com/mattn/go-colorable v0.1.14/go.mod h1:6LmQG8QLFO4G5z1gPvYEzlUgJ2wF+stgPZH1UqBm1s8=
|
||||
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/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/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/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
|
||||
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8/go.mod h1:HKlIX3XHQyzLZPlr7++PzdhaXEj94dEiJgZDTsxEqUI=
|
||||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ=
|
||||
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/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
@@ -63,51 +60,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.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ=
|
||||
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.46.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As=
|
||||
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/tkrajina/go-reflector v0.5.6 h1:hKQ0gyocG7vgMD2M3dRlYN6WBBOmdoOzJ6njQSepKdE=
|
||||
github.com/tkrajina/go-reflector v0.5.6/go.mod h1:ECbqLgccecY5kPmPmXg1MrHW585yMcDkVl6IvJe64T4=
|
||||
github.com/samber/lo v1.49.1 h1:4BIFyVfuQSEpluc7Fua+j1NolZHiEHEpaSEKdsH0tew=
|
||||
github.com/samber/lo v1.49.1/go.mod h1:dO6KHFzUKXgP8LDhU0oI8d2hekjXnGOu0DB8Jecxd6o=
|
||||
github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY=
|
||||
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/tidwall/gjson v1.18.0 h1:FIDeeyB800efLX89e5a8Y0BNH+LOngJyGrIWxG2FKQY=
|
||||
github.com/tidwall/gjson v1.18.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
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/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
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/wailsapp/go-webview2 v1.0.10 h1:PP5Hug6pnQEAhfRzLCoOh2jJaPdrqeRgJKZhyYyDV/w=
|
||||
github.com/wailsapp/go-webview2 v1.0.10/go.mod h1:Uk2BePfCRzttBBjFrBmqKGJd41P6QIHeV9kTgIeOZNo=
|
||||
github.com/wailsapp/go-webview2 v1.0.19 h1:7U3QcDj1PrBPaxJNCui2k1SkWml+Q5kvFUFyTImA6NU=
|
||||
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/go.mod h1:9aV5k31bBOv5z6u+QP8TltzvNGJPmNJD4XlAL3U+j3o=
|
||||
github.com/wailsapp/wails/v2 v2.9.1 h1:irsXnoQrCpeKzKTYZ2SUVlRRyeMR6I0vCO9Q1cvlEdc=
|
||||
github.com/wailsapp/wails/v2 v2.9.1/go.mod h1:7maJV2h+Egl11Ak8QZN/jlGLj2wg05bsQS+ywJPT0gI=
|
||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||
github.com/wailsapp/wails/v2 v2.10.1 h1:QWHvWMXII2nI/nXz77gpPG8P3ehl6zKe+u4su5BWIns=
|
||||
github.com/wailsapp/wails/v2 v2.10.1/go.mod h1:zrebnFV6MQf9kx8HI4iAv63vsR5v67oS7GTEZ7Pz1TY=
|
||||
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
|
||||
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
|
||||
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.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||
golang.org/x/net v0.47.0 h1:Mx+4dIFzqraBXUugkia1OOvlD6LemFo1ALMHjrXDOhY=
|
||||
golang.org/x/net v0.47.0/go.mod h1:/jNxtkgq5yWUGYkaZGqo27cfGZ1c5Nen03aYrrKpVRU=
|
||||
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-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.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.38.0 h1:3yZWxaJjBmCWXqhN1qh02AkOnCQ1poK6oF+a7xWL6Gc=
|
||||
golang.org/x/sys v0.38.0/go.mod h1:OgkHotnGiDImocRcuBABYBEXf8A9a87e/uXjp9XT3ks=
|
||||
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.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=
|
||||
golang.org/x/term v0.37.0 h1:8EGAD0qCmHYZg6J17DvsMy9/wJ7/D/4pV/wfnld5lTU=
|
||||
golang.org/x/term v0.37.0/go.mod h1:5pB4lxRNYYVZuTLmy8oR2BH8dflOR+IbTYFD8fi3254=
|
||||
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.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/text v0.31.0 h1:aC8ghyu4JhP8VojJ2lEHBnochRno1sgL6nEi9WGFGMM=
|
||||
golang.org/x/text v0.31.0/go.mod h1:tKRAlv61yKIjGGHX/4tP1LTbc13YSec1pxVEWXzfoeM=
|
||||
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/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/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
|
||||
22
main.go
@@ -2,20 +2,13 @@ package main
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"github.com/joho/godotenv"
|
||||
|
||||
"github.com/wailsapp/wails/v2"
|
||||
"github.com/wailsapp/wails/v2/pkg/options"
|
||||
"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
|
||||
var assets embed.FS
|
||||
|
||||
@@ -33,11 +26,20 @@ func main() {
|
||||
},
|
||||
BackgroundColour: &options.RGBA{R: 27, G: 38, B: 54, A: 1},
|
||||
OnStartup: app.startup,
|
||||
SingleInstanceLock: &options.SingleInstanceLock{
|
||||
UniqueId: "49c93b6d-663d-4b7a-9cb0-8a469ea9182b",
|
||||
OnSecondInstanceLaunch: app.onSecondInstanceLaunch,
|
||||
},
|
||||
Bind: []interface{}{
|
||||
app,
|
||||
},
|
||||
Linux: &linux.Options{
|
||||
Icon: []byte("./build/AniTrack.png"),
|
||||
WindowIsTranslucent: false,
|
||||
WebviewGpuPolicy: linux.WebviewGpuPolicyNever,
|
||||
ProgramName: "AniTrack",
|
||||
},
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
println("Error:", err.Error())
|
||||
}
|
||||
|
||||
@@ -9,5 +9,9 @@
|
||||
"author": {
|
||||
"name": "John O'Keefe",
|
||||
"email": "jokeefe@fastmail.com"
|
||||
},
|
||||
"info": {
|
||||
"productName": "AniTrack",
|
||||
"productVersion": "0.7.0"
|
||||
}
|
||||
}
|
||||
|
||||