2022-03-16 01:28:54 +01:00
|
|
|
// const Podcast = require('podcast')
|
2021-08-23 21:08:54 +02:00
|
|
|
const express = require('express')
|
2022-03-16 01:28:54 +01:00
|
|
|
// const ip = require('ip')
|
2021-08-23 21:08:54 +02:00
|
|
|
const Logger = require('./Logger')
|
|
|
|
|
2021-09-01 20:47:18 +02:00
|
|
|
// Not functional at the moment - just an idea
|
2021-08-23 21:08:54 +02:00
|
|
|
class RssFeeds {
|
|
|
|
constructor(Port, db) {
|
|
|
|
this.Port = Port
|
|
|
|
this.db = db
|
|
|
|
this.feeds = {}
|
|
|
|
|
|
|
|
this.router = express()
|
|
|
|
this.init()
|
|
|
|
}
|
|
|
|
|
|
|
|
init() {
|
|
|
|
this.router.get('/:id', this.getFeed.bind(this))
|
|
|
|
}
|
|
|
|
|
|
|
|
getFeed(req, res) {
|
2021-10-31 02:12:36 +01:00
|
|
|
Logger.info('Get Feed', req.params.id, this.feeds[req.params.id])
|
|
|
|
|
2021-08-23 21:08:54 +02:00
|
|
|
var feed = this.feeds[req.params.id]
|
|
|
|
if (!feed) return null
|
|
|
|
var xml = feed.buildXml()
|
|
|
|
res.set('Content-Type', 'text/xml')
|
|
|
|
res.send(xml)
|
|
|
|
}
|
|
|
|
|
|
|
|
openFeed(audiobook) {
|
2022-03-16 01:28:54 +01:00
|
|
|
// Removed Podcast npm package and ip package
|
|
|
|
return null
|
|
|
|
// var ipAddress = ip.address('public', 'ipv4')
|
|
|
|
// var serverAddress = 'http://' + ipAddress + ':' + this.Port
|
|
|
|
// Logger.info('Open RSS Feed', 'Server address', serverAddress)
|
2021-08-23 21:08:54 +02:00
|
|
|
|
2022-03-16 01:28:54 +01:00
|
|
|
// var feedId = (Date.now() + Math.floor(Math.random() * 1000)).toString(36)
|
|
|
|
// const feed = new Podcast({
|
|
|
|
// title: audiobook.title,
|
|
|
|
// description: 'AudioBookshelf RSS Feed',
|
|
|
|
// feed_url: `${serverAddress}/feeds/${feedId}`,
|
|
|
|
// image_url: `${serverAddress}/Logo.png`,
|
|
|
|
// author: 'advplyr',
|
|
|
|
// language: 'en'
|
|
|
|
// })
|
|
|
|
// audiobook.tracks.forEach((track) => {
|
|
|
|
// feed.addItem({
|
|
|
|
// title: `Track ${track.index}`,
|
|
|
|
// description: `AudioBookshelf Audiobook Track #${track.index}`,
|
|
|
|
// url: `${serverAddress}/feeds/${feedId}?track=${track.index}`,
|
|
|
|
// author: 'advplyr'
|
|
|
|
// })
|
|
|
|
// })
|
|
|
|
// this.feeds[feedId] = feed
|
|
|
|
// return feed
|
2021-08-23 21:08:54 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = RssFeeds
|