Add custom metadata provider controller, update model, move to item metadata utils

This commit is contained in:
advplyr 2024-02-11 16:48:16 -06:00
parent ddf4b2646c
commit 0cf2f8885e
21 changed files with 496 additions and 373 deletions

View file

@ -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