Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 11-06-2011, 11:43 PM   #1
Joe42
Junior Member
Joe42 began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2011
Device: Nook Color
Question 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}
When I save to disk, my ebooks are saved with a simple folder & file name structure. Going by the first letter of the author's last name, a folder is created and named with that letter, then inside that folder another folder with the author's name is made, and inside that folder is where the file goes, and it get's named with just the title of the book.

Example:
Code:
A
   Will Adams
      The Alexander Cypher.epub
   Mark Ames
       Going Postal.epub

B
   Alan Ball
       American Beauty.epub
You get the idea.

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
This error has been a constant pain in my backside since I started using Calibre somewhere in the version 6.xx area and it still exists with the latest version, 0.8.25.

Any ideas?
Joe42 is offline   Reply With Quote
Old 11-07-2011, 12:55 AM   #2
DoctorOhh
US Navy, Retired
DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.DoctorOhh ought to be getting tired of karma fortunes by now.
 
DoctorOhh's Avatar
 
Posts: 9,864
Karma: 13806776
Join Date: Feb 2009
Location: North Carolina
Device: Icarus Illumina XL HD, Nexus 7
Quote:
Originally Posted by Joe42 View Post
This error has been a constant pain in my backside since I started using Calibre somewhere in the version 6.xx area and it still exists with the latest version, 0.8.25.

Any ideas?
Submit a bug report.

Kovid is good, but I don't believe he has ever claimed to be Psychic.
DoctorOhh is offline   Reply With Quote
Advert
Old 11-07-2011, 07:56 AM   #3
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 29,768
Karma: 54401244
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}/
As a work around:
Change all Unknown to (the word) Unknown (or Authors Unknown)
(the first is probably a blank value that only displays as Unknown)
theducks is offline   Reply With Quote
Old 11-07-2011, 08:57 AM   #4
Joe42
Junior Member
Joe42 began at the beginning.
 
Posts: 5
Karma: 10
Join Date: Nov 2011
Device: Nook Color
Quote:
Originally Posted by dwanthny View Post
Submit a bug report.

Kovid is good, but I don't believe he has ever claimed to be Psychic.
I'll do that. Thanks.


Quote:
Originally Posted by theducks View Post
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}/
As a work around:
Change all Unknown to (the word) Unknown (or Authors Unknown)
(the first is probably a blank value that only displays as Unknown)
Typing Unknown in the author field doesn't work, same result. Hadn't thought of using Authors Unknown. I'll give that a try. Thanks.

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 09:40 AM. Reason: update
Joe42 is offline   Reply With Quote
Old 11-07-2011, 09:42 AM   #5
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by theducks View Post
Change all Unknown to (the word) Unknown (or Authors Unknown)
(the first is probably a blank value that only displays as Unknown)
"Unknown" as an author has entries in the metadata.db database for both author and author_sort. In fact, IIRC, there is an author table, with an author name field and a sort field for the author names, as well as a book table, with an author_sort field. All 3 of those author fields are populated with "Unknown" on an English system and with the corresponding translation for other languages.

"Unknown" is handled specially on input, but I'm surprised at this error on output.
Starson17 is offline   Reply With Quote
Advert
Old 11-07-2011, 09:51 AM   #6
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,731
Karma: 6690881
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'.
chaley is offline   Reply With Quote
Old 11-07-2011, 10:04 AM   #7
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by chaley View Post
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.
I wonder if this has changed? My db has author_sort set to Unknown for all my Unknowns? I did a quick test by adding an empty book, and author_sort was set to Unknown for it. Under what circumstances is author_sort left empty? Is it during import, with an empty author, or only by clearing the author_sort field?
Starson17 is offline   Reply With Quote
Old 11-07-2011, 10:55 AM   #8
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,731
Karma: 6690881
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Starson17 View Post
I wonder if this has changed? My db has author_sort set to Unknown for all my Unknowns? I did a quick test by adding an empty book, and author_sort was set to Unknown for it. Under what circumstances is author_sort left empty? Is it during import, with an empty author, or only by clearing the author_sort field?
I also haven't been able to make it happen. I have tried empty books, books with empty file-as in the OPF, etc.

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.
chaley is offline   Reply With Quote
Old 11-07-2011, 11:02 AM   #9
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by chaley View Post
My suspicion is that the OP has books from way-back-when when we might have handled null values incorrectly.
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.
Starson17 is offline   Reply With Quote
Old 11-07-2011, 11:13 AM   #10
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
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.
Starson17 is offline   Reply With Quote
Old 11-07-2011, 12:35 PM   #11
Joe42
Junior Member
Joe42 began at the beginning.
 
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 01:08 PM.
Joe42 is offline   Reply With Quote
Old 11-07-2011, 01:41 PM   #12
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by Joe42 View Post
I don't understand what you guys are saying. It's obviously a bug in Calibre, hence the error msg.
It's not a bug now. It may have been in the past.
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.
Starson17 is offline   Reply With Quote
Old 11-07-2011, 01:53 PM   #13
GoingDown
Zealot
GoingDown is no ebook tyro.GoingDown is no ebook tyro.GoingDown is no ebook tyro.GoingDown is no ebook tyro.GoingDown is no ebook tyro.GoingDown is no ebook tyro.GoingDown is no ebook tyro.GoingDown is no ebook tyro.GoingDown is no ebook tyro.
 
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 01:57 PM.
GoingDown is offline   Reply With Quote
Old 11-07-2011, 03:20 PM   #14
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,731
Karma: 6690881
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.
chaley is offline   Reply With Quote
Old 11-07-2011, 04:11 PM   #15
Starson17
Wizard
Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.Starson17 can program the VCR without an owner's manual.
 
Posts: 4,004
Karma: 177841
Join Date: Dec 2009
Device: WinMo: IPAQ; Android: HTC HD2, Archos 7o; Java:Gravity T
Quote:
Originally Posted by chaley View Post
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.
I would like to emphasize Charles' comments. I recall looking closely at the code for adding a book to the calibre library. If calibre can't find an author, it inserts the local language word for "Unknown" as the author. The author name, whatever it is, is converted to an author_sort name. For a long time, author_sort was relatively inaccessible. It no longer is inaccessible. You are perfectly free to force it to be null, and if you do, you will get the error of the OP.

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 04:21 PM.
Starson17 is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Field "author(s)" vanishes when attached to reader DrChiper Calibre 2 09-23-2011 04:10 PM
"Unknown Author" and can't open when transferring to Nook unclelobsterman Calibre 4 02-08-2011 02:31 PM
Problem "saving to disk" pdf files lucone Calibre 1 06-28-2010 05:29 AM
Rebuild "author sort" field enriquep Calibre 2 07-24-2009 11:21 AM
Newbie question for Calibre: "Unknown Book Type" error rvdparis Calibre 8 04-28-2009 04:20 AM


All times are GMT -4. The time now is 07:06 AM.


MobileRead.com is a privately owned, operated and funded community.