mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2024-12-20 19:06:06 +01:00
Single file audiobook rss feed naming logic moved to FeedEpisode.js
This commit is contained in:
parent
1f02cbddd3
commit
12abb1731c
@ -101,11 +101,7 @@ class Feed {
|
|||||||
feedEpisode.setFromPodcastEpisode(libraryItem, serverAddress, slug, episode, this.meta)
|
feedEpisode.setFromPodcastEpisode(libraryItem, serverAddress, slug, episode, this.meta)
|
||||||
this.episodes.push(feedEpisode)
|
this.episodes.push(feedEpisode)
|
||||||
})
|
})
|
||||||
} else if (media.tracks.length == 1) { // SINGLE FILE AUDIOBOOKS
|
} else { // AUDIOBOOK EPISODES
|
||||||
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) => {
|
media.tracks.forEach((audioTrack) => {
|
||||||
var feedEpisode = new FeedEpisode()
|
var feedEpisode = new FeedEpisode()
|
||||||
feedEpisode.setFromAudiobookTrack(libraryItem, serverAddress, slug, audioTrack, this.meta)
|
feedEpisode.setFromAudiobookTrack(libraryItem, serverAddress, slug, audioTrack, this.meta)
|
||||||
|
@ -92,11 +92,15 @@ class FeedEpisode {
|
|||||||
const media = libraryItem.media
|
const media = libraryItem.media
|
||||||
const mediaMetadata = media.metadata
|
const mediaMetadata = media.metadata
|
||||||
|
|
||||||
var title = audioTrack.title
|
if (libraryItem.media.tracks.length == 1) { // If audiobook is a single file, use book title instead of chapter/file title
|
||||||
if (libraryItem.media.chapters.length) {
|
var title = libraryItem.media.metadata.title
|
||||||
// If audio track start and chapter start are within 1 seconds of eachother then use the chapter title
|
} else {
|
||||||
var matchingChapter = libraryItem.media.chapters.find(ch => Math.abs(ch.start - audioTrack.startOffset) < 1)
|
var title = audioTrack.title
|
||||||
if (matchingChapter && matchingChapter.title) title = matchingChapter.title
|
if (libraryItem.media.chapters.length) {
|
||||||
|
// If audio track start and chapter start are within 1 seconds of eachother then use the chapter title
|
||||||
|
var matchingChapter = libraryItem.media.chapters.find(ch => Math.abs(ch.start - audioTrack.startOffset) < 1)
|
||||||
|
if (matchingChapter && matchingChapter.title) title = matchingChapter.title
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.id = String(audioTrack.index)
|
this.id = String(audioTrack.index)
|
||||||
@ -118,35 +122,6 @@ class FeedEpisode {
|
|||||||
this.fullPath = audioTrack.metadata.path
|
this.fullPath = audioTrack.metadata.path
|
||||||
}
|
}
|
||||||
|
|
||||||
setFromSingleAudiobookTrack(libraryItem, serverAddress, slug, audioTrack, meta) {
|
|
||||||
// Example: <pubDate>Fri, 04 Feb 2015 00:00:00 GMT</pubDate>
|
|
||||||
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() {
|
getRSSData() {
|
||||||
return {
|
return {
|
||||||
title: this.title,
|
title: this.title,
|
||||||
|
Loading…
Reference in New Issue
Block a user