This commit is contained in:
Arunesh Dwivedi 2026-06-30 07:04:00 +00:00 committed by GitHub
commit 82213806f3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -477,6 +477,10 @@ class PodcastScanner {
libraryScan.addLog(LogLevel.DEBUG, `Success saving abmetadata to "${metadataFilePath}"`)
if (storeMetadataWithItem && libraryItem.media.podcastEpisodes?.length) {
await this.writeEpisodeMetadata(libraryItem, libraryItem.media.podcastEpisodes, libraryScan)
}
return metadataLibraryFile
})
.catch((error) => {
@ -484,5 +488,38 @@ class PodcastScanner {
return null
})
}
async writeEpisodeMetadata(libraryItem, episodes, libraryScan) {
for (const ep of episodes) {
if (!ep.audioFile?.metadata?.path) continue
const metaPath = ep.audioFile.metadata.path.replace(/\.[^.]+$/, '.json')
const data = {
title: ep.title,
subtitle: ep.subtitle,
season: ep.season,
episode: ep.episode,
episodeType: ep.episodeType,
pubDate: ep.pubDate,
publishedAt: ep.publishedAt,
description: ep.description,
chapters: ep.chapters || []
}
try {
await fsExtra.writeFile(metaPath, JSON.stringify(data, null, 2))
libraryScan.addLog(LogLevel.DEBUG, `Saved episode meta: ${metaPath}`)
const exists = libraryItem.libraryFiles.find((f) => f.metadata.path === filePathToPOSIX(metaPath))
if (!exists) {
const lf = new LibraryFile()
await lf.setDataFromPath(metaPath, Path.basename(metaPath))
libraryItem.libraryFiles.push(lf.toJSON())
}
} catch (err) {
libraryScan.addLog(LogLevel.ERROR, `Failed writing ${metaPath}: ${err.message}`)
}
}
}
}
module.exports = new PodcastScanner()