Skip to content
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

Merged
merged 6 commits into from
Jul 15, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"querystring": "^0.2.0",
"rss-parser": "^3.11.0",
"tslib": "^2",
"turndown": "^7.1.1",
"uri-scheme": "^1.0.76"
},
"devDependencies": {
Expand Down
30 changes: 27 additions & 3 deletions src/commands/scheduled/recently-published.ts
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 =
Expand Down Expand Up @@ -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 = [
{
Expand All @@ -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}>`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

},
},
{
type: "section",
text: {
type: "mrkdwn",
text: `> ${content}`,
text: `${formattedContent}`,
},
},
{
Expand Down Expand Up @@ -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>",
},
],
},
Expand Down Expand Up @@ -173,5 +177,25 @@ 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", "")
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 .mp3.

}

function formatContent(content: string | undefined) {
if (content === undefined) {
return ""
}

// BuzzSprout gives us html for this field; slack needs markdown or plaintext.
var turndownService = new TurndownService()
var markdown = turndownService.turndown(`<blockquote>${content}</blockquote>`)
return markdown
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice 💯

}
6 changes: 3 additions & 3 deletions test/commands/scheduled/recently-published.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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>",
},
})
)
Expand All @@ -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>",
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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.",
},
})
)
Expand Down Expand Up @@ -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>",
},
],
})
Expand Down
12 changes: 12 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2443,6 +2443,11 @@ doctrine@0.7.2:
esutils "^1.1.6"
isarray "0.0.1"

domino@^2.1.6:
version "2.1.6"
resolved "https://registry.yarnpkg.com/domino/-/domino-2.1.6.tgz#fe4ace4310526e5e7b9d12c7de01b7f485a57ffe"
integrity sha512-3VdM/SXBZX2omc9JF9nOPCtDaYQ67BGp5CoLpIQlO2KCAPETs8TcDHacF26jXadGbvUteZzRTeos2fhID5+ucQ==

dot-case@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-3.0.4.tgz#9b2b670d00a431667a8a75ba29cd1b98809ce751"
Expand Down Expand Up @@ -5367,6 +5372,13 @@ tunnel-agent@^0.6.0:
dependencies:
safe-buffer "^5.0.1"

turndown@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/turndown/-/turndown-7.1.1.tgz#96992f2d9b40a1a03d3ea61ad31b5a5c751ef77f"
integrity sha512-BEkXaWH7Wh7e9bd2QumhfAXk5g34+6QUmmWx+0q6ThaVOLuLUqsnkq35HQ5SBHSaxjSfSM7US5o4lhJNH7B9MA==
dependencies:
domino "^2.1.6"

type-detect@4.0.8, type-detect@^4.0.0, type-detect@^4.0.5, type-detect@^4.0.8:
version "4.0.8"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
Expand Down