Skip to content

Commit c1004e5

Browse files
committed
Start working on wishlist model
1 parent 78bedde commit c1004e5

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

api/model/wishlist.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const _WISHLIST_PATH = 'src/_data/toread.yml';
2+
3+
export interface WishListBook {
4+
title: string;
5+
slug: string;
6+
author: string;
7+
addedAt: Date;
8+
notes?: string;
9+
}

script/fetch-kobo-wishlist.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import { encodeBase64 } from 'jsr:@std/encoding/base64';
2+
import { slug } from 'slug';
3+
import { type WishListBook } from '../api/model/wishlist.ts';
24

35
// Rewritten from Python (https://github.com/subdavis/kobo-book-downloader/blob/main/kobodl/kobo.py) by Johan.
46
// Huge props to the great reverse engineering by them.
@@ -19,7 +21,14 @@ const main = async () => {
1921
const settings = await loadInitSettings(accessToken);
2022
const wishlist = await fetchWishlist(accessToken, settings.user_wishlist);
2123

22-
console.log(JSON.stringify(wishlist, null, 2));
24+
const books = wishlist.map<WishListBook>((w) => ({
25+
title: w.ProductMetadata.Book.Title,
26+
author: w.ProductMetadata.Book.Contributors,
27+
slug: slug(w.ProductMetadata.Book.Title),
28+
addedAt: w.DateAdded,
29+
}));
30+
31+
console.log(books);
2332
} catch (error) {
2433
console.error(error);
2534
}

0 commit comments

Comments
 (0)