mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-02-03 16:59:41 +00:00
Update:Remove rss feed dependencies add node-xml lib
This commit is contained in:
parent
46fc89e247
commit
03bffb725a
9 changed files with 556 additions and 105 deletions
|
|
@ -1,6 +1,6 @@
|
|||
const FeedMeta = require('./FeedMeta')
|
||||
const FeedEpisode = require('./FeedEpisode')
|
||||
const { Podcast } = require('podcast')
|
||||
const RSS = require('../libs/rss')
|
||||
|
||||
class Feed {
|
||||
constructor(feed) {
|
||||
|
|
@ -90,6 +90,7 @@ class Feed {
|
|||
this.meta.imageUrl = media.coverPath ? `${serverAddress}/feed/${slug}/cover` : `${serverAddress}/Logo.png`
|
||||
this.meta.feedUrl = feedUrl
|
||||
this.meta.link = `${serverAddress}/items/${libraryItem.id}`
|
||||
this.meta.explicit = !!mediaMetadata.explicit
|
||||
|
||||
this.episodes = []
|
||||
if (isPodcast) { // PODCAST EPISODES
|
||||
|
|
@ -113,11 +114,11 @@ class Feed {
|
|||
buildXml() {
|
||||
if (this.xml) return this.xml
|
||||
|
||||
const pod = new Podcast(this.meta.getPodcastMeta())
|
||||
var rssfeed = new RSS(this.meta.getRSSData())
|
||||
this.episodes.forEach((ep) => {
|
||||
pod.addItem(ep.getPodcastEpisode())
|
||||
rssfeed.item(ep.getRSSData())
|
||||
})
|
||||
this.xml = pod.buildXml()
|
||||
this.xml = rssfeed.xml()
|
||||
return this.xml
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
const Path = require('path')
|
||||
const date = require('date-and-time')
|
||||
const { secondsToTimestamp } = require('../utils/index')
|
||||
|
||||
class FeedEpisode {
|
||||
constructor(episode) {
|
||||
|
|
@ -116,14 +117,23 @@ class FeedEpisode {
|
|||
this.fullPath = audioTrack.metadata.path
|
||||
}
|
||||
|
||||
getPodcastEpisode() {
|
||||
getRSSData() {
|
||||
return {
|
||||
title: this.title,
|
||||
description: this.description || '',
|
||||
enclosure: this.enclosure,
|
||||
date: this.pubDate || '',
|
||||
url: this.link,
|
||||
author: this.author
|
||||
guid: this.enclosure.url,
|
||||
author: this.author,
|
||||
date: this.pubDate,
|
||||
enclosure: this.enclosure,
|
||||
custom_elements: [
|
||||
{ 'itunes:author': this.author },
|
||||
{ 'itunes:duration': secondsToTimestamp(this.duration) },
|
||||
{ 'itunes:summary': this.description || '' },
|
||||
{
|
||||
"itunes:explicit": !!this.explicit
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ class FeedMeta {
|
|||
this.imageUrl = null
|
||||
this.feedUrl = null
|
||||
this.link = null
|
||||
this.explicit = null
|
||||
|
||||
if (meta) {
|
||||
this.construct(meta)
|
||||
|
|
@ -19,6 +20,7 @@ class FeedMeta {
|
|||
this.imageUrl = meta.imageUrl
|
||||
this.feedUrl = meta.feedUrl
|
||||
this.link = meta.link
|
||||
this.explicit = meta.explicit
|
||||
}
|
||||
|
||||
toJSON() {
|
||||
|
|
@ -28,19 +30,46 @@ class FeedMeta {
|
|||
author: this.author,
|
||||
imageUrl: this.imageUrl,
|
||||
feedUrl: this.feedUrl,
|
||||
link: this.link
|
||||
link: this.link,
|
||||
explicit: this.explicit
|
||||
}
|
||||
}
|
||||
|
||||
getPodcastMeta() {
|
||||
getRSSData() {
|
||||
return {
|
||||
title: this.title,
|
||||
description: this.description,
|
||||
feedUrl: this.feedUrl,
|
||||
siteUrl: this.link,
|
||||
imageUrl: this.imageUrl,
|
||||
author: this.author || 'advplyr',
|
||||
language: 'en'
|
||||
description: this.description || '',
|
||||
generator: 'Audiobookshelf',
|
||||
feed_url: this.feedUrl,
|
||||
site_url: this.link,
|
||||
image_url: this.imageUrl,
|
||||
language: 'en',
|
||||
custom_namespaces: {
|
||||
'itunes': 'http://www.itunes.com/dtds/podcast-1.0.dtd',
|
||||
'psc': 'http://podlove.org/simple-chapters',
|
||||
'podcast': 'https://podcastindex.org/namespace/1.0'
|
||||
},
|
||||
custom_elements: [
|
||||
{ 'author': this.author || 'advplyr' },
|
||||
{ 'itunes:author': this.author || 'advplyr' },
|
||||
{ 'itunes:summary': this.description || '' },
|
||||
{
|
||||
'itunes:image': {
|
||||
_attr: {
|
||||
href: this.imageUrl
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
'itunes:owner': [
|
||||
{ 'itunes:name': this.author || '' },
|
||||
{ 'itunes:email': '' }
|
||||
]
|
||||
},
|
||||
{
|
||||
"itunes:explicit": !!this.explicit
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue