diff --git a/package-lock.json b/package-lock.json index a1e4b9f..24ad240 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "KawAnime", - "version": "0.4.1", + "version": "0.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5fc2eeb..ff676dc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "KawAnime", - "version": "0.4.1", + "version": "0.4.2", "main": "background.js", "repository": "https://github.com/Kylart/KawAnime.git", "description": "The ultimate otaku software", diff --git a/src/main/externals/kitsu.io/auth/setup.js b/src/main/externals/kitsu.io/auth/setup.js index 37434d0..cd3c2ea 100644 --- a/src/main/externals/kitsu.io/auth/setup.js +++ b/src/main/externals/kitsu.io/auth/setup.js @@ -1,5 +1,5 @@ import { setupCreds } from '../../vault' -import { TOKEN_URL, LIST_URL as USER_URL } from '../utils' +import { TOKEN_URL, USERS_URL as USER_URL } from '../utils' import { https } from '../../../utils' import { eventsList } from 'vendor' import sendToWindows from '../../sendToWindows' diff --git a/src/main/externals/kitsu.io/helpers.js b/src/main/externals/kitsu.io/helpers.js index 2d16fd8..9d187e8 100644 --- a/src/main/externals/kitsu.io/helpers.js +++ b/src/main/externals/kitsu.io/helpers.js @@ -147,18 +147,8 @@ export function formatSearch (data) { } export function formatList (data) { - const { entries, animes } = data.included.reduce( - (acc, elem) => { - elem.type === 'libraryEntries' - ? acc.entries.push(elem) - : acc.animes.push(elem) - - return acc - }, { - entries: [], - animes: [] - } - ) + const entries = data.data + const animes = data.included return entries.map(({ id, attributes: entry }, index) => { const anime = animes[index].attributes diff --git a/src/main/externals/kitsu.io/utils.js b/src/main/externals/kitsu.io/utils.js index aaa7356..c171a07 100644 --- a/src/main/externals/kitsu.io/utils.js +++ b/src/main/externals/kitsu.io/utils.js @@ -2,5 +2,5 @@ export const BASE_URL = 'https://kitsu.io/api/edge/anime' export const GRAPHQL_ENDPOINT = 'https://kitsu.io/api/graphql' export const TOKEN_URL = 'https://kitsu.io/api/oauth/token' -export const LIST_URL = 'https://kitsu.io/api/edge/users' -export const UPDATE_LIST_URL = 'https://kitsu.io/api/edge/library-entries' +export const USERS_URL = 'https://kitsu.io/api/edge/users' +export const LIST_URL = 'https://kitsu.io/api/edge/library-entries' diff --git a/src/main/externals/kitsu.io/watchLists.js b/src/main/externals/kitsu.io/watchLists.js index ec7f9ce..61f5f6c 100644 --- a/src/main/externals/kitsu.io/watchLists.js +++ b/src/main/externals/kitsu.io/watchLists.js @@ -1,14 +1,21 @@ import { https } from '../../utils' -import { LIST_URL, UPDATE_LIST_URL } from './utils' +import { USERS_URL, LIST_URL } from './utils' import { retrieveToken, isAuthed } from './auth' import { formatList } from './helpers' async function get (username) { try { + const userData = await https.get(USERS_URL, [ + { name: 'filter[slug]', value: username } + ]) + + const { id: userId } = userData.data[0] // Hopefully we won't run into doubles + const data = await https.get(LIST_URL, [ - { name: 'filter[name]', value: username }, - { name: 'include', value: 'libraryEntries,libraryEntries.anime' } + { name: 'filter[user_id]', value: userId }, + { name: 'include', value: 'anime' }, + { name: 'page[limit]', value: '500' } ], {}, false) return formatList(data) @@ -31,7 +38,7 @@ async function update (opts) { } if (isEdit) { - await https.patch(`${UPDATE_LIST_URL}/${id}`, { + await https.patch(`${LIST_URL}/${id}`, { data: { type: 'library-entries', id, @@ -39,7 +46,7 @@ async function update (opts) { } }, [], headers) } else { - await https.post(UPDATE_LIST_URL, { + await https.post(LIST_URL, { data: { type: 'library-entries', attributes: data,