mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
GwR revisions - skip Catalog and Clippings when appending annotations to comments
This commit is contained in:
parent
b340d1d883
commit
ac1be602fe
@ -179,7 +179,7 @@ class Bookmark():
|
||||
self.get_bookmark_data()
|
||||
self.get_book_length()
|
||||
try:
|
||||
self.percent_read = float(100*self.last_read / self.book_length)
|
||||
self.percent_read = min(float(100*self.last_read / self.book_length),100)
|
||||
except:
|
||||
self.percent_read = 0
|
||||
|
||||
|
@ -1075,12 +1075,12 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
self.pd.hide()
|
||||
|
||||
def run(self):
|
||||
ignore_tags = set(['Catalog','Clippings'])
|
||||
for (i, id) in enumerate(self.am):
|
||||
bm = Device.UserAnnotation(self.am[id][0],self.am[id][1])
|
||||
if bm.type == 'kindle_bookmark':
|
||||
user_notes_soup = self.generate_annotation_html(bm.value)
|
||||
|
||||
mi = self.db.get_metadata(id, index_is_id=True)
|
||||
user_notes_soup = self.generate_annotation_html(bm.value)
|
||||
if mi.comments:
|
||||
a_offset = mi.comments.find('<div class="user_annotations">')
|
||||
ad_offset = mi.comments.find('<hr class="annotations_divider" />')
|
||||
@ -1089,6 +1089,8 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
mi.comments = mi.comments[:a_offset]
|
||||
if ad_offset >= 0:
|
||||
mi.comments = mi.comments[:ad_offset]
|
||||
if set(mi.tags).intersection(ignore_tags):
|
||||
continue
|
||||
if mi.comments:
|
||||
hrTag = Tag(user_notes_soup,'hr')
|
||||
hrTag['class'] = 'annotations_divider'
|
||||
@ -1099,9 +1101,12 @@ class Main(MainWindow, Ui_MainWindow, DeviceGUI):
|
||||
mi.comments = unicode(user_notes_soup.prettify())
|
||||
# Update library comments
|
||||
self.db.set_comment(id, mi.comments)
|
||||
# Update 'read' tag
|
||||
|
||||
# Update 'read' tag except for Catalogs/Clippings
|
||||
if bm.value.percent_read >= self.FINISHED_READING_PCT_THRESHOLD:
|
||||
if not set(mi.tags).intersection(ignore_tags):
|
||||
self.mark_book_as_read(id)
|
||||
|
||||
# Add bookmark file to id
|
||||
self.db.add_format_with_hooks(id, bm.value.bookmark_extension,
|
||||
bm.value.path, index_is_id=True)
|
||||
|
@ -1261,7 +1261,7 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
bookmark_ext = path_map[id].rpartition('.')[2]
|
||||
myBookmark = Bookmark(path_map[id], id, book_ext[id], bookmark_ext)
|
||||
try:
|
||||
book['percent_read'] = float(100*myBookmark.last_read / myBookmark.book_length)
|
||||
book['percent_read'] = min(float(100*myBookmark.last_read / myBookmark.book_length),100)
|
||||
except:
|
||||
book['percent_read'] = 0
|
||||
dots = int((book['percent_read'] + 5)/10)
|
||||
@ -2113,7 +2113,7 @@ class EPUB_MOBI(CatalogPlugin):
|
||||
#print "bm_book: %s" % bm_book
|
||||
book[1]['bookmark_timestamp'] = book[0].timestamp
|
||||
try:
|
||||
book[1]['percent_read'] = float(100*book[0].last_read / book[0].book_length)
|
||||
book[1]['percent_read'] = min(float(100*book[0].last_read / book[0].book_length),100)
|
||||
except:
|
||||
book[1]['percent_read'] = 0
|
||||
bookmarked_books.append(book[1])
|
||||
|
Loading…
x
Reference in New Issue
Block a user