Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ComicInfo.xmlの情報を取得
import zipfile
import xml.etree.ElementTree as etree
class ComicInfoXmlHandler():
def __init__(self):
self.series = ''
self.number = ''
self.title = ''
self.circle = ''
self.member = ''
self.genre = ''
self.year = ''
self.month = ''
self.day = ''
self.fromxml = ['Series', 'Number', 'Title', 'Writer', 'Penciller', 'Genre', 'Year', 'Month', 'Day']
self.todisplay = [self.series, self.number, self.title, self.circle, self.member, self.genre, self.year, self.month, self.day]
def get_info(self, filepath):
with zipfile.ZipFile(filepath, mode='r',) as z:
comicinfoxml = z.open('ComicInfo.xml', mode='r')
infoTree = etree.parse(comicinfoxml)
root = infoTree.getroot()
for i in range(len(self.fromxml)):
self.todisplay[i] = root.findtext(self.fromxml[i])
for i in range(len(self.todisplay)):
print(self.todisplay[i])
if __name__ == '__main__':
cix = ComicInfoXmlHandler()
cix.get_info(r'path/to/archive.cbz)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment