generated from CaliCastle/cali-fm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpodcast.config.ts
66 lines (60 loc) · 1.77 KB
/
podcast.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { cache } from 'react'
import { parse } from 'rss-to-json'
/**
* TODO: Add your podcast config here
*/
export const podcastConfig: PodcastConfig = {
/**
* Step 1. Add your podcast directories here
* We support links from:
* Apple Podcasts, Google Podcasts, Spotify, Stitcher, Overcast,
* Pocket Casts Castro, 小宇宙, 哔哩哔哩, YouTube
*/
directories: [
'https://open.spotify.com/show/4vpLJCVh64qh4MOgvHwPeE',
'https://podcasts.apple.com/us/podcast/%E7%A7%91%E6%8A%80%E5%8F%8C%E7%9C%BC%E5%95%A4/id1642252327',
'https://podcasts.google.com/feed/aHR0cHM6Ly9ranN5cC5mbS9mZWVk',
],
/**
* Step 2. Add your podcast hosts here
*/
hosts: [
{
name: 'Cali Castle',
link: 'https://twitter.com/thecalicastle',
},
{
name: 'Rather Jie',
link: 'https://twitter.com/RatherJie',
},
],
}
export const getPodcast = cache(async () => {
const feed = await parse(process.env.NEXT_PUBLIC_PODCAST_RSS || '')
const podcast: Podcast = {
title: feed.title,
description: feed.description,
link: feed.link,
coverArt: feed.image,
}
return podcast
})
export const getPodcastEpisodes = cache(async () => {
const feed = await parse(process.env.NEXT_PUBLIC_PODCAST_RSS || '')
const episodes: Episode[] = feed.items.map((item) => ({
id: item.id.split('/').pop(),
title: item.title,
description: item.description,
link: item.link,
published: item.published,
content: item.content,
duration: item.itunes_duration,
enclosure: item.enclosures[0],
coverArt: item.itunes_image?.href,
}))
return episodes
})
export const getPodcastEpisode = cache(async (id: string) => {
const episodes = await getPodcastEpisodes()
return episodes.find((episode) => episode.id.endsWith(id))
})