Improve shownotes parsing

This commit is contained in:
Dennis Reimann
2024-01-11 11:00:00 +01:00
parent f7ebc82056
commit 6820224f98

View File

@@ -36,6 +36,8 @@ const json2xmlOpts = {
indentBy: ' ' indentBy: ' '
} }
const regexBlockzeit = /Blockzeit\s(\d+(?:\.)?\d+)/
const parser = new XMLParser(xml2jsonOpts, true) const parser = new XMLParser(xml2jsonOpts, true)
const builder = new XMLBuilder(json2xmlOpts) const builder = new XMLBuilder(json2xmlOpts)
@@ -53,9 +55,9 @@ const parseEpisode = e => {
if (categoryName === 'Buchclub') categoryName = 'Lesestunde' if (categoryName === 'Buchclub') categoryName = 'Lesestunde'
if (categoryName === 'reCATion') categoryName = 'Verschiedenes' if (categoryName === 'reCATion') categoryName = 'Verschiedenes'
if (categoryName === 'NostrTalk') categoryName = 'NostrTalk' if (categoryName === 'NostrTalk') categoryName = 'NostrTalk'
const firstLine = descriptionPlain.split('\n')[0] const firstLine = descriptionPlain.split('\n').find(l => l.match(regexBlockzeit)) || ''
const blockMatch = firstLine.match(/Blockzeit\s(\d+)/) const blockMatch = firstLine.match(regexBlockzeit)
const block = blockMatch ? parseInt(blockMatch[1]) : null const block = blockMatch ? parseInt(blockMatch[1].replace('.', '')) : null
const category = slugify(categoryName) const category = slugify(categoryName)
const slug = slugify(`${categoryName} ${number || ''} ${titlePlain}`) const slug = slugify(`${categoryName} ${number || ''} ${titlePlain}`)
const date = new Date(e.pubDate) const date = new Date(e.pubDate)