Closed saitoh183 closed 6 years ago
The thraxis docker with lazylibrarian and calibredb makes it much easier if you are using two dockers as the calibredb in the thraxis docker talks to the calibre content server in the other docker.
You could use a custom notifier to zip the files up, or you could use the same method as the lazylibrarian rss feed, which zips up audiobooks if you download using their rss link. A custom notifier gives you more control over the filename though. Alternatively you could feed the audiobooks to your users via the rss link and save using calibre at all?
I think Calibre will rename the audiobook folder according to it's own naming pattern, it needs to add it's own (id_number) on the end of the foldername, but I don't think it will rename the zipfile.
In the custom notifier you will be given all sorts of info about the download, including whether it's ebook or audiobook in the AuxInfo field. See the supplied example_custom_notification.py If you put this example program into lazylibrarian config and use "test custom notifier" button it will pretend the first book in the database has just been downloaded and show the details that were passed to it in the log.
I think Calibre will rename the audiobook folder according to it's own naming pattern, it needs to add it's own (id_number) on the end of the foldername, but I don't think it will rename the zipfile.
It can do both
Alternatively you could feed the audiobooks to your users via the rss link and save using calibre at all?
My users are setup to use Calibre web already and they like the layout and such.
You could use a custom notifier to zip the files up, or you could use the same method as the lazylibrarian rss feed, which zips up audiobooks if you download using their rss link. A custom notifier gives you more control over the filename though.
I was thinking of using Sabnzbd/Deluge to run a script to zip up the file using the the same name as the download and putting it in the download folder LL would be monitoring but i dont know if LL would recognized the zip and move it to the audiobook library location. Then i was thinking once it was moved by LL the custom notifier "on download" could launch the calibredb with the proper flag to modify the values i need to achieve the formatting i need.
The thraxis docker with lazylibrarian and calibredb makes it much easier if you are using two dockers as the calibredb in the thraxis docker talks to the calibre content server in the other docker.
If you dont mind me asking, how does it work? it would be able to communicate with my Calibre-RDP docker? i would have to turn on the content server?
LL queries the downloaders for the name of the file, so that part should be ok. When we send a torrent/nzb to deluge/sab they return us an id, which we use to check progress and get the filename. LL will then try to unzip the file though, as we're expecting to put epub/mobi/mp3 or whatever into the library, not zip. Would be better if lazylibrarian or custom notifier did the zipping.
You would need content server enabling in calibre for the thraxis docker to work, or use calibre watch directory instead. Problem with watch directory is that lazylibrarian doesn't get to talk to calibre to find out where calibre put the files.
You would need content server enabling in calibre for the thraxis docker to work, or use calibre watch directory instead. Problem with watch directory is that lazylibrarian doesn't get to talk to calibre to find out where calibre put the files.
I dont mind enabling content server if it means it would work better.
as we're expecting to put epub/mobi/mp3 or whatever into the library, not zip. Would be better if lazylibrarian or custom notifier did the zipping.
If i were to add the zip extension to the File Format section, it wouldnt work? If i let LL or custom notifier do the zipping, how would the process look?
So i installed the Thraxis docker container, added the path to calibredb, anything else i got to do?
Also since im going to use calibre with Audiobooks, i must point the Audiobook library to /books as well?
If i were to add the zip extension to the File Format section, it wouldnt work?
No, lazylibrarian will try to look inside zip/tar/rar archives as some torrents arrive zipped up
If i let LL or custom notifier do the zipping, how would the process look?
The custom notifier will be given the full path and filename of part one of the audiobook. You can use that to find the directory that the audiobook is in, and then you just have to zip up all the files in that directory. In python you would do something like this...
# audiofile is part one of the audiobook
if os.path.isfile(audiofile):
parentdir = os.path.dirname(audiofile)
with tempfile.NamedTemporaryFile() as tmp:
with zipfile.ZipFile(tmp, 'w', zipfile.ZIP_DEFLATED) as myzip:
for root, dirs, files in os.walk(parentdir):
for fname in files:
myzip.write(os.path.join(root, fname), fname)
# at this point copy the zipfile to a calibre folder
So i used the example custom script and saw all the info it returned, but how can i use that info in my own custom script? I would only want certain sections..like
If you are using python, the example script produces a dictionary of results, just use the parts you want
So custom script would
If you are using python, the example script produces a dictionary of results, just use the parts you want
Yeah thought so
Actually that might be a problem, I think calibre will be called before the notifier runs so the notifier gets the result of the download. You would need to run calibredb again inside the custom notifier, which is getting a bit messy.
Isnt calibre only called for ebooks? since Audiobooks are in there own directory, they shouldnt be affected by calibredb?
Yes I just checked, you are right we dont call calibredb for audiobooks, you would need to do that yourself in the notifier.
Ok
@philborman
When starting the content server from within the container
/opt/calibre/calibre-server --daemonize --pidfile=/app/calibre-server.pid --port=9000 --listen-on=:: --log=/app/calibre-server.log --enable-local-write /books
and i test calibredb i get this
ok, so you are talking to calibredb, and calibredb is talking to the content server, which is talking to the database. Nearly there. Write failed is usually a permissions (database is redable but not writeable by calibredb) or authorization problem (you can read if not authorized, but can't write). See the lazylibrarian wiki page https://github.com/DobyTang/LazyLibrarian/wiki/Config_Processing
The write works when i disable the content server. At first i thought it was because i was using the content server of my Calibre-RDP container but i get the same problem using the content server of this container Everything is using the same user/group...even the content server
@philborman
Few other questions...if you know the answer...
I ask because i am trying to create a script to add audiobooks to my calibre library and was going to include the opf file.
For the audiobook library, if i set it to be the same location as ebooks (which is the location of the calibre library/metadata.db), would this be a problem for LL. In my script, aside from zipping the abook, i would need to move it to the calibre book library. but if it is already there, i would just need to zip it delete the non-zipped abook, rename the opf file and call calibredb to add the book.
Do you know if calibredb -add will add the abook and read the opf file to populate the metadata or do i need to do another command to make it use the opf file?
If we rename the opf file to calibre format (metadata.opf) will calibre pick it up even if it doesnt contain all the info a calibre opf file usually contains? I ask because i am trying to create a script to add audiobooks to my calibre library and was going to include the opf file.
I think calibre should still use it, and add it's own info into the file, it does this with ebooks, BUT it will completely ignore the opf file we send it if there is any embedded metadata in the book file, ie book metadata is preferred. Don't think this will be an issue with audiobooks as calibre doesn't have id3 tag reading?
For the audiobook library, if i set it to be the same location as ebooks (which is the location of the calibre library/metadata.db), would this be a problem for LL. In my script, aside from zipping the abook, i would need to move it to the calibre book library. but if it is already there, i would just need to zip it delete the non-zipped abook, rename the opf file and call calibredb to add the book.
Don't think it will be a problem, but I haven't tried it. LL only checks valid ebook types and ignores everything else.
Do you know if calibredb -add will add the abook and read the opf file to populate the metadata or do i need to do another command to make it use the opf file?
Add the audiobook with calibredb, it tells you the calibre "bookid" in it's reply, then... calibredb set_metadata bookid opf_file or you can do the fields individually... calibredb set_metadata --field author:authorname bookid
Hi @philborman
My script is almost finish but i still need to run LL library update via the script but cant find any reference to doing that.
calibredb set_metadata --field author:authorname bookid
I tried this with --field tags:test and it returns Forbidden and if i just try --list-fields i get
Title Field name
Forbidden
You can run lazylibrarian library update from the lazylibrarian api, something like http://192.168.1.2/lazylibrarian/api?apikey=whatever&cmd=forceAudioBookScan&wait&dir=sub_folder
For calibredb set_metadata you might need to include the library eg calibredb set_metadata --field author:authorname --with-library library_or_server bookid
@philborman
calibredb set_metadata --field author:authorname --with-library library_or_server bookid
yeah i did that and it still gives that result...it is not a big deal, i will just have to add the tag manually once the book is added to calibre/calibreweb
You can run lazylibrarian library update from the lazylibrarian api, something like http://192.168.1.2/lazylibrarian/api?apikey=whatever&cmd=forceAudioBookScan&wait&dir=sub_folder
Thanks i will give that a try
I use Calibre Web to serve my books and audiobook to my users. Now i know Calibre doesnt really support Audiobooks except when it is a single mp3 file, i was able to do it with multi-file audiobooks by zipping the audiobook first before adding it to calibre. This works great. Now wanting to add LL into the mix to get some automation going, im trying to figure out how best to approach my situation. Im currently using LL docker from LS and Calibre-RDP docker from aptalca. Im also aware of the docker container that has both calibre and LL in it but i dont know if i need to switch to that in order to achieve what i explain below.
First off the format i use in Calibre for Audiobooks is
I was doing this manually for each media i added. Since my media is all in google drive, i use unionFS/plexdrive + rclone(for upload) to manage the RW of the metadata.db/opf files and adding new books.
I already have an idea of how to get stuff zipped after download via script and have them placed in the watch directory of LL but i would like to have the format mention above done automatically when the book is added to calibre.
Thanks