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

Go Back   MobileRead Forums > E-Book Software > Calibre > Devices

Notices

Reply
 
Thread Tools Search this Thread
Old 12-17-2010, 08:41 AM   #16
ch4os
Junior Member
ch4os began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Dec 2010
Device: K3
Thanks for catching my eye on azw files.

I've changed 466 line from

Code:
print collDesc.encode('utf-8')
to

Code:
print collDesc
and it worked, so i don't know if u need to convert all strings to utf-8 before print, i think calibre ensure proper encoding of metadata file.

edit.
After while i think it could be os depedent, i'm running your script at linux where utf-8 is default encoding, windows (with kernel 6.x - vista, 7, 2k8) use utf-16. Calibre force utf-8 to write metadata file? or use system encoding?

Last edited by ch4os; 12-17-2010 at 08:44 AM.
ch4os is offline   Reply With Quote
Old 12-17-2010, 08:58 AM   #17
mornington
Connoisseur
mornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enough
 
Posts: 63
Karma: 732
Join Date: Nov 2010
Device: Sony PRS-650
Quote:
Originally Posted by ch4os View Post
i don't know if u need to convert all strings to utf-8 before print, i think calibre ensure proper encoding of metadata file.

edit.
After while i think it could be os depedent, i'm running your script at linux where utf-8 is default encoding, windows (with kernel 6.x - vista, 7, 2k8) use utf-16. Calibre force utf-8 to write metadata file? or use system encoding?
I'm not sure myself, but I do know that if I didn't explicitly encode everything from Calibre to utf-8 then the script just constantly fell over on the slightest deviation from plain-ASCII characters. There's probably a more robust way to handle this kind of thing in Python, but like I said I don't know Python...

Glad the edit works for you, though. Did you try out the most recent version of the script, incidentally? I'm still not able to test it on the kindle, so I'd appreciate some reassurance that it works.
mornington is offline   Reply With Quote
 
Advertisement
Old 12-18-2010, 05:33 AM   #18
ch4os
Junior Member
ch4os began at the beginning.
 
Posts: 3
Karma: 10
Join Date: Dec 2010
Device: K3
I've tested latest version of your script and with my 'edit' everything works fine, great job it should be built-in into calibre
ch4os is offline   Reply With Quote
Old 12-18-2010, 04:45 PM   #19
beckywc
Addict
beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.
 
beckywc's Avatar
 
Posts: 270
Karma: 1050426
Join Date: Feb 2010
Location: California
Device: iPad Mini w/Retina, Kindle 3, Kindle Fire HDX 8.9, & Asus Transformer
I have a custom column thats called "In Collection" this column is a text, but with a set of permitted values. These values are the collections I have currently on my Kindle. When I add a book to my library I select which collection it will go in.

How would I be able to alter you script to fit my set up?

Thanks
beckywc is offline   Reply With Quote
Old 12-18-2010, 05:45 PM   #20
mornington
Connoisseur
mornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enough
 
Posts: 63
Karma: 732
Join Date: Nov 2010
Device: Sony PRS-650
Quote:
Originally Posted by beckywc View Post
I have a custom column thats called "In Collection" this column is a text, but with a set of permitted values. These values are the collections I have currently on my Kindle. When I add a book to my library I select which collection it will go in.

How would I be able to alter you script to fit my set up?

Thanks
Pretty much the same as for tags/authors/series, except that you'd be retrieving the values from a custom column instead. Those values are also stored in calibre.metadata but you may need to dig a little deeper into the json structure to extract them.

You can open your calibre.metadata in a text editor to see exactly how its structured (and so from where you need to extract the values you want): It's just a json format structure.

Probably it'd be something like this to obtain the values to parse (based on a quick glance at the json structure just now - I've not tested this at all):

Code:
mycustom = book["user_metadata"]["#mycustomcolumnid"]["#value#"]
So, parse the calibre data in parseCalibreMetadata() then use your parsed data to build your collections in createCollectionsFromCalibre(). Follow through how this is done for tags and you should be able to handle your custom column similarly.
mornington is offline   Reply With Quote
Old 12-18-2010, 06:57 PM   #21
beckywc
Addict
beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.
 
beckywc's Avatar
 
Posts: 270
Karma: 1050426
Join Date: Feb 2010
Location: California
Device: iPad Mini w/Retina, Kindle 3, Kindle Fire HDX 8.9, & Asus Transformer
Wow sounds complicated, but will give it a shot. Thanks
beckywc is offline   Reply With Quote
Old 12-18-2010, 07:28 PM   #22
beckywc
Addict
beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.beckywc ought to be getting tired of karma fortunes by now.
 
beckywc's Avatar
 
Posts: 270
Karma: 1050426
Join Date: Feb 2010
Location: California
Device: iPad Mini w/Retina, Kindle 3, Kindle Fire HDX 8.9, & Asus Transformer
Please bare with me, I've never done this before and so I'm trying to get an understanding here. I checked the calibre.metadata and found this pertaining to my custom column:


Spoiler:
"languages": [],
"user_metadata": {
"#collection": {
"is_category": true,
"#extra#": null,
"kind": "field",
"is_custom": true,
"name": "In Collection",
"datatype": "enumeration",
"rec_index": 21,
"search_terms": [
"#collection"
],
"link_column": "value",
"label": "collection",
"colnum": 1,
"column": "value",
"#value#": "Various Authors G - M",
"category_sort": "value",
"table": "custom_column_1",
"is_editable": true,
"is_multiple": null,
"display": {
"enum_values": [
"Author's Series A - M",
"Author's Series N - Z",
"Various Authors A - F",
"Various Authors G - M",
"Various Authors N - Z",
"Various Authors A - F Read",
"Various Authors G - M Read",
"Various Authors N - Z Read",
"Reference",
"Christian",
"Self-Help",
"Short Stories",
"Author: Alexandria Ivy",
"Author: Brenda Jackson",
"Author: Bridget Midway",
"Author: Camille Anthony",
"Author: Cherise Sinclair",
"Author: Christina Dodd",
"Author: Christine Feehan",
"Author: D. McEntire",
"Author: Dana Marie Bell",
"Author: Diana Palmer",
"Author: Eve Vaughn",
"Author: Gena Showalter",
"Author: J.C. Wilder",
"Author: Jaden Sinclair",
"Author: Jaid Black",
"Author: J. R. Ward",
"Author: Kresley Cole",
"Author: Lara Adrian",
"Author: Lauren Dane",
"Author: Leah Brooke",
"Author: Lena Mathews",
"Author: Linda Lael Miller",
"Author: Lora Leigh",
"Author: Lorelei James",
"Author: Lori Foster",
"Author: Madison Layle",
"Author: Marie Rochelle",
"Author: Marilyn Lee",
"Author: Marisa Chenery",
"Author: Maya Banks",
"Author: Melissa Schroeder",
"Author: Mima",
"Author: Moira Rogers",
"Author: Nalini Singh",
"Author: Rae Morgan",
"Author: Rhyannon Byrd",
"Author: Sarah McCarty",
"Author: Shelly Laurenston",
"Author: Sherrilyn Kenyon",
"Author: Sherryl Woods",
"Author: Shiloh Walker",
"Author: Stephanie Morris",
"Author: Tressie Lockwood",
"Author: Vivi Andrews",
"Author: Vivian Arend",
"Author: Wendy Stone",
"Author: Zena Wynn"
]
}


What do I do now with the script?
beckywc is offline   Reply With Quote
Old 12-19-2010, 04:26 AM   #23
mornington
Connoisseur
mornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enough
 
Posts: 63
Karma: 732
Join Date: Nov 2010
Device: Sony PRS-650
Quote:
Originally Posted by beckywc View Post
Wow sounds complicated, but will give it a shot. Thanks
That's why I didn't do it that way in the script, but used tags/authors/series instead. Much easier.

If you're not comfortable rewriting the script for your specific needs, why not just copy the custom column values into your tags using Calibre's bulk metadata edit tool?

To do this: Select books to edit in calibre, right click, Edit metadata in bulk, "Search and Replace" tab. Set Search mode to "Regular Expression", Search field to your column name, search for to "(.+)" (without the quotes), replace with to "-\1" (again, without the quotes), destination field to "tags", mode to "append to field", ensure "use comma" is ticked then apply

Back up your library before doing this, but it should create a new tag for each book and give that tag a dash prefix so that the script will detect it and turn it into a collection. If you don't want the collection names to have a prefix then change prefixTag in the script to an empty string (the script uses the dash to identify tags to turn into collections and then removes the dash before adding the prefixTag to the name).

Last edited by mornington; 12-19-2010 at 04:34 AM.
mornington is offline   Reply With Quote
Old 12-19-2010, 08:37 AM   #24
Mixx
Zealot
Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.
 
Posts: 140
Karma: 387
Join Date: Sep 2010
Device: Kindle 3
Dear mornington,

after much prep work in my calibre data, I was ready to start with revamping the collections on my Kindle today.

Alas, I am getting this error message:
Quote:
ERROR loadCalibre: 'ascii' codec can't encode character u'\xe4' in position 23: ordinal not in range(128)
It apparently has to do with character sets. My Kindle collections or the Calibre tags do not have non-ascii, but my author names do.

What can I do? Thanks for any help.

Regards, Mixx
Mixx is offline   Reply With Quote
Old 12-19-2010, 02:17 PM   #25
mornington
Connoisseur
mornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enoughmornington will become famous soon enough
 
Posts: 63
Karma: 732
Join Date: Nov 2010
Device: Sony PRS-650
Quote:
Originally Posted by Mixx View Post
Dear mornington,

after much prep work in my calibre data, I was ready to start with revamping the collections on my Kindle today.

Alas, I am getting this error message:


It apparently has to do with character sets. My Kindle collections or the Calibre tags do not have non-ascii, but my author names do.

What can I do? Thanks for any help.

Regards, Mixx
If you're using the latest version of the script, I've no idea what could be causing that error, sorry.

If you're using an old version then try using the latest one.
mornington is offline   Reply With Quote
Old 12-24-2010, 05:28 AM   #26
Mixx
Zealot
Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.Mixx has a complete set of Star Wars action figures.
 
Posts: 140
Karma: 387
Join Date: Sep 2010
Device: Kindle 3
Yeah, I am using the latest version of the script. Is there a particular version of Python that needs to be used, perhaps?

Thanks, Mixx
Mixx is offline   Reply With Quote
Old 12-25-2010, 12:30 PM   #27
MrTissues
Junior Member
MrTissues began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Dec 2010
Device: Kindle 3
I am getting an odd syntax error with my script, I have no idea what is wrong. I am not too familiar with Python. Could someone maybe take a look? It is on line 54.

Thanks for any help.

Attached Files
File Type: txt CalibreKindleCollections.txt (40.2 KB, 135 views)
MrTissues is offline   Reply With Quote
Old 12-25-2010, 12:42 PM   #28
Perkin
Guru
Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.Perkin calls his or her ebook reader Vera.
 
Perkin's Avatar
 
Posts: 647
Karma: 64171
Join Date: Sep 2010
Location: Kent, England, Sol 3, ZZ9 plural Z Alpha
Device: Sony PRS-300, Kobo Aura HD
The print in python3 needs braces () for the arguments.
(I'm only just starting out in python, noticing differences between 2.7 and 3.#)
Perkin is offline   Reply With Quote
Old 12-25-2010, 03:22 PM   #29
MrTissues
Junior Member
MrTissues began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Dec 2010
Device: Kindle 3
So instead if the braces I should use the parentheses?
MrTissues is offline   Reply With Quote
Old 12-25-2010, 03:30 PM   #30
chaley
"chaley", not "charley"
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: 5,808
Karma: 1216080
Join Date: Jan 2010
Location: France
Device: Many android devices
My guess is that you should use python 2.6 or 2.7 instead of 3. There are *many* differences between python 2 and python 3, and you will have to fight your way through all of them.
chaley is offline   Reply With Quote
Reply

Tags
calibre, collections, kindle, kindle 3

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PRS-300 creating collections terraskye Sony Reader 4 11-28-2010 11:01 AM
Collections data format in 2.5 firmware ngukho Kindle Developer's Corner 18 10-30-2010 12:19 AM
Backing Up Data (Collections) Cpl Punishment Amazon Kindle 14 10-27-2010 02:41 PM
Calibre and creating Kindle collections on the PC? guiyoforward Calibre 1 07-30-2010 03:11 AM
Creating collections within collections larlissm Sony Reader 2 10-04-2008 09:02 PM


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


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