From c07dd3b3072cc3d68d389166d1115b647cf2412c Mon Sep 17 00:00:00 2001 From: Anthony Correa Date: Tue, 10 Dec 2024 15:11:22 -0600 Subject: [PATCH] add transcripts --- content/episodes/episodes.11tydata.js | 1 + layouts/podcast.11ty.js | 14 +++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/content/episodes/episodes.11tydata.js b/content/episodes/episodes.11tydata.js index 5bdb582..b76d95a 100644 --- a/content/episodes/episodes.11tydata.js +++ b/content/episodes/episodes.11tydata.js @@ -9,6 +9,7 @@ module.exports = { "podcast": (data) => { return { "enclosureUrl": data.podcast.enclosureUrl ||`${data.site.cdn}/${seasonEpisodeFormat(null, data).toLowerCase()}.mp3`, + "transcriptUrl": data.podcast.transcriptUrl ||`${data.site.cdn}/${seasonEpisodeFormat(null, data).toLowerCase()}.srt`, "title": data.podcast.title || `${seasonEpisodeFormat(null, data)}: ${data.title || "Episode " + data.episode}`, "image" : data.podcast.image || data.image || "{{page.url}}/../image.jpg" }} diff --git a/layouts/podcast.11ty.js b/layouts/podcast.11ty.js index 6f7306f..ec9d0d8 100644 --- a/layouts/podcast.11ty.js +++ b/layouts/podcast.11ty.js @@ -2,8 +2,6 @@ const { Podcast } = require('podcast'); const music_metadata = require('music-metadata'); const fs = require('fs'); -const PODCAST_CDN_ROOT="https://podcast.rpg.cdn.ascorrea.com" - async function getMp3Duration(filePath) { try { const metadata = await music_metadata.parseFile(filePath); @@ -49,19 +47,25 @@ class PodcastFeed { }); const items = data.collections[data.episodeCollection]?.filter(episode=>episode.data.podcast!=false) - + var item items.forEach(episode=>{ // const duration = getMp3Duration(`../episodes/s${zero_pad_season}/s${zero_pad_season}e${episode.data.episode}.mp3`) /* loop over data and add to feed */ - feed.addItem({ + item = { title: `${episode.data.podcast.title}`, description: episode.content, url: data.site.url+this.url(episode.url), // link to the item guid: episode.url, // optional - defaults to url date: episode.data.date, // any format that js Date can parse. enclosure : {url:`${episode.data.podcast.enclosureUrl}`}, // optional enclosure + customElements: [] // itunesDuration: duration, - }); + } + if (episode.data.podcast.transcriptUrl) { + item.customElements.push({ 'podcast:transcript': `${episode.data.podcast.transcriptUrl}` }) + } + item = feed.addItem(item); + })