added ability to get anime as needed from MAL
This commit is contained in:
@ -14,7 +14,8 @@
|
||||
title,
|
||||
watchListPage,
|
||||
animePerPage,
|
||||
malWatchList
|
||||
malWatchList,
|
||||
malPrimary
|
||||
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||
import {
|
||||
CheckIfAniListLoggedIn,
|
||||
@ -38,11 +39,13 @@
|
||||
|
||||
let isAniListLoggedIn: boolean
|
||||
let isAniListPrimary: boolean
|
||||
let isMalPrimary: boolean
|
||||
let aniListWatchListLoaded: AniListCurrentUserWatchList
|
||||
|
||||
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
||||
aniListPrimary.subscribe((value) => isAniListPrimary = value)
|
||||
aniListWatchlist.subscribe((value) => aniListWatchListLoaded = value)
|
||||
malPrimary.subscribe((value) => isMalPrimary = value)
|
||||
|
||||
|
||||
let page: number
|
||||
@ -72,10 +75,14 @@
|
||||
if (loggedIn) {
|
||||
GetMyAnimeListLoggedInUser().then(user => {
|
||||
malUser.set(user)
|
||||
GetMyAnimeList(1000).then(watchList => {
|
||||
malWatchList.set(watchList)
|
||||
if (isMalPrimary){
|
||||
GetMyAnimeList(1000).then(watchList => {
|
||||
malWatchList.set(watchList)
|
||||
malLoggedIn.set(loggedIn)
|
||||
})
|
||||
} else {
|
||||
malLoggedIn.set(loggedIn)
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
@ -3,7 +3,9 @@
|
||||
anilistModal,
|
||||
simklWatchList,
|
||||
aniListLoggedIn,
|
||||
simklLoggedIn
|
||||
simklLoggedIn,
|
||||
malLoggedIn,
|
||||
malAnime
|
||||
} from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||
import {aniListAnime} from "./GlobalVariablesAndHelperFunctions.svelte";
|
||||
import {Button} from "flowbite-svelte";
|
||||
@ -14,16 +16,28 @@
|
||||
import { writable } from 'svelte/store';
|
||||
import type {SimklAnime} from "./simkl/types/simklTypes";
|
||||
import { get } from 'svelte/store';
|
||||
import {AniListUpdateEntry, SimklSyncEpisodes, SimklSyncRating, SimklSyncStatus} from "../wailsjs/go/main/App";
|
||||
import {
|
||||
AniListUpdateEntry,
|
||||
SimklSyncEpisodes,
|
||||
SimklSyncRating,
|
||||
SimklSyncStatus
|
||||
} from "../wailsjs/go/main/App";
|
||||
import type {MALAnime} from "./mal/types/MALTypes";
|
||||
import type {AniListUpdateVariables} from "./anilist/types/AniListTypes";
|
||||
|
||||
const simklWatch = get(simklWatchList);
|
||||
let isAniListLoggedIn: boolean
|
||||
let isMalLoggedIn: boolean
|
||||
let isSimklLoggedIn: boolean
|
||||
let simklAnimeIndex: number
|
||||
let currentMalAnime: MALAnime
|
||||
let simklAnime: SimklAnime | undefined = undefined
|
||||
|
||||
aniListLoggedIn.subscribe((value) => isAniListLoggedIn = value)
|
||||
malLoggedIn.subscribe((value) => isMalLoggedIn = value)
|
||||
simklLoggedIn.subscribe((value) => isSimklLoggedIn = value)
|
||||
malAnime.subscribe((value) => currentMalAnime = value)
|
||||
|
||||
|
||||
for (let i = 0; i < simklWatch.anime.length; i++) {
|
||||
if (Number(simklWatch.anime[i].show.ids.mal) === aniListAnime.data.MediaList.media.idMal) {
|
||||
@ -35,23 +49,34 @@
|
||||
type statusOption = {
|
||||
id: number,
|
||||
aniList: string,
|
||||
mal: string,
|
||||
simkl: string,
|
||||
}
|
||||
|
||||
const statusOptions: statusOption[] = [
|
||||
{ id: 0, aniList: "CURRENT", simkl: "watching"},
|
||||
{ id: 1, aniList: "PLANNING", simkl: "plantowatch"},
|
||||
{ id: 2, aniList: "COMPLETED", simkl: "completed"},
|
||||
{ id: 3, aniList: "DROPPED", simkl: "dropped"},
|
||||
{ id: 4, aniList: "PAUSED", simkl: "hold"},
|
||||
{ id: 5, aniList: "REPEATING", simkl: "watching"}
|
||||
{ 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
|
||||
|
||||
startingAnilistStatusOption = statusOptions.filter(option => aniListAnime.data.MediaList.status === option.aniList)[0]
|
||||
|
||||
let items = [];
|
||||
let items = [] as {
|
||||
id: number
|
||||
service: string
|
||||
progress: number
|
||||
status: string
|
||||
startedAt: string
|
||||
completedAt: string
|
||||
score: number
|
||||
repeat: number
|
||||
notes: string
|
||||
}[];
|
||||
|
||||
if(isAniListLoggedIn) {
|
||||
items.push({
|
||||
@ -67,6 +92,20 @@
|
||||
})
|
||||
}
|
||||
|
||||
if(isMalLoggedIn) {
|
||||
items.push({
|
||||
id: currentMalAnime.id,
|
||||
service: "MyAnimeList",
|
||||
progress: currentMalAnime.my_list_status.num_episodes_watched,
|
||||
status: currentMalAnime.my_list_status.status,
|
||||
startedAt: currentMalAnime.my_list_status.start_date,
|
||||
completedAt: currentMalAnime.my_list_status.finish_date,
|
||||
score: currentMalAnime.my_list_status.score,
|
||||
repeat: currentMalAnime.my_list_status.num_times_rewatched,
|
||||
notes: currentMalAnime.my_list_status.comments
|
||||
})
|
||||
}
|
||||
|
||||
if(isSimklLoggedIn && simklAnime !== undefined) {
|
||||
items.push({
|
||||
id: simklAnime.show.ids.simkl,
|
||||
@ -114,7 +153,7 @@
|
||||
|
||||
const ratingInWords = {
|
||||
0: "Not Reviewed",
|
||||
1: "Apalling",
|
||||
1: "Appalling",
|
||||
2: "Horrible",
|
||||
3: "Very Bad",
|
||||
4: "Bad",
|
||||
@ -213,43 +252,45 @@
|
||||
}
|
||||
|
||||
const submitData = async () => {
|
||||
await AniListUpdateEntry(
|
||||
aniListAnime.data.MediaList.mediaId,
|
||||
values.progress,
|
||||
values.status.aniList,
|
||||
values.score,
|
||||
values.repeat,
|
||||
values.notes,
|
||||
values.startedAt.year,
|
||||
values.startedAt.month,
|
||||
values.startedAt.day,
|
||||
values.completedAt.year,
|
||||
values.completedAt.month,
|
||||
values.completedAt.day
|
||||
).then((value) => {
|
||||
let body: AniListUpdateVariables = {
|
||||
mediaId: aniListAnime.data.MediaList.mediaId,
|
||||
progress: values.progress,
|
||||
status: values.status.aniList,
|
||||
score: values.score,
|
||||
repeat: values.repeat,
|
||||
notes: values.notes,
|
||||
startedAt: {
|
||||
year: values.startedAt.year,
|
||||
month: values.startedAt.month,
|
||||
day: values.startedAt.day
|
||||
},
|
||||
completedAt: {
|
||||
year: values.completedAt.year,
|
||||
month: values.completedAt.month,
|
||||
day: values.completedAt.day
|
||||
}
|
||||
}
|
||||
await AniListUpdateEntry(body).then((value) => {
|
||||
console.log(value)
|
||||
})
|
||||
|
||||
if (simklLoggedIn) {
|
||||
if (simklAnime.watched_episodes_count !== values.progress) {
|
||||
await SimklSyncEpisodes(simklAnime, values.progress).then(value => {
|
||||
console.log(value)
|
||||
await SimklSyncEpisodes(simklAnime, values.progress).then(() => {
|
||||
simklAnime.watched_episodes_count = values.progress
|
||||
simklWatch.anime[simklAnimeIndex].watched_episodes_count = values.progress
|
||||
})
|
||||
}
|
||||
|
||||
if (simklAnime.user_rating !== values.score) {
|
||||
await SimklSyncRating(simklAnime, values.score).then(value => {
|
||||
console.log(value)
|
||||
await SimklSyncRating(simklAnime, values.score).then(() => {
|
||||
simklAnime.user_rating = values.score
|
||||
simklWatch.anime[simklAnimeIndex].user_rating = values.score
|
||||
})
|
||||
}
|
||||
|
||||
if (simklAnime.status !== values.status.simkl) {
|
||||
SimklSyncStatus(simklAnime, values.status.simkl).then(value => {
|
||||
console.log(value)
|
||||
SimklSyncStatus(simklAnime, values.status.simkl).then(() => {
|
||||
simklAnime.status = values.status.simkl
|
||||
simklWatch.anime[simklAnimeIndex].status = values.status.simkl
|
||||
})
|
||||
|
@ -1,7 +1,7 @@
|
||||
<script lang="ts" context="module">
|
||||
import {
|
||||
GetAniListItem,
|
||||
GetAniListLoggedInUser, GetAniListUserWatchingList, GetMyAnimeListLoggedInUser,
|
||||
GetAniListLoggedInUser, GetAniListUserWatchingList, GetMyAnimeListAnime, GetMyAnimeListLoggedInUser,
|
||||
GetSimklLoggedInUser, LogoutAniList, LogoutMyAnimeList, LogoutSimkl
|
||||
} from "../wailsjs/go/main/App";
|
||||
import type {
|
||||
@ -11,7 +11,7 @@
|
||||
import {writable} from 'svelte/store'
|
||||
import type {SimklUser, SimklWatchList} from "./simkl/types/simklTypes";
|
||||
import {type AniListUser, MediaListSort} from "./anilist/types/AniListTypes";
|
||||
import type {MALWatchlist, MyAnimeListUser} from "./mal/types/MALTypes";
|
||||
import type {MALAnime, MALWatchlist, MyAnimeListUser} from "./mal/types/MALTypes";
|
||||
|
||||
export let aniListAnime: AniListGetSingleAnime
|
||||
export let title = writable("")
|
||||
@ -21,11 +21,13 @@
|
||||
export let malLoggedIn = writable(false)
|
||||
export let simklWatchList = writable({} as SimklWatchList)
|
||||
export let aniListPrimary = writable(true)
|
||||
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 watchListPage = writable(1)
|
||||
export let animePerPage = writable(20)
|
||||
@ -35,18 +37,30 @@
|
||||
let perPage: number
|
||||
let aniWatchlist: AniListCurrentUserWatchList
|
||||
|
||||
let isMalLoggedIn: 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)
|
||||
|
||||
|
||||
export function GetAniListSingleItemAndOpenModal(aniId: number, login: boolean): void {
|
||||
GetAniListItem(aniId, login).then(result => {
|
||||
aniListAnime = result
|
||||
GetAniListItem(aniId, login).then(aniListResult => {
|
||||
aniListAnime = aniListResult
|
||||
title.set(aniListAnime.data.MediaList.media.title.english === "" ?
|
||||
aniListAnime.data.MediaList.media.title.romaji :
|
||||
aniListAnime.data.MediaList.media.title.english)
|
||||
anilistModal.set(true)
|
||||
if(isMalLoggedIn) {
|
||||
GetMyAnimeListAnime(aniListAnime.data.MediaList.media.idMal).then(malResult => {
|
||||
console.log(malResult)
|
||||
malAnime.set(malResult)
|
||||
anilistModal.set(true)
|
||||
})
|
||||
} else {
|
||||
anilistModal.set(true)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -80,4 +80,27 @@ export enum MediaListSort {
|
||||
MediaTitleNativeDesc = "MEDIA_TITLE_NATIVE_DESC",
|
||||
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
|
||||
}
|
@ -31,13 +31,15 @@ export interface AnimeStatistics {
|
||||
}
|
||||
|
||||
export interface MALWatchlist {
|
||||
data: {
|
||||
node: Node
|
||||
listStatus: ListStatus
|
||||
}[]
|
||||
data: [MALAnimeFromList]
|
||||
paging: Paging
|
||||
}
|
||||
|
||||
export interface MALAnimeFromList {
|
||||
node: Node
|
||||
listStatus: ListStatus | MyListStatus
|
||||
}
|
||||
|
||||
export interface Node {
|
||||
id: number
|
||||
title: string
|
||||
@ -63,3 +65,90 @@ 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: MyListStatus;
|
||||
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 MyListStatus {
|
||||
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;
|
||||
}
|
Reference in New Issue
Block a user