[XYScript] CalibreLibrary: List Calibre Books

Discuss and share scripts and script files...
Post Reply
WirlyWirly
Posts: 312
Joined: 21 Oct 2020 23:33
Location: XY 64-Bit | Win 10 @ 100% (3440x1440)

[XYScript] CalibreLibrary: List Calibre Books

Post by WirlyWirly »

CalibreLibrary
2024-12-18_22-34-20.png
Introduction

Calibre's renaming convention leaves filenames butchered and often only half intact, making it annoying to browse for a book from within XY. Many times I've found myself starting Calibre just so I could then open the book I want.

This script will read a calibre database file, pull the complete title for each book, and display them all in a list so you can pick which to open.

At the moment, if there is more than one filetype for a book, only the first type that the database reports will be displayed.

:info: The database is NOT accessible while Calibre is running, meaning this script won't work until you close the program. This is a limitation of Calibre.

Instructions
Simply copy the CalibreLibrary folder to your <xyscripts> directory and update the config.ini with your actual paths. The calibredb.exe is not the Calibre program itself, it is another .exe usually in the same directory as the normal Calibre.exe.

For the libraryFolder, paste the path to the directory that contains the Calibre author folders and the metadata.db file.

The included jq.exe is used to parse the Calibre database results.

Download
CalibreLibrary.zip
To see the attached files, you need to log into the forum.

Malarki
Posts: 211
Joined: 03 Dec 2019 02:51
Location: Windows 10 x64; 100% Scaling

Re: [XYScript] CalibreLibrary: List Calibre Books

Post by Malarki »

I tried this on XY v26.70.0401 under Win 10 x64.

My config.ini file is:

Code: Select all

[general]
calibreDbExe=C:\Program Files\Calibre2\calibredb.exe
libraryFolder=D:\Libraries\Documents\Calibre Library
It builds this variable:
$calibreQuery = "C:\Program Files\Calibre2\calibredb.exe --library-path D:\Libraries\Documents\Calibre Library list --ascending --sort-by title --for-machine --fields title,formats"

but the next line
$calibreResults = runret("cmd /c " . $calibreQuery, , 65001)
reports in the debugger that:
'C:\Program' is not recognized as an internal or external command,¶operable program or batch file.¶

Eventually when jq.exe is called it fails, reporting a problem with line 1.

And fyi my Calibre library is almost all author folders but there are two oddball folders ".calnotes" and ".caltrash". I assume your jq.exe will handle that.

Sorry, I can't spend a lot of time on this now. The above may be enough for you to see a weakness somewhere. Maybe not enough quote signs?

WirlyWirly
Posts: 312
Joined: 21 Oct 2020 23:33
Location: XY 64-Bit | Win 10 @ 100% (3440x1440)

Re: [XYScript] CalibreLibrary: List Calibre Books

Post by WirlyWirly »

Yes, my file paths don't have spaces, so I forgot to add quotes after puling the config paths.

You can quote yours, but I'll push a script-side fix when I get home.

Malarki
Posts: 211
Joined: 03 Dec 2019 02:51
Location: Windows 10 x64; 100% Scaling

Re: [XYScript] CalibreLibrary: List Calibre Books

Post by Malarki »

I did try adding quotes in the .ini file but that didn't fix it. Those generally baffle me anyway; and it's usually trial and error.

WirlyWirly
Posts: 312
Joined: 21 Oct 2020 23:33
Location: XY 64-Bit | Win 10 @ 100% (3440x1440)

Re: [XYScript] CalibreLibrary: List Calibre Books

Post by WirlyWirly »

It ended up being a script-side issue that was making quotation more complicated than necessary... Quoting is definitely trial-and-error, I put this together over a couple hours, most of that time was spent figuring out the quoting for jq to work... It should be fixed in v1.1 👍

I also added a couple config lines to adjust the window size, since I don't think everyone is on an ultra-wide.

Malarki
Posts: 211
Joined: 03 Dec 2019 02:51
Location: Windows 10 x64; 100% Scaling

Re: [XYScript] CalibreLibrary: List Calibre Books

Post by Malarki »

It woks now on my system. In order to browse books it would be good to have an option to keep the list open after choosing a title, instead of having the script end and having to run it again. Keeping the script active keeps XY tied up but I don't need it while browsing books.

Thanks

Post Reply