From aad213fa40229d4512ab78806fd24932f844f416 Mon Sep 17 00:00:00 2001 From: Kylart Date: Fri, 31 Jan 2020 14:42:28 +0100 Subject: [PATCH 1/2] Fix #69 Fix kitsu watch list retrieval for too long lists --- bindings/lib/anitomy | 1 + bindings/lib/libtorrent | 1 + src/main/externals/kitsu.io/auth/setup.js | 2 +- src/main/externals/kitsu.io/helpers.js | 14 ++------------ src/main/externals/kitsu.io/utils.js | 4 ++-- src/main/externals/kitsu.io/watchLists.js | 17 ++++++++++++----- 6 files changed, 19 insertions(+), 20 deletions(-) create mode 160000 bindings/lib/anitomy create mode 160000 bindings/lib/libtorrent diff --git a/bindings/lib/anitomy b/bindings/lib/anitomy new file mode 160000 index 0000000..55e00a4 --- /dev/null +++ b/bindings/lib/anitomy @@ -0,0 +1 @@ +Subproject commit 55e00a40cc66109e5c926130bea1eb902b27f2f2 diff --git a/bindings/lib/libtorrent b/bindings/lib/libtorrent new file mode 160000 index 0000000..4054cbb --- /dev/null +++ b/bindings/lib/libtorrent @@ -0,0 +1 @@ +Subproject commit 4054cbbaeeb942e2f8f3cecff13711e9279fe631 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, From 12df5f619d421be5e5f37cf53f5a2afd0186e6a5 Mon Sep 17 00:00:00 2001 From: Kylart Date: Fri, 31 Jan 2020 14:42:52 +0100 Subject: [PATCH 2/2] 0.4.2 --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9878e9a..83bca9a 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 abbf198..5f540f7 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",