booklogr support

This commit is contained in:
Melanie Kat 2025-12-21 18:42:53 -08:00
parent 03ca72d917
commit 940627fb07
2 changed files with 16 additions and 0 deletions

View file

@ -3,6 +3,7 @@ import {
getJsonFeedItemTitle, getJsonFeedItemTitle,
getLetterboxdActivity, getLetterboxdActivity,
getMalojaScrobble, getMalojaScrobble,
getReadingBooklogr,
getRSSItemTitle, getRSSItemTitle,
getTraktEpisode, getTraktEpisode,
markdownLinkRegex, markdownLinkRegex,
@ -32,6 +33,12 @@ export const items = [
regex: markdownLinkRegex('scrobbles.melkat.dev'), regex: markdownLinkRegex('scrobbles.melkat.dev'),
getLatest: async () => getMalojaScrobble('https://scrobbles.melkat.dev'), getLatest: async () => getMalojaScrobble('https://scrobbles.melkat.dev'),
}, },
{
id: 'books',
regex: markdownLinkRegex('reads.melkat.dev/profile/melanie'),
getLatest: async () =>
getReadingBooklogr('https://reads-api.melkat.dev', 'melanie'),
},
{ {
id: 'letterboxd', id: 'letterboxd',
regex: markdownLinkRegex('letterboxd.com/zicklepop'), regex: markdownLinkRegex('letterboxd.com/zicklepop'),

View file

@ -98,3 +98,12 @@ export async function getTraktEpisode(username, id) {
const cleanTitle = markdownCharEscape(title) const cleanTitle = markdownCharEscape(title)
return `${cleanTitle} ![${cleanTitle}](https://widgets.trakt.tv/users/${id}/watched/thumb@2x.jpg?type=episode&image_only=1)` return `${cleanTitle} ![${cleanTitle}](https://widgets.trakt.tv/users/${id}/watched/thumb@2x.jpg?type=episode&image_only=1)`
} }
export async function getReadingBooklogr(booklogrUrl, booklogrUser) {
const res = await fetch(`${booklogrUrl}/v1/profiles/${booklogrUser}`)
const data = await res.json()
const books = data.books.filter(
({ reading_status }) => reading_status === 'Currently reading',
)
return books.map(({ title }) => title).join(', ')
}