mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-07-09 19:01:41 +00:00
Merge 4de8bb5949 into ca2327aba3
This commit is contained in:
commit
c86c48ef17
3 changed files with 33 additions and 6 deletions
|
|
@ -296,6 +296,9 @@ class Server {
|
||||||
router.get('/feed/:slug/cover*', (req, res) => {
|
router.get('/feed/:slug/cover*', (req, res) => {
|
||||||
this.rssFeedManager.getFeedCover(req, res)
|
this.rssFeedManager.getFeedCover(req, res)
|
||||||
})
|
})
|
||||||
|
router.get('/feed/:slug/item/:episodeId/image*', (req, res) => {
|
||||||
|
this.rssFeedManager.getFeedItemImage(req, res)
|
||||||
|
})
|
||||||
router.get('/feed/:slug/item/:episodeId/*', (req, res) => {
|
router.get('/feed/:slug/item/:episodeId/*', (req, res) => {
|
||||||
Logger.debug(`[Server] Requesting rss feed episode ${req.params.slug}/${req.params.episodeId}`)
|
Logger.debug(`[Server] Requesting rss feed episode ${req.params.slug}/${req.params.episodeId}`)
|
||||||
this.rssFeedManager.getFeedItem(req, res)
|
this.rssFeedManager.getFeedItem(req, res)
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,22 @@ class RssFeedManager {
|
||||||
readStream.pipe(res)
|
readStream.pipe(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getFeedItemImage(req, res) {
|
||||||
|
const feed = await this.findFeedBySlug(req.params.slug)
|
||||||
|
if (!feed) {
|
||||||
|
Logger.debug(`[RssFeedManager] Feed not found ${req.params.slug}`)
|
||||||
|
res.sendStatus(404)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!feed.coverPath) {
|
||||||
|
res.sendStatus(404)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: ???
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param {*} options
|
* @param {*} options
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
const Path = require('path')
|
const Path = require('path')
|
||||||
const uuidv4 = require('uuid').v4
|
const uuidv4 = require('uuid').v4
|
||||||
const date = require('../libs/dateAndTime')
|
const date = require('../libs/dateAndTime')
|
||||||
const { secondsToTimestamp } = require('../utils/index')
|
|
||||||
|
|
||||||
class FeedEpisode {
|
class FeedEpisode {
|
||||||
constructor(episode) {
|
constructor(episode) {
|
||||||
|
|
@ -23,6 +22,7 @@ class FeedEpisode {
|
||||||
this.episodeId = null
|
this.episodeId = null
|
||||||
this.trackIndex = null
|
this.trackIndex = null
|
||||||
this.fullPath = null
|
this.fullPath = null
|
||||||
|
this.imageUrl = null
|
||||||
|
|
||||||
if (episode) {
|
if (episode) {
|
||||||
this.construct(episode)
|
this.construct(episode)
|
||||||
|
|
@ -119,6 +119,7 @@ class FeedEpisode {
|
||||||
const contentUrl = `/feed/${slug}/item/${episodeId}/media${contentFileExtension}`
|
const contentUrl = `/feed/${slug}/item/${episodeId}/media${contentFileExtension}`
|
||||||
const media = libraryItem.media
|
const media = libraryItem.media
|
||||||
const mediaMetadata = media.metadata
|
const mediaMetadata = media.metadata
|
||||||
|
const coverFileExtension = media.coverPath ? Path.extname(media.coverPath) : null
|
||||||
|
|
||||||
let title = audioTrack.title
|
let title = audioTrack.title
|
||||||
if (libraryItem.media.tracks.length == 1) {
|
if (libraryItem.media.tracks.length == 1) {
|
||||||
|
|
@ -149,6 +150,8 @@ class FeedEpisode {
|
||||||
this.episodeId = null
|
this.episodeId = null
|
||||||
this.trackIndex = audioTrack.index
|
this.trackIndex = audioTrack.index
|
||||||
this.fullPath = audioTrack.metadata.path
|
this.fullPath = audioTrack.metadata.path
|
||||||
|
// debugger
|
||||||
|
this.imageUrl = media.coverPath ? `${serverAddress}/feed/${slug}/item/${media.libraryItemId}/image${coverFileExtension}` : meta.imageUrl
|
||||||
}
|
}
|
||||||
|
|
||||||
getRSSData(hostPrefix) {
|
getRSSData(hostPrefix) {
|
||||||
|
|
@ -166,14 +169,19 @@ class FeedEpisode {
|
||||||
},
|
},
|
||||||
custom_elements: [
|
custom_elements: [
|
||||||
{ 'itunes:author': this.author },
|
{ 'itunes:author': this.author },
|
||||||
{ 'itunes:duration': secondsToTimestamp(this.duration) },
|
{ 'itunes:duration': Math.round(this.duration) },
|
||||||
{ 'itunes:summary': this.description || '' },
|
{ 'itunes:summary': this.description || '' },
|
||||||
{
|
{ 'itunes:explicit': !!this.explicit },
|
||||||
'itunes:explicit': !!this.explicit
|
|
||||||
},
|
|
||||||
{ 'itunes:episodeType': this.episodeType },
|
{ 'itunes:episodeType': this.episodeType },
|
||||||
{ 'itunes:season': this.season },
|
{ 'itunes:season': this.season },
|
||||||
{ 'itunes:episode': this.episode }
|
{ 'itunes:episode': this.episode },
|
||||||
|
{
|
||||||
|
'itunes:image': {
|
||||||
|
_attr: {
|
||||||
|
href: this.imageUrl
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue