Update team and description parsing

This commit is contained in:
Dennis Reimann
2024-04-28 12:17:14 +02:00
parent 94bf896221
commit 7812610172
6 changed files with 22 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
const { writeFileSync } = require('fs')
const { join, resolve } = require('path')
const { replacements, slugify, stripHTML, teamWithAliases } = require('../helpers')
const { replacements, slugify, stripHTML, teamWithAliases, participantToId } = require('../helpers')
const { masterFeedUrl, publicFeedUrl } = require('../content/meta.json')
const teamRaw = require('../content/team.json')
const request = require('sync-request')
@@ -67,13 +67,14 @@ const parseEpisode = e => {
: `/img/cover/${category}.png`
const duration = e['itunes:duration']
const enclosure = e.enclosure.__attr
const [, participantsString] =
const [, participantsString, additionalString] =
firstLine.match(/[-–—]\s?(?:(?:(?:von\sund\s)?mit\s)|(?:gelesen\svon\s))([^.]*)/i) || []
const participants = participantsString
? participantsString
.replace(/(\s*,\s*|\s*und\s*|\s*&\s*)/gi, '%')
.replace(/(\s*,\s*|\s*und\s*|\s*sowie\s*|\s*&\s*)/gi, '%')
.trim()
.split('%')
.filter(p => !!p)
.map(p => p.trim())
: []
return {
@@ -149,7 +150,6 @@ const parseEpisode = e => {
...item,
link, // replace Anchor link
description: { __cdata: description },
//'itunes:summary': description // please the validator, Anchor's itunes:summary contains HTML
}
// itunes:summary seems to be gone: https://help.apple.com/itc/podcasts_connect/#/itcb54353390
delete updated['itunes:summary']
@@ -164,7 +164,7 @@ const parseEpisode = e => {
}
const value = episode.participants.reduce((result, name) => {
const id = name.toLowerCase()
const id = participantToId(name)
const v4v = team[id] && team[id].v4v
if (v4v) {
result.push({ name, ...v4v })
@@ -193,7 +193,7 @@ const parseEpisode = e => {
}
const people = episode.participants.reduce((result, name) => {
const id = name.toLowerCase()
const id = participantToId(name)
const person = team[id]
if (person) {
result.push(person)

View File

@@ -1,7 +1,7 @@
const pug = require('pug')
const { mkdirSync, writeFileSync } = require('fs')
const { dirname, resolve } = require('path')
const { slugify, teamWithAliases } = require('../helpers')
const { slugify, teamWithAliases, participantToId } = require('../helpers')
const config = require('../pug.config')
const site = require('../generated/site-data.json')
const episodes = require('../generated/episodes.json')
@@ -61,6 +61,6 @@ Object.keys(categories).forEach(category => renderPage('category', `podcast/${sl
Object.keys(teamRaw).forEach(id => {
const member = teamRaw[id]
const aliases = (member.aliases || []).map(m => m.toLowerCase()).concat(member.name.toLowerCase())
const eps = episodes.filter(e => e.participants.find(p => [id, ...aliases].includes(p.toLowerCase())))
const eps = episodes.filter(e => e.participants.find(p => [id, ...aliases].includes(participantToId(p))))
renderPage('member', `team/${slugify(id)}`, { navCurrent: 'podcast', member, episodes: eps, team })
})