audiobookshelf icon indicating copy to clipboard operation
audiobookshelf copied to clipboard

[Enhancement]: Setup periodic library scans

Open andonevris opened this issue 2 years ago • 6 comments

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

andonevris avatar Jun 01 '22 08:06 andonevris

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 avatar Jun 01 '22 13:06 advplyr

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 avatar Jun 01 '22 13:06 andonevris

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 avatar Jun 03 '22 13:06 szemlicka

Plex does it well I think

image

andonevris avatar Jun 03 '22 13:06 andonevris

Good idea, we will do it similar to plex.

advplyr avatar Jun 03 '22 13:06 advplyr

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 avatar Jul 31 '22 13:07 mdbell

Added in 2.1.3

advplyr avatar Aug 20 '22 22:08 advplyr