Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 08-24-2022, 06:55 PM   #16
DNSB
Bibliophagist
DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.DNSB ought to be getting tired of karma fortunes by now.
 
DNSB's Avatar
 
Posts: 46,338
Karma: 169098492
Join Date: Jul 2010
Location: Vancouver
Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos
I thought I had corrected the identation but copy/pasted your version over the one I generated.

I still got the 'bool' object is not iterable error

Code:
calibre, version 6.3.0
ERROR: Unhandled exception: <b>TypeError</b>:'bool' object is not iterable

calibre 6.3  embedded-python: True
Windows-10-10.0.22000-SP0 Windows ('64bit', 'WindowsPE')
('Windows', '10', '10.0.22000')
Python 3.10.1
Windows: ('10', '10.0.22000', 'SP0', 'Multiprocessor Free')
Interface language: en_CA
Successfully initialized third party plugins: Auto Datestamp and View (0, 0, 9)
...
<deleted rest of plugins.  I really need to start culling them.>
...
Traceback (most recent call last):
  File "calibre\gui2\actions\view.py", line 308, in _view_calibre_books
TypeError: 'bool' object is not iterable
DNSB is offline   Reply With Quote
Old 08-24-2022, 07:12 PM   #17
Comfy.n
want to learn what I want
Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.Comfy.n ought to be getting tired of karma fortunes by now.
 
Posts: 1,612
Karma: 7891011
Join Date: Sep 2020
Device: none
Quote:
Originally Posted by DNSB View Post
Looking at the code, chaley posted:

Code:
    if book_ids:
        self.gui.library_view.model().refresh_ids(book_ids)
Looking at the after the loop in the zip archive:

Code:
    if book_id:
        self.gui.library_view.model().refresh_ids(book_ids)
It seems as if you are missing an s in the if line.

Edit: Tried changing book_id to book_ids and got a BOOL error on install.

I had originally pasted "if book_ids:" as Chaley posted. Modification in the file attached to "if book_id:" was an attempt to guess what could have triggered the install error. (and I forgot to undo that modification before posting the files here, sorry about that!)


Quote:
Originally Posted by chaley View Post
Yes, this is part of the problem. However, the main problem is that the indentation isn't right. I think the file should look like
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
TBH I don't know why the last 2 lines are in this file, but I'm not going to go deep into development.
I just tested that code with and without the last 2 lines; both resulted in emblem not updating. So I think I will just keep using the "before the loop" version (edit: "in the loop", actually), until a proper solution emerges. Thank you!

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:31 PM. Reason: update
Comfy.n is offline   Reply With Quote
Advert
Reply

Tags
cover grid, emblems


Forum Jump

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


All times are GMT -4. The time now is 02:04 AM.


MobileRead.com is a privately owned, operated and funded community.