mirror of
https://github.com/Einundzwanzig-Podcast/einundzwanzig.space.git
synced 2025-12-13 16:26:50 +00:00
Update fast-xml-parser
This commit is contained in:
36
package-lock.json
generated
36
package-lock.json
generated
@@ -16,9 +16,8 @@
|
|||||||
"broken-link-checker": "0.7.8",
|
"broken-link-checker": "0.7.8",
|
||||||
"browser-sync": "2.27.9",
|
"browser-sync": "2.27.9",
|
||||||
"csso-cli": "3.0.0",
|
"csso-cli": "3.0.0",
|
||||||
"fast-xml-parser": "3.21.1",
|
"fast-xml-parser": "4.0.7",
|
||||||
"glob": "8.0.1",
|
"glob": "8.0.1",
|
||||||
"he": "1.2.0",
|
|
||||||
"html-entities": "2.3.3",
|
"html-entities": "2.3.3",
|
||||||
"jstransformer-markdown-it": "2.1.0",
|
"jstransformer-markdown-it": "2.1.0",
|
||||||
"markdown-it": "12.3.2",
|
"markdown-it": "12.3.2",
|
||||||
@@ -2015,15 +2014,15 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fast-xml-parser": {
|
"node_modules/fast-xml-parser": {
|
||||||
"version": "3.21.1",
|
"version": "4.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.21.1.tgz",
|
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.0.7.tgz",
|
||||||
"integrity": "sha512-FTFVjYoBOZTJekiUsawGsSYV9QL0A+zDYCRj7y34IO6Jg+2IMYEtQa+bbictpdpV8dHxXywqU7C0gRDEOFtBFg==",
|
"integrity": "sha512-dMtibyus3kC7nbxj1CpVtysLzO13UOAZEFAb5vpQg3T4O6qvetmSePpXKFx5KPNCHKoGwjtgjfF5DOyn7s1ylQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"strnum": "^1.0.4"
|
"strnum": "^1.0.5"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
"xml2js": "cli.js"
|
"fxparser": "src/cli/cli.js"
|
||||||
},
|
},
|
||||||
"funding": {
|
"funding": {
|
||||||
"type": "paypal",
|
"type": "paypal",
|
||||||
@@ -2407,15 +2406,6 @@
|
|||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/he": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
|
||||||
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
|
|
||||||
"dev": true,
|
|
||||||
"bin": {
|
|
||||||
"he": "bin/he"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/hosted-git-info": {
|
"node_modules/hosted-git-info": {
|
||||||
"version": "2.8.9",
|
"version": "2.8.9",
|
||||||
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
|
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
|
||||||
@@ -8240,12 +8230,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"fast-xml-parser": {
|
"fast-xml-parser": {
|
||||||
"version": "3.21.1",
|
"version": "4.0.7",
|
||||||
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-3.21.1.tgz",
|
"resolved": "https://registry.npmjs.org/fast-xml-parser/-/fast-xml-parser-4.0.7.tgz",
|
||||||
"integrity": "sha512-FTFVjYoBOZTJekiUsawGsSYV9QL0A+zDYCRj7y34IO6Jg+2IMYEtQa+bbictpdpV8dHxXywqU7C0gRDEOFtBFg==",
|
"integrity": "sha512-dMtibyus3kC7nbxj1CpVtysLzO13UOAZEFAb5vpQg3T4O6qvetmSePpXKFx5KPNCHKoGwjtgjfF5DOyn7s1ylQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"strnum": "^1.0.4"
|
"strnum": "^1.0.5"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"fastq": {
|
"fastq": {
|
||||||
@@ -8534,12 +8524,6 @@
|
|||||||
"type-fest": "^0.8.0"
|
"type-fest": "^0.8.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"he": {
|
|
||||||
"version": "1.2.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
|
|
||||||
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"hosted-git-info": {
|
"hosted-git-info": {
|
||||||
"version": "2.8.9",
|
"version": "2.8.9",
|
||||||
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
|
"resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz",
|
||||||
|
|||||||
@@ -48,9 +48,8 @@
|
|||||||
"broken-link-checker": "0.7.8",
|
"broken-link-checker": "0.7.8",
|
||||||
"browser-sync": "2.27.9",
|
"browser-sync": "2.27.9",
|
||||||
"csso-cli": "3.0.0",
|
"csso-cli": "3.0.0",
|
||||||
"fast-xml-parser": "3.21.1",
|
"fast-xml-parser": "4.0.7",
|
||||||
"glob": "8.0.1",
|
"glob": "8.0.1",
|
||||||
"he": "1.2.0",
|
|
||||||
"html-entities": "2.3.3",
|
"html-entities": "2.3.3",
|
||||||
"jstransformer-markdown-it": "2.1.0",
|
"jstransformer-markdown-it": "2.1.0",
|
||||||
"markdown-it": "12.3.2",
|
"markdown-it": "12.3.2",
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:anchor="https://anchor.fm/xmlns" xmlns:podcast="https://podcastindex.org/namespace/1.0">
|
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:anchor="https://anchor.fm/xmlns" xmlns:podcast="https://podcastindex.org/namespace/1.0">
|
||||||
<channel>
|
<channel>
|
||||||
<podcast:value type="lightning" method="keysend">
|
<podcast:value type="lightning" method="keysend">
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ const { replacements, slugify, stripHTML } = require('../helpers')
|
|||||||
const { masterFeedUrl, publicFeedUrl } = require('../content/meta.json')
|
const { masterFeedUrl, publicFeedUrl } = require('../content/meta.json')
|
||||||
const nodes = require('../content/nodes.json')
|
const nodes = require('../content/nodes.json')
|
||||||
const request = require('sync-request')
|
const request = require('sync-request')
|
||||||
const parser = require('fast-xml-parser')
|
const { XMLParser, XMLBuilder, XMLValidator } = require('fast-xml-parser')
|
||||||
const JSON2XMLParser = require('fast-xml-parser').j2xParser
|
|
||||||
const xmlFormat = require('xml-formatter')
|
const xmlFormat = require('xml-formatter')
|
||||||
const he = require('he')
|
|
||||||
|
|
||||||
const debug = process.env.CI
|
const debug = process.env.CI
|
||||||
const dir = resolve(__dirname, '..')
|
const dir = resolve(__dirname, '..')
|
||||||
@@ -16,37 +14,28 @@ const writeJSON = (name, data) => write(`generated/${name}.json`, JSON.stringify
|
|||||||
|
|
||||||
const commonOpts = {
|
const commonOpts = {
|
||||||
attributeNamePrefix: '',
|
attributeNamePrefix: '',
|
||||||
attrNodeName: '__attr',
|
attributesGroupName: '__attr',
|
||||||
textNodeName: '#text',
|
|
||||||
ignoreAttributes: false,
|
ignoreAttributes: false,
|
||||||
cdataTagName: '__cdata',
|
cdataPropName: '__cdata'
|
||||||
cdataPositionChar: '\\c'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const xml2jsonOpts = {
|
const xml2jsonOpts = {
|
||||||
...commonOpts,
|
...commonOpts,
|
||||||
ignoreNameSpace: false,
|
parseTagValue: true,
|
||||||
parseNodeValue: true,
|
|
||||||
parseAttributeValue: false,
|
parseAttributeValue: false,
|
||||||
trimValues: true,
|
trimValues: true,
|
||||||
parseTrueNumberOnly: false,
|
parseTrueNumberOnly: false,
|
||||||
arrayMode: false,
|
arrayMode: false
|
||||||
numParseOptions: {
|
|
||||||
hex: true,
|
|
||||||
leadingZeros: true,
|
|
||||||
},
|
|
||||||
tagValueProcessor: val => he.decode(val),
|
|
||||||
attrValueProcessor: val => he.decode(val, { isAttributeValue: true })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var json2xmlOpts = {
|
const json2xmlOpts = {
|
||||||
...commonOpts,
|
...commonOpts,
|
||||||
format: false,
|
|
||||||
indentBy: ' ',
|
indentBy: ' ',
|
||||||
supressEmptyNode: false,
|
processEntities: false
|
||||||
tagValueProcessor: a => a,
|
}
|
||||||
attrValueProcessor: a => he.encode(a, { isAttributeValue: true, useNamedReferences: true })
|
|
||||||
};
|
const parser = new XMLParser(xml2jsonOpts, true)
|
||||||
|
const builder = new XMLBuilder(json2xmlOpts)
|
||||||
|
|
||||||
const parseEpisode = e => {
|
const parseEpisode = e => {
|
||||||
const guid = e.guid['#text']
|
const guid = e.guid['#text']
|
||||||
@@ -86,7 +75,7 @@ const parseEpisode = e => {
|
|||||||
<podcast:valueRecipient type="node" split="20" name="Daniel" address="${nodes.daniel}" />
|
<podcast:valueRecipient type="node" split="20" name="Daniel" address="${nodes.daniel}" />
|
||||||
</podcast:value>`)
|
</podcast:value>`)
|
||||||
|
|
||||||
const feed = parser.parse(xml, xml2jsonOpts, true)
|
const feed = parser.parse(xml)
|
||||||
const episodes = []
|
const episodes = []
|
||||||
const _noParticipants = [], _noNode = []
|
const _noParticipants = [], _noNode = []
|
||||||
|
|
||||||
@@ -136,12 +125,17 @@ const parseEpisode = e => {
|
|||||||
|
|
||||||
writeJSON('feed', feed)
|
writeJSON('feed', feed)
|
||||||
|
|
||||||
const JSON2XML = new JSON2XMLParser(json2xmlOpts)
|
const outputXML = builder.build(feed)
|
||||||
const outputXML = JSON2XML.parse(feed)
|
|
||||||
|
|
||||||
writeJSON('episodes', episodes)
|
writeJSON('episodes', episodes)
|
||||||
write('dist/feed.xml', xmlFormat(outputXML, { indentation: ' ', collapseContent: true }))
|
|
||||||
write('static/feed.xml', xmlFormat(outputXML, { indentation: ' ', collapseContent: true }))
|
const validation = XMLValidator.validate(outputXML)
|
||||||
|
if (validation) {
|
||||||
|
write('dist/feed.xml', xmlFormat(outputXML, { indentation: json2xmlOpts.indentBy, collapseContent: true }))
|
||||||
|
write('static/feed.xml', xmlFormat(outputXML, { indentation: json2xmlOpts.indentBy, collapseContent: true }))
|
||||||
|
} else {
|
||||||
|
console.error(validation.err)
|
||||||
|
}
|
||||||
|
|
||||||
if (_noParticipants.length) {
|
if (_noParticipants.length) {
|
||||||
console.log('Keine Teilnehmerliste')
|
console.log('Keine Teilnehmerliste')
|
||||||
|
|||||||
Reference in New Issue
Block a user