feat: parse episode document content

This commit is contained in:
Hossein Mehrabi 2023-08-18 18:51:19 +03:30
parent 11c994a693
commit e2cdc0886d
No known key found for this signature in database
GPG Key ID: 45C04964191AFAA1
2 changed files with 18 additions and 18 deletions

View File

@ -47,15 +47,23 @@ export const PodcastEpisodeDataType: UnbodyDataTypeConfig<
const channels: LPE.Podcast.Content['channels'] = [] const channels: LPE.Podcast.Content['channels'] = []
const credits: LPE.Podcast.Content['credits'] = [] const credits: LPE.Podcast.Content['credits'] = []
const transcription: LPE.Podcast.Content['transcription'] = [] const transcription: LPE.Podcast.Content['transcription'] = []
const timestamps: LPE.Podcast.Content['timestamps'] = [] const content: LPE.Podcast.Content['content'] = []
const allBlocks = data.content.filter((block) => {
if (
((block.type === 'text' && block.html) || '').match(
`<a href="#ftnt_ref`,
)?.length
)
return false
return true
})
if (context?.parseContent) { if (context?.parseContent) {
const sections = findSections( const sections = findSections(['Credits', 'Content'], allBlocks)
['Credits', 'Timestamps', 'Transcription'],
data.content,
)
const textBlocks = data.content.filter( const textBlocks = allBlocks.filter(
(block) => block.type === 'text', (block) => block.type === 'text',
) as LPE.Post.TextBlock[] ) as LPE.Post.TextBlock[]
@ -71,16 +79,8 @@ export const PodcastEpisodeDataType: UnbodyDataTypeConfig<
break break
} }
case 'Timestamps': { case 'Content': {
const blocks = section.blocks.filter((block) => { content.push(...section.blocks)
if (block.type === 'image') return false
if ((block.html || '').match(`<a href="#ftnt_ref`)?.length)
return false
return true
}) as LPE.Post.TextBlock[]
timestamps.push(...blocks)
break break
} }
@ -104,7 +104,7 @@ export const PodcastEpisodeDataType: UnbodyDataTypeConfig<
episodeNumber, episodeNumber,
tags: data.tags, tags: data.tags,
credits, credits,
timestamps, content,
transcription, transcription,
channels, channels,
...(show ? { show } : {}), ...(show ? { show } : {}),

View File

@ -197,7 +197,7 @@ export namespace LPE {
export type Content = { export type Content = {
channels: Channel[] channels: Channel[]
credits: Post.TextBlock[] credits: Post.TextBlock[]
timestamps: Post.TextBlock[] content: Post.ContentBlock[]
transcription: TranscriptionItem[] transcription: TranscriptionItem[]
} }