Skip to content

Commit

Permalink
feat: add 'release_year' option for episode template
Browse files Browse the repository at this point in the history
  • Loading branch information
lightpohl committed Aug 25, 2024
1 parent 97cfd7d commit 223022e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ 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.
- `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
9 changes: 7 additions & 2 deletions bin/naming.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@ const getItemFilename = ({
}) => {
const episodeNum = feed.items.length - item._originalIndex + offset;
const title = item.title || "";
const formattedPubDate = item.pubDate
const releaseYear = item.pubDate
? dayjs(new Date(item.pubDate)).format("YYYY")
: null;

const releaseDate = item.pubDate
? dayjs(new Date(item.pubDate)).format("YYYYMMDD")
: null;

Expand All @@ -43,7 +47,8 @@ const getItemFilename = ({

const templateReplacementsTuples = [
["title", title],
["release_date", formattedPubDate || ""],
["release_date", releaseDate || ""],
["release_year", releaseYear || ""],
["episode_num", `${episodeNum}`.padStart(width, "0")],
["url", url],
["podcast_title", feed.title || ""],
Expand Down

0 comments on commit 223022e

Please sign in to comment.