def _discover_cover_image(zf, opf_xmldoc, opf_filepath):
content = None<EOL>filepath = None<EOL>extension = None<EOL>tag = find_tag(opf_xmldoc, '<STR_LIT>', '<STR_LIT:name>', '<STR_LIT>')<EOL>if tag and '<STR_LIT:content>' in tag.attributes.keys():<EOL><INDENT>item_id = tag.attributes['<STR_LIT:content>'].value<EOL>if item_id:<EOL><INDENT>filepath, extension = find_img_tag(opf_xmldoc, '<STR_LIT>', '<STR_LIT:id>', item_id)<EOL><DEDENT><DEDENT>if not filepath:<EOL><INDENT>filepath, extension = find_img_tag(opf_xmldoc, '<STR_LIT>', '<STR_LIT:id>', '<STR_LIT>')<EOL><DEDENT>if not filepath:<EOL><INDENT>filepath, extension = find_img_tag(opf_xmldoc, '<STR_LIT>', '<STR_LIT:id>', '<STR_LIT>')<EOL><DEDENT>if filepath:<EOL><INDENT>base_dir = os.path.dirname(opf_filepath)<EOL>coverpath = os.path.normpath(os.path.join(base_dir, filepath))<EOL>content = zf.read(coverpath)<EOL>content = base64.b64encode(content)<EOL><DEDENT>return content, extension<EOL>
Find the cover image path in the OPF file.
Returns a tuple: (image content in base64, file extension)