View Single Post
Old 04-15-2011, 12:44 PM   #3
webwizard
Member
webwizard began at the beginning.
 
webwizard's Avatar
 
Posts: 20
Karma: 10
Join Date: Feb 2011
Device: Kindle DX
Quote:
Originally Posted by kovidgoyal View Post
calibredb set_metadata

will do it for you, provided you can create the OPF files correctly.
Probably I'm missing something, but as soon as I can make an OPF file structured as needed by calibredb, the only thing I have to do next is a simple file replacement.

it would be much easier for me if I can create an XML file including ONLY the items I have to add, such as:

Code:
<?xml version='1.0' encoding='utf-8'?>
<package xmlns="http://www.idpf.org/2007/opf" unique-identifier="uuid_id">
    <metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
        <dc:description>&lt;p&gt;here goes the test description&lt;/p&gt;</dc:description>
		<meta name="calibre:user_metadata:#originale" content="{&quot;#value#&quot;: &quot;here goes the original title&quot;}"/>
        <meta name="calibre:user_metadata:#anno" content="{&quot;#value#&quot;: &quot;1984&quot;}"/>       
    </metadata>
    <guide>
        <reference href="1197.jpg" type="cover" title="Copertina"/>
    </guide>
</package>
but if I use something like it, the answer is:

Code:
U:\BdB>calibredb set_metadata 7 x.xml
Python function terminated unexpectedly
  'datatype' (Error Code: 1)
Traceback (most recent call last):
  File "site.py", line 103, in main
  File "site.py", line 85, in run_entry_point
  File "site-packages\calibre\library\cli.py", line 1183, in main
  File "site-packages\calibre\library\cli.py", line 483, in command_set_metadata

  File "site-packages\calibre\library\cli.py", line 457, in do_set_metadata
  File "site-packages\calibre\library\database2.py", line 1842, in set_metadata
KeyError: 'datatype'
then the folders are renamed to "unknown" and the metadata.opf file disappears.

Do I have to pass the complete OPF structure to calibredb ? In that case, it's not much help since I need to parse every file anyway...
webwizard is offline   Reply With Quote