mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2025-07-10 09:24:56 +02:00
Add custom metadata provider controller, update model, move to item metadata utils
This commit is contained in:
parent
ddf4b2646c
commit
0cf2f8885e
21 changed files with 496 additions and 373 deletions
|
@ -700,45 +700,6 @@ class Database {
|
|||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a custom provider with the given slug exists
|
||||
* @param {string} providerSlug
|
||||
* @return {boolean}
|
||||
*/
|
||||
async doesCustomProviderExistWithSlug(providerSlug) {
|
||||
const id = providerSlug.split("custom-")[1]
|
||||
|
||||
if (!id) {
|
||||
return false
|
||||
}
|
||||
|
||||
return !!await this.customMetadataProviderModel.findByPk(id)
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a custom metadata provider
|
||||
* @param {string} id
|
||||
*/
|
||||
async removeCustomMetadataProviderById(id) {
|
||||
// destroy metadta provider
|
||||
await this.customMetadataProviderModel.destroy({
|
||||
where: {
|
||||
id,
|
||||
}
|
||||
})
|
||||
|
||||
const slug = `custom-${id}`;
|
||||
|
||||
// fallback libraries using it to google
|
||||
await this.libraryModel.update({
|
||||
provider: "google",
|
||||
}, {
|
||||
where: {
|
||||
provider: slug,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean invalid records in database
|
||||
* Series should have atleast one Book
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue