chore: add backdrops

This commit is contained in:
Cory Dransfeldt 2024-05-14 11:13:09 -07:00
parent e3bf4c15e8
commit 9b1528dda1
No known key found for this signature in database
3 changed files with 53 additions and 29 deletions

View file

@ -1,6 +1,6 @@
{
"name": "coryd.dev",
"version": "14.6.0",
"version": "14.6.1",
"description": "The source for my personal site. Built using 11ty.",
"type": "module",
"scripts": {

View file

@ -22,7 +22,6 @@ export default async function () {
if (error) return []
const formatMovieData = (movies) => movies.map((item) => {
const movie = {
title: item['title'],
@ -31,6 +30,7 @@ export default async function () {
description: `<p>${item['title']} (${item['year']})</p><p>Watched at: ${DateTime.fromISO(item['last_watched'], { zone: 'utc' }).setZone('America/Los_Angeles').toFormat('MMMM d, yyyy, h:mma')}</p>`,
type: 'movie',
image: `https://coryd.dev/media/movies/poster-${item['tmdb_id']}.jpg`,
backdrop: `https://coryd.dev/media/movies/backdrops/backdrop-${item['tmdb_id']}.jpg`,
plays: item['plays'],
collected: item['collected'],
favorite: item['favorite'],
@ -38,9 +38,14 @@ export default async function () {
return movie;
})
const favoriteMovies = movies.filter(movie => movie['favorite'])
const collectedMovies = movies.filter(movie => movie['collected'])
return {
movies,
watchHistory: formatMovieData(movies),
recentlyWatched: formatMovieData(movies.slice(0, 6)),
favorites: formatMovieData(favoriteMovies),
collection: formatMovieData(collectedMovies),
}
}

View file

@ -26,15 +26,15 @@ export default async function () {
show.episodes.forEach(episode => {
episodes.push({
...episode,
show_title: show.title,
show_tmdb_id: show.tmdb_id,
collected: show.collected,
favorite: show.favorite
show_title: show['title'],
show_tmdb_id: show['tmdb_id'],
collected: show['collected'],
favorite: show['favorite']
})
})
})
episodes.sort((a, b) => new Date(b.last_watched_at) - new Date(a.last_watched_at))
episodes.sort((a, b) => new Date(b['last_watched_at']) - new Date(a['last_watched_at']))
const allEpisodes = episodes
episodes = episodes.slice(0, 75)
@ -43,13 +43,13 @@ export default async function () {
const showEpisodesMap = {}
episodes.forEach((episode) => {
const showTitle = episode.show_title
const showTmdbId = episode.show_tmdb_id
const episodeNumber = episode.episode_number
const seasonNumber = episode.season_number
const lastWatchedAt = episode.last_watched_at
const collected = episode.collected
const favorite = episode.favorite
const showTitle = episode['show_title']
const showTmdbId = episode['show_tmdb_id']
const episodeNumber = episode['episode_number']
const seasonNumber = episode['season_number']
const lastWatchedAt = episode['last_watched_at']
const collected = episode['collected']
const favorite = episode['favorite']
if (!showEpisodesMap[showTmdbId]) {
showEpisodesMap[showTmdbId] = {
@ -70,37 +70,39 @@ export default async function () {
tmdbId: showTmdbId,
type: 'tv',
image: `https://coryd.dev/media/shows/poster-${showTmdbId}.jpg`,
backdrop: `https://coryd.dev/media/shows/backdrops/backdrop-${showTmdbId}.jpg`,
lastWatchedAt: lastWatchedAt
})
})
const sortedShows = Object.values(showEpisodesMap).sort((a, b) => new Date(b.episodes[0].lastWatchedAt) - new Date(a.episodes[0].lastWatchedAt))
const sortedShows = Object.values(showEpisodesMap).sort((a, b) => new Date(b['episodes'][0]['lastWatchedAt']) - new Date(a['episodes'][0]['lastWatchedAt']))
sortedShows.forEach((show) => {
const startingEpisode = show.episodes[show.episodes.length - 1].episode
const startingSeason = show.episodes[show.episodes.length - 1].season
const endingEpisode = show.episodes[0].episode
const endingSeason = show.episodes[0].season
const startingEpisode = show['episodes'][show['episodes'].length - 1]['episode']
const startingSeason = show['episodes'][show['episodes'].length - 1]['season']
const endingEpisode = show['episodes'][0]['episode']
const endingSeason = show['episodes'][0]['season']
if (show.episodes.length > 1) {
episodeData.push({
name: show.title,
url: `https://www.themoviedb.org/tv/${show.tmdbId}`,
url: `https://www.themoviedb.org/tv/${show['tmdbId']}`,
subtext: `S${startingSeason}E${startingEpisode} - S${endingSeason}E${endingEpisode}`,
startingEpisode,
startingSeason,
episode: endingEpisode,
season: endingSeason,
tmdbId: show.tmdbId,
collected: show.collected,
favorite: show.favorite,
tmdbId: show['tmdbId'],
collected: show['collected'],
favorite: show['favorite'],
type: 'tv-range',
image: `https://coryd.dev/media/shows/poster-${show.tmdbId}.jpg`,
image: `https://coryd.dev/media/shows/poster-${show['tmdbId']}.jpg`,
backdrop: `https://coryd.dev/media/shows/backdrops/backdrop-${show['tmdbId']}.jpg`,
})
} else {
const singleEpisode = show.episodes[0]
singleEpisode.collected = show.collected
singleEpisode.favorite = show.favorite
const singleEpisode = show['episodes'][0]
singleEpisode.collected = show['collected']
singleEpisode.favorite = show['favorite']
episodeData.push(singleEpisode)
}
})
@ -108,9 +110,26 @@ export default async function () {
return episodeData
}
const favoriteShows = shows.filter(show => show['favorite'])
const collectedShows = shows.filter(show => show['collected'])
return {
shows,
watchHistory: formatEpisodeData(allEpisodes),
recentlyWatched: formatEpisodeData(episodes)
recentlyWatched: formatEpisodeData(episodes),
favorites: formatEpisodeData(favoriteShows.flatMap(show => show['episodes'].map(episode => ({
...episode,
show_title: show['title'],
show_tmdb_id: show['tmdb_id'],
collected: show['collected'],
favorite: show['favorite']
})))),
collection: formatEpisodeData(collectedShows.flatMap(show => show['episodes'].map(episode => ({
...episode,
show_title: show['title'],
show_tmdb_id: show['tmdb_id'],
collected: show['collected'],
favorite: show['favorite']
}))))
}
}