11-07-2011, 12:43 AM | #1 |
Junior Member
Posts: 5
Karma: 10
Join Date: Nov 2011
Device: Nook Color
|
Saving to disk with "Unknown" in author field
Calibre can't handle having "Unknown" in the author field when saving to disk despite my save template working perfectly for anything else.
Here's my save template: Code:
{author_sort[0]}/{author}/{series:||} {series_index:0>2s|| -} {title} Example: Code:
A Will Adams The Alexander Cypher.epub Mark Ames Going Postal.epub B Alan Ball American Beauty.epub Anyway, Calibre should just create a folder called "U" and inside that one called "Unknown" then drop the ebooks in there, but instead the python scripting breaks down and I get the following error, no folder structure for "U" is made and no file is saved: Code:
Traceback (most recent call last): File "site-packages\calibre\library\save_to_disk.py", line 437, in save_serialized_to_disk File "site-packages\calibre\library\save_to_disk.py", line 305, in do_save_book_to_disk ValueError: Failed to calculate path for save to disk. Template: {author_sort[0]}/{authors}/{series:||} {series_index:0>2s|| -} {title} Error: string index out of range Any ideas? |
11-07-2011, 01:55 AM | #2 | |
US Navy, Retired
Posts: 9,868
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Kindle PaperWhite SE 11th Gen
|
Quote:
Kovid is good, but I don't believe he has ever claimed to be Psychic. |
|
Advert | |
|
11-07-2011, 08:56 AM | #3 |
Well trained by Cats
Posts: 30,478
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
OMG it is amazing that I have not tripped that bug.
I use a similar folder structure (Authors_A) Code:
Authors_{author_sort[0]}/{author}/ Change all Unknown to (the word) Unknown (or Authors Unknown) (the first is probably a blank value that only displays as Unknown) |
11-07-2011, 09:57 AM | #4 | ||
Junior Member
Posts: 5
Karma: 10
Join Date: Nov 2011
Device: Nook Color
|
Quote:
Quote:
I forgot to add that if I browse in Win Explorer to my library, those with unknown author are actually named as such and are placed in a folder called "Unknown". Here's a screenshot of just one example. I have several separate libraries with unknown authors. *Using "Unknown Authors" works fine. Last edited by Joe42; 11-07-2011 at 10:40 AM. Reason: update |
||
11-07-2011, 10:42 AM | #5 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
"Unknown" is handled specially on input, but I'm surprised at this error on output. |
|
Advert | |
|
11-07-2011, 10:51 AM | #6 |
Grand Sorcerer
Posts: 12,063
Karma: 7874545
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
The problem is that author_sort is empty, which is arguably appropriate when there is no author. You can see this by sorting on author -- the "Unknown"s will show up at the beginning of the list unless author_sort has been manually set. Note that the same thing will happen if you clear author_sort by hand.
To avoid this problem, set the author sort for all books where it is empty. Search for author_sort:false, select the books, open bulk metadata edit, check the "Automatically set author sort", and press OK. Alternatively, set it to what you want, which may be something other than 'Unknown'. |
11-07-2011, 11:04 AM | #7 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
|
|
11-07-2011, 11:55 AM | #8 | |
Grand Sorcerer
Posts: 12,063
Karma: 7874545
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
My suspicion is that the OP has books from way-back-when when we might have handled null values incorrectly. Alternatively, author_sort was explicitly set to empty at some point. Pure speculation on my part. |
|
11-07-2011, 12:02 PM | #9 |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Yes, there was a period it was handled incorrectly that I recall. It also explains why others haven't seen this and why it's bugged him for a long time. I suspect a quick search and correction on the nulls is all that's needed. It may already be fixed if he's changed to Unknown_Author. That would have populated his nulls and he won't get them back without some intentional effort.
|
11-07-2011, 12:13 PM | #10 |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
BTW, "Unknown" as an author name (or it's set-language equivalent) is handled specially for various options, such as Merge and Copy to Library. If the database holds "Unknown" (or language equivalent), I treated it as an empty field in a Merge, etc. so that a book having an author name of Unknown in the first selected record is overwritten by the author name of the second selected book if it's other than "Unknown." If Automerge is set, the same thing happens with Copy To Library.
Using "Unknown Author" instead of "Unknown" will be treated as a real author name, not a null for those operations. If you simply don't know the author, I'd use "Unknown," but if no one knows the name, "Unknown Author" might be a better choice so you aren't tempted to go looking for what can't be found. |
11-07-2011, 01:35 PM | #11 |
Junior Member
Posts: 5
Karma: 10
Join Date: Nov 2011
Device: Nook Color
|
I don't understand what you guys are saying. It's obviously a bug in Calibre, hence the error msg. Kovid killed my bug report saying it's invalid and provided no reason other than "see thread for details." Too bad there's no details to see.
I guess I'll just live with using "Author Unknown" since that seems to work fine. Is it possible for me to change the default "Unknown" to "Author Unknown"? As for my ebooks possibly being old, I've been building my collection for less than 1 year, so none of the files are very old. Besides, the files themselves should have no bearing on how Calibre exports them since all it's doing it creating folders and naming files according to my template. Also when exporting, Calibre automatically updates the metadata within the files themselves, so older formats shouldn't be a problem. I did find out that when author is Unknown, whether it's automatic or I type it, that only applies to author_sort, not author. Last edited by Joe42; 11-07-2011 at 02:08 PM. |
11-07-2011, 02:41 PM | #12 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
Your problem is that you had some null author_sort records. It shouldn't be possible to have that unless you specifically nulled them. It could have been by mistake or an old bug. Try this: 1) First search for the problems: author_sort:false If you get results, check that the author is "Unknown" for all. If it is, select them all, enter bulk metadata edit by pressing "e" and set both the author and author_sort to "Unknown." (if it isn't, then you've got some null author_sort records for valid author names, and you should fix those separately) That should solve your problem. I would also search for author:"Author Unknown" and change that and the author_sort back to Unknown for the reasons above. |
|
11-07-2011, 02:53 PM | #13 |
Zealot
Posts: 114
Karma: 1274
Join Date: Dec 2010
Location: Finland
Device: Kobo Touch
|
I tested this in Linux version in Calibre, and it seems to give the error message in OP if the "Unknown" is typed so that first letter is uppercase.
If the whole string is lowercase, then saving works, but if I change it back to capital U, then it breaks again. Note that I am talking about Author - field, not author_sort. Strange Edit. Tested again by editing one book and renamed author to Unknown. Saving to disk failed. Renamed author to "unknown" and it worked. So it seems to be bug Last edited by GoingDown; 11-07-2011 at 02:57 PM. |
11-07-2011, 04:20 PM | #14 |
Grand Sorcerer
Posts: 12,063
Karma: 7874545
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
The error reported by the OP regards author_sort. The contents of Author is not relevant. Specifically, the error message says that author_sort is empty, meaning author_sort[0] is undefined, which calibre is reporting. This is correct behavior -- calibre is reporting the error that the template asks for information that is not available. There is no "obvious bug" here.
The next question is "how did author_sort become empty?" There are several ways to do this, including the "manage authors" dialog and metadata edit. Apparently it was possible to do this during import sometime in the past, but I think not since middle 2010. Starson17 and I have tried several ways to create a book with an empty author_sort and have not been able to do it. If someone has a way to enter a new author or import a new book and have the author_sort remain empty, I would like to see it. The author name must not exist before the book is imported/changed. If the author already exists, then the test is flawed because that author might already have a stored empty author_sort value. @goingdown: you don't say which version of calibre you are using. It would be useful to know whether or not the authors Unknown and unknown both simultaneously exist and if so whether the author_sort values for these two authors are defined, something you can see using "manage authors" (right-click on an author in the tag browser and choose "manage authors"). It also would be useful to know what the author_sort value is for a failing book after you make the change, and whether calibre considers that value as correct (not pink) -- both of these can be seen using edit metadata. |
11-07-2011, 05:11 PM | #15 | |
Wizard
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
|
Quote:
Neither Charles nor I can find a way to accidentally make it null during an import (except as below). There may be one (other than below), and if there is, that's a bug. I'll also comment that author_sort is defined for a book, not an author. There is a corresponding field for the author called simply "sort." You can see "author_sort" in a book record. You can see the "sort" field for the author in Manage Authors. The sort field in the author table is used for the author_sort field in the book table if the author was previously defined. If the OP has accidentally nulled the sort field in the author's table for the "Unknown" author (using Manage Authors), it will produce a null author_sort field for each newly added Unknown author. This needs to be fixed with Manage Authors and all old books with this problem also need fixing to solve the OP's problem. I just tested it to confirm this. Nulling the sort field for the author "Unknown" produces null author_sort fields for new books with unknown authors. This problem applies to all authors, not just the special Unknown, but it's more likely that someone tried to blank out the Unknown author than any other. Generally, calibre will catch any attempt to null the author field and replace it with Unknown, but it's possible that there is some situation where calibre caught the attempt to blank the author field (which is prohibited due to the filename requirements of the library), but didn't catch the blank "author_sort" or "sort" fields, which are both permitted. Last edited by Starson17; 11-07-2011 at 05:21 PM. |
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Field "author(s)" vanishes when attached to reader | DrChiper | Calibre | 2 | 09-23-2011 05:10 PM |
"Unknown Author" and can't open when transferring to Nook | unclelobsterman | Calibre | 4 | 02-08-2011 03:31 PM |
Problem "saving to disk" pdf files | lucone | Calibre | 1 | 06-28-2010 06:29 AM |
Rebuild "author sort" field | enriquep | Calibre | 2 | 07-24-2009 12:21 PM |
Newbie question for Calibre: "Unknown Book Type" error | rvdparis | Calibre | 8 | 04-28-2009 05:20 AM |