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 02-12-2009, 06:49 AM   #1
kevin_boone
Enthusiast
kevin_boone began at the beginning.
 
Posts: 35
Karma: 10
Join Date: Feb 2009
Device: prs-505
Calibre as a helper for PRS-505 navigation?

Hi

I was wondering to what extent Calibre (or just the calibre metadata database) could be useful in generating documents to assist in navigating a large book collection on a PRS-500.

I'm one of those people who likes to keep lots of books around, not because I'm a particularly fast reader, but because I can never figure out in advance what I want to read. I have the same problem with my MP3 player, but that's a different matter ...

I currently have about 200 books on my PRS-505, which only use a fraction of its capacity, and that's without using expansion cards. But already it's pretty hard to find stuff. So far as I can tell, you can't even get a list of authors and then find books by a selected author. There is a `list books by author' facility, but even then the author you want may be ten pages away from the starting point.

The relatively slow screen refresh rate of the PRS makes this navigation even more frustrating.

Calibre is quite helpful in that it can generate PRS `collections' according to tags in the metadata. Even that becomes a bit cumbersome if you have large numbers of tags, but it's certainly a step up from what Sony offers, so far as I can tell.

It seems to me that Calibre, or some program that worked on the Calibre database, could be quite useful here.

For example, it would be relatively easy to scan the database and generate a new LRF document (via HTML?) that contained a list of authors, each of which linked to a new page (or set of pages) with books by that author. Or a document that listed all books (in title order, or author order, or both) along with their summaries or comments.

I don't know how useful any of this would be -- it would be more useful if you could actually navigate from an index document of this sort to the real books; but I don't think the LRF format allows for that (does it?). It may have already been implemented, for all I know.

If nobody else is interested, I'll probably throw something together for my own purposes using perl and sqlite3, which would spit out HTML which I could feed into html2lrf. But I thought I'd see if anybody else was interested and whether there's scope for a collaborative effort

Best wishes
Kevin
kevin_boone is offline   Reply With Quote
Old 02-12-2009, 11:30 AM   #2
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,774
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
You can use the command line tool calibredb to create an XML listing of books in the calibre database, then easily postprocess the XML to create HTML and from that create LRF/EPUB. I dont know how useful this will be as the SONY Reader doesn't allow yout to have links to other books on the device.
kovidgoyal is online now   Reply With Quote
Advert
Old 02-12-2009, 01:29 PM   #3
kevin_boone
Enthusiast
kevin_boone began at the beginning.
 
Posts: 35
Karma: 10
Join Date: Feb 2009
Device: prs-505
Well, I threw something together in Python that seems to do the trick. It just runs a lump of SQL and mixes up the results with HTML. Attached, in case anybody's interested. I've never written Python before, so it's doubtless a bit crude. But it works for me.

The output can be passed through html2rtf

html2lrf --add-chapters-to-toc --chapter-attr=h2,none, --page-break-before-tag=$ --author="aaa" --title="aaa index" aaa_index.html

to create an LRF. Naming the author and title `aaa' means that the file will show up on the top of all the lists on the PRS.

As you say, it's of limited usefulness, because you can't do `real' navigation. But I find it helpful to have an indexed list of all books in one place, particularly if I include the summaries from the metadata..

Is there a way to add functionality to Calibre other than building the whole thing from source? Some sort of plug-in system? I'd like to add a feature to build an index file on the PRS every time I add or remove files, but I don't think I have time to learn enough about Calibre to put it into the code proper. Not without breaking it, anyhow

==================
Code:
#!/usr/bin/python

from sqlite3 import dbapi2 as sqlite

connection = sqlite.connect('/media/ebooks_calibre/metadata.db')

cursor = connection.cursor()

cursor.execute('SELECT id,name FROM authors ORDER BY name')

i = 0
author_ids = []
firstletter = ''
for row in cursor:
  id = str(row[0])
  name = row[1]
  if (name[0] != firstletter) :
    firstletter = name[0];
    print "<h2>" + firstletter + "</h2>";
  print "<a href=\"#author_" + id + "\">" + name + "</a><br>\n";
  author_ids.append(row[0]);
  i = i + 1;

for author_id in author_ids:
  print "<a name=\"#author_" + str(author_id) + "\"></a>"
  firstrow = 1;
  cursor.execute('SELECT books.title,authors.name,comments.text FROM authors,books,books_authors_link,comments WHERE books.id=books_authors_link.book AND comments.book=books.id AND authors.id=books_authors_link.author AND books_authors_link.author=' + str(author_id))
  for row in cursor:
    if (firstrow == 1) :
      print "<h3 id=\"author_" + str(author_id) + "\">"
      print row[1]
      print "</h3>"
      print "<br/>"
      firstrow = 0
    print "<b>"
    print row[0]
    print "</b><br/>"
    print " "
    print row[2].encode("utf-8")
    print " "
    print "<p>&nbsp;</p>"

Last edited by kevin_boone; 02-12-2009 at 01:32 PM.
kevin_boone is offline   Reply With Quote
Old 02-12-2009, 01:50 PM   #4
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
Nice - A couple of minor points that might help reduce your typing are the way that you can use either "" or '' as string delimiters - the advantage being that you don't need to escape the use of the other one in the string! Also, Python's got a string formatter type, so you can write things such as
print "<h2>%s</h2>" % firstletter
or
print '<a href="#author_%s">%s</a><br>\n' % (id, name)
gwynevans is offline   Reply With Quote
Old 02-12-2009, 02:09 PM   #5
kovidgoyal
creator of calibre
kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.kovidgoyal ought to be getting tired of karma fortunes by now.
 
kovidgoyal's Avatar
 
Posts: 43,774
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
calibre does have a plugin system, but it cant do this at the moment. See the customize calibre section of the user manual.
kovidgoyal is online now   Reply With Quote
Advert
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Calibre Mount Helper in Ubuntu 10.04 capidamonte Calibre 13 09-04-2010 04:39 PM
calibre with prs 505 querty Calibre 3 11-03-2009 04:38 PM
Calibre for PRS 505 Bowhuntxx78 Sony Reader 9 06-29-2009 06:47 PM
Calibre only detects one of two memory cards (PRS-505 and PRS-700) Momo_Germany Calibre 2 05-25-2009 01:25 AM
Preprocessing to PRS-505 from Calibre jeff363 Calibre 7 06-02-2008 07:20 AM


All times are GMT -4. The time now is 10:25 AM.


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