View Single Post
Old 03-11-2011, 04:35 PM   #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,742
Karma: 6997045
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Try something like this test program (which works):
Code:
from calibre.ebooks.metadata.book.base import Metadata
from calibre.library.database2 import LibraryDatabase2
from calibre.utils.config import prefs


class MyMetadata(Metadata):

    def __init__(self, mi):
        Metadata.__init__(self, None)
        self.smart_update(mi, replace_metadata=True)

    def mm_print(self, attr):
        print attr, '=', getattr(self, attr, 'not found')

src = prefs['library_path']
db = LibraryDatabase2(src)

my_mi = MyMetadata(db.get_metadata(1283, index_is_id=True))
print my_mi
my_mi.mm_print('application_id')
chaley is offline   Reply With Quote