mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-06-30 20:44:56 +02:00
Migrate Feed updating and build xml to new model
This commit is contained in:
parent
369c05936b
commit
f8fbd3ac8c
10 changed files with 373 additions and 426 deletions
|
@ -3,6 +3,7 @@ const { DataTypes, Model } = require('sequelize')
|
|||
const uuidv4 = require('uuid').v4
|
||||
const Logger = require('../Logger')
|
||||
const date = require('../libs/dateAndTime')
|
||||
const { secondsToTimestamp } = require('../utils')
|
||||
|
||||
class FeedEpisode extends Model {
|
||||
constructor(values, options) {
|
||||
|
@ -13,6 +14,8 @@ class FeedEpisode extends Model {
|
|||
/** @type {string} */
|
||||
this.title
|
||||
/** @type {string} */
|
||||
this.author
|
||||
/** @type {string} */
|
||||
this.description
|
||||
/** @type {string} */
|
||||
this.siteURL
|
||||
|
@ -301,6 +304,37 @@ class FeedEpisode extends Model {
|
|||
fullPath: this.filePath
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {string} hostPrefix
|
||||
*/
|
||||
getRSSData(hostPrefix) {
|
||||
return {
|
||||
title: this.title,
|
||||
description: this.description || '',
|
||||
url: `${hostPrefix}${this.siteURL}`,
|
||||
guid: `${hostPrefix}${this.enclosureURL}`,
|
||||
author: this.author,
|
||||
date: this.pubDate,
|
||||
enclosure: {
|
||||
url: `${hostPrefix}${this.enclosureURL}`,
|
||||
type: this.enclosureType,
|
||||
size: this.enclosureSize
|
||||
},
|
||||
custom_elements: [
|
||||
{ 'itunes:author': this.author },
|
||||
{ 'itunes:duration': secondsToTimestamp(this.duration) },
|
||||
{ 'itunes:summary': this.description || '' },
|
||||
{
|
||||
'itunes:explicit': !!this.explicit
|
||||
},
|
||||
{ 'itunes:episodeType': this.episodeType },
|
||||
{ 'itunes:season': this.season },
|
||||
{ 'itunes:episode': this.episode }
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = FeedEpisode
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue