mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-01-08 00:08:14 +01:00
Fix download podcast episode that is not mp3
This commit is contained in:
parent
fc36e86db7
commit
1a3f0e332e
@ -4,7 +4,7 @@ const SocketAuthority = require('../SocketAuthority')
|
|||||||
const fs = require('../libs/fsExtra')
|
const fs = require('../libs/fsExtra')
|
||||||
|
|
||||||
const { getPodcastFeed } = require('../utils/podcastUtils')
|
const { getPodcastFeed } = require('../utils/podcastUtils')
|
||||||
const { removeFile } = require('../utils/fileUtils')
|
const { removeFile, downloadFile } = require('../utils/fileUtils')
|
||||||
const filePerms = require('../utils/filePerms')
|
const filePerms = require('../utils/filePerms')
|
||||||
const { levenshteinDistance } = require('../utils/index')
|
const { levenshteinDistance } = require('../utils/index')
|
||||||
const opmlParser = require('../utils/parsers/parseOPML')
|
const opmlParser = require('../utils/parsers/parseOPML')
|
||||||
@ -94,11 +94,22 @@ class PodcastManager {
|
|||||||
await filePerms.setDefault(this.currentDownload.libraryItem.path)
|
await filePerms.setDefault(this.currentDownload.libraryItem.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Downloads episode and tags it
|
|
||||||
let success = await ffmpegHelpers.downloadPodcastEpisode(this.currentDownload).catch((error) => {
|
let success = false
|
||||||
Logger.error(`[PodcastManager] Podcast Episode download failed`, error)
|
if (this.currentDownload.urlFileExtension === 'mp3') {
|
||||||
return false
|
// Download episode and tag it
|
||||||
})
|
success = await ffmpegHelpers.downloadPodcastEpisode(this.currentDownload).catch((error) => {
|
||||||
|
Logger.error(`[PodcastManager] Podcast Episode download failed`, error)
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// Download episode only
|
||||||
|
success = await downloadFile(this.currentDownload.url, this.currentDownload.targetPath).then(() => true).catch((error) => {
|
||||||
|
Logger.error(`[PodcastManager] Podcast Episode download failed`, error)
|
||||||
|
return false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
success = await this.scanAddPodcastEpisodeAudioFile()
|
success = await this.scanAddPodcastEpisodeAudioFile()
|
||||||
if (!success) {
|
if (!success) {
|
||||||
|
@ -41,8 +41,12 @@ class PodcastEpisodeDownload {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get urlFileExtension() {
|
||||||
|
const cleanUrl = this.url.split('?')[0] // Remove query string
|
||||||
|
return Path.extname(cleanUrl).substring(1).toLowerCase()
|
||||||
|
}
|
||||||
get fileExtension() {
|
get fileExtension() {
|
||||||
const extname = Path.extname(this.url).substring(1).toLowerCase()
|
const extname = this.urlFileExtension
|
||||||
if (globals.SupportedAudioTypes.includes(extname)) return extname
|
if (globals.SupportedAudioTypes.includes(extname)) return extname
|
||||||
return 'mp3'
|
return 'mp3'
|
||||||
}
|
}
|
||||||
|
@ -98,53 +98,44 @@ module.exports.downloadPodcastEpisode = (podcastEpisodeDownload) => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const ffmpeg = Ffmpeg(response.data)
|
const ffmpeg = Ffmpeg(response.data)
|
||||||
ffmpeg.outputOptions([
|
ffmpeg.outputOptions(
|
||||||
'-c copy',
|
'-c', 'copy',
|
||||||
'-metadata',
|
'-metadata', 'podcast=1'
|
||||||
`album=${podcastEpisodeDownload.libraryItem?.media.metadata.title ?? ""}`, // Podcast Title
|
)
|
||||||
'-metadata',
|
|
||||||
`album-sort=${podcastEpisodeDownload.libraryItem?.media.metadata.title ?? ""}`, // Podcast Title
|
const podcastMetadata = podcastEpisodeDownload.libraryItem.media.metadata
|
||||||
'-metadata',
|
const podcastEpisode = podcastEpisodeDownload.podcastEpisode
|
||||||
`artist=${podcastEpisodeDownload.libraryItem?.media.metadata.author ?? ""}`, // Podcast Artist
|
|
||||||
'-metadata',
|
const taggings = {
|
||||||
`artist-sort=${podcastEpisodeDownload.libraryItem?.media.metadata.author ?? ""}`, // Podcast Artist
|
'album': podcastMetadata.title,
|
||||||
'-metadata',
|
'album-sort': podcastMetadata.title,
|
||||||
`comment=${podcastEpisodeDownload.podcastEpisode?.description ?? ""}`, // Episode Description
|
'artist': podcastMetadata.author,
|
||||||
'-metadata',
|
'artist-sort': podcastMetadata.author,
|
||||||
`subtitle=${podcastEpisodeDownload.podcastEpisode?.subtitle ?? ""}`, // Episode Subtitle
|
'comment': podcastEpisode.description,
|
||||||
'-metadata',
|
'subtitle': podcastEpisode.subtitle,
|
||||||
`disc=${podcastEpisodeDownload.podcastEpisode?.season ?? ""}`, // Episode Season
|
'disc': podcastEpisode.season,
|
||||||
'-metadata',
|
'genre': podcastMetadata.genres.length ? podcastMetadata.genres.join(';') : null,
|
||||||
`genre=${podcastEpisodeDownload.libraryItem?.media.metadata.genres.join(';') ?? ""}`, // Podcast Genres
|
'language': podcastMetadata.language,
|
||||||
'-metadata',
|
'MVNM': podcastMetadata.title,
|
||||||
`language=${podcastEpisodeDownload.libraryItem?.media.metadata.language ?? ""}`, // Podcast Language
|
'MVIN': podcastEpisode.episode,
|
||||||
'-metadata',
|
'track': podcastEpisode.episode,
|
||||||
`MVNM=${podcastEpisodeDownload.libraryItem?.media.metadata.title ?? ""}`, // Podcast Title
|
'series-part': podcastEpisode.episode,
|
||||||
'-metadata',
|
'title': podcastEpisode.title,
|
||||||
`MVIN=${podcastEpisodeDownload.podcastEpisode?.episode ?? ""}`, // Episode Number
|
'title-sort': podcastEpisode.title,
|
||||||
'-metadata',
|
'year': podcastEpisode.pubYear,
|
||||||
`track=${podcastEpisodeDownload.podcastEpisode?.episode ?? ""}`, // Episode Number
|
'date': podcastEpisode.pubDate,
|
||||||
'-metadata',
|
'releasedate': podcastEpisode.pubDate,
|
||||||
`series-part=${podcastEpisodeDownload.podcastEpisode?.episode ?? ""}`, // Episode Number
|
'itunes-id': podcastMetadata.itunesId,
|
||||||
'-metadata',
|
'podcast-type': podcastMetadata.type,
|
||||||
`podcast=1`,
|
'episode-type': podcastMetadata.episodeType
|
||||||
'-metadata',
|
}
|
||||||
`title=${podcastEpisodeDownload.podcastEpisode?.title ?? ""}`, // Episode Title
|
|
||||||
'-metadata',
|
for (const tag in taggings) {
|
||||||
`title-sort=${podcastEpisodeDownload.podcastEpisode?.title ?? ""}`, // Episode Title
|
if (taggings[tag]) {
|
||||||
'-metadata',
|
ffmpeg.addOption('-metadata', `${tag}=${taggings[tag]}`)
|
||||||
`year=${podcastEpisodeDownload.podcastEpisode?.pubYear ?? ""}`, // Episode Pub Year
|
}
|
||||||
'-metadata',
|
}
|
||||||
`date=${podcastEpisodeDownload.podcastEpisode?.pubDate ?? ""}`, // Episode PubDate
|
|
||||||
'-metadata',
|
|
||||||
`releasedate=${podcastEpisodeDownload.podcastEpisode?.pubDate ?? ""}`, // Episode PubDate
|
|
||||||
'-metadata',
|
|
||||||
`itunes-id=${podcastEpisodeDownload.libraryItem?.media.metadata.itunesId ?? ""}`, // Podcast iTunes ID
|
|
||||||
'-metadata',
|
|
||||||
`podcast-type=${podcastEpisodeDownload.libraryItem?.media.metadata.type ?? ""}`, // Podcast Type
|
|
||||||
'-metadata',
|
|
||||||
`episode-type=${podcastEpisodeDownload.podcastEpisode?.episodeType ?? ""}` // Episode Type
|
|
||||||
])
|
|
||||||
ffmpeg.addOutput(podcastEpisodeDownload.targetPath)
|
ffmpeg.addOutput(podcastEpisodeDownload.targetPath)
|
||||||
|
|
||||||
ffmpeg.on('start', (cmd) => {
|
ffmpeg.on('start', (cmd) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user