mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
Kobo driver cleanups
This commit is contained in:
commit
ec83ad38e8
@ -44,16 +44,17 @@ class Book(MetaInformation):
|
|||||||
self.mime = mime
|
self.mime = mime
|
||||||
|
|
||||||
self.size = size # will be set later if None
|
self.size = size # will be set later if None
|
||||||
try:
|
|
||||||
if ContentType == '6':
|
|
||||||
self.datetime = time.strptime(date, "%Y-%m-%dT%H:%M:%S.%f")
|
|
||||||
else:
|
|
||||||
self.datetime = time.gmtime(os.path.getctime(self.path))
|
|
||||||
except:
|
|
||||||
self.datetime = time.gmtime()
|
|
||||||
|
|
||||||
if thumbnail_name is not None:
|
if ContentType == '6':
|
||||||
self.thumbnail = ImageWrapper(thumbnail_name)
|
self.datetime = time.strptime(date, "%Y-%m-%dT%H:%M:%S.%f")
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
self.datetime = time.gmtime(os.path.getctime(self.path))
|
||||||
|
except:
|
||||||
|
self.datetime = time.gmtime()
|
||||||
|
|
||||||
|
if thumbnail_name is not None:
|
||||||
|
self.thumbnail = ImageWrapper(thumbnail_name)
|
||||||
self.tags = []
|
self.tags = []
|
||||||
if other:
|
if other:
|
||||||
self.smart_update(other)
|
self.smart_update(other)
|
||||||
|
@ -106,11 +106,14 @@ class KOBO(USBMS):
|
|||||||
changed = True
|
changed = True
|
||||||
bl[idx].device_collections = playlist_map.get(lpath, [])
|
bl[idx].device_collections = playlist_map.get(lpath, [])
|
||||||
else:
|
else:
|
||||||
book = self.book_from_path(prefix, lpath, title, authors, mime, date, ContentType, ImageID)
|
if ContentType == '6':
|
||||||
|
book = Book(prefix, lpath, title, authors, mime, date, ContentType, ImageID, size=1048576)
|
||||||
|
else:
|
||||||
|
book = self.book_from_path(prefix, lpath, title, authors, mime, date, ContentType, ImageID)
|
||||||
# print 'Update booklist'
|
# print 'Update booklist'
|
||||||
|
book.device_collections = playlist_map.get(book.lpath, [])
|
||||||
if bl.add_book(book, replace_metadata=False):
|
if bl.add_book(book, replace_metadata=False):
|
||||||
changed = True
|
changed = True
|
||||||
book.device_collections = playlist_map.get(book.lpath, [])
|
|
||||||
except: # Probably a path encoding error
|
except: # Probably a path encoding error
|
||||||
import traceback
|
import traceback
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
@ -231,21 +234,9 @@ class KOBO(USBMS):
|
|||||||
path = self.normalize_path(path)
|
path = self.normalize_path(path)
|
||||||
# print "Delete file normalized path: " + path
|
# print "Delete file normalized path: " + path
|
||||||
extension = os.path.splitext(path)[1]
|
extension = os.path.splitext(path)[1]
|
||||||
|
ContentType = self.get_content_type_from_extension(extension)
|
||||||
if extension == '.kobo':
|
|
||||||
# Kobo books do not have book files. They do have some images though
|
ContentID = self.contentid_from_path(path, ContentType)
|
||||||
#print "kobo book"
|
|
||||||
ContentType = 6
|
|
||||||
ContentID = self.contentid_from_path(path, ContentType)
|
|
||||||
elif extension == '.pdf' or extension == '.epub':
|
|
||||||
# print "ePub or pdf"
|
|
||||||
ContentType = 16
|
|
||||||
#print "Path: " + path
|
|
||||||
ContentID = self.contentid_from_path(path, ContentType)
|
|
||||||
# print "ContentID: " + ContentID
|
|
||||||
else: # if extension == '.html' or extension == '.txt':
|
|
||||||
ContentType = 999 # Yet another hack: to get around Kobo changing how ContentID is stored
|
|
||||||
ContentID = self.contentid_from_path(path, ContentType)
|
|
||||||
|
|
||||||
ImageID = self.delete_via_sql(ContentID, ContentType)
|
ImageID = self.delete_via_sql(ContentID, ContentType)
|
||||||
#print " We would now delete the Images for" + ImageID
|
#print " We would now delete the Images for" + ImageID
|
||||||
@ -343,6 +334,17 @@ class KOBO(USBMS):
|
|||||||
ContentID = ContentID.replace("\\", '/')
|
ContentID = ContentID.replace("\\", '/')
|
||||||
return ContentID
|
return ContentID
|
||||||
|
|
||||||
|
def get_content_type_from_extension(self, extension):
|
||||||
|
if extension == '.kobo':
|
||||||
|
# Kobo books do not have book files. They do have some images though
|
||||||
|
#print "kobo book"
|
||||||
|
ContentType = 6
|
||||||
|
elif extension == '.pdf' or extension == '.epub':
|
||||||
|
# print "ePub or pdf"
|
||||||
|
ContentType = 16
|
||||||
|
else: # if extension == '.html' or extension == '.txt':
|
||||||
|
ContentType = 999 # Yet another hack: to get around Kobo changing how ContentID is stored
|
||||||
|
return ContentType
|
||||||
|
|
||||||
def path_from_contentid(self, ContentID, ContentType, oncard):
|
def path_from_contentid(self, ContentID, ContentType, oncard):
|
||||||
path = ContentID
|
path = ContentID
|
||||||
|
Loading…
x
Reference in New Issue
Block a user