-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: improve recent podcast summary #247
Changes from all commits
a307892
5a4fd71
a54e2ca
a57e5ac
455d086
ebfaea7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { Command } from "@oclif/command" | ||
import Parser = require("rss-parser") | ||
import TurndownService = require("turndown") | ||
|
||
export default class ScheduledRecentlyPublished extends Command { | ||
static description = | ||
|
@@ -86,8 +87,11 @@ export default class ScheduledRecentlyPublished extends Command { | |
content, | ||
pubDate, | ||
itunes: { author }, | ||
enclosure, | ||
} = lastEpisode | ||
const formattedDate = formatDate(pubDate) | ||
const webURL = formatWebURL(enclosure?.url) | ||
const formattedContent = formatContent(content) | ||
|
||
const blocks = [ | ||
{ | ||
|
@@ -101,14 +105,14 @@ export default class ScheduledRecentlyPublished extends Command { | |
type: "section", | ||
text: { | ||
type: "mrkdwn", | ||
text: `${title} | <https://podcasts.apple.com/us/podcast/artsy-engineering-radio/id1545870104|Apple Podcasts> | <https://podcasts.google.com/feed/aHR0cHM6Ly9hcnRzeS5naXRodWIuaW8vcG9kY2FzdC54bWw|Google Podcasts> | <https://open.spotify.com/show/0gJYxpqN6P11dbjNw8VT2a?si=L4TWDrQETwuVO6JR1SOZTQ|Spotify>`, | ||
text: `<${webURL}|${title}>`, | ||
}, | ||
}, | ||
{ | ||
type: "section", | ||
text: { | ||
type: "mrkdwn", | ||
text: `> ${content}`, | ||
text: `${formattedContent}`, | ||
}, | ||
}, | ||
{ | ||
|
@@ -144,7 +148,7 @@ export default class ScheduledRecentlyPublished extends Command { | |
{ | ||
type: "mrkdwn", | ||
text: | ||
"<https://artsy.github.io|Artsy Engineering> | Podcast (<https://podcasts.apple.com/us/podcast/artsy-engineering-radio/id1545870104|iTunes>, <https://podcasts.google.com/feed/aHR0cHM6Ly9hcnRzeS5naXRodWIuaW8vcG9kY2FzdC54bWw|Google>)", | ||
"<https://artsy.github.io|Artsy Engineering> | <https://artsyengineeringradio.buzzsprout.com|Artsy Engineering Radio>", | ||
}, | ||
], | ||
}, | ||
|
@@ -173,5 +177,27 @@ function formatDate(dateString: string | undefined) { | |
year: "numeric", | ||
month: "short", | ||
day: "numeric", | ||
timeZone: "UTC", | ||
}) | ||
} | ||
|
||
function formatWebURL(urlString: string | undefined) { | ||
if (urlString === undefined) { | ||
return "" | ||
} | ||
|
||
return urlString.replace(".mp3", "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. buzzsprout's webpage for the episode is the same URL as the mp3 itself, without |
||
} | ||
|
||
function formatContent(content: string | undefined) { | ||
if (content === undefined) { | ||
return "" | ||
} | ||
|
||
// BuzzSprout gives us html for this field; slack needs markdown or plaintext. | ||
const turndownService = new TurndownService() | ||
const markdown = turndownService.turndown( | ||
`<blockquote>${content}</blockquote>` | ||
) | ||
return markdown | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice 💯 |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,7 +71,7 @@ describe("scheduled:recently-published", () => { | |
text: { | ||
type: "mrkdwn", | ||
text: | ||
"19: Humanizing The Workplace | <https://podcasts.apple.com/us/podcast/artsy-engineering-radio/id1545870104|Apple Podcasts> | <https://podcasts.google.com/feed/aHR0cHM6Ly9hcnRzeS5naXRodWIuaW8vcG9kY2FzdC54bWw|Google Podcasts> | <https://open.spotify.com/show/0gJYxpqN6P11dbjNw8VT2a?si=L4TWDrQETwuVO6JR1SOZTQ|Spotify>", | ||
"<https://www.buzzsprout.com/1781859/8600736-19-humanizing-the-workplace|19: Humanizing The Workplace>", | ||
}, | ||
}) | ||
) | ||
|
@@ -81,7 +81,7 @@ describe("scheduled:recently-published", () => { | |
text: { | ||
type: "mrkdwn", | ||
text: | ||
"> <p>Steve Hicks and Justin Bennett talk about empathy in workplace culture, how to build trust and safety, and the importance of providing space for people.</p>", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oops! I didn't notice this until after pointing at buzzsprout for this command, but this block wouldn't have displayed very nicely in slack. |
||
"> Steve Hicks and Justin Bennett talk about empathy in workplace culture, how to build trust and safety, and the importance of providing space for people.", | ||
}, | ||
}) | ||
) | ||
|
@@ -127,7 +127,7 @@ describe("scheduled:recently-published", () => { | |
{ | ||
type: "mrkdwn", | ||
text: | ||
"<https://artsy.github.io|Artsy Engineering> | Podcast (<https://podcasts.apple.com/us/podcast/artsy-engineering-radio/id1545870104|iTunes>, <https://podcasts.google.com/feed/aHR0cHM6Ly9hcnRzeS5naXRodWIuaW8vcG9kY2FzdC54bWw|Google>)", | ||
"<https://artsy.github.io|Artsy Engineering> | <https://artsyengineeringradio.buzzsprout.com|Artsy Engineering Radio>", | ||
}, | ||
], | ||
}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💯