Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help needed] Misc. RSS Improvements #3451

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions server/Server.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,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)
Expand Down
16 changes: 16 additions & 0 deletions server/managers/RssFeedManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,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 {string} userId
Expand Down
20 changes: 14 additions & 6 deletions server/objects/FeedEpisode.js
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -23,6 +22,7 @@ class FeedEpisode {
this.episodeId = null
this.trackIndex = null
this.fullPath = null
this.imageUrl = null

if (episode) {
this.construct(episode)
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand All @@ -162,14 +165,19 @@ class FeedEpisode {
enclosure: this.enclosure,
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
}
}
},
]
}
}
Expand Down
Loading