mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-08-17 16:22:15 +02:00
Added support for custom metadata providers
WiP but already open to feedback
This commit is contained in:
parent
8c6a2ac5dd
commit
8027c4a06f
14 changed files with 642 additions and 4 deletions
58
server/models/CustomMetadataProvider.js
Normal file
58
server/models/CustomMetadataProvider.js
Normal file
|
@ -0,0 +1,58 @@
|
|||
const { DataTypes, Model, Sequelize } = require('sequelize')
|
||||
|
||||
class CustomMetadataProvider extends Model {
|
||||
constructor(values, options) {
|
||||
super(values, options)
|
||||
|
||||
/** @type {UUIDV4} */
|
||||
this.id
|
||||
/** @type {string} */
|
||||
this.name
|
||||
/** @type {string} */
|
||||
this.url
|
||||
/** @type {string} */
|
||||
this.apiKey
|
||||
}
|
||||
|
||||
getSlug() {
|
||||
return `custom-${this.id}`
|
||||
}
|
||||
|
||||
toUserJson() {
|
||||
return {
|
||||
name: this.name,
|
||||
id: this.id,
|
||||
slug: this.getSlug()
|
||||
}
|
||||
}
|
||||
|
||||
static findByPk(id) {
|
||||
this.findOne({
|
||||
where: {
|
||||
id,
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize model
|
||||
* @param {import('../Database').sequelize} sequelize
|
||||
*/
|
||||
static init(sequelize) {
|
||||
super.init({
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
primaryKey: true
|
||||
},
|
||||
name: DataTypes.STRING,
|
||||
url: DataTypes.STRING,
|
||||
apiKey: DataTypes.STRING
|
||||
}, {
|
||||
sequelize,
|
||||
modelName: 'customMetadataProvider'
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = CustomMetadataProvider
|
Loading…
Add table
Add a link
Reference in a new issue