![]() |
#1 |
hopeless n00b
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
CLI: calibredb add_custom_column
Tried looking through the manual and searching the forums but wasn't able to find the info I needed.
1. Is it possible to use calibredb add_custom_column command line for creating composite columns with the template already populated? So far, I've only been able to use it for creating composite columns with an empty template. 2. How do I use the --display option for formatting dates? (e.g. MM/dd/yy: 12/31/12) Thank you very much in advance! |
![]() |
![]() |
![]() |
#2 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,224
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
IIRC it isn't possible, but chaley is the one who can give you a definitive answer.
|
![]() |
![]() |
Advert | |
|
![]() |
#3 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,348
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
The template goes into the display variable, which is JSON encoded. You can see what it should be by looking at the OPF for a book in your library. One example is
Code:
{"composite_template": "{:'approximate_formats()'}", "contains_html": false, "make_category": true, "composite_sort": "text" } Regarding date formatting, this is also a JSON-encoded string. One example is Code:
{ "date_format": "yyyy/MM/dd" } |
![]() |
![]() |
![]() |
#4 |
creator of calibre
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 45,224
Karma: 27110894
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
@chaley: Maybe we should add some examples to the documentation of that command, or at least a line telling the user to look at OPF files.
|
![]() |
![]() |
![]() |
#5 | ||
hopeless n00b
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Quote:
Quote:
Code:
--display='{"date_format":"MM/dd/yy"}' Edit: I believe calibredb custom_columns -d would also show the basic JSON structure. Shows everything in single-quotes, though, but easy enough to figure out which needs to be converted to double-quotes. Last edited by ilovejedd; 10-18-2012 at 02:40 PM. |
||
![]() |
![]() |
Advert | |
|
![]() |
#6 |
hopeless n00b
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Since I'm working on Windows 7 right now, tried to see if I can get the full error message.
CLI: Code:
calibredb add_custom_column --display '{"date_format":"MM/dd/yy"}' updated Updated datetime --with-library="Z:\library\fanfic" Code:
Python function terminated unexpectedly No JSON object could be decoded (Error Code: 1) Traceback (most recent call last): File "site.py", line 132, in main File "site.py", line 109, in run_entry_point File "site-packages\calibre\library\cli.py", line 1363, in main File "site-packages\calibre\library\cli.py", line 709, in command_add_custom_column File "json\__init__.py", line 326, in loads File "json\decoder.py", line 366, in decode File "json\decoder.py", line 384, in raw_decode ValueError: No JSON object could be decoded |
![]() |
![]() |
![]() |
#7 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,348
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Apparently the Win7 CLI does not strip single quotes from arguments, making the JSON string invalid. The following works.
Code:
--display="{\"date_format\":\"MM/dd/yy\"}" Code:
--display='{\"date_format\":\"MM/dd/yy\"}' Code:
{"date_format":"MM/dd/yy"} Code:
'{"date_format":"MM/dd/yy"}' So, the solution for Win7 is to use double quotes and escape all internal quotes. |
![]() |
![]() |
![]() |
#8 |
Grand Sorcerer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 12,348
Karma: 8012652
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
|
![]() |
![]() |
![]() |
#9 | |
hopeless n00b
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 5,110
Karma: 19597086
Join Date: Jan 2009
Location: in the middle of nowhere
Device: PW4, PW3, Libra H2O, iPad 10.5, iPad 11, iPad 12.9
|
Quote:
Funnily enough, I tried: Code:
--display="{'date_format':'MM/dd/yy'}" Code:
--display='{\"date_format\":\"MM/dd/yy\"}' Code:
--display="{\"date_format\":\"MM/dd/yy\"}" |
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
calibredb catalog CLI error | ilovejedd | Library Management | 4 | 02-06-2012 10:26 AM |
Cli-usage in plugins | drMerry | Development | 8 | 09-24-2011 03:58 PM |
Struggling with CLI | Paulinafrica | Calibre | 4 | 01-08-2011 02:04 PM |
prs505 cli | ees | Calibre | 3 | 01-10-2009 03:27 AM |