feat: self host movies/tv
This commit is contained in:
parent
eccf1027b8
commit
e3bf4c15e8
13 changed files with 178 additions and 164 deletions
2
.env
2
.env
|
@ -1,7 +1,5 @@
|
|||
SITE_ID_CLICKY=
|
||||
SITE_KEY_CLICKY=
|
||||
API_KEY_TRAKT=
|
||||
API_KEY_MOVIEDB=
|
||||
ACCOUNT_ID_PLEX=
|
||||
SUPABASE_URL=
|
||||
SUPABASE_KEY=
|
||||
|
|
36
cache/jsonfeed-to-mastodon.json
vendored
36
cache/jsonfeed-to-mastodon.json
vendored
|
@ -12477,11 +12477,11 @@
|
|||
],
|
||||
"lastTootTimestamp": 1713031404184
|
||||
},
|
||||
"https://trakt.tv/movies/fallen-1998": {
|
||||
"https://www.themoviedb.org/movie/9411": {
|
||||
"id": "aHR0cHM6Ly90cmFrdC50di9tb3ZpZXMvZmFsbGVuLTE5OTg=",
|
||||
"title": "🎥: Fallen",
|
||||
"url": "https://trakt.tv/movies/fallen-1998",
|
||||
"content_text": "🎥: Fallen #Movies #Watching #Trakt https://trakt.tv/movies/fallen-1998",
|
||||
"url": "https://www.themoviedb.org/movie/9411",
|
||||
"content_text": "🎥: Fallen #Movies #Watching #Trakt https://www.themoviedb.org/movie/9411",
|
||||
"date_published": "Sat, 13 Apr 2024 23:43:00 GMT",
|
||||
"toots": [
|
||||
"https://social.lol/users/cory/statuses/112267248945790971"
|
||||
|
@ -12510,11 +12510,11 @@
|
|||
],
|
||||
"lastTootTimestamp": 1713143465132
|
||||
},
|
||||
"https://trakt.tv/movies/road-house-2024": {
|
||||
"https://www.themoviedb.org/movie/359410": {
|
||||
"id": "aHR0cHM6Ly90cmFrdC50di9tb3ZpZXMvcm9hZC1ob3VzZS0yMDI0",
|
||||
"title": "🎥: Road House",
|
||||
"url": "https://trakt.tv/movies/road-house-2024",
|
||||
"content_text": "🎥: Road House #Movies #Watching #Trakt https://trakt.tv/movies/road-house-2024",
|
||||
"url": "https://www.themoviedb.org/movie/359410",
|
||||
"content_text": "🎥: Road House #Movies #Watching #Trakt https://www.themoviedb.org/movie/359410",
|
||||
"date_published": "Sun, 14 Apr 2024 17:06:00 GMT",
|
||||
"toots": [
|
||||
"https://social.lol/users/cory/statuses/112271865248733450"
|
||||
|
@ -12653,11 +12653,11 @@
|
|||
],
|
||||
"lastTootTimestamp": 1713645991312
|
||||
},
|
||||
"https://trakt.tv/movies/dune-part-two-2024": {
|
||||
"https://www.themoviedb.org/movie/693134": {
|
||||
"id": "aHR0cHM6Ly90cmFrdC50di9tb3ZpZXMvZHVuZS1wYXJ0LXR3by0yMDI0",
|
||||
"title": "🎥: Dune: Part Two",
|
||||
"url": "https://trakt.tv/movies/dune-part-two-2024",
|
||||
"content_text": "🎥: Dune: Part Two #Movies #Watching #SciFi #Adventure https://trakt.tv/movies/dune-part-two-2024",
|
||||
"url": "https://www.themoviedb.org/movie/693134",
|
||||
"content_text": "🎥: Dune: Part Two #Movies #Watching #SciFi #Adventure https://www.themoviedb.org/movie/693134",
|
||||
"date_published": "Fri, 19 Apr 2024 14:00:00 GMT",
|
||||
"toots": [
|
||||
"https://social.lol/users/cory/statuses/112305063432909748"
|
||||
|
@ -12829,11 +12829,11 @@
|
|||
],
|
||||
"lastTootTimestamp": 1713981835960
|
||||
},
|
||||
"https://trakt.tv/movies/monkey-man-2024": {
|
||||
"https://www.themoviedb.org/movie/560016": {
|
||||
"id": "aHR0cHM6Ly90cmFrdC50di9tb3ZpZXMvbW9ua2V5LW1hbi0yMDI0",
|
||||
"title": "🎥: Monkey Man",
|
||||
"url": "https://trakt.tv/movies/monkey-man-2024",
|
||||
"content_text": "🎥: Monkey Man #Movies #Watching #Thriller #Action https://trakt.tv/movies/monkey-man-2024",
|
||||
"url": "https://www.themoviedb.org/movie/560016",
|
||||
"content_text": "🎥: Monkey Man #Movies #Watching #Thriller #Action https://www.themoviedb.org/movie/560016",
|
||||
"date_published": "Wed, 24 Apr 2024 18:14:00 GMT",
|
||||
"toots": [
|
||||
"https://social.lol/users/cory/statuses/112328455422041088"
|
||||
|
@ -12884,11 +12884,11 @@
|
|||
],
|
||||
"lastTootTimestamp": 1714233838679
|
||||
},
|
||||
"https://trakt.tv/movies/late-night-with-the-devil-2024": {
|
||||
"https://www.themoviedb.org/movie/938614": {
|
||||
"id": "aHR0cHM6Ly90cmFrdC50di9tb3ZpZXMvbGF0ZS1uaWdodC13aXRoLXRoZS1kZXZpbC0yMDI0",
|
||||
"title": "🎥: Late Night with the Devil",
|
||||
"url": "https://trakt.tv/movies/late-night-with-the-devil-2024",
|
||||
"content_text": "🎥: Late Night with the Devil #Movies #Watching #Horror https://trakt.tv/movies/late-night-with-the-devil-2024",
|
||||
"url": "https://www.themoviedb.org/movie/938614",
|
||||
"content_text": "🎥: Late Night with the Devil #Movies #Watching #Horror https://www.themoviedb.org/movie/938614",
|
||||
"date_published": "Sat, 27 Apr 2024 18:07:00 GMT",
|
||||
"toots": [
|
||||
"https://social.lol/users/cory/statuses/112345809656993382"
|
||||
|
@ -12983,11 +12983,11 @@
|
|||
],
|
||||
"lastTootTimestamp": 1714449885234
|
||||
},
|
||||
"https://trakt.tv/movies/john-mulaney-kid-gorgeous-at-radio-city-2018": {
|
||||
"https://www.themoviedb.org/movie/520594": {
|
||||
"id": "aHR0cHM6Ly90cmFrdC50di9tb3ZpZXMvam9obi1tdWxhbmV5LWtpZC1nb3JnZW91cy1hdC1yYWRpby1jaXR5LTIwMTg=",
|
||||
"title": "🎥: John Mulaney: Kid Gorgeous at Radio City",
|
||||
"url": "https://trakt.tv/movies/john-mulaney-kid-gorgeous-at-radio-city-2018",
|
||||
"content_text": "🎥: John Mulaney: Kid Gorgeous at Radio City #Movies #Watching undefined https://trakt.tv/movies/john-mulaney-kid-gorgeous-at-radio-city-2018",
|
||||
"url": "https://www.themoviedb.org/movie/520594",
|
||||
"content_text": "🎥: John Mulaney: Kid Gorgeous at Radio City #Movies #Watching undefined https://www.themoviedb.org/movie/520594",
|
||||
"date_published": "Wed, 01 May 2024 05:36:00 GMT",
|
||||
"toots": [
|
||||
"https://social.lol/users/cory/statuses/112364796498005793"
|
||||
|
|
|
@ -49,7 +49,6 @@ export const tagMap = (collection) => {
|
|||
const posts = collectionData.data.collections.posts
|
||||
const links = collectionData.data.collections.links
|
||||
const books = collectionData.data.books
|
||||
const movies = collectionData.data.movies
|
||||
|
||||
if (posts) posts.forEach((post) => {
|
||||
const url = post.url.includes('http') ? post.url : `https://coryd.dev${post.url}`
|
||||
|
@ -74,13 +73,6 @@ export const tagMap = (collection) => {
|
|||
if (tagString) tags[book.url] = tagString.replace(/\s+/g,' ')
|
||||
})
|
||||
|
||||
if (movies) movies.forEach((movie) => {
|
||||
const tagString = movie['tags']?.map((tag) => tagAliases[tag.toLowerCase()])
|
||||
.join(' ')
|
||||
.trim()
|
||||
if (tagString) tags[movie.url] = tagString.replace(/\s+/g,' ')
|
||||
})
|
||||
|
||||
return tags
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
export default {
|
||||
'11ty': '#Eleventy',
|
||||
accessibility: '#Accessibility',
|
||||
action: '#Action',
|
||||
adventure: '#Adventure',
|
||||
ai: '#AI',
|
||||
backblaze: '#Backblaze',
|
||||
'black metal': '#BlackMetal',
|
||||
|
@ -18,14 +16,12 @@ export default {
|
|||
eleventy: '#Eleventy',
|
||||
email: '#Email',
|
||||
emo: '#Emo',
|
||||
fantasy: '#Fantasy',
|
||||
fastmail: '#Email',
|
||||
fiction: '#Fiction',
|
||||
gmail: '#Email',
|
||||
grindcore: '#Grindcore',
|
||||
health: '#Health',
|
||||
'indie web': '#IndieWeb #SmallWeb',
|
||||
'horror': '#Horror',
|
||||
ios: '#iOS #Apple',
|
||||
javascript: '#JavaScript',
|
||||
'last.fm': '#Music',
|
||||
|
|
|
@ -57,7 +57,7 @@ export default {
|
|||
if (!url) return
|
||||
if (url.includes('#artists')) return `#Music`
|
||||
if (url.includes('openlibrary.org')) return `#Books #NowReading ${tagMap[url]}`.trim()
|
||||
if (url.includes('trakt.tv')) return `#Movies #Watching ${tagMap[url]}`.trim()
|
||||
if (url.includes('themoviedb.org/movie')) return `#Movies #Watching`
|
||||
return tagMap[url] || ''
|
||||
},
|
||||
|
||||
|
|
36
package-lock.json
generated
36
package-lock.json
generated
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "coryd.dev",
|
||||
"version": "14.4.0",
|
||||
"version": "14.6.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "coryd.dev",
|
||||
"version": "14.4.0",
|
||||
"version": "14.6.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@cdransf/api-text": "^1.2.2",
|
||||
|
@ -2619,9 +2619,9 @@
|
|||
"peer": true
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.12.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.11.tgz",
|
||||
"integrity": "sha512-vDg9PZ/zi+Nqp6boSOT7plNuthRugEKixDv5sFTIpkE89MmNtEArAShI4mxuX2+UrLEe9pxC1vm2cjm9YlWbJw==",
|
||||
"version": "20.12.12",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.12.12.tgz",
|
||||
"integrity": "sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
|
@ -2908,9 +2908,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/caniuse-lite": {
|
||||
"version": "1.0.30001617",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001617.tgz",
|
||||
"integrity": "sha512-mLyjzNI9I+Pix8zwcrpxEbGlfqOkF9kM3ptzmKNw5tizSyYwMe+nGLTqMK9cO+0E+Bh6TsBxNAaHWEM8xwSsmA==",
|
||||
"version": "1.0.30001618",
|
||||
"resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001618.tgz",
|
||||
"integrity": "sha512-p407+D1tIkDvsEAPS22lJxLQQaG8OTBEqo0KhzfABGk0TU4juBNDSfH0hyAp/HRyx+M8L17z/ltyhxh27FTfQg==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
|
@ -3432,9 +3432,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/electron-to-chromium": {
|
||||
"version": "1.4.764",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.764.tgz",
|
||||
"integrity": "sha512-ZXbPV46Y4dNCA+k7YHB+BYlzcoMtZ1yH6V0tQ1ul0wmA7RiwJfS29LSdRlE1myWBXRzEgm/Lz6tryj5WVQiLmg==",
|
||||
"version": "1.4.767",
|
||||
"resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.767.tgz",
|
||||
"integrity": "sha512-nzzHfmQqBss7CE3apQHkHjXW77+8w3ubGCIoEijKCJebPufREaFETgGXWTkh32t259F3Kcq+R8MZdFdOJROgYw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/encodeurl": {
|
||||
|
@ -5384,9 +5384,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/picocolors": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.0.tgz",
|
||||
"integrity": "sha512-1fygroTLlHu66zi26VoTDv8yRgm0Fccecssto+MhsZ0D/DGW2sm8E8AjW7NU5VVTRt5GxbeZ5qBuJr+HyLYkjQ==",
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz",
|
||||
"integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/picomatch": {
|
||||
|
@ -6319,9 +6319,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/update-browserslist-db": {
|
||||
"version": "1.0.15",
|
||||
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.15.tgz",
|
||||
"integrity": "sha512-K9HWH62x3/EalU1U6sjSZiylm9C8tgq2mSvshZpqc7QE69RaA2qjhkW2HlNA0tFpEbtyFz7HTqbSdN4MSwUodA==",
|
||||
"version": "1.0.16",
|
||||
"resolved": "https://registry.npmjs.org/update-browserslist-db/-/update-browserslist-db-1.0.16.tgz",
|
||||
"integrity": "sha512-KVbTxlBYlckhF5wgfyZXTWnMn7MMZjMu9XG8bPlliUOP9ThaF4QnhP8qrjrH7DRzHfSk0oQv1wToW+iA5GajEQ==",
|
||||
"dev": true,
|
||||
"funding": [
|
||||
{
|
||||
|
@ -6339,7 +6339,7 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"escalade": "^3.1.2",
|
||||
"picocolors": "^1.0.0"
|
||||
"picocolors": "^1.0.1"
|
||||
},
|
||||
"bin": {
|
||||
"update-browserslist-db": "cli.js"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "coryd.dev",
|
||||
"version": "14.5.1",
|
||||
"version": "14.6.0",
|
||||
"description": "The source for my personal site. Built using 11ty.",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
|
|
|
@ -1,47 +1,46 @@
|
|||
import EleventyFetch from '@11ty/eleventy-fetch'
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
import { DateTime } from 'luxon'
|
||||
|
||||
const SUPABASE_URL = process.env.SUPABASE_URL
|
||||
const SUPABASE_KEY = process.env.SUPABASE_KEY
|
||||
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
|
||||
|
||||
export default async function () {
|
||||
const TV_KEY = process.env.API_KEY_TRAKT
|
||||
const MOVIEDB_KEY = process.env.API_KEY_MOVIEDB
|
||||
const url = 'https://api.trakt.tv/users/cdransf/history/movies?page=1&limit=6&extended=full'
|
||||
const { data: movies, error } = await supabase
|
||||
.from('movies')
|
||||
.select(`
|
||||
tmdb_id,
|
||||
slug,
|
||||
last_watched,
|
||||
title,
|
||||
year,
|
||||
collected,
|
||||
plays,
|
||||
favorite
|
||||
`)
|
||||
.order('last_watched', { ascending: false })
|
||||
|
||||
if (error) return []
|
||||
|
||||
|
||||
const formatMovieData = (movies) => movies.map((item) => {
|
||||
const movie = {
|
||||
title: item['movie']['title'],
|
||||
dateAdded: item['watched_at'],
|
||||
url: `https://trakt.tv/movies/${item['movie']['ids']['slug']}`,
|
||||
id: item['movie']['ids']['trakt'],
|
||||
tmdbId: item['movie']['ids']['tmdb'],
|
||||
description: `${item['movie']['overview']}<br/><br/>`,
|
||||
tags: item['movie']['genres'],
|
||||
title: item['title'],
|
||||
dateAdded: item['last_watched'],
|
||||
url: `https://www.themoviedb.org/movie/${item['tmdb_id']}`,
|
||||
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`,
|
||||
plays: item['plays'],
|
||||
collected: item['collected'],
|
||||
favorite: item['favorite'],
|
||||
}
|
||||
return movie;
|
||||
})
|
||||
|
||||
const res = EleventyFetch(url, {
|
||||
duration: '1h',
|
||||
type: 'json',
|
||||
fetchOptions: {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'trakt-api-version': 2,
|
||||
'trakt-api-key': TV_KEY,
|
||||
},
|
||||
},
|
||||
}).catch()
|
||||
const data = await res
|
||||
const movies = formatMovieData(data)
|
||||
|
||||
for (const movie of movies) {
|
||||
const tmdbId = movie['tmdbId']
|
||||
const tmdbUrl = `https://api.themoviedb.org/3/movie/${tmdbId}?api_key=${MOVIEDB_KEY}`
|
||||
const tmdbRes = EleventyFetch(tmdbUrl, {
|
||||
duration: '1h',
|
||||
type: 'json',
|
||||
})
|
||||
const tmdbData = await tmdbRes
|
||||
const posterPath = tmdbData['poster_path']
|
||||
movie.image = `https://image.tmdb.org/t/p/w500/${posterPath}`
|
||||
return {
|
||||
movies,
|
||||
watchHistory: formatMovieData(movies),
|
||||
recentlyWatched: formatMovieData(movies.slice(0, 6)),
|
||||
}
|
||||
return movies;
|
||||
}
|
||||
}
|
167
src/_data/tv.js
167
src/_data/tv.js
|
@ -1,87 +1,116 @@
|
|||
import EleventyFetch from '@11ty/eleventy-fetch'
|
||||
import { createClient } from '@supabase/supabase-js'
|
||||
|
||||
const SUPABASE_URL = process.env.SUPABASE_URL
|
||||
const SUPABASE_KEY = process.env.SUPABASE_KEY
|
||||
const supabase = createClient(SUPABASE_URL, SUPABASE_KEY)
|
||||
|
||||
export default async function () {
|
||||
const TV_KEY = process.env.API_KEY_TRAKT
|
||||
const MOVIEDB_KEY = process.env.API_KEY_MOVIEDB
|
||||
const url = 'https://api.trakt.tv/users/cdransf/history/shows?page=1&limit=75'
|
||||
const formatEpisodeData = (shows) => {
|
||||
const { data: shows, error } = await supabase
|
||||
.from('shows')
|
||||
.select(`
|
||||
title,
|
||||
tmdb_id,
|
||||
collected,
|
||||
favorite,
|
||||
episodes (
|
||||
episode_number,
|
||||
season_number,
|
||||
last_watched_at
|
||||
)
|
||||
`)
|
||||
|
||||
if (error) return []
|
||||
|
||||
let episodes = []
|
||||
shows.forEach(show => {
|
||||
show.episodes.forEach(episode => {
|
||||
episodes.push({
|
||||
...episode,
|
||||
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))
|
||||
const allEpisodes = episodes
|
||||
episodes = episodes.slice(0, 75)
|
||||
|
||||
const formatEpisodeData = (episodes) => {
|
||||
const episodeData = []
|
||||
const startingEpisodes = []
|
||||
const startingSeasons = []
|
||||
shows.reverse().forEach((episode) => {
|
||||
const episodeNumber = episode['episode']['number']
|
||||
const seasonNumber = episode['episode']['season']
|
||||
if (!startingEpisodes.find((e) => e.show === episode['show']['title'])) startingEpisodes.push({ show: episode['show']['title'], episode: episodeNumber })
|
||||
if (!startingSeasons.find((e) => e.show === episode['show']['title'])) startingSeasons.push({ show: episode['show']['title'], season: seasonNumber })
|
||||
const showEpisodesMap = {}
|
||||
|
||||
if (episodeData.find((e) => e.name === episode?.['show']?.['title'])) {
|
||||
// cache the matched episode reference
|
||||
const matchedEpisode = episodeData.find((e) => e.name === episode?.['show']?.['title'])
|
||||
const startingEpisode = startingEpisodes.find((e) => e.show === episode['show']['title'])['episode']
|
||||
const startingSeason = startingSeasons.find((e) => e.show === episode['show']['title'])['season']
|
||||
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
|
||||
|
||||
// remove the matched episode from the array
|
||||
episodeData.splice(
|
||||
episodeData.findIndex((e) => e.name === episode['show']['title']),
|
||||
1
|
||||
)
|
||||
if (!showEpisodesMap[showTmdbId]) {
|
||||
showEpisodesMap[showTmdbId] = {
|
||||
title: showTitle,
|
||||
tmdbId: showTmdbId,
|
||||
collected: collected,
|
||||
favorite: favorite,
|
||||
episodes: []
|
||||
}
|
||||
}
|
||||
|
||||
// push the new episode to the array
|
||||
showEpisodesMap[showTmdbId].episodes.push({
|
||||
name: showTitle,
|
||||
url: `https://www.themoviedb.org/tv/${showTmdbId}/season/${seasonNumber}/episode/${episodeNumber}`,
|
||||
subtext: `${showTitle} • S${seasonNumber}E${episodeNumber}`,
|
||||
episode: episodeNumber,
|
||||
season: seasonNumber,
|
||||
tmdbId: showTmdbId,
|
||||
type: 'tv',
|
||||
image: `https://coryd.dev/media/shows/poster-${showTmdbId}.jpg`,
|
||||
lastWatchedAt: 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
|
||||
|
||||
if (show.episodes.length > 1) {
|
||||
episodeData.push({
|
||||
name: matchedEpisode['name'],
|
||||
url: `https://trakt.tv/shows/${episode['show']['ids']['slug']}`,
|
||||
subtext: `S${startingSeason}E${startingEpisode} - S${episode['episode']['season']}E${episode['episode']['number']}`,
|
||||
name: show.title,
|
||||
url: `https://www.themoviedb.org/tv/${show.tmdbId}`,
|
||||
subtext: `S${startingSeason}E${startingEpisode} - S${endingSeason}E${endingEpisode}`,
|
||||
startingEpisode,
|
||||
startingSeason,
|
||||
episode: episodeNumber,
|
||||
season: seasonNumber,
|
||||
id: episode['show']['ids']['trakt'],
|
||||
tmdbId: episode['show']['ids']['tmdb'],
|
||||
episode: endingEpisode,
|
||||
season: endingSeason,
|
||||
tmdbId: show.tmdbId,
|
||||
collected: show.collected,
|
||||
favorite: show.favorite,
|
||||
type: 'tv-range',
|
||||
image: `https://coryd.dev/media/shows/poster-${show.tmdbId}.jpg`,
|
||||
})
|
||||
} else {
|
||||
// if an episode with the same show name doesn't exist, push it to the array
|
||||
episodeData.push({
|
||||
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']}`,
|
||||
subtext: `${episode['show']['title']} • S${episode['episode']['season']}E${episode['episode']['number']}`,
|
||||
episode: episodeNumber,
|
||||
season: seasonNumber,
|
||||
id: episode['show']['ids']['trakt'],
|
||||
tmdbId: episode['show']['ids']['tmdb'],
|
||||
type: 'tv',
|
||||
})
|
||||
const singleEpisode = show.episodes[0]
|
||||
singleEpisode.collected = show.collected
|
||||
singleEpisode.favorite = show.favorite
|
||||
episodeData.push(singleEpisode)
|
||||
}
|
||||
})
|
||||
|
||||
return episodeData.reverse()
|
||||
return episodeData
|
||||
}
|
||||
|
||||
const res = EleventyFetch(url, {
|
||||
duration: '1h',
|
||||
type: 'json',
|
||||
fetchOptions: {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'trakt-api-version': 2,
|
||||
'trakt-api-key': TV_KEY,
|
||||
},
|
||||
},
|
||||
}).catch()
|
||||
const shows = await res
|
||||
const episodes = formatEpisodeData(shows)
|
||||
for (const episode of episodes) {
|
||||
const tmdbId = episode['tmdbId']
|
||||
const tmdbUrl = `https://api.themoviedb.org/3/tv/${tmdbId}?api_key=${MOVIEDB_KEY}`
|
||||
const tmdbRes = EleventyFetch(tmdbUrl, {
|
||||
duration: '1h',
|
||||
type: 'json',
|
||||
})
|
||||
const tmdbData = await tmdbRes
|
||||
const posterPath = tmdbData['poster_path']
|
||||
episode.image = `https://coryd.dev/.netlify/images/?url=https://image.tmdb.org//t/p/w500${posterPath}&w=200&h=307&fit=fill`
|
||||
return {
|
||||
shows,
|
||||
watchHistory: formatEpisodeData(allEpisodes),
|
||||
recentlyWatched: formatEpisodeData(episodes)
|
||||
}
|
||||
|
||||
return episodes;
|
||||
}
|
||||
}
|
|
@ -94,11 +94,11 @@ layout: default
|
|||
{% tablericon "movie" "Movies" %}
|
||||
Movies
|
||||
</h2>
|
||||
{% render "partials/now/media-grid.liquid", data:movies, icon: "movie", title: "Movies", shape: "vertical", count: 6 %}
|
||||
{% render "partials/now/media-grid.liquid", data:movies.recentlyWatched, icon: "movie", title: "Movies", shape: "vertical", count: 6 %}
|
||||
<h2 id="tv" class="section-header flex-centered">
|
||||
{% tablericon "device-tv" "TV" %}
|
||||
TV
|
||||
</h2>
|
||||
{% render "partials/now/media-grid.liquid", data:tv, icon: "device-tv", title: "TV", shape: "vertical", count: 6 %}
|
||||
{% render "partials/now/media-grid.liquid", data:tv.recentlyWatched, icon: "device-tv", title: "TV", shape: "vertical", count: 6 %}
|
||||
<p class="now-explainer text-small text-centered">This is a <a href="https://nownownow.com/about">now page</a>, and if you have your own site, <a href="https://nownownow.com/about">you should make one too</a>.</p>
|
||||
<p class="text-small text-centered"><em>This page was last updated on {{ "now" | date: "%B %-d, %-I:%M%p", "America/Los_Angeles" }}.</em></p>
|
|
@ -1,6 +1,6 @@
|
|||
{%- assign artist = artists | first -%}
|
||||
{%- assign book = books | bookStatus: 'started' | reverse | first -%}
|
||||
{%- assign show = tv | first -%}
|
||||
{%- assign show = tv.recentlyWatched | first -%}
|
||||
<div class="now-topper">
|
||||
<p><strong class="highlight-text">I'm a software developer based in Camarillo, California</strong>. I enjoy hanging out with my beautiful family and 3 rescue dogs, technology, automation, <a href="https://coryd.dev/now#artists">music</a>, writing, <a href="https://coryd.dev/now#books">reading</a>, <a href="https://coryd.dev/now#tv">tv</a> and <a href="https://coryd.dev/now#movies">movies</a>. Lately I've been listening to a lot of <strong class="highlight-text">{{ artist.title }}</strong>, reading <strong class="highlight-text">{{ book.title }}</strong> and watching <strong class="highlight-text">{{ show.name }}</strong>.</p>
|
||||
{% render "partials/now/status.liquid", status:status %}
|
||||
|
|
|
@ -7,7 +7,7 @@ permalink: /feeds/movies
|
|||
permalink:"/feeds/movies"
|
||||
title:"Movies • Cory Dransfeldt"
|
||||
description:"Movies I've watched recently."
|
||||
data:movies
|
||||
updated:movies[0].dateAdded
|
||||
data:movies.recentlyWatched
|
||||
updated:movies.recentlyWatched[0].dateAdded
|
||||
site:site
|
||||
%}
|
|
@ -5,7 +5,7 @@ permalink: /about.html
|
|||
---
|
||||
{%- assign artist = music.week.artists | first -%}
|
||||
{%- assign book = books | bookStatus: 'started' | reverse | first -%}
|
||||
{%- assign show = tv | first -%}
|
||||
{%- assign show = tv.recentlyWatched | first -%}
|
||||
<div class="avatar-wrapper flex-centered">
|
||||
<div class="interior">
|
||||
{%- capture about_alt -%}{{ meta.siteName }} - image by David Neal / @reverentgeek{%- endcapture -%}
|
||||
|
|
Reference in a new issue