mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Simplify ContentID to path conversion
This commit is contained in:
parent
5c093f846e
commit
ff3433cde9
@ -22,6 +22,7 @@ class KOBO(USBMS):
|
|||||||
gui_name = 'Kobo Reader'
|
gui_name = 'Kobo Reader'
|
||||||
description = _('Communicate with the Kobo Reader')
|
description = _('Communicate with the Kobo Reader')
|
||||||
author = 'Timothy Legge and Kovid Goyal'
|
author = 'Timothy Legge and Kovid Goyal'
|
||||||
|
version = (1, 0, 1)
|
||||||
|
|
||||||
supported_platforms = ['windows', 'osx', 'linux']
|
supported_platforms = ['windows', 'osx', 'linux']
|
||||||
|
|
||||||
@ -121,40 +122,22 @@ class KOBO(USBMS):
|
|||||||
cursor.execute (query)
|
cursor.execute (query)
|
||||||
|
|
||||||
changed = False
|
changed = False
|
||||||
|
|
||||||
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...'))
|
||||||
|
|
||||||
filename = row[3]
|
path = self.path_from_contentid(row[3], row[5], oncard)
|
||||||
if row[5] == "6":
|
|
||||||
filename = filename + '.kobo'
|
|
||||||
mime = mime_type_ext(path_to_ext(row[3]))
|
mime = mime_type_ext(path_to_ext(row[3]))
|
||||||
|
|
||||||
if oncard != 'carda' and oncard != 'cardb':
|
if oncard != 'carda' and oncard != 'cardb':
|
||||||
if row[5] == '6':
|
# print "shortbook: " + filename
|
||||||
# print "shortbook: " + filename
|
changed = update_booklist(self._main_prefix, path, 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:
|
|
||||||
need_sync = True
|
|
||||||
else:
|
|
||||||
if filename.startswith("file:///mnt/onboard/"):
|
|
||||||
filename = filename.replace("file:///mnt/onboard/", self._main_prefix)
|
|
||||||
# print "Internal: " + filename
|
|
||||||
changed = update_booklist(self._main_prefix, filename, row[0], row[1], mime, row[2], row[5], row[6])
|
|
||||||
if changed:
|
|
||||||
need_sync = True
|
|
||||||
elif oncard == 'carda':
|
elif oncard == 'carda':
|
||||||
if filename.startswith("file:///mnt/sd/"):
|
changed = update_booklist(self._card_a_prefix, path, row[0], row[1], mime, row[2], row[5], row[6])
|
||||||
filename = filename.replace("file:///mnt/sd/", self._card_a_prefix)
|
|
||||||
# print "SD Card: " + filename
|
|
||||||
changed = update_booklist(self._card_a_prefix, filename, row[0], row[1], mime, row[2], row[5], row[6])
|
|
||||||
if changed:
|
|
||||||
need_sync = True
|
|
||||||
else:
|
else:
|
||||||
print "Add card b support"
|
print "Add card b support"
|
||||||
|
|
||||||
#FIXME - NOT NEEDED flist.append({'filename': filename, 'path':row[3]})
|
if changed:
|
||||||
#bl.append(book)
|
need_sync = True
|
||||||
|
|
||||||
cursor.close()
|
cursor.close()
|
||||||
connection.close()
|
connection.close()
|
||||||
@ -344,3 +327,21 @@ class KOBO(USBMS):
|
|||||||
ContentID = ContentID.replace(self._card_a_prefix, "file:///mnt/sd/")
|
ContentID = ContentID.replace(self._card_a_prefix, "file:///mnt/sd/")
|
||||||
ContentID = ContentID.replace("\\", '/')
|
ContentID = ContentID.replace("\\", '/')
|
||||||
return ContentType
|
return ContentType
|
||||||
|
|
||||||
|
|
||||||
|
def path_from_contentid(self, ContentID, ContentType, oncard):
|
||||||
|
path = ContentID
|
||||||
|
|
||||||
|
if oncard != 'carda' and oncard != 'cardb':
|
||||||
|
if ContentType == "6":
|
||||||
|
path = path + '.kobo'
|
||||||
|
else:
|
||||||
|
if path.startswith("file:///mnt/onboard/"):
|
||||||
|
path = path.replace("file:///mnt/onboard/", self._main_prefix)
|
||||||
|
# print "Internal: " + filename
|
||||||
|
elif oncard == 'carda':
|
||||||
|
if path.startswith("file:///mnt/sd/"):
|
||||||
|
path = path.replace("file:///mnt/sd/", self._card_a_prefix)
|
||||||
|
# print "SD Card: " + filename
|
||||||
|
|
||||||
|
return path
|
||||||
|
Loading…
x
Reference in New Issue
Block a user