chore: normalize movie data

This commit is contained in:
Cory Dransfeldt 2023-08-13 16:58:54 -07:00
parent b5223a5923
commit 162448faa9
No known key found for this signature in database
3 changed files with 17 additions and 11 deletions

View file

@ -12,10 +12,18 @@ module.exports = async function () {
const data = res.items
.map((item) => {
const images = item['content']?.match(/<img [^>]*src="[^"]*"[^>]*>/gm) || []
item.image = images.length
? images.map((image) => image.replace(/.*src="([^"]*)".*/, '$1'))[0]
: 'https://cdn.coryd.dev/movies/missing-movie.jpg'
return item
return {
name: item['title'],
date: item['pubDate'],
summary: item['contentSnippet'],
image: images.length
? images
.map((image) => image.replace(/.*src="([^"]*)".*/, '$1'))[0]
.replace('https://a.ltrbxd.com', 'https://movies.coryd.dev')
: 'https://cdn.coryd.dev/movies/missing-movie.jpg',
url: item['link'],
id: item['guid'],
}
})
.splice(0, 6)
await asset.save(data, 'json')

View file

@ -7,7 +7,5 @@ module.exports = async function () {
title: 'Cory Dransfeldt',
description:
"I'm a software developer in Camarillo, California. I enjoy hanging out with my beautiful family and 4 rescue dogs, technology, automation, music, writing, reading and tv and movies.",
'letterboxd-host': 'https://a.ltrbxd.com',
'cdn-movies': 'https://movies.coryd.dev',
}
}