New data model edit tracks page, match, quick match, clean out old files

This commit is contained in:
advplyr 2022-03-13 19:34:31 -05:00
parent be1e1e7ba0
commit 7d66f1eec9
68 changed files with 354 additions and 1529 deletions

View file

@ -138,6 +138,26 @@ class LibraryItemController {
this.streamManager.openStreamApiRequest(res, req.user, req.libraryItem)
}
// POST api/items/:id/match
async match(req, res) {
var libraryItem = req.libraryItem
var options = req.body || {}
var matchResult = await this.scanner.quickMatchBook(libraryItem, options)
res.json(matchResult)
}
// PATCH: api/items/:id/tracks
async updateTracks(req, res) {
var libraryItem = req.libraryItem
var orderedFileData = req.body.orderedFileData
Logger.info(`Updating item tracks called ${libraryItem.id}`)
libraryItem.media.updateAudioTracks(orderedFileData)
await this.db.updateLibraryItem(libraryItem)
this.emitter('item_updated', libraryItem.toJSONExpanded())
res.json(libraryItem.toJSON())
}
// POST: api/items/batch/delete
async batchDelete(req, res) {
if (!req.user.canDelete) {
@ -202,6 +222,18 @@ class LibraryItemController {
res.json(libraryItems)
}
// DELETE: api/items/all
async deleteAll(req, res) {
if (!req.user.isRoot) {
Logger.warn('User other than root attempted to delete all library items', req.user)
return res.sendStatus(403)
}
Logger.info('Removing all Library Items')
var success = await this.db.recreateLibraryItemsDb()
if (success) res.sendStatus(200)
else res.sendStatus(500)
}
middleware(req, res, next) {
var item = this.db.libraryItems.find(li => li.id === req.params.id)