Skip to content

Commit

Permalink
feat: add 'release_month' and 'release_day' template options
Browse files Browse the repository at this point in the history
  • Loading branch information
lightpohl committed Aug 29, 2024
1 parent 7ef8e23 commit 27c2e8b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
11 changes: 11 additions & 0 deletions bin/naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 || ""],
Expand Down

0 comments on commit 27c2e8b

Please sign in to comment.