Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 10-02-2013, 05:02 PM   #1
hakan42
Zealot
hakan42 is on a distinguished road
 
hakan42's Avatar
 
Posts: 136
Karma: 60
Join Date: Jul 2009
Location: Munich, Germany
Device: Nook Classic rooted; Galaxy S IV with Aldiko, other older devices
Accessing Series and Metadata with the "new api"

I used to (at least with the 0.9 tree) be able to access metadata and series information for a book with "self.metadata" and "self.series".

With the switch to db/backend.py, I can't find those methods anymore:
Code:
calibre, version 1.5.0
...
ERROR: Unhandled exception: <b>AttributeError</b>:'DB' object has no attribute 'series'
What is the current best practice to access this information?
hakan42 is offline   Reply With Quote
Old 10-02-2013, 10:03 PM   #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,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
Those functions still exist, though note that it is get_metadata.

Code:
calibre-debug -c "from calibre.library import db; db = db(); print db.series, db.get_metadata"                                                                                                      
<bound method LibraryDatabase.func of <calibre.db.legacy.LibraryDatabase object at 0x7f856b61fc10>> <bound method LibraryDatabase.get_metadata of <calibre.db.legacy.LibraryDatabase object at 0x7f856b61fc10>>
kovidgoyal is offline   Reply With Quote
Old 10-03-2013, 04:22 AM   #3
hakan42
Zealot
hakan42 is on a distinguished road
 
hakan42's Avatar
 
Posts: 136
Karma: 60
Join Date: Jul 2009
Location: Munich, Germany
Device: Nook Classic rooted; Galaxy S IV with Aldiko, other older devices
Quote:
Originally Posted by kovidgoyal View Post
Those functions still exist, though note that it is get_metadata.

Code:
calibre-debug -c "from calibre.library import db; db = db(); print db.series, db.get_metadata"                                                                                                      
<bound method LibraryDatabase.func of <calibre.db.legacy.LibraryDatabase object at 0x7f856b61fc10>> <bound method LibraryDatabase.get_metadata of <calibre.db.legacy.LibraryDatabase object at 0x7f856b61fc10>>
Hmmmm.... My code lives in db/backend.py, specifically in the method construct_path_name().

Code:
print("db/backend.py: self: '%s'" % (self))
print("db/backend.py: metadata: '%s'" % (self.get_metadata))
gives

Code:
db/backend.py: self: '<calibre.db.backend.DB object at 0x056FD350>'
...
  File "H:\src\calibre\calibre-github\src\calibre\db\backend.py", line 1099, in construct_path_name
AttributeError: 'DB' object has no attribute 'get_metadata'
Am I still allowed to "from calibre.library import db;" in construct_path_name() or would I somehow break caching?
hakan42 is offline   Reply With Quote
Old 10-03-2013, 04:57 AM   #4
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,858
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
At that level there is no access to other metadata. If you want to change how paths are created you will need to change update_path() in db/cache.py in addition to changing construct_path_name and construct_file_name
kovidgoyal is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Alter Double-click behaviour to "edit metadata" instead of "open ebook?" Feather_Qwill Library Management 5 09-15-2013 11:20 AM
Modification of Metadata recipe "Put series into the title, using either initials .." Riva3000 Library Management 0 05-08-2013 04:33 PM
Issue Editing MetaData in "Series" Field slammerkin Library Management 4 12-09-2012 01:33 AM
Plugboard "Metadata: Show series [series index] - title as title (Kindle)" Deep Cover Library Management 6 11-30-2012 05:17 PM
PRS-T1 Sony "Collections" vs Calibre "Series" ted13b Sony Reader 3 02-20-2012 09:46 AM


All times are GMT -4. The time now is 03:22 AM.


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