From 27c2e8b1229079018eb14404915bddcca2543fce Mon Sep 17 00:00:00 2001 From: Joshua Pohl Date: Wed, 28 Aug 2024 22:21:31 -0600 Subject: [PATCH] feat: add 'release_month' and 'release_day' template options --- README.md | 4 +++- bin/naming.js | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 51d0525..4b845b8 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,9 @@ Options that support templates allow users to specify a template for the generat - `title`: The title of the episode. - `release_date`: The release date of the episode in `YYYYMMDD` format. -- `release_year`: The release year of the episode. +- `release_year`: The release year (`YYYY`) of the episode. +- `release_month`: The release month (`MM`) of the episode. +- `release_day`: The release day (`DD`) of the episode. - `episode_num`: The location number of where the episodes appears in the feed. - `url`: URL of episode audio file. - `duration`: Provided `mm:ss` duration (if found). diff --git a/bin/naming.js b/bin/naming.js index bb6d6d0..005176b 100644 --- a/bin/naming.js +++ b/bin/naming.js @@ -30,10 +30,19 @@ const getItemFilename = ({ }) => { const episodeNum = feed.items.length - item._originalIndex + offset; const title = item.title || ""; + const releaseYear = item.pubDate ? dayjs(new Date(item.pubDate)).format("YYYY") : null; + const releaseMonth = item.pubDate + ? dayjs(new Date(item.pubDate)).format("MM") + : null; + + const releaseDay = item.pubDate + ? dayjs(new Date(item.pubDate)).format("DD") + : null; + const releaseDate = item.pubDate ? dayjs(new Date(item.pubDate)).format("YYYYMMDD") : null; @@ -49,6 +58,8 @@ const getItemFilename = ({ ["title", title], ["release_date", releaseDate || ""], ["release_year", releaseYear || ""], + ["release_month", releaseMonth || ""], + ["release_day", releaseDay || ""], ["episode_num", `${episodeNum}`.padStart(width, "0")], ["url", url], ["podcast_title", feed.title || ""],