mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-05-27 22:01:32 +00:00
Added check for date in extract metadata
This commit is contained in:
parent
0b3fd53681
commit
30f1c9c252
1 changed files with 17 additions and 1 deletions
|
|
@ -4,6 +4,7 @@ const Logger = require('../Logger')
|
||||||
const { xmlToJSON, timestampToSeconds } = require('./index')
|
const { xmlToJSON, timestampToSeconds } = require('./index')
|
||||||
const htmlSanitizer = require('../utils/htmlSanitizer')
|
const htmlSanitizer = require('../utils/htmlSanitizer')
|
||||||
const Fuse = require('../libs/fusejs')
|
const Fuse = require('../libs/fusejs')
|
||||||
|
const parseDate = require('../utils/parsers/parseDate')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef RssPodcastChapter
|
* @typedef RssPodcastChapter
|
||||||
|
|
@ -147,6 +148,12 @@ function extractPodcastMetadata(channel) {
|
||||||
if (value?.['_']) value = value['_']
|
if (value?.['_']) value = value['_']
|
||||||
metadata[cleanKey] = value
|
metadata[cleanKey] = value
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if (!metadata['pubDate']) {
|
||||||
|
const dateVal = extractFirstArrayItem(channel, 'date')
|
||||||
|
if (dateVal) metadata['pubDate'] = dateVal
|
||||||
|
}
|
||||||
|
|
||||||
return metadata
|
return metadata
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -198,6 +205,15 @@ function extractEpisodeData(item) {
|
||||||
} else {
|
} else {
|
||||||
Logger.error(`[podcastUtils] Invalid pubDate ${item['pubDate']} for ${episode.enclosure.url}`)
|
Logger.error(`[podcastUtils] Invalid pubDate ${item['pubDate']} for ${episode.enclosure.url}`)
|
||||||
}
|
}
|
||||||
|
} else if (item['date']) {
|
||||||
|
const date = extractFirstArrayItem(item, 'date')
|
||||||
|
if (typeof date === 'string') {
|
||||||
|
episode.pubDate = date
|
||||||
|
} else if (typeof date?._ === 'string') {
|
||||||
|
episode.pubDate = date._
|
||||||
|
} else {
|
||||||
|
Logger.error(`[podcastUtils] Invalid date ${item['date']} for ${episode.enclosure.url}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item['guid']) {
|
if (item['guid']) {
|
||||||
|
|
@ -261,7 +277,7 @@ function extractEpisodeData(item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanEpisodeData(data) {
|
function cleanEpisodeData(data) {
|
||||||
const pubJsDate = data.pubDate ? new Date(data.pubDate) : null
|
const pubJsDate = data.pubDate ? parseDate.parse(data.pubDate) : null
|
||||||
const publishedAt = pubJsDate && !isNaN(pubJsDate) ? pubJsDate.valueOf() : null
|
const publishedAt = pubJsDate && !isNaN(pubJsDate) ? pubJsDate.valueOf() : null
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue