mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
...
This commit is contained in:
commit
aa3731fa61
@ -171,13 +171,10 @@ class Bookmark():
|
|||||||
|
|
||||||
self.get_bookmark_data()
|
self.get_bookmark_data()
|
||||||
self.get_book_length()
|
self.get_book_length()
|
||||||
if self.book_length >= 0:
|
|
||||||
try:
|
try:
|
||||||
self.percent_read = float(100*self.last_read / self.book_length)
|
self.percent_read = float(100*self.last_read / self.book_length)
|
||||||
except:
|
except:
|
||||||
self.percent_read = 0
|
self.percent_read = 0
|
||||||
else:
|
|
||||||
self.percent_read = -1
|
|
||||||
|
|
||||||
def record(self, n):
|
def record(self, n):
|
||||||
from calibre.ebooks.metadata.mobi import StreamSlicer
|
from calibre.ebooks.metadata.mobi import StreamSlicer
|
||||||
@ -459,7 +456,7 @@ class Bookmark():
|
|||||||
|
|
||||||
elif self.bookmark_extension == 'pdr':
|
elif self.bookmark_extension == 'pdr':
|
||||||
# Book length not yet implemented for PDF files
|
# Book length not yet implemented for PDF files
|
||||||
self.book_length = -1
|
self.book_length = 0
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print "unsupported bookmark_extension: %s" % self.bookmark_extension
|
print "unsupported bookmark_extension: %s" % self.bookmark_extension
|
||||||
|
@ -1189,12 +1189,17 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
|
|
||||||
MBP_FORMATS = [u'azw', u'mobi', u'prc', u'txt']
|
MBP_FORMATS = [u'azw', u'mobi', u'prc', u'txt']
|
||||||
TAN_FORMATS = [u'tpz', u'azw1']
|
TAN_FORMATS = [u'tpz', u'azw1']
|
||||||
|
PDR_FORMATS = [u'pdf']
|
||||||
|
|
||||||
mbp_formats = set()
|
mbp_formats = set()
|
||||||
for fmt in MBP_FORMATS:
|
for fmt in MBP_FORMATS:
|
||||||
mbp_formats.add(fmt)
|
mbp_formats.add(fmt)
|
||||||
tan_formats = set()
|
tan_formats = set()
|
||||||
for fmt in TAN_FORMATS:
|
for fmt in TAN_FORMATS:
|
||||||
tan_formats.add(fmt)
|
tan_formats.add(fmt)
|
||||||
|
pdr_formats = set()
|
||||||
|
for fmt in PDR_FORMATS:
|
||||||
|
pdr_formats.add(fmt)
|
||||||
|
|
||||||
class BookmarkDevice(Device):
|
class BookmarkDevice(Device):
|
||||||
def initialize(self, save_template):
|
def initialize(self, save_template):
|
||||||
@ -1218,12 +1223,14 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
elif file_fmts.intersection(tan_formats):
|
elif file_fmts.intersection(tan_formats):
|
||||||
book_extension = list(file_fmts.intersection(tan_formats))[0]
|
book_extension = list(file_fmts.intersection(tan_formats))[0]
|
||||||
bookmark_extension = 'tan'
|
bookmark_extension = 'tan'
|
||||||
|
elif file_fmts.intersection(pdr_formats):
|
||||||
|
book_extension = list(file_fmts.intersection(pdr_formats))[0]
|
||||||
|
bookmark_extension = 'pdr'
|
||||||
|
|
||||||
if bookmark_extension:
|
if bookmark_extension:
|
||||||
for vol in storage:
|
for vol in storage:
|
||||||
bkmk_path = path_map[id]['path'].replace(os.path.abspath('/<storage>'),vol)
|
bkmk_path = path_map[id]['path'].replace(os.path.abspath('/<storage>'),vol)
|
||||||
bkmk_path = bkmk_path.replace('bookmark',bookmark_extension)
|
bkmk_path = bkmk_path.replace('bookmark',bookmark_extension)
|
||||||
print "looking for %s" % bkmk_path
|
|
||||||
if os.path.exists(bkmk_path):
|
if os.path.exists(bkmk_path):
|
||||||
path_map[id] = bkmk_path
|
path_map[id] = bkmk_path
|
||||||
book_ext[id] = book_extension
|
book_ext[id] = book_extension
|
||||||
@ -1260,11 +1267,10 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
if path_map:
|
if path_map:
|
||||||
bookmark_ext = path_map[id].rpartition('.')[2]
|
bookmark_ext = path_map[id].rpartition('.')[2]
|
||||||
myBookmark = Bookmark(path_map[id], id, book_ext[id], bookmark_ext)
|
myBookmark = Bookmark(path_map[id], id, book_ext[id], bookmark_ext)
|
||||||
print "book: %s\nlast_read_location: %d\nlength: %d" % (book['title'],
|
try:
|
||||||
myBookmark.last_read_location,
|
book['percent_read'] = float(100*myBookmark.last_read / myBookmark.book_length)
|
||||||
myBookmark.book_length)
|
except:
|
||||||
if myBookmark.book_length:
|
book['percent_read'] = 0
|
||||||
book['percent_read'] = float(100*myBookmark.last_read_location / myBookmark.book_length)
|
|
||||||
dots = int((book['percent_read'] + 5)/10)
|
dots = int((book['percent_read'] + 5)/10)
|
||||||
dot_string = self.READ_PROGRESS_SYMBOL * dots
|
dot_string = self.READ_PROGRESS_SYMBOL * dots
|
||||||
empty_dots = self.UNREAD_PROGRESS_SYMBOL * (10 - dots)
|
empty_dots = self.UNREAD_PROGRESS_SYMBOL * (10 - dots)
|
||||||
@ -2113,7 +2119,10 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
book = self.bookmarked_books[bm_book]
|
book = self.bookmarked_books[bm_book]
|
||||||
#print "bm_book: %s" % bm_book
|
#print "bm_book: %s" % bm_book
|
||||||
book[1]['bookmark_timestamp'] = book[0].timestamp
|
book[1]['bookmark_timestamp'] = book[0].timestamp
|
||||||
book[1]['percent_read'] = float(100*book[0].last_read_location / book[0].book_length)
|
try:
|
||||||
|
book[1]['percent_read'] = float(100*book[0].last_read / book[0].book_length)
|
||||||
|
except:
|
||||||
|
book[1]['percent_read'] = 0
|
||||||
bookmarked_books.append(book[1])
|
bookmarked_books.append(book[1])
|
||||||
|
|
||||||
self.booksByDateRead = sorted(bookmarked_books,
|
self.booksByDateRead = sorted(bookmarked_books,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user