@nirosan
Copy a .png file to your plugin folder, rename it to cover.png and test the following code:
Code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys, os, string, random
def run(bk):
image_name = 'cover.png'
mime_type = 'image/png'
image_path = os.path.join(bk._w.plugin_dir, bk._w.plugin_name, image_name)
if os.path.isfile(image_path):
with open(image_path, 'rb') as f:
image_data = f.read()
try:
bk.addfile(image_name, image_name, image_data, mime_type)
except:
random_prefix = ''.join(random.choices(string.ascii_uppercase + string.digits, k=6))
image_name = random_prefix + image_name
bk.addfile(image_name, image_name, image_data, mime_type)
return 0
It should add a cover.png file to your epub.