|  08-22-2022, 03:57 AM | #1 | 
| want to learn what I want            Posts: 1,679 Karma: 7908443 Join Date: Sep 2020 Device: none | 
				
				Emblem in Cover Grid not updating instantly like it used to
			 
			
			Hi, I've been using successfully, for a long time now, a rule that sets an emblem in Cover Grid, as following: "If the #lastopened column is set (single condition), add emblem X" Issue is that, since Calibre 6, IIRC, the emblem will not display instantly after viewing any book (of any filetype). The custom column #lastopened is updating instantly as it used to. I have it displayed on the details sidebar, so I can see it's working as usual. Today I tried switching from this PI to use the Job Spy PI similar functionality, that updates the custom column, but the emblem still won't show up after opening/viewing the books, unless I restart Calibre. (BTW, I'm not sure whether a PI is really necessary to get the #lastopened custom column updated.) Anyway, problem is just that the emblem won't show up instantly as it used to. Thoughts? I should clarify that I have many titles that were added to the Library, however haven't been viewed, hence I find that emblem kind of useful. Update: today I tested again JS Plugin "Activate Last-viewed" option, and to my pleasant surprise, I had the emblem update instantly, after viewing any title even with external viewers. (JS version 1.0.196) Last edited by Comfy.n; 12-07-2022 at 09:32 PM. Reason: update | 
|   |   | 
|  08-23-2022, 03:54 AM | #2 | 
| Zealot  Posts: 124 Karma: 34 Join Date: Jun 2015 Device: ipad & inkpad X | 
			
			I can confirm that certain rows dont get updated instantly (using external plugins), but normally if i do something in the library (open a book, add a new book or whatever), the affected rows get updated. I dont use emblems, so this "problem" could be something different. Maybe your row #lastopened is "malformed": Look inside the row settings, if that row only contains the date without hour, the row only gets updated once a day... My setting is german view, set yours according your language   Last edited by igorius; 08-23-2022 at 03:59 AM. | 
|   |   | 
| Advert | |
|  | 
|  08-23-2022, 05:04 AM | #3 | |
| want to learn what I want            Posts: 1,679 Karma: 7908443 Join Date: Sep 2020 Device: none | Quote: 
 So I think I had three different behaviours happen as Calibre/QT versions would change: 1) All good, once I viewed any title, the emblem would show instantly; 2) The behaviour you described: while doing other things in the library, at some point the emblem would show up; and... 3) The current issue: emblem for that condition only shows up after restarting the program. I just tried setting #lastopened to dd-MM-yyyy hh:mm:ss and still no good.   | |
|   |   | 
|  08-23-2022, 01:55 PM | #4 | 
| Zealot  Posts: 124 Karma: 34 Join Date: Jun 2015 Device: ipad & inkpad X | 
			
			Ok, some silly question: What kind of value is your #lastopened? Is it of type date? Then your rule is wrong! is set expects a yes/no, but if its a date in this field, your rule has to fail! I tested this here. When its date you should change to whatever has to do with date/time-settings. The only one which works is "not set". It applies when no date is set. My faulty first answer, i should have looked better to your pic... Sorry! Hope that helps | 
|   |   | 
|  08-23-2022, 02:29 PM | #5 | |
| want to learn what I want            Posts: 1,679 Karma: 7908443 Join Date: Sep 2020 Device: none | Quote: 
 When #lastopened has any stored value (which in this case is a Date), emblem should show up instantly, as it used to. The last field in this kind of rule is greyed out (disabled), meaning "there's no value to assign, since this rule will just see if there's any date stored in database for that custom column". BTW, yesterday I found a workaround to have the emblem show up lol It goes like this: 1) View any book (emblem still won't show up, right?) 2) Click the EDIT METADATA button, for any title in the library. Don't change anything after the dialog box comes up. Just click OK. (Boom, emblem in that previously viewed book now SHOWS UP)   Last edited by Comfy.n; 08-24-2022 at 01:08 AM. | |
|   |   | 
| Advert | |
|  | 
|  08-23-2022, 07:57 PM | #6 | |
| null operator (he/him)            Posts: 22,012 Karma: 30277294 Join Date: Mar 2012 Location: Sydney Australia Device: none | Quote: 
 BR | |
|   |   | 
|  08-23-2022, 08:26 PM | #7 | |
| want to learn what I want            Posts: 1,679 Karma: 7908443 Join Date: Sep 2020 Device: none | Quote: 
 ..changed it to ctrl-alt-J, no good either anyway, I guess this is a highly irrelevant issue   | |
|   |   | 
|  08-23-2022, 10:45 PM | #8 | 
| creator of calibre            Posts: 45,604 Karma: 28548974 Join Date: Oct 2006 Location: Mumbai, India Device: Various | 
			
			Is this happening only when the value is changed using a plugin or when using the edit metadata dialog as well? If its the former, its a bug in the plugin, the plugin must call refresh_ids() after making a change to ensure things are updated.
		 | 
|   |   | 
|  08-24-2022, 12:44 AM | #9 | |
| want to learn what I want            Posts: 1,679 Karma: 7908443 Join Date: Sep 2020 Device: none | Quote: 
  Well... I just tested that here, by changing the custom column #lastopened on the Edit Metadata dialog to "today" and the emblem showed up instantly! (I have attached a screenshot) That indeed indicates a bug in the plugins. I'm using this one, called Auto Datestamp and View. Is there some quick fix I can apply to it? I'm no coder, but sometimes I customise plugins and browser extensions for personal use. Here is the code of Auto Datestamp and View: Code: #!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
__license__   = 'GPL v3'
__copyright__ = '2019, Paul'
__docformat__ = 'restructuredtext en'
from calibre.gui2.actions import InterfaceAction
from calibre.customize import InterfaceActionBase
from calibre.gui2 import error_dialog
from calibre.utils.date import format_date
import datetime
class InterfacePluginBase(InterfaceActionBase):
    name                = 'Auto Datestamp and View'
    description         = 'Add a date stamp and view current book'
    supported_platforms = ['windows', 'osx', 'linux']
    author              = 'Paul'
    version             = (0, 0, 9)
    minimum_calibre_version = (0, 7, 53)
    actual_plugin = 'calibre_plugins.auto_datestamp_and_view:AutoDatestampAndView'
class AutoDatestampAndView(InterfaceAction):
    name = 'Auto Datestamp and View'
    action_spec = (_('Date and view book'), None, None, None)
    action_type = 'current'
    
    def genesis(self):
        self.qaction.triggered.connect(self.gui.iactions['View']._view_calibre_books)
        orig_func = self.gui.iactions['View']._view_calibre_books
        def datestamp_and_view(book_ids):
            # View the book(s)
            orig_func(book_ids)
            # Then update the date stamp
            db = self.gui.library_view.model().db
            dateformat = 'iso'
            date_column = '#lastopened'
            custom_columns = db.custom_field_keys()
            # Make sure column exists
            if date_column not in custom_columns: 
                return error_dialog(self.gui, 'Before running this plugin', 
                        'You need to create a custom Date column called %s '%date_column, show=True)
            label = db.field_metadata.key_to_label(date_column)
            # Stamp each one by one
            for book_id in book_ids:
                now = datetime.datetime.now()
                viewdate = format_date(now, dateformat, assume_utc=False, as_utc=False)
                db.set_custom(book_id, viewdate, label=label, commit=True)
        # thanks to Kovid Goyal for the following line, also for Calibre in general
        self.gui.iactions['View']._view_calibre_books = datestamp_and_view | |
|   |   | 
|  08-24-2022, 01:27 AM | #10 | 
| creator of calibre            Posts: 45,604 Karma: 28548974 Join Date: Oct 2006 Location: Mumbai, India Device: Various | 
			
			self.gui.library_view.model().refresh_ids(book_ids  )
		 | 
|   |   | 
|  08-24-2022, 02:48 AM | #11 | 
| want to learn what I want            Posts: 1,679 Karma: 7908443 Join Date: Sep 2020 Device: none |   
			
			Wheeeeeeeeeeee !!   That works lol!! NOW THE EMBLEM SHOWS UP INSTANTLY! (for any filetype) I just added that line here: Code:    for book_id in book_ids:
                now = datetime.datetime.now()
                viewdate = format_date(now, dateformat, assume_utc=False, as_utc=False)
                db.set_custom(book_id, viewdate, label=label, commit=True)
                self.gui.library_view.model().refresh_ids(book_ids)  | 
|   |   | 
|  08-24-2022, 06:45 AM | #12 | |
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | Quote: 
 Code:     for book_id in book_ids:
        now = datetime.datetime.now()
        viewdate = format_date(now, dateformat, assume_utc=False, as_utc=False)
        db.set_custom(book_id, viewdate, label=label, commit=True)
    if book_ids:
        self.gui.library_view.model().refresh_ids(book_ids) | |
|   |   | 
|  08-24-2022, 06:05 PM | #13 | |
| want to learn what I want            Posts: 1,679 Karma: 7908443 Join Date: Sep 2020 Device: none | Quote: 
 Code: ERROR: Unhandled exception: <b>NameError</b>:name 'book_ids' is not defined [...] Traceback (most recent call last): File "calibre\gui2\preferences\plugins.py", line 325, in add_plugin File "calibre\customize\ui.py", line 479, in add_plugin File "calibre\customize\ui.py", line 64, in load_plugin File "calibre\customize\zipplugin.py", line 307, in load File "polyglot\builtins.py", line 123, in reload File "importlib\__init__.py", line 169, in reload File "<frozen importlib._bootstrap>", line 619, in _exec File "calibre\customize\zipplugin.py", line 208, in exec_module File "calibre_plugins.auto_datestamp_and_view.__init__", line 23, in <module> File "calibre_plugins.auto_datestamp_and_view.__init__", line 46, in AutoDatestampAndView NameError: name 'book_ids' is not defined | |
|   |   | 
|  08-24-2022, 06:21 PM | #14 | 
| Bibliophagist            Posts: 48,100 Karma: 174315444 Join Date: Jul 2010 Location: Vancouver Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos | 
			
			Looking at the code, chaley posted: Code:     if book_ids:
        self.gui.library_view.model().refresh_ids(book_ids)Code:     if book_id:
        self.gui.library_view.model().refresh_ids(book_ids)Edit: Tried changing book_id to book_ids and got a BOOL error on install. Last edited by DNSB; 08-24-2022 at 06:43 PM. | 
|   |   | 
|  08-24-2022, 06:40 PM | #15 | |
| Grand Sorcerer            Posts: 12,525 Karma: 8065948 Join Date: Jan 2010 Location: Notts, England Device: Kobo Libra 2 | Quote: 
 Code: #!/usr/bin/env python2
# vim:fileencoding=UTF-8:ts=4:sw=4:sta:et:sts=4:ai
__license__   = 'GPL v3'
__copyright__ = '2019, Paul'
__docformat__ = 'restructuredtext en'
from calibre.gui2.actions import InterfaceAction
from calibre.customize import InterfaceActionBase
from calibre.gui2 import error_dialog
from calibre.utils.date import format_date
import datetime
class InterfacePluginBase(InterfaceActionBase):
    name                = 'Auto Datestamp and View'
    description         = 'Add a date stamp and view current book'
    supported_platforms = ['windows', 'osx', 'linux']
    author              = 'Paul'
    version             = (0, 0, 9)
    minimum_calibre_version = (0, 7, 53)
    actual_plugin = 'calibre_plugins.auto_datestamp_and_view:AutoDatestampAndView'
class AutoDatestampAndView(InterfaceAction):
    name = 'Auto Datestamp and View'
    action_spec = (_('Date and view book'), None, None, None)
    action_type = 'current'
    
    def genesis(self):
        self.qaction.triggered.connect(self.gui.iactions['View']._view_calibre_books)
        orig_func = self.gui.iactions['View']._view_calibre_books
        def datestamp_and_view(book_ids):
            # View the book(s)
            orig_func(book_ids)
            # Then update the date stamp
            db = self.gui.library_view.model().db
            dateformat = 'iso'
            date_column = '#lastopened'
            custom_columns = db.custom_field_keys()
            # Make sure column exists
            if date_column not in custom_columns: 
                return error_dialog(self.gui, 'Before running this plugin', 
                        'You need to create a custom Date column called %s '%date_column, show=True)
            label = db.field_metadata.key_to_label(date_column)
            # Stamp each one by one
            for book_id in book_ids:
                now = datetime.datetime.now()
                viewdate = format_date(now, dateformat, assume_utc=False, as_utc=False)
                db.set_custom(book_id, viewdate, label=label, commit=True)
            if book_ids:
                self.gui.library_view.model().refresh_ids(book_ids)
            # thanks to Kovid Goyal for the following line, also for Calibre in general
            self.gui.iactions['View']._view_calibre_books = datestamp_and_view | |
|   |   | 
|  | 
| Tags | 
| cover grid, emblems | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| Cover grid tooltip | ownedbycats | Library Management | 1 | 02-04-2022 09:33 AM | 
| Cover grid of Caliber | Laval | Calibre | 2 | 03-07-2019 07:21 PM | 
| Can't show the emblem in grid view | Ansem_93 | Library Management | 2 | 04-24-2017 05:21 PM | 
| Cover grid not updating in large window | Snorkledorf | Calibre | 2 | 07-30-2014 03:33 AM | 
| Cover Grid Ignoring Tweaks? | danwdoo | Calibre | 1 | 09-16-2013 09:32 AM |