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", "name": "coryd.dev",
"version": "14.6.0", "version": "14.6.1",
"description": "The source for my personal site. Built using 11ty.", "description": "The source for my personal site. Built using 11ty.",
"type": "module", "type": "module",
"scripts": { "scripts": {

View file

@ -22,7 +22,6 @@ export default async function () {
if (error) return [] if (error) return []
const formatMovieData = (movies) => movies.map((item) => { const formatMovieData = (movies) => movies.map((item) => {
const movie = { const movie = {
title: item['title'], 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>`, 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', type: 'movie',
image: `https://coryd.dev/media/movies/poster-${item['tmdb_id']}.jpg`, 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'], plays: item['plays'],
collected: item['collected'], collected: item['collected'],
favorite: item['favorite'], favorite: item['favorite'],
@ -38,9 +38,14 @@ export default async function () {
return movie; return movie;
}) })
const favoriteMovies = movies.filter(movie => movie['favorite'])
const collectedMovies = movies.filter(movie => movie['collected'])
return { return {
movies, movies,
watchHistory: formatMovieData(movies), watchHistory: formatMovieData(movies),
recentlyWatched: formatMovieData(movies.slice(0, 6)), 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 => { show.episodes.forEach(episode => {
episodes.push({ episodes.push({
...episode, ...episode,
show_title: show.title, show_title: show['title'],
show_tmdb_id: show.tmdb_id, show_tmdb_id: show['tmdb_id'],
collected: show.collected, collected: show['collected'],
favorite: show.favorite 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 const allEpisodes = episodes
episodes = episodes.slice(0, 75) episodes = episodes.slice(0, 75)
@ -43,13 +43,13 @@ export default async function () {
const showEpisodesMap = {} const showEpisodesMap = {}
episodes.forEach((episode) => { episodes.forEach((episode) => {
const showTitle = episode.show_title const showTitle = episode['show_title']
const showTmdbId = episode.show_tmdb_id const showTmdbId = episode['show_tmdb_id']
const episodeNumber = episode.episode_number const episodeNumber = episode['episode_number']
const seasonNumber = episode.season_number const seasonNumber = episode['season_number']
const lastWatchedAt = episode.last_watched_at const lastWatchedAt = episode['last_watched_at']
const collected = episode.collected const collected = episode['collected']
const favorite = episode.favorite const favorite = episode['favorite']
if (!showEpisodesMap[showTmdbId]) { if (!showEpisodesMap[showTmdbId]) {
showEpisodesMap[showTmdbId] = { showEpisodesMap[showTmdbId] = {
@ -70,37 +70,39 @@ export default async function () {
tmdbId: showTmdbId, tmdbId: showTmdbId,
type: 'tv', type: 'tv',
image: `https://coryd.dev/media/shows/poster-${showTmdbId}.jpg`, image: `https://coryd.dev/media/shows/poster-${showTmdbId}.jpg`,
backdrop: `https://coryd.dev/media/shows/backdrops/backdrop-${showTmdbId}.jpg`,
lastWatchedAt: lastWatchedAt 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) => { sortedShows.forEach((show) => {
const startingEpisode = show.episodes[show.episodes.length - 1].episode const startingEpisode = show['episodes'][show['episodes'].length - 1]['episode']
const startingSeason = show.episodes[show.episodes.length - 1].season const startingSeason = show['episodes'][show['episodes'].length - 1]['season']
const endingEpisode = show.episodes[0].episode const endingEpisode = show['episodes'][0]['episode']
const endingSeason = show.episodes[0].season const endingSeason = show['episodes'][0]['season']
if (show.episodes.length > 1) { if (show.episodes.length > 1) {
episodeData.push({ episodeData.push({
name: show.title, 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}`, subtext: `S${startingSeason}E${startingEpisode} - S${endingSeason}E${endingEpisode}`,
startingEpisode, startingEpisode,
startingSeason, startingSeason,
episode: endingEpisode, episode: endingEpisode,
season: endingSeason, season: endingSeason,
tmdbId: show.tmdbId, tmdbId: show['tmdbId'],
collected: show.collected, collected: show['collected'],
favorite: show.favorite, favorite: show['favorite'],
type: 'tv-range', 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 { } else {
const singleEpisode = show.episodes[0] const singleEpisode = show['episodes'][0]
singleEpisode.collected = show.collected singleEpisode.collected = show['collected']
singleEpisode.favorite = show.favorite singleEpisode.favorite = show['favorite']
episodeData.push(singleEpisode) episodeData.push(singleEpisode)
} }
}) })
@ -108,9 +110,26 @@ export default async function () {
return episodeData return episodeData
} }
const favoriteShows = shows.filter(show => show['favorite'])
const collectedShows = shows.filter(show => show['collected'])
return { return {
shows, shows,
watchHistory: formatEpisodeData(allEpisodes), 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']
}))))
} }
} }