diff --git a/src/calibre/devices/cybook/driver.py b/src/calibre/devices/cybook/driver.py index d314646a87..7c436a7d0e 100644 --- a/src/calibre/devices/cybook/driver.py +++ b/src/calibre/devices/cybook/driver.py @@ -42,7 +42,7 @@ class CYBOOK(USBMS): DELETE_EXTS = ['.mbp', '.dat', '.bin', '_6090.t2b', '.thn'] SUPPORTS_SUB_DIRS = True - def upload_cover(self, path, filename, metadata): + def upload_cover(self, path, filename, metadata, filepath): coverdata = getattr(metadata, 'thumbnail', None) if coverdata and coverdata[2]: coverdata = coverdata[2] diff --git a/src/calibre/devices/hanvon/driver.py b/src/calibre/devices/hanvon/driver.py index 7933b9885d..1fe18afc58 100644 --- a/src/calibre/devices/hanvon/driver.py +++ b/src/calibre/devices/hanvon/driver.py @@ -77,7 +77,7 @@ class ALEX(N516): name = os.path.splitext(os.path.basename(file_abspath))[0] + '.png' return os.path.join(base, 'covers', name) - def upload_cover(self, path, filename, metadata): + def upload_cover(self, path, filename, metadata, filepath): from calibre.ebooks import calibre_cover from calibre.utils.magick.draw import thumbnail coverdata = getattr(metadata, 'thumbnail', None) @@ -129,7 +129,7 @@ class AZBOOKA(ALEX): def can_handle(self, device_info, debug=False): return not is_alex(device_info) - def upload_cover(self, path, filename, metadata): + def upload_cover(self, path, filename, metadata, filepath): pass class EB511(USBMS): diff --git a/src/calibre/devices/misc.py b/src/calibre/devices/misc.py index a1c9b790e4..bca4e8ec52 100644 --- a/src/calibre/devices/misc.py +++ b/src/calibre/devices/misc.py @@ -102,7 +102,7 @@ class PDNOVEL(USBMS): DELETE_EXTS = ['.jpg', '.jpeg', '.png'] - def upload_cover(self, path, filename, metadata): + def upload_cover(self, path, filename, metadata, filepath): coverdata = getattr(metadata, 'thumbnail', None) if coverdata and coverdata[2]: with open('%s.jpg' % os.path.join(path, filename), 'wb') as coverfile: diff --git a/src/calibre/devices/nook/driver.py b/src/calibre/devices/nook/driver.py index f697ee5202..a809b2c08a 100644 --- a/src/calibre/devices/nook/driver.py +++ b/src/calibre/devices/nook/driver.py @@ -45,7 +45,7 @@ class NOOK(USBMS): DELETE_EXTS = ['.jpg'] SUPPORTS_SUB_DIRS = True - def upload_cover(self, path, filename, metadata): + def upload_cover(self, path, filename, metadata, filepath): try: from PIL import Image, ImageDraw Image, ImageDraw diff --git a/src/calibre/devices/usbms/driver.py b/src/calibre/devices/usbms/driver.py index a83a8eb0ea..2f26c4a353 100644 --- a/src/calibre/devices/usbms/driver.py +++ b/src/calibre/devices/usbms/driver.py @@ -186,7 +186,8 @@ class USBMS(CLI, Device): self.put_file(infile, filepath, replace_file=True) try: self.upload_cover(os.path.dirname(filepath), - os.path.splitext(os.path.basename(filepath))[0], mdata) + os.path.splitext(os.path.basename(filepath))[0], + mdata, filepath) except: # Failure to upload cover is not catastrophic import traceback traceback.print_exc() @@ -197,14 +198,15 @@ class USBMS(CLI, Device): debug_print('USBMS: finished uploading %d books'%(len(files))) return zip(paths, cycle([on_card])) - def upload_cover(self, path, filename, metadata): + def upload_cover(self, path, filename, metadata, filepath): ''' Upload book cover to the device. Default implementation does nothing. - :param path: the full path were the associated book is located. - :param filename: the name of the book file without the extension. + :param path: The full path to the directory where the associated book is located. + :param filename: The name of the book file without the extension. :param metadata: metadata belonging to the book. Use metadata.thumbnail for cover + :param filepath: The full path to the ebook file ''' pass