mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Simplify path to ContentID
This commit is contained in:
parent
4414ed01f6
commit
54d360e95a
@ -74,7 +74,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(mountpath, ContentID, filename, title, authors, mime, date, ContentType, ImageID):
|
def update_booklist(mountpath, filename, title, authors, mime, date, ContentType, ImageID):
|
||||||
changed = False
|
changed = False
|
||||||
# if path_to_ext(filename) in self.FORMATS:
|
# if path_to_ext(filename) in self.FORMATS:
|
||||||
try:
|
try:
|
||||||
@ -89,7 +89,7 @@ class KOBO(USBMS):
|
|||||||
idx = bl_cache.get(filename, None)
|
idx = bl_cache.get(filename, None)
|
||||||
if idx is not None:
|
if idx is not None:
|
||||||
imagename = self.normalize_path(mountpath + '.kobo/images/' + ImageID + ' - iPhoneThumbnail.parsed')
|
imagename = self.normalize_path(mountpath + '.kobo/images/' + ImageID + ' - iPhoneThumbnail.parsed')
|
||||||
# print "Image name Normalized: " + imagename
|
print "Image name Normalized: " + imagename
|
||||||
bl[idx].thumbnail = ImageWrapper(imagename)
|
bl[idx].thumbnail = ImageWrapper(imagename)
|
||||||
bl_cache[filename] = None
|
bl_cache[filename] = None
|
||||||
if ContentType != '6':
|
if ContentType != '6':
|
||||||
@ -133,21 +133,21 @@ class KOBO(USBMS):
|
|||||||
if oncard != 'carda' and oncard != 'cardb':
|
if oncard != 'carda' and oncard != 'cardb':
|
||||||
if row[5] == '6':
|
if row[5] == '6':
|
||||||
# print "shortbook: " + filename
|
# print "shortbook: " + filename
|
||||||
changed = update_booklist(self._main_prefix, row[3], filename, row[0], row[1], mime, row[2], row[5], row[6])
|
changed = update_booklist(self._main_prefix, filename, row[0], row[1], mime, row[2], row[5], row[6])
|
||||||
if changed:
|
if changed:
|
||||||
need_sync = True
|
need_sync = True
|
||||||
else:
|
else:
|
||||||
if filename.startswith("file:///mnt/onboard/"):
|
if filename.startswith("file:///mnt/onboard/"):
|
||||||
filename = filename.replace("file:///mnt/onboard/", self._main_prefix)
|
filename = filename.replace("file:///mnt/onboard/", self._main_prefix)
|
||||||
# print "Internal: " + filename
|
# print "Internal: " + filename
|
||||||
changed = update_booklist(self._main_prefix, row[3], filename, row[0], row[1], mime, row[2], row[5], row[6])
|
changed = update_booklist(self._main_prefix, filename, row[0], row[1], mime, row[2], row[5], row[6])
|
||||||
if changed:
|
if changed:
|
||||||
need_sync = True
|
need_sync = True
|
||||||
elif oncard == 'carda':
|
elif oncard == 'carda':
|
||||||
if filename.startswith("file:///mnt/sd/"):
|
if filename.startswith("file:///mnt/sd/"):
|
||||||
filename = filename.replace("file:///mnt/sd/", self._card_a_prefix)
|
filename = filename.replace("file:///mnt/sd/", self._card_a_prefix)
|
||||||
# print "SD Card: " + filename
|
# print "SD Card: " + filename
|
||||||
changed = update_booklist(self._card_a_prefix, row[3], filename, row[0], row[1], mime, row[2], row[5], row[6])
|
changed = update_booklist(self._card_a_prefix, filename, row[0], row[1], mime, row[2], row[5], row[6])
|
||||||
if changed:
|
if changed:
|
||||||
need_sync = True
|
need_sync = True
|
||||||
else:
|
else:
|
||||||
@ -247,24 +247,12 @@ class KOBO(USBMS):
|
|||||||
# Kobo books do not have book files. They do have some images though
|
# Kobo books do not have book files. They do have some images though
|
||||||
#print "kobo book"
|
#print "kobo book"
|
||||||
ContentType = 6
|
ContentType = 6
|
||||||
ContentID = os.path.splitext(path)[0]
|
ContentID = self.contentid_from_path(path, ContentType)
|
||||||
# Remove the prefix on the file. it could be either
|
|
||||||
ContentID = ContentID.replace(self._main_prefix, '')
|
|
||||||
if self._card_a_prefix is not None:
|
|
||||||
ContentID = ContentID.replace(self._card_a_prefix, '')
|
|
||||||
ContentID = ContentID.replace("\\", '/')
|
|
||||||
ImageID = self.delete_via_sql(ContentID, ContentType)
|
|
||||||
#print " We would now delete the Images for" + ImageID
|
|
||||||
self.delete_images(ImageID)
|
|
||||||
if extension == '.pdf' or extension == '.epub':
|
if extension == '.pdf' or extension == '.epub':
|
||||||
# print "ePub or pdf"
|
# print "ePub or pdf"
|
||||||
ContentType = 16
|
ContentType = 16
|
||||||
#print "Path: " + path
|
#print "Path: " + path
|
||||||
ContentID = path
|
ContentID = self.contentid_from_path(path, ContentType)
|
||||||
ContentID = ContentID.replace(self._main_prefix, "file:///mnt/onboard/")
|
|
||||||
if self._card_a_prefix is not None:
|
|
||||||
ContentID = ContentID.replace(self._card_a_prefix, "file:///mnt/sd/")
|
|
||||||
ContentID = ContentID.replace("\\", '/')
|
|
||||||
# print "ContentID: " + ContentID
|
# print "ContentID: " + ContentID
|
||||||
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
|
||||||
@ -342,3 +330,17 @@ class KOBO(USBMS):
|
|||||||
booklists[blist].add_book(book, replace_metadata=True)
|
booklists[blist].add_book(book, replace_metadata=True)
|
||||||
self.report_progress(1.0, _('Adding books to device metadata listing...'))
|
self.report_progress(1.0, _('Adding books to device metadata listing...'))
|
||||||
|
|
||||||
|
def contentid_from_path(self, path, ContentType):
|
||||||
|
if ContentType == 6:
|
||||||
|
ContentID = os.path.splitext(path)[0]
|
||||||
|
# Remove the prefix on the file. it could be either
|
||||||
|
ContentID = ContentID.replace(self._main_prefix, '')
|
||||||
|
if self._card_a_prefix is not None:
|
||||||
|
ContentID = ContentID.replace(self._card_a_prefix, '')
|
||||||
|
else: # ContentType = 16
|
||||||
|
ContentID = path
|
||||||
|
ContentID = ContentID.replace(self._main_prefix, "file:///mnt/onboard/")
|
||||||
|
if self._card_a_prefix is not None:
|
||||||
|
ContentID = ContentID.replace(self._card_a_prefix, "file:///mnt/sd/")
|
||||||
|
ContentID = ContentID.replace("\\", '/')
|
||||||
|
return ContentType
|
||||||
|
Loading…
x
Reference in New Issue
Block a user