This commit is contained in:
Kieran 2024-12-14 22:27:26 -08:00 committed by GitHub
commit c86c48ef17
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 6 deletions

View file

@ -296,6 +296,9 @@ class Server {
router.get('/feed/:slug/cover*', (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) => {
Logger.debug(`[Server] Requesting rss feed episode ${req.params.slug}/${req.params.episodeId}`)
this.rssFeedManager.getFeedItem(req, res)

View file

@ -221,6 +221,22 @@ class RssFeedManager {
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

View file

@ -1,7 +1,6 @@
const Path = require('path')
const uuidv4 = require('uuid').v4
const date = require('../libs/dateAndTime')
const { secondsToTimestamp } = require('../utils/index')
class FeedEpisode {
constructor(episode) {
@ -23,6 +22,7 @@ class FeedEpisode {
this.episodeId = null
this.trackIndex = null
this.fullPath = null
this.imageUrl = null
if (episode) {
this.construct(episode)
@ -119,6 +119,7 @@ class FeedEpisode {
const contentUrl = `/feed/${slug}/item/${episodeId}/media${contentFileExtension}`
const media = libraryItem.media
const mediaMetadata = media.metadata
const coverFileExtension = media.coverPath ? Path.extname(media.coverPath) : null
let title = audioTrack.title
if (libraryItem.media.tracks.length == 1) {
@ -149,6 +150,8 @@ class FeedEpisode {
this.episodeId = null
this.trackIndex = audioTrack.index
this.fullPath = audioTrack.metadata.path
// debugger
this.imageUrl = media.coverPath ? `${serverAddress}/feed/${slug}/item/${media.libraryItemId}/image${coverFileExtension}` : meta.imageUrl
}
getRSSData(hostPrefix) {
@ -166,14 +169,19 @@ class FeedEpisode {
},
custom_elements: [
{ 'itunes:author': this.author },
{ 'itunes:duration': secondsToTimestamp(this.duration) },
{ 'itunes:duration': Math.round(this.duration) },
{ 'itunes:summary': this.description || '' },
{
'itunes:explicit': !!this.explicit
},
{ 'itunes:explicit': !!this.explicit },
{ 'itunes:episodeType': this.episodeType },
{ 'itunes:season': this.season },
{ 'itunes:episode': this.episode }
{ 'itunes:episode': this.episode },
{
'itunes:image': {
_attr: {
href: this.imageUrl
}
}
},
]
}
}