mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-09-10 17:58:02 +02:00
fix timestamps
This commit is contained in:
parent
69b6c0c79a
commit
44f13ea4f6
@ -152,29 +152,7 @@ module.exports.downloadPodcastEpisode = (podcastEpisodeDownload) => {
|
|||||||
const podcastEpisode = podcastEpisodeDownload.rssPodcastEpisode
|
const podcastEpisode = podcastEpisodeDownload.rssPodcastEpisode
|
||||||
const finalSizeInBytes = Number(podcastEpisode.enclosure?.length || 0)
|
const finalSizeInBytes = Number(podcastEpisode.enclosure?.length || 0)
|
||||||
|
|
||||||
const taggings = {
|
const taggings = getPodcastEpisodeFFMetadataObject(podcast, podcastEpisode, podcastEpisodeDownload)
|
||||||
album: podcast.title,
|
|
||||||
'album-sort': podcast.title,
|
|
||||||
artist: podcast.author,
|
|
||||||
'artist-sort': podcast.author,
|
|
||||||
comment: podcastEpisode.description,
|
|
||||||
subtitle: podcastEpisode.subtitle,
|
|
||||||
disc: podcastEpisode.season,
|
|
||||||
genre: podcast.genres.length ? podcast.genres.join(';') : null,
|
|
||||||
language: podcast.language,
|
|
||||||
MVNM: podcast.title,
|
|
||||||
MVIN: podcastEpisode.episode,
|
|
||||||
track: podcastEpisode.episode,
|
|
||||||
'series-part': podcastEpisode.episode,
|
|
||||||
title: podcastEpisode.title,
|
|
||||||
'title-sort': podcastEpisode.title,
|
|
||||||
year: podcastEpisodeDownload.pubYear,
|
|
||||||
date: podcastEpisode.pubDate,
|
|
||||||
releasedate: podcastEpisode.pubDate,
|
|
||||||
'itunes-id': podcast.itunesId,
|
|
||||||
'podcast-type': podcast.podcastType,
|
|
||||||
'episode-type': podcastEpisode.episodeType
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const tag in taggings) {
|
for (const tag in taggings) {
|
||||||
if (taggings[tag]) {
|
if (taggings[tag]) {
|
||||||
@ -433,27 +411,62 @@ module.exports.getFFMetadataObject = getFFMetadataObject
|
|||||||
* @param {import('../models/PodcastEpisode')} podcastEpisode
|
* @param {import('../models/PodcastEpisode')} podcastEpisode
|
||||||
* @returns {Object}
|
* @returns {Object}
|
||||||
*/
|
*/
|
||||||
function getPodcastEpisodeFFMetadataObject(libraryItem, podcastEpisode) {
|
function getPodcastEpisodeFFMetadataObject(podcast, podcastEpisode, podcastEpisodeDownload = {}) {
|
||||||
const podcast = libraryItem.media
|
function formatToISO8601(date) {
|
||||||
const ffmetadata = {
|
if (!date) return null
|
||||||
title: podcastEpisode.title || podcast.title,
|
|
||||||
artist: podcast.author || podcast.title,
|
let d
|
||||||
album_artist: podcast.author || podcast.title,
|
if (date instanceof Date) {
|
||||||
album: podcast.title,
|
d = date
|
||||||
genre: Array.isArray(podcast.genres) && podcast.genres.length ? podcast.genres.join('; ') : undefined,
|
} else {
|
||||||
date: podcast.releasedate,
|
d = new Date(date)
|
||||||
comment: podcastEpisode.description,
|
|
||||||
description: podcastEpisode.description,
|
|
||||||
language: podcast.language,
|
|
||||||
'itunes-id': podcast.itunesId,
|
|
||||||
track: podcastEpisode.episode || undefined,
|
|
||||||
disc: podcastEpisode.season || undefined,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Object.keys(ffmetadata).forEach((key) => {
|
if (isNaN(d.getTime())) return null
|
||||||
if (ffmetadata[key] === undefined || ffmetadata[key] === null || ffmetadata[key] === '') delete ffmetadata[key]
|
return d.toISOString()
|
||||||
|
}
|
||||||
|
|
||||||
|
const pubDateISO = formatToISO8601(podcastEpisode.pubDate)
|
||||||
|
let pubYearISO = null
|
||||||
|
if (podcastEpisodeDownload?.pubYear) {
|
||||||
|
pubYearISO = podcastEpisodeDownload.pubYear
|
||||||
|
} else if (podcastEpisode.pubDate) {
|
||||||
|
const pubDateObj = new Date(podcastEpisode.pubDate)
|
||||||
|
if (pubDateObj && !isNaN(pubDateObj.getTime())) {
|
||||||
|
pubYearISO = pubDateObj.getUTCFullYear().toString()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const taggings = {
|
||||||
|
album: podcast.title,
|
||||||
|
'album-sort': podcast.title,
|
||||||
|
artist: podcast.author,
|
||||||
|
'artist-sort': podcast.author,
|
||||||
|
comment: podcastEpisode.description,
|
||||||
|
subtitle: podcastEpisode.subtitle,
|
||||||
|
disc: podcastEpisode.season,
|
||||||
|
genre: Array.isArray(podcast.genres) && podcast.genres.length ? podcast.genres.join(';') : null,
|
||||||
|
language: podcast.language,
|
||||||
|
MVNM: podcast.title,
|
||||||
|
MVIN: podcastEpisode.episode,
|
||||||
|
track: podcastEpisode.episode,
|
||||||
|
'series-part': podcastEpisode.episode,
|
||||||
|
title: podcastEpisode.title,
|
||||||
|
'title-sort': podcastEpisode.title,
|
||||||
|
year: pubYearISO,
|
||||||
|
date: pubDateISO,
|
||||||
|
releasedate: pubDateISO,
|
||||||
|
'itunes-id': podcast.itunesId,
|
||||||
|
'podcast-type': podcast.podcastType,
|
||||||
|
'episode-type': podcastEpisode.episodeType
|
||||||
|
}
|
||||||
|
|
||||||
|
Object.keys(taggings).forEach((key) => {
|
||||||
|
if (taggings[key] === undefined || taggings[key] === null || taggings[key] === '') {
|
||||||
|
delete taggings[key]
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return ffmetadata
|
return taggings
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports.getPodcastEpisodeFFMetadataObject = getPodcastEpisodeFFMetadataObject
|
module.exports.getPodcastEpisodeFFMetadataObject = getPodcastEpisodeFFMetadataObject
|
||||||
|
Loading…
Reference in New Issue
Block a user