[Enhancement]: Setup periodic library scans #405

Closed
opened 2026-04-24 23:07:59 +02:00 by adam · 7 comments
Owner

Originally created by @andonevris on GitHub (Jun 1, 2022).

Describe the issue

Running AB in docker on Ubuntu host with a mapped network drive (on a NAS) where the audiobooks are stored.

Whenever I add a new book to the audiobooks folder it will not be auto discovered and added to the library, in fact no library changes are detected automatically, I must run manual scans to detect changes.

I'm guessing maybe the mapping of the network drive on the host may be the issue but either way I think it would be a good idea to have a periodic folder scan as an option for these cases where folder watching may break down.

Steps to reproduce the issue

  1. Add a new book to audiobooks folder
  2. wait for book to be discovered
  3. book is never discovered unless I run a manual scan of the library.

Audiobookshelf version

2.0.18

How are you running audiobookshelf?

Docker

Originally created by @andonevris on GitHub (Jun 1, 2022). ### Describe the issue Running AB in docker on Ubuntu host with a mapped network drive (on a NAS) where the audiobooks are stored. Whenever I add a new book to the audiobooks folder it will not be auto discovered and added to the library, in fact no library changes are detected automatically, I must run manual scans to detect changes. I'm guessing maybe the mapping of the network drive on the host may be the issue but either way I think it would be a good idea to have a periodic folder scan as an option for these cases where folder watching may break down. ### Steps to reproduce the issue 1. Add a new book to audiobooks folder 2. wait for book to be discovered 3. book is never discovered unless I run a manual scan of the library. ### Audiobookshelf version 2.0.18 ### How are you running audiobookshelf? Docker
adam added the enhancement label 2026-04-24 23:07:59 +02:00
adam closed this issue 2026-04-24 23:07:59 +02:00
Author
Owner

@advplyr commented on GitHub (Jun 1, 2022):

This isn't a bug, it is because of the network drive.
Periodic scans could be added but when you add an audiobook don't you want access to it right away? How frequent would these scans be?

@advplyr commented on GitHub (Jun 1, 2022): This isn't a bug, it is because of the network drive. Periodic scans could be added but when you add an audiobook don't you want access to it right away? How frequent would these scans be?
Author
Owner

@andonevris commented on GitHub (Jun 1, 2022):

Yeah network drive that's what I thought.

Most apps that have a periodic scan let you set the frequency yourself, a few times a day is fine.

I use readarr to add books to my library so I don't necessarily need immediate access but the new books should appear at some point on their own without a manual scan.

@andonevris commented on GitHub (Jun 1, 2022): Yeah network drive that's what I thought. Most apps that have a periodic scan let you set the frequency yourself, a few times a day is fine. I use readarr to add books to my library so I don't necessarily need immediate access but the new books should appear at some point on their own without a manual scan.
Author
Owner

@szemlicka commented on GitHub (Jun 3, 2022):

I wish a checkbox to enable/disable auto scan and a time field where you can enter the time for a scan. I do the same for my squeezebox server...:-)

grafik

@szemlicka commented on GitHub (Jun 3, 2022): I wish a checkbox to enable/disable auto scan and a time field where you can enter the time for a scan. I do the same for my squeezebox server...:-) ![grafik](https://user-images.githubusercontent.com/15927779/171859763-6477d655-68fe-400a-91b7-8300956ca843.png)
Author
Owner

@andonevris commented on GitHub (Jun 3, 2022):

Plex does it well I think

image

@andonevris commented on GitHub (Jun 3, 2022): Plex does it well I think ![image](https://user-images.githubusercontent.com/1779529/171860343-51154ca7-fa15-43ac-9f1b-6585c54921c9.png)
Author
Owner

@advplyr commented on GitHub (Jun 3, 2022):

Good idea, we will do it similar to plex.

@advplyr commented on GitHub (Jun 3, 2022): Good idea, we will do it similar to plex.
Author
Owner

@mdbell commented on GitHub (Jul 31, 2022):

I was asking about some similar stuff on discord, and was able to get a bit of a workaround by calling the API endpoints directly via curl + crontab. Not the most elegant solution, but works until there's a scheduler built into ABS.

The script:

#!/bin/bash

if [ "$#" -lt 4 ]; then
        echo "USAGE: $0 COMMAND HOST TOKEN LIBRARY_ID"
        exit
fi

#TODO validate commands

LibraryCommand="$1"
AbsHost="$2"
LoginToken="$3"
LibraryId="$4"

CommandUrl="http://${AbsHost}/api/libraries/${LibraryId}/${LibraryCommand}"


result=$(curl --silent -G \
        "${CommandUrl}" \
        -d "token=${LoginToken}"
        )

if [ "$result" != "OK" ]; then
        echo "Unexpected result from ABS! Result:'${result}'" 1>&2
else
        echo "Command '${LibraryCommand}' on library '${LibraryId}' executed!"
fi

And a sample crontab (runs a scan, and then 30 min later runs a match all):

#scan ebooks & audiobooks
0 * * * * /opt/audiobookshelf/command.sh scan localhost:1337 USER_TOKEN_HERE EBOOKS_LIBRARY_ID_HERE
0 * * * * /opt/audiobookshelf/command.sh scan localhost:1337 USER_TOKEN_HERE AUDIOBOOKS_LIBRARY_ID_HERE

#match ebooks & audiobooks
30 * * * * /opt/audiobookshelf/command.sh matchall localhost:1337 USER_TOKEN_HERE EBOOKS_LIBRARY_ID_HERE
30 * * * * /opt/audiobookshelf/command.sh matchall localhost:1337 USER_TOKEN_HERE AUDIOBOOKS_LIBRARY_ID_HERE
@mdbell commented on GitHub (Jul 31, 2022): I was asking about some similar stuff on discord, and was able to get a bit of a workaround by calling the API endpoints directly via curl + crontab. Not the most elegant solution, but works until there's a scheduler built into ABS. The script: ``` #!/bin/bash if [ "$#" -lt 4 ]; then echo "USAGE: $0 COMMAND HOST TOKEN LIBRARY_ID" exit fi #TODO validate commands LibraryCommand="$1" AbsHost="$2" LoginToken="$3" LibraryId="$4" CommandUrl="http://${AbsHost}/api/libraries/${LibraryId}/${LibraryCommand}" result=$(curl --silent -G \ "${CommandUrl}" \ -d "token=${LoginToken}" ) if [ "$result" != "OK" ]; then echo "Unexpected result from ABS! Result:'${result}'" 1>&2 else echo "Command '${LibraryCommand}' on library '${LibraryId}' executed!" fi ``` And a sample crontab (runs a scan, and then 30 min later runs a match all): ``` #scan ebooks & audiobooks 0 * * * * /opt/audiobookshelf/command.sh scan localhost:1337 USER_TOKEN_HERE EBOOKS_LIBRARY_ID_HERE 0 * * * * /opt/audiobookshelf/command.sh scan localhost:1337 USER_TOKEN_HERE AUDIOBOOKS_LIBRARY_ID_HERE #match ebooks & audiobooks 30 * * * * /opt/audiobookshelf/command.sh matchall localhost:1337 USER_TOKEN_HERE EBOOKS_LIBRARY_ID_HERE 30 * * * * /opt/audiobookshelf/command.sh matchall localhost:1337 USER_TOKEN_HERE AUDIOBOOKS_LIBRARY_ID_HERE ```
Author
Owner

@advplyr commented on GitHub (Aug 21, 2022):

Added in 2.1.3

@advplyr commented on GitHub (Aug 21, 2022): Added in [2.1.3](https://github.com/advplyr/audiobookshelf/releases/tag/v2.1.3)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/audiobookshelf#405