diff --git a/server/utils/parsers/parseOpfMetadata.js b/server/utils/parsers/parseOpfMetadata.js index 6788faae..3a34db57 100644 --- a/server/utils/parsers/parseOpfMetadata.js +++ b/server/utils/parsers/parseOpfMetadata.js @@ -17,7 +17,7 @@ function parseCreators(metadata) { function fetchCreators(creators, role) { if (!creators || !creators.length) return null - return creators.filter(c => c.role === role).map(c => c.value) + return [...new Set(creators.filter(c => c.role === role).map(c => c.value))] } function fetchTagString(metadata, tag) { @@ -92,7 +92,7 @@ function fetchDescription(metadata) { function fetchGenres(metadata) { if (!metadata['dc:subject'] || !metadata['dc:subject'].length) return [] - return metadata['dc:subject'].map(g => typeof g === 'string' ? g : null).filter(g => !!g) + return [...new Set(metadata['dc:subject'].filter(g => typeof g === 'string'))] } function fetchLanguage(metadata) { @@ -122,7 +122,7 @@ function fetchNarrators(creators, metadata) { function fetchTags(metadata) { if (!metadata['dc:tag'] || !metadata['dc:tag'].length) return [] - return metadata['dc:tag'].filter(tag => (typeof tag === 'string')) + return [...new Set(metadata['dc:tag'].filter(tag => typeof tag === 'string'))] } function stripPrefix(str) {