advplyr / audiobookshelf

Self-hosted audiobook and podcast server
https://audiobookshelf.org
GNU General Public License v3.0
6.17k stars 431 forks source link

[Enhancement]:Authors With 0 Books - Automatic Cleanup #2466

Open slyfoxgh opened 8 months ago

slyfoxgh commented 8 months ago

Describe the feature/enhancement

Please allow the automatic removal of authors with 0 books. I have many authors with 0 books across multiple libraries. The only way to remove them is manually. This is a tedious process that can be automated by ABS.

Screenshot 2023-12-29 at 12 06 54 PM
methosinhiding commented 7 months ago

Copying this content in from #2547 which is a semi-duplicate (I don't think auto-pruning unused authors should be the default given the level of curation some folks put into their author profile information, however maybe a toggleable option would make sense)

The authors view is currently sorted by Author name by default, but there are no other sorting/filtering options.

Since the addition of authors is automatic but removals are a manual action, a common interaction with the authors page is to use the browser search functionality to locate and then manually delete authors who have 0 books attributed to them (either because their name was wrong/corrected, the 'author' was multiple merged names that had since been split out, or because the file was removed/moved to a different library, etc)

It would be very useful for this repeated author removal task to either be able to sort the author list by book count so that 0-book authors could be deleted en-masse or to provide a shortcut to perform that specific action such as a 'Purge Authors who have no books' button

advplyr commented 7 months ago

As of the current version (v2.7.2) authors with 0 books are removed automatically if asin, description and imagePath has not been set on the author. This is to prevent removing an author that the user filled out details for.

https://github.com/advplyr/audiobookshelf/blob/19e18036334d5a44525f9b6fef745e5faf4c2f1b/server/scanner/BookScanner.js#L838-L878

slyfoxgh commented 7 months ago

"authors with 0 books are removed automatically"

I don't see this happening. in 2.7.2

Screenshot 2024-01-23 at 9 37 36 AM Screenshot 2024-01-23 at 9 39 09 AM Screenshot 2024-01-23 at 9 39 06 AM Screenshot 2024-01-23 at 9 38 51 AM Screenshot 2024-01-23 at 9 38 45 AM Screenshot 2024-01-23 at 9 38 08 AM Screenshot 2024-01-23 at 9 38 01 AM Screenshot 2024-01-23 at 9 37 40 AM
advplyr commented 7 months ago

Yeah looks like there is a bug somewhere. With regular scans it should work but I'll have to test more when user does manual edits

slyfoxgh commented 7 months ago

When you say "With regular scans" what specifically do you mean? Doing Library Scan from Setting - Libraries does not cleanup Authors with 0 books.

After doing a full scan of the library, I get 55 results for Authors with 0 books.

Screenshot 2024-01-23 at 5 58 13 PM
ZLoth commented 4 months ago

Here is a screenshot from my end. This is probably because of one of two things:

image

Harwood commented 2 months ago

I was able to clean up my authors with the following sql query against /config/absdatabase.sqlite.

DELETE
FROM authors
WHERE id NOT IN (
    SELECT authorId
    FROM authors
    JOIN bookAuthors ON (
        authors.id = bookAuthors.authorId
    )
)