feat: dry up + normalize now page

This commit is contained in:
Cory Dransfeldt 2023-08-14 11:36:07 -07:00
parent 022ce82f81
commit 6dda493d7b
No known key found for this signature in database
13 changed files with 86 additions and 136 deletions

View file

@ -11,7 +11,7 @@ module.exports = async function () {
const data = await res
return data['topalbums'].album.map((album) => {
return {
name: album['name'],
title: album['name'],
artist: album['artist']['name'],
plays: album['playcount'],
rank: album['@attr']['rank'],
@ -26,6 +26,7 @@ module.exports = async function () {
url: album['mbid']
? `https://musicbrainz.org/album/${album['mbid']}`
: `https://musicbrainz.org/search?query=${encodeURI(album['name'])}&type=release_group`,
type: 'album',
}
})
}

View file

@ -10,7 +10,7 @@ module.exports = async function () {
const data = await res
return data['topartists'].artist.map((artist) => {
return {
name: artist['name'],
title: artist['name'],
plays: artist['playcount'],
rank: artist['@attr']['rank'],
image:
@ -19,6 +19,7 @@ module.exports = async function () {
url: artist['mbid']
? `https://musicbrainz.org/artist/${artist['mbid']}`
: `https://musicbrainz.org/search?query=${encodeURI(artist['name'])}&type=artist`,
type: 'artist',
}
})
}

View file

@ -25,6 +25,7 @@ module.exports = async function () {
isbn: book['isbn'],
description: book['book_description'],
dateAdded: book['user_date_added'],
type: 'book',
})
})
const books = data.splice(0, 6)

View file

@ -13,7 +13,7 @@ module.exports = async function () {
.map((item) => {
const images = item['content']?.match(/<img [^>]*src="[^"]*"[^>]*>/gm) || []
return {
name: item['title'],
title: item['title'],
date: item['pubDate'],
summary: item['contentSnippet'],
image: images.length
@ -23,6 +23,7 @@ module.exports = async function () {
: 'https://cdn.coryd.dev/movies/missing-movie.jpg',
url: item['link'],
id: item['guid'],
type: 'movie',
}
})
.filter((movie) => !movie.url.includes('/list/'))

View file

@ -14,6 +14,19 @@ module.exports = async function () {
},
},
}).catch()
const shows = await res
return shows.splice(0, 6)
const data = await res
return data.map((episode) => {
return {
name: episode['show']['title'],
title: episode['episode']['title'],
url: `https://trakt.tv/shows/${episode['show']['ids']['slug']}/seasons/${episode['episode']['season']}/episodes/${episode['episode']['number']}`,
episode: `S${episode['episode']['season']}E${episode['episode']['number']}`,
image:
`https://cdn.coryd.dev/tv/${episode['show']['title']
.replace(':', '')
.replace(/\s+/g, '-')
.toLowerCase()}.jpg` || 'https://cdn.coryd.dev/tv/missing-tv.jpg',
type: 'tv',
}
})
}