08-12-2018, 07:23 AM | #1 |
Enthusiast
Posts: 28
Karma: 10
Join Date: Oct 2010
Device: iPad / Kindle DX
|
Deducing "Author sort" and "Title sort" through CLI
Hello,
I add books to Calibre through a shell script that properly sets "Author" and "Title". I am aware that I could also include "Author sort" and "Title sort", but that would make me write into the script rules to generate the latter from the former. I would rather avoid that. For consistency, I prefer to use always Calibre's rules. Therefore, after the script finishes running, I bulk edit the metadata of the books I've added. No bid deal, but I would rather this step be done automatically through the command line interface. My question is: Is there a way to use a CLI command such as calibredb to deduce "Author sort" and "Title sort" from "Author" and "Title"? Many thanks in advance! W. |
08-12-2018, 11:34 AM | #2 |
creator of calibre
Posts: 44,305
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
calibredb can output all metadata via the show_metadata sub-command.
calibredb show_metadata --as-opf book_id |
07-31-2020, 02:05 AM | #3 | |
Junior Member
Posts: 9
Karma: 10
Join Date: Aug 2019
Device: PocketBook Touch Lux 3
|
CLI option to parse author_sort field from author field?
Quote:
I think you misunderstood the question maybe. As you can see from the question he wanted to know if he could use Calibre's algorithm from the CLI to parse the "sort fields" from the original fields. I think your previous answer does not show the correctly parsed sort fields, if they are not yet set. I am replying here because I am interested in exactly this also. Thank you! |
|
07-31-2020, 03:20 AM | #4 |
creator of calibre
Posts: 44,305
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
show_metadata shows all metadata including sort values. If you want to use the algorithm for values not in the databse, then you can do so via calibre-debug
Code:
calibre-debug -c "from calibre.ebooks.metadata import *; import sys; print(author_to_author_sort(' '.join(sys.argv[1:])))" Kovid Goyal |
08-02-2020, 06:09 PM | #5 |
Junior Member
Posts: 9
Karma: 10
Join Date: Aug 2019
Device: PocketBook Touch Lux 3
|
Great!
Thanks for your quick and very useful response!
If you are interested, someone wrote an 'alternative frontend' for Calibre for Emacs. If you know vim and you are on GNU/Linux or Mac then you could quickly check it out via this Spacemacs layer. |
08-02-2020, 11:21 PM | #6 |
creator of calibre
Posts: 44,305
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
cute I am indeed a vim user. And its actually on my TODO list to create a nice terminal interface for managing libraries as a kitten for https://github.com/kovidgoyal/kitty someday.
|
08-03-2020, 07:48 PM | #7 |
Junior Member
Posts: 9
Karma: 10
Join Date: Aug 2019
Device: PocketBook Touch Lux 3
|
Haha, managing as a kitten? Well anyway, that terminal looks quite 'futuristic' and amazing.
Somewhat like an Emacs, but fast with modern technology and python. I don't know if you know Emacs and Spacemacs. I switched from vim to Spacemacs. It implemented some very beautiful concepts, especially the leveraging of the spacebar to function as the main control key and also the which-key extension. For me Emacs was/is much more (easier) hackable than vim due to its intuitive self-documentation and amazing introspection features. Anyway, I really don't have any intention to convert you or something. For sure you know very well what you are doing (more than me). But anyway, if you never had a look at Spacemacs then quickly check it out for a few minutes or hours, just to check out the concepts I mentioned here (would be great if you could get inspired for kitty). You have a full python environment setup in 5 minutes. And then especially check out the describe features. Well, it is just a humble suggestion of course... |
08-03-2020, 10:57 PM | #8 |
creator of calibre
Posts: 44,305
Karma: 23661992
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I used emacs fairly extensively a couple of decades ago. But I settled on vim for the modal editing (back then there was no spacemacs). And nowadays I program vim in python as well, so vimscript does not bother me as much. Though I do agree that emacs is far more programmable.
|
08-04-2020, 05:20 AM | #9 |
Junior Member
Posts: 9
Karma: 10
Join Date: Aug 2019
Device: PocketBook Touch Lux 3
|
Ah well, with (neo)vim programmable in python, combined with your superterminal you have a very nice environment too. I guess indeed a little less hackable (more difficult to get into), but using more modern technologies. Well... still you could quickly have a look at Spacemacs if you like... or otherwise Spacevim although that is not yet very comparable to Spacemacs.
Anyway your calibre-debug magic now is implemented in calibre.el. Thanks again! |
Tags |
author sort, calibredb, cli, title sort |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Sort on data+time entered into the column "title"? | nikoski | Calibre Companion | 4 | 07-29-2017 03:51 AM |
Use "short" instead of "full" title for title sort & renaming? | wolpi | Library Management | 2 | 08-04-2016 05:25 PM |
PW doesn't sort by "author-sort" | thesn00ze | Devices | 4 | 05-23-2014 06:37 PM |
A warning for Linux users: slow "Add Books", "Unknown" title and Author | rolgiati | Library Management | 8 | 07-24-2013 04:36 PM |
How do I turn off the red highlight around "author sort" | lunixer | Calibre | 5 | 09-19-2010 11:25 AM |