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

Go Back   MobileRead Forums > E-Book Readers > Sony Reader > Sony Reader Dev Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 03-11-2008, 10:24 AM   #1
gwynevans
Wizzard
gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.
 
gwynevans's Avatar
 
Posts: 1,402
Karma: 2000000
Join Date: Nov 2007
Location: UK
Device: iPad 2, iPhone 6s, Kindle Voyage & Kindle PaperWhite
Python script to create collections

Just in case this might be useful to someone else...

I've attatched a Python script that I've created that reads the internal metadata DB on the 505 and creates collections based on the filenames of the books found there. It's nothing particularly new, as there's a Perl script to do something similar, as well as kovid's code in libprs500, but I wanted a minimal implementation.

It's only going to be directly useful if you use the same format filenames as I do, but if not, it should be easy enough to modify. I use a "<author> - [<series> - ]<title>.<ext>" format, e.g. "Brenner, Meyer Alan - The Dance of Gods 1 - Catastrophe&apos;s Spell.lrf", so the script can pick out that it's part of a "The Dance of Gods" series and create & populate a collection of the same name.

I've not tried to create the 'book' entries from scratch, so I currently just parse the books the reader's already entered there, which means that when adding books, you need to let the reader sync (after the USB disconnect) before resyncing to get at the 'new' media.xml file. My Python's still very basic (and linear), so I'm sure there's a lot that could be done to tidy it up too!

Anyway, you pass the filespec of the 'media.xml' file (e.g. lrfCategorize.py a:\database\cache\media.xml) and it'll save the old one to media.xml.sav and create a new media.xml with the new categories. Categories that don't match ones found from filespecs are left alone, while any files not in a category are put into an '_Other' category.
Attached Files
File Type: zip lrfCategorize.zip (1.5 KB, 663 views)
gwynevans is offline   Reply With Quote
Old 03-13-2008, 10:47 AM   #2
astrodad
Guru
astrodad ought to be getting tired of karma fortunes by now.astrodad ought to be getting tired of karma fortunes by now.astrodad ought to be getting tired of karma fortunes by now.astrodad ought to be getting tired of karma fortunes by now.astrodad ought to be getting tired of karma fortunes by now.astrodad ought to be getting tired of karma fortunes by now.astrodad ought to be getting tired of karma fortunes by now.astrodad ought to be getting tired of karma fortunes by now.astrodad ought to be getting tired of karma fortunes by now.astrodad ought to be getting tired of karma fortunes by now.astrodad ought to be getting tired of karma fortunes by now.
 
astrodad's Avatar
 
Posts: 962
Karma: 568242
Join Date: Dec 2007
Device: Kindle Oasis 3, Kindle Paperwhite 1, iPad, iPhone
Seems interesting. I'll take a look. As a Python developer, have you volunteered to help with libprs500? There are lots of open tickets! One of which is the script to import via command line, which is on the top of my list but I am still trying to learn the language.
astrodad is offline   Reply With Quote
Advert
Old 03-13-2008, 12:29 PM   #3
gwynevans
Wizzard
gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.gwynevans ought to be getting tired of karma fortunes by now.
 
gwynevans's Avatar
 
Posts: 1,402
Karma: 2000000
Join Date: Nov 2007
Location: UK
Device: iPad 2, iPhone 6s, Kindle Voyage & Kindle PaperWhite
Unfortunately, I'm more of a Java developer who (very infrequently) gets to dabble with Python but I'll take a look to see if there's anything that looks possible...
gwynevans 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
Kindlestrip Python script and AppleScript wrapper pdurrant Kindle Formats 137 08-15-2017 01:16 AM
how to use python script with windows xp tuufbiz1 Other formats 12 01-08-2011 08:22 AM
Import ebook conversion in python script erollisi Calibre 1 08-19-2010 09:43 PM
How do I get a shortcut for a Python script onto the taskbar in W7? Sydney's Mom Workshop 6 03-28-2010 08:11 PM
Nedd a little help with a python script gandor62 Calibre 1 08-07-2008 09:59 PM


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


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