updated getLetterboxdActivity to conditionally include image in returned text

This commit is contained in:
dylan 2025-12-25 19:19:09 +00:00
parent c7717e6d29
commit 360465395a

View file

@ -102,10 +102,16 @@ export async function getLetterboxdActivity(username, showImage = true) {
const title = item.querySelector('title').textContent
const link = item.querySelector('link').textContent.trim()
const cleanTitle = markdownCharEscape(title)
const image = item.querySelector('description > img').src
const text = !showImage
? cleanTitle
: `${cleanTitle} ![${cleanTitle}](${image})`
let text = cleanTitle
if (showImage) {
// Parse CDATA content as HTML to extract image
const description = item.querySelector('description').textContent
const imgMatch = description.match(/<img[^>]+src="([^"]+)"/)
const image = imgMatch ? imgMatch[1] : null
text = image ? `${cleanTitle} ![${cleanTitle}](${image})` : cleanTitle
}
return { text, url: link }
}