feat: add movie posters to now page

This commit is contained in:
Cory Dransfeldt 2023-04-26 13:42:45 -07:00
parent 4158faac60
commit 54e5e67643
No known key found for this signature in database
6 changed files with 31 additions and 15 deletions

View file

@ -5,10 +5,17 @@ module.exports = async function () {
const url = 'https://letterboxd.com/cdme/rss'
const asset = new AssetCache('movies_data')
if (asset.isCacheValid('1h')) return await asset.getCachedValue()
const res = await extract(url).catch((error) => {
const res = await extract(url, {
getExtraEntryFields: (feedEntry) => {
const images = feedEntry['description']?.match(/<img [^>]*src="[^"]*"[^>]*>/gm) || []
return {
image: images.length ? images.map((x) => x.replace(/.*src="([^"]*)".*/, '$1'))[0] : '',
}
},
}).catch((error) => {
console.log(error.message)
})
const data = res.entries.splice(0, 5)
const data = res.entries.splice(0, 6)
await asset.save(data, 'json')
return data
}