mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
USBMS drivers: Pass full filepath of ebook file to the upload_cover function
This commit is contained in:
parent
7dc8e70b71
commit
1dd72e682c
@ -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]
|
||||
|
@ -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):
|
||||
|
@ -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:
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user