diff --git a/server/objects/Feed.js b/server/objects/Feed.js index 9e00d57c..e3b54fed 100644 --- a/server/objects/Feed.js +++ b/server/objects/Feed.js @@ -101,7 +101,11 @@ class Feed { feedEpisode.setFromPodcastEpisode(libraryItem, serverAddress, slug, episode, this.meta) this.episodes.push(feedEpisode) }) - } else { // AUDIOBOOK EPISODES + } else if (media.tracks.length == 1) { // SINGLE FILE AUDIOBOOKS + var feedEpisode = new FeedEpisode() + feedEpisode.setFromSingleAudiobookTrack(libraryItem, serverAddress, slug, media.tracks[0], this.meta) + this.episodes.push(feedEpisode) + } else { // MULTI-FILE AUDIOBOOKS media.tracks.forEach((audioTrack) => { var feedEpisode = new FeedEpisode() feedEpisode.setFromAudiobookTrack(libraryItem, serverAddress, slug, audioTrack, this.meta) diff --git a/server/objects/FeedEpisode.js b/server/objects/FeedEpisode.js index 28a60e78..8c166bfc 100644 --- a/server/objects/FeedEpisode.js +++ b/server/objects/FeedEpisode.js @@ -118,6 +118,35 @@ class FeedEpisode { this.fullPath = audioTrack.metadata.path } + setFromSingleAudiobookTrack(libraryItem, serverAddress, slug, audioTrack, meta) { + // Example: Fri, 04 Feb 2015 00:00:00 GMT + const audiobookPubDate = date.format(new Date(libraryItem.addedAt), 'ddd, DD MMM YYYY HH:mm:ss [GMT]') + + const contentUrl = `/feed/${slug}/item/${audioTrack.index}/${audioTrack.metadata.filename}` + const media = libraryItem.media + const mediaMetadata = media.metadata + + var title = libraryItem.media.metadata.title + + this.id = String(audioTrack.index) + this.title = title + this.description = mediaMetadata.description || '' + this.enclosure = { + url: `${serverAddress}${contentUrl}`, + type: audioTrack.mimeType, + size: audioTrack.metadata.size + } + this.pubDate = audiobookPubDate + this.link = meta.link + this.author = meta.author + this.explicit = mediaMetadata.explicit + this.duration = audioTrack.duration + this.libraryItemId = libraryItem.id + this.episodeId = null + this.trackIndex = audioTrack.index + this.fullPath = audioTrack.metadata.path + } + getRSSData() { return { title: this.title,