mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
...
This commit is contained in:
commit
66221aefbb
@ -96,7 +96,7 @@ class KOBO(USBMS):
|
|||||||
for idx,b in enumerate(bl):
|
for idx,b in enumerate(bl):
|
||||||
bl_cache[b.lpath] = idx
|
bl_cache[b.lpath] = idx
|
||||||
|
|
||||||
def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus):
|
def update_booklist(prefix, path, title, authors, mime, date, ContentType, ImageID, readstatus, MimeType):
|
||||||
changed = False
|
changed = False
|
||||||
# if path_to_ext(path) in self.FORMATS:
|
# if path_to_ext(path) in self.FORMATS:
|
||||||
try:
|
try:
|
||||||
@ -124,7 +124,7 @@ class KOBO(USBMS):
|
|||||||
#print "Image name Normalized: " + imagename
|
#print "Image name Normalized: " + imagename
|
||||||
if imagename is not None:
|
if imagename is not None:
|
||||||
bl[idx].thumbnail = ImageWrapper(imagename)
|
bl[idx].thumbnail = ImageWrapper(imagename)
|
||||||
if (ContentType != '6'and self.has_kepubs == False) or (self.has_kepubs == True):
|
if (ContentType != '6' and MimeType != 'Shortcover'):
|
||||||
if self.update_metadata_item(bl[idx]):
|
if self.update_metadata_item(bl[idx]):
|
||||||
# print 'update_metadata_item returned true'
|
# print 'update_metadata_item returned true'
|
||||||
changed = True
|
changed = True
|
||||||
@ -132,7 +132,7 @@ class KOBO(USBMS):
|
|||||||
playlist_map[lpath] not in bl[idx].device_collections:
|
playlist_map[lpath] not in bl[idx].device_collections:
|
||||||
bl[idx].device_collections.append(playlist_map[lpath])
|
bl[idx].device_collections.append(playlist_map[lpath])
|
||||||
else:
|
else:
|
||||||
if ContentType == '6' and self.has_kepubs == False:
|
if ContentType == '6' and MimeType == 'Shortcover':
|
||||||
book = Book(prefix, lpath, title, authors, mime, date, ContentType, ImageID, size=1048576)
|
book = Book(prefix, lpath, title, authors, mime, date, ContentType, ImageID, size=1048576)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
@ -177,15 +177,15 @@ class KOBO(USBMS):
|
|||||||
for i, row in enumerate(cursor):
|
for i, row in enumerate(cursor):
|
||||||
# self.report_progress((i+1) / float(numrows), _('Getting list of books on device...'))
|
# self.report_progress((i+1) / float(numrows), _('Getting list of books on device...'))
|
||||||
|
|
||||||
path = self.path_from_contentid(row[3], row[5], oncard)
|
path = self.path_from_contentid(row[3], row[5], row[4], oncard)
|
||||||
mime = mime_type_ext(path_to_ext(path)) if path.find('kepub') == -1 else 'application/epub+zip'
|
mime = mime_type_ext(path_to_ext(path)) if path.find('kepub') == -1 else 'application/epub+zip'
|
||||||
# debug_print("mime:", mime)
|
# debug_print("mime:", mime)
|
||||||
|
|
||||||
if oncard != 'carda' and oncard != 'cardb' and not row[3].startswith("file:///mnt/sd/"):
|
if oncard != 'carda' and oncard != 'cardb' and not row[3].startswith("file:///mnt/sd/"):
|
||||||
changed = update_booklist(self._main_prefix, path, row[0], row[1], mime, row[2], row[5], row[6], row[7])
|
changed = update_booklist(self._main_prefix, path, row[0], row[1], mime, row[2], row[5], row[6], row[7], row[4])
|
||||||
# print "shortbook: " + path
|
# print "shortbook: " + path
|
||||||
elif oncard == 'carda' and row[3].startswith("file:///mnt/sd/"):
|
elif oncard == 'carda' and row[3].startswith("file:///mnt/sd/"):
|
||||||
changed = update_booklist(self._card_a_prefix, path, row[0], row[1], mime, row[2], row[5], row[6], row[7])
|
changed = update_booklist(self._card_a_prefix, path, row[0], row[1], mime, row[2], row[5], row[6], row[7], row[4])
|
||||||
|
|
||||||
if changed:
|
if changed:
|
||||||
need_sync = True
|
need_sync = True
|
||||||
@ -363,7 +363,8 @@ class KOBO(USBMS):
|
|||||||
|
|
||||||
def contentid_from_path(self, path, ContentType):
|
def contentid_from_path(self, path, ContentType):
|
||||||
if ContentType == 6:
|
if ContentType == 6:
|
||||||
if self.has_kepubs == False:
|
extension = os.path.splitext(path)[1]
|
||||||
|
if extension == '.kobo':
|
||||||
ContentID = os.path.splitext(path)[0]
|
ContentID = os.path.splitext(path)[0]
|
||||||
# Remove the prefix on the file. it could be either
|
# Remove the prefix on the file. it could be either
|
||||||
ContentID = ContentID.replace(self._main_prefix, '')
|
ContentID = ContentID.replace(self._main_prefix, '')
|
||||||
@ -411,7 +412,7 @@ class KOBO(USBMS):
|
|||||||
ContentType = 999 # Yet another hack: to get around Kobo changing how ContentID is stored
|
ContentType = 999 # Yet another hack: to get around Kobo changing how ContentID is stored
|
||||||
return ContentType
|
return ContentType
|
||||||
|
|
||||||
def path_from_contentid(self, ContentID, ContentType, oncard):
|
def path_from_contentid(self, ContentID, ContentType, MimeType, oncard):
|
||||||
path = ContentID
|
path = ContentID
|
||||||
|
|
||||||
if oncard == 'cardb':
|
if oncard == 'cardb':
|
||||||
@ -420,13 +421,13 @@ class KOBO(USBMS):
|
|||||||
path = path.replace("file:///mnt/sd/", self._card_a_prefix)
|
path = path.replace("file:///mnt/sd/", self._card_a_prefix)
|
||||||
# print "SD Card: " + path
|
# print "SD Card: " + path
|
||||||
else:
|
else:
|
||||||
if ContentType == "6" and self.has_kepubs == False:
|
if ContentType == "6" and MimeType == 'Shortcover':
|
||||||
# This is a hack as the kobo files do not exist
|
# This is a hack as the kobo files do not exist
|
||||||
# but the path is required to make a unique id
|
# but the path is required to make a unique id
|
||||||
# for calibre's reference
|
# for calibre's reference
|
||||||
path = self._main_prefix + path + '.kobo'
|
path = self._main_prefix + path + '.kobo'
|
||||||
# print "Path: " + path
|
# print "Path: " + path
|
||||||
elif (ContentType == "6" or ContentType == "10") and self.has_kepubs == True:
|
elif (ContentType == "6" or ContentType == "10") and MimeType == 'application/x-kobo-epub+zip':
|
||||||
path = self._main_prefix + '.kobo/kepub/' + path
|
path = self._main_prefix + '.kobo/kepub/' + path
|
||||||
# print "Internal: " + path
|
# print "Internal: " + path
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user