Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Plugins

Notices

Reply
 
Thread Tools Search this Thread
Old 05-09-2024, 08:56 PM   #61
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 9,589
Karma: 65099765
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Convert public-domain identifiers

Here is a chain that uses templates to convert url/uri identifiers from three public-domain book websites (Project Gutenberg, Standard Ebooks, and Global Grey) to site-specific ones. Mostly because it looks nicer in book details.

Before installing this, go to Preferences > Look & Feel > Book Details > Create rules to convert identifiers into link. Then add these three rules:

Project Gutenberg
Key: gutenberg
Template: https://www.gutenberg.org/ebooks/{id}

Standard Ebooks
Key: standard
Template: https://standardebooks.org/ebooks/{id}

Global Grey
Key: gg
Template: https://www.globalgreyebooks.com/{id}-ebook.html

Note that it uses the publisher field to identify whether to convert the IDs.
Attached Files
File Type: zip PublicDomainIdentifiers.zip (2.9 KB, 186 views)

Last edited by ownedbycats; 05-18-2024 at 08:44 PM.
ownedbycats is offline   Reply With Quote
Old 05-12-2024, 01:53 AM   #62
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,291
Karma: 6543210
Join Date: Sep 2020
Device: Calibre E-book viewer
Quote:
Originally Posted by ownedbycats View Post
Here is a chain that uses templates to convert url/uri identifiers from three public-domain book websites (Project Gutenberg, Standard Ebooks, and Global Grey) to site-specific ones. Mostly because it looks nicer in book details.
yes it looks neat and works fine, thank you.
Attached Thumbnails
Click image for larger version

Name:	MWSnap 2024-05-12, 01_44_48.png
Views:	109
Size:	54.4 KB
ID:	208204   Click image for larger version

Name:	MWSnap 2024-05-12, 01_43_31.png
Views:	130
Size:	74.7 KB
ID:	208205  
Comfy.n is offline   Reply With Quote
Old 05-17-2024, 01:54 AM   #63
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 9,589
Karma: 65099765
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
[FanFicFare] Copy StoryURL to personal.ini

For FanFicFare users, this chain I made to easily add a new StoryURL section. First it copies this to clipboard:

Code:
## Test Author - Test Title
[https://www.fanfiction.net/s/123456/1/]

Then it opens personal.ini to paste it in.
Attached Files
File Type: zip AddStoryURL.zip (2.4 KB, 159 views)

Last edited by ownedbycats; 05-18-2024 at 08:43 PM.
ownedbycats is offline   Reply With Quote
Old 06-30-2024, 04:43 PM   #64
tkshorty
Junior Member
tkshorty began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jun 2024
Device: Koba Aura
FanFicFare module

This module was not created by me but by the creator of FanFicFare. Just wanted to share it
https://www.mobileread.com/forums/sh...postcount=9637
The FFF plugin has a signal it will emit after the "proceed with updating your library" dialog.

Code:
from calibre_plugins.action_chains.events import ChainEvent

class SearchChanged(ChainEvent):

    # replace with the name of your event
    name = 'FFF done'

    def get_event_signal(self):
        return self.gui.iactions['FanFicFare'].download_finished_signal
tkshorty is offline   Reply With Quote
Old 07-01-2024, 12:31 PM   #65
capink
Wizard
capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.capink ought to be getting tired of karma fortunes by now.
 
Posts: 1,139
Karma: 1954142
Join Date: Aug 2015
Device: Kindle
Quote:
Originally Posted by tkshorty View Post
This module was not created by me but by the creator of FanFicFare. Just wanted to share it
https://www.mobileread.com/forums/sh...postcount=9637
The FFF plugin has a signal it will emit after the "proceed with updating your library" dialog.

Code:
from calibre_plugins.action_chains.events import ChainEvent

class SearchChanged(ChainEvent):

    # replace with the name of your event
    name = 'FFF done'

    def get_event_signal(self):
        return self.gui.iactions['FanFicFare'].download_finished_signal
That's interesting. I added it to the index in the first post. Although this can be automatically available for users of FFF plugin, if this code is copied into a file called action_chains.py in the root folder of the FFF plugin.
capink is offline   Reply With Quote
Old 07-01-2024, 04:12 PM   #66
tkshorty
Junior Member
tkshorty began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Jun 2024
Device: Koba Aura
Quote:
Originally Posted by capink View Post
That's interesting. I added it to the index in the first post. Although this can be automatically available for users of FFF plugin, if this code is copied into a file called action_chains.py in the root folder of the FFF plugin.
cool. I tried it and it works fine.

I asked JimmXinu to add such a file to his plugin for future updates
tkshorty is offline   Reply With Quote
Old 11-10-2024, 08:13 PM   #67
correoparaappzz
Enthusiast
correoparaappzz began at the beginning.
 
Posts: 40
Karma: 10
Join Date: Nov 2023
Device: Kindle Oasis
Quote:
Originally Posted by capink View Post
Code:
#!/usr/bin/env python
# ~*~ coding: utf-8 ~*~

__license__ = 'GPL v3'
__copyright__ = '2021, Ahmed Zaki <azaki00.dev@gmail.com>'
__docformat__ = 'restructuredtext en'

from functools import partial

from qt.core import (QApplication, Qt, QTimer, QWidget, QVBoxLayout, QCheckBox, pyqtSignal)

from calibre import prints
from calibre.constants import DEBUG
from calibre.db.listeners import EventType
from calibre.utils.date import now

from calibre_plugins.action_chains.events.base import ChainEvent
import calibre_plugins.action_chains.config as cfg

try:
    load_translations()
except NameError:
    prints("ActionChains::events/books_added.py - exception when loading translations")

class ConfigWidget(QWidget):
    def __init__(self, plugin_action):
        QWidget.__init__(self)
        self.plugin_action = plugin_action
        self.gui = plugin_action.gui
        self.db = self.gui.current_db
        self._init_controls()

    def _init_controls(self):

        l = self.l = QVBoxLayout()
        self.setLayout(l)

        self.select_chk = QCheckBox(_('Select newly added books'))
        self.select_chk.setChecked(True)
        l.addWidget(self.select_chk)
        
        l.addStretch(1)

        self.setMinimumSize(300,300)

    def load_settings(self, settings):
        if settings:
            self.select_chk.setChecked(settings['select_books'])

    def save_settings(self):
        settings = {}
        settings['select_books'] = self.select_chk.isChecked()
        return settings

class BooksAddedEvent(ChainEvent):

    name = 'Books Added'
    books_added = pyqtSignal(object)
    timer_interval = 30

    def __init__(self, plugin_action):
        ChainEvent.__init__(self, plugin_action)
        self.db = plugin_action.gui.current_db
        self.gui.add_db_listener(self.process_event_in_db)
        self.book_created_cache = set()
        self.book_created_cache_last_updated = None
        QTimer.singleShot(self.timer_interval * 1000, self._on_timeout)

    def process_event_in_db(self, db, event_type, event_data):
        if not db.library_id == self.gui.current_db.library_id:
            return
        if event_type == EventType.book_created:
            book_id = event_data[0]
            self.add_to_book_created_cache(book_id, now())
        elif event_type == EventType.books_removed:
            removed_book_ids = event_data[0]
            self.book_created_cache = self.book_created_cache.difference(set(removed_book_ids))
        
    def _on_timeout(self):
        # Make sure no modal widget dialog is present (e.g. add books duplicate dialog). Otherwise, postpone
        if QApplication.instance().activeModalWidget():
            pass
        # postpone event if another action chains is running
        elif self.plugin_action.chainStack:
            pass
        else:
            utime = self.book_created_cache_last_updated
            if utime:
                elapsed = now() - utime
                if elapsed.seconds > 20:
                    QTimer.singleShot(0, partial(self.books_added.emit, self.book_created_cache))
                    QTimer.singleShot(0, self.clean_book_created_cache)
        
        # keep the timer runnig
        QTimer.singleShot(self.timer_interval * 1000, self._on_timeout) 

    def add_to_book_created_cache(self, book_id, timestamp):
        self.book_created_cache.add(book_id)
        self.book_created_cache_last_updated = timestamp

    def clean_book_created_cache(self):
        self.book_created_cache = set()
        self.book_created_cache_last_updated = None
    
    def get_event_signal(self):
        return self.books_added

    def config_widget(self):
        return ConfigWidget

    def pre_chains_event_actions(self, event_args, event_opts):
        if event_opts.get('select_books', False):
            book_ids = event_args[0]
            self.gui.library_view.select_rows(book_ids)
            if DEBUG:
                prints('Action Chains: Books Added Event: Selecting newly added book_ids: {}')
After adding this you should have an event called "Books Added" in the dropdown list of the Event Manager. You can attach whatever chains you want to that event.

Notes:
  • The event will automatically select all added books, so that any chains attached to the event can act on them. If whatever reason you don't want this, you can turn it off (Event Manager > Books Added > Event options)
  • There is a lag of several seconds before the event is activated. This is done to ensure calibre's adder (and auto-adder) has added all the books.
  • You can attach one or more chain(s) to the event: Event Manager > Add Event > Books Added > click settings button next to the event.
  • Whenever you change the name of a chain attached to an event, you will need to open the Event Manager to re-attach it.
is there a way to reduse the time?
correoparaappzz is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI Plugin] Action Chains capink Plugins 1410 11-14-2024 01:49 AM
Book Scanning tool chains tomsem Workshop 17 12-03-2023 10:19 AM
Mystery and Crime Thorne, Guy: Chance in Chains (1914); v1 Pulpmeister Kindle Books 0 11-25-2018 10:09 PM
Mystery and Crime Thorne, Guy: Chance in Chains (1914); v1 Pulpmeister ePub Books 0 11-25-2018 10:08 PM
Could this be the last year for the big chains? Connallmac News 66 01-07-2011 05:11 PM


All times are GMT -4. The time now is 09:58 AM.


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