11 Commits

11 changed files with 220 additions and 72 deletions

View File

@ -360,27 +360,47 @@ func (a *App) GetAniListUserWatchingList(page int, perPage int, sort string) Ani
},
}
returnedBody, _ := AniListQuery(body, true)
returnedBody, status := AniListQuery(body, true)
var badPost struct {
Errors []struct {
Message string `json:"message"`
Status int `json:"status"`
Locations []struct {
Line int `json:"line"`
Column int `json:"column"`
} `json:"locations"`
} `json:"errors"`
Data any `json:"data"`
}
var post AniListCurrentUserWatchList
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
post.Data.Page.PageInfo.Total = total
post.Data.Page.PageInfo.LastPage = lastPage
if status == "403 Forbidden" {
err := json.Unmarshal(returnedBody, &badPost)
if err != nil {
log.Printf("Failed at unmarshal, %s\n", err)
}
log.Fatal(badPost.Errors[0].Message)
}
return post
}

View 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
}
}

View File

@ -25,7 +25,7 @@ body:graphql {
media {
id
idMal
tags{
tags {
id
name
description

View File

@ -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>

Binary file not shown.

View File

@ -193,9 +193,9 @@
};
await AniListUpdateEntry(body).then(
(value: AniListGetSingleAnime) => {
// in future when you inevitably add tags to typescript, until Anilist fixes the api bug
// where tags break the SaveMediaListEntry return, you'll want to use this delete line
// delete value.data.MediaList.media.tags
/* TODO in future when you inevitably add tags to typescript, until Anilist fixes the api bug
where tags break the SaveMediaListEntry return, you'll want to use this delete line
delete value.data.MediaList.media.tags */
aniListAnime.update((newValue) => {
newValue = value;
return newValue;
@ -397,6 +397,16 @@
submitSuccess.set(true);
setTimeout(() => submitSuccess.set(false), 2000);
};
let max = 999
if (currentAniListAnime.data.MediaList.media.episodes !== 0) {
max = currentAniListAnime.data.MediaList.media.episodes
}
if (currentAniListAnime.data.MediaList.media.episodes === 0 &&
currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode !== 0) {
max = currentAniListAnime.data.MediaList.media.nextAiringEpisode.episode - 1
}
</script>
<form on:submit|preventDefault={handleSubmit} class="container pt-3 pb-10">
@ -427,7 +437,7 @@
type="number"
name="episodes"
min="0"
max={currentAniListAnime.data.MediaList.media.episodes}
max={max}
id="episodes"
class="border {currentAniListAnime.data.MediaList
.progress < 0 ||
@ -441,9 +451,18 @@
bind:value={currentAniListAnime.data.MediaList.progress}
required
/>
<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>

View File

@ -4,20 +4,31 @@
import {
aniListLoggedIn,
aniListUser,
malUser,
simklUser,
malLoggedIn,
simklLoggedIn,
loginToAniList,
loginToMAL,
loginToSimkl,
logoutOfAniList,
logoutOfMAL,
logoutOfSimkl,
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte";
import * as runtime from "../../wailsjs/runtime";
import type {MyAnimeListUser} from "../mal/types/MALTypes";
import type {SimklUser} from "../simkl/types/simklTypes";
let currentAniListUser: AniListUser;
let currentMALUser: MyAnimeListUser;
let currentSimklUser: SimklUser;
let isAniListLoggedIn: boolean;
let isSimklLoggedIn: boolean;
let isMALLoggedIn: boolean;
aniListUser.subscribe((value) => (currentAniListUser = value));
malUser.subscribe((value) => (currentMALUser = value))
simklUser.subscribe(value => currentSimklUser = value)
aniListLoggedIn.subscribe((value) => (isAniListLoggedIn = value));
simklLoggedIn.subscribe((value) => (isSimklLoggedIn = value));
malLoggedIn.subscribe((value) => (isMALLoggedIn = value));
@ -59,9 +70,16 @@
<li>
<button
on:click={logoutOfAniList}
class="block px-4 py-2 w-full hover:bg-gray-600 hover:text-white"
class="block px-4 py-2 w-full hover:bg-gray-600 truncate bg-green-800 hover:text-white"
>
Logout Anilist
<span class="maple-font text-lg text-green-200 mr-4">A</span>Logout {currentAniListUser.data.Viewer.name}
</button>
</li>
{:else}
<li>
<button on:click={loginToAniList}
class="block px-4 py-2 w-full hover:bg-gray-600 truncate hover:text-white">
<span class="maple-font text-lg mr-4">A</span>Login to AniList
</button>
</li>
{/if}
@ -69,9 +87,16 @@
<li>
<button
on:click={logoutOfMAL}
class="block px-4 py-2 w-full hover:bg-gray-600 hover:text-white"
class="block px-4 py-2 w-full hover:bg-gray-600 truncate bg-blue-800 hover:text-white"
>
Logout MAL
<span class="maple-font text-lg text-blue-200 mr-4">M</span>Logout {currentMALUser.name}
</button>
</li>
{:else}
<li>
<button on:click={loginToMAL}
class="block px-4 py-2 w-full hover:bg-gray-600 truncate hover:text-white">
<span class="maple-font text-lg mr-4">M</span>Login to MyAnimeList
</button>
</li>
{/if}
@ -79,9 +104,16 @@
<li>
<button
on:click={logoutOfSimkl}
class="block px-4 py-2 w-full hover:bg-gray-600 hover:text-white"
class="block px-4 py-2 w-full hover:bg-gray-600 truncate bg-indigo-800 hover:text-white"
>
Logout Simkl
<span class="maple-font text-lg text-indigo-200 mr-4">S</span>Logout {currentSimklUser.user.name}
</button>
</li>
{:else}
<li>
<button on:click={loginToSimkl}
class="block px-4 py-2 w-full hover:bg-gray-600 truncate hover:text-white">
<span class="maple-font text-lg mr-4">S</span>Login to Simkl
</button>
</li>
{/if}
@ -95,5 +127,4 @@
</button>
</div>
</div>
</div>
</div>

View File

@ -2,38 +2,22 @@
import Search from "./Search.svelte"
import {
aniListLoggedIn,
aniListUser,
loginToAniList,
loginToMAL,
loginToSimkl,
malLoggedIn,
malUser,
simklLoggedIn,
simklUser,
} from "../helperModules/GlobalVariablesAndHelperFunctions.svelte"
import type {AniListUser} from "../anilist/types/AniListTypes";
import type {SimklUser} from "../simkl/types/simklTypes";
import type {MyAnimeListUser} from "../mal/types/MALTypes";
import AvatarMenu from "./AvatarMenu.svelte";
import logo from "../assets/images/AniTrackLogo.svg"
import {location} from "svelte-spa-router";
let isAniListLoggedIn: boolean
let isSimklLoggedIn: boolean
let isMALLoggedIn: boolean
let currentAniListUser: AniListUser
let currentSimklUser: SimklUser
let currentMALUser: MyAnimeListUser
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
malLoggedIn.subscribe((value) => isMALLoggedIn = value)
aniListUser.subscribe((value) => currentAniListUser = value)
simklUser.subscribe((value) => currentSimklUser = value)
malUser.subscribe((value) => currentMALUser = value)
let currentLocation: any
location.subscribe(value => currentLocation = value)
</script>
<nav class="border-gray-200 bg-gray-900">
@ -63,37 +47,23 @@
<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}
<div class="flex justify-center py-2 px-3 rounded bg-transparent min-[950px]:p-0">
<span class="w-48 min-[950px]:w-auto text-sm font-medium me-2 px-3 py-2 rounded bg-green-800 text-green-200 cursor-default">AniList: {currentAniListUser.data.Viewer.name}</span>
</div>
{:else}
<button on:click={loginToAniList}
class="block py-2 px-3 w-full min-[950px]:w-auto rounded min-[950px]:hover:text-blue-500 hover:bg-gray-700 hover:text-white min-[950px]:hover:bg-transparent border-gray-700">
{#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}
</li>
<li>
{#if isMALLoggedIn}
<div class="flex justify-center py-2 px-3 rounded bg-transparent min-[950px]:p-0">
<span class="w-48 min-[950px]:w-auto text-sm font-medium me-2 px-3 py-2 rounded bg-blue-800 text-blue-200 cursor-default">MyAnimeList: {currentMALUser.name}</span>
</div>
{:else}
<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">
{#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}
<div class="flex justify-center py-2 px-3 rounded bg-transparent min-[950px]:p-0">
<span class="w-48 min-[950px]:w-auto text-sm font-medium me-2 px-3 py-2 rounded bg-indigo-800 text-indigo-200 cursor-default">Simkl: {currentSimklUser.user.name}</span>
</div>
{:else}
<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">
{#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}

View File

@ -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;

View File

@ -1,3 +1,4 @@
import flowbitePlugin from 'flowbite/plugin'
/** @type {import('tailwindcss').Config} */
export default {
content: [
@ -6,9 +7,7 @@ export default {
"./node_modules/flowbite/**/*.{html,js,svelte,ts}",
"./node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}",
],
plugins: [
require('flowbite/plugin')
],
plugins: [ flowbitePlugin ],
darkMode: 'media',

View File

@ -12,6 +12,6 @@
},
"info": {
"productName": "AniTrack",
"productVersion": "0.1.1"
"productVersion": "0.1.3"
}
}