diff --git a/bdnex/conf/ComicInfo.xsd b/bdnex/conf/ComicInfo.xsd index 244a989..0fa3a10 100755 --- a/bdnex/conf/ComicInfo.xsd +++ b/bdnex/conf/ComicInfo.xsd @@ -2,7 +2,7 @@ - + @@ -41,7 +41,7 @@ - + diff --git a/bdnex/conf/bdgest_mapping.json b/bdnex/conf/bdgest_mapping.json index fa23991..a12695b 100644 --- a/bdnex/conf/bdgest_mapping.json +++ b/bdnex/conf/bdgest_mapping.json @@ -5,7 +5,8 @@ "Editeur": "Publisher", "Format": "Format", "Language": "LanguageISO", - "Scénario": "Letterer", + "Lettrage": "Letterer", + "Scénario": "Writer", "Titre": "Title", "Tome": "Volume", "author": "Writer", diff --git a/bdnex/lib/comicrack.py b/bdnex/lib/comicrack.py index fd99595..2f1a9f4 100644 --- a/bdnex/lib/comicrack.py +++ b/bdnex/lib/comicrack.py @@ -5,6 +5,8 @@ import rarfile import zipfile import logging +import json +import xmlschema from pkg_resources import resource_filename @@ -22,20 +24,13 @@ def __init__(self, input_filename=None, comic_info=None): def comicInfo_xml_create(self): self.logger.info("Create ComicInfo.xml") - mytree = ET.parse(COMICINFO_TEMPLATE) - myroot = mytree.getroot() - - for element in myroot[1][0]: - metadata_key = element.attrib['name'] - if metadata_key in self.comic_info.keys(): - if element.attrib["type"] == "xs:string": - element.attrib['default'] = str(self.comic_info[metadata_key]) - elif element.attrib["type"] == "xs:int": - element.attrib['default'] = str(self.comic_info[metadata_key]) - tmpdir = tempfile.mkdtemp() comic_info_fp = os.path.join(tmpdir, 'ComicInfo.xml') - mytree.write(comic_info_fp, encoding='UTF-8', xml_declaration=True) + + schema = xmlschema.XMLSchema(COMICINFO_TEMPLATE) + data = json.dumps(self.comic_info) + tmp_xml = xmlschema.from_json(data, preserve_root=True, schema=schema) + ET.ElementTree(tmp_xml).write(comic_info_fp, encoding='UTF-8', xml_declaration=True) return comic_info_fp diff --git a/setup.py b/setup.py index bce7ea5..c12b049 100755 --- a/setup.py +++ b/setup.py @@ -56,6 +56,7 @@ def _read(fn): 'tenacity', 'opencv-contrib-python-headless', 'pandas', + 'xmlschema', ], extras_require={