![]() |
#361 | |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 352
Karma: 47240
Join Date: Aug 2015
Device: Kindle
|
Quote:
Code:
program: all_authors = category_items('authors'); res = ''; for a in '&' all_authors: ratings = from_search('rating', strcat('rating:true and author"=', a, '"')); if ratings then avg = divide(mean(ratings), 2); res = list_union(res, strcat(a, ':', avg), ',') fi rof; res Last edited by capink; 02-23-2021 at 05:24 AM. |
|
![]() |
![]() |
![]() |
#362 | |
Grumpy old git
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 9,566
Karma: 3125998
Join Date: Jan 2010
Location: UK
Device: Reader
|
Quote:
Code:
for a in authors separator '&': Code:
for a in authors separator if something then '&' else ',' fi: |
|
![]() |
![]() |
![]() |
#363 | ||
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 352
Karma: 47240
Join Date: Aug 2015
Device: Kindle
|
Quote:
Code:
program: book_ids = from_selection('id'); all_authors = category_items('authors',book_ids); res = ''; for a in all_authors separator '&': ratings = from_search('rating', strcat('rating:true and author:"=', a, '"')); if ratings then avg = divide(mean(ratings), 2); res = list_union(res, strcat(a, ':', avg), ',') fi rof; res Quote:
![]() |
||
![]() |
![]() |
![]() |
#364 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 352
Karma: 47240
Join Date: Aug 2015
Device: Kindle
|
Also turns out subitems() automatically removes duplicates anyway. So this works fine to get the top level genres:
Code:
program: genres = category_items('#genre'); subitems(genres, 0, 1) |
![]() |
![]() |
![]() |
#365 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,909
Karma: 9610948
Join Date: Oct 2018
Device: Kobo Aura HD
|
Question: In View Manager, I have a view called "On Device." I use a one-action chain and Event Manager to switch to it when the device plug in.
Is it possible to make a condition to make it not run if the view is already set to On Device? Thank you! Last edited by ownedbycats; 02-23-2021 at 06:07 PM. |
![]() |
![]() |
![]() |
#366 |
Addict
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 352
Karma: 47240
Join Date: Aug 2015
Device: Kindle
|
You will need a custom template function to check for that. Taking a quick look at the view manager code, this can be easily done using this template:
Code:
from calibre_plugins.action_chains.templates import TemplateFunction class ViewManagerLastVIew(TemplateFunction): name = 'view_manager_last_view' arg_count = 0 def evaluate(self, formatter, kwargs, mi, locals): import calibre_plugins.view_manager.config as cfg gui = self.plugin_action.gui library_config = cfg.get_library_config(gui.current_db) return library_config.get(cfg.KEY_LAST_VIEW, '') Code:
Template : program: view_manager_last_view() Datatype : text Comparison : != Condition Value : On Device In the mean time, you can test the above to see whether it works. |
![]() |
![]() |
![]() |
#367 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,909
Karma: 9610948
Join Date: Oct 2018
Device: Kobo Aura HD
|
A while ago I did some experimenting and found that adding the condition to the actions rather than the chain itself doesn't result in error. This is clumsy though, and doesn't work if you want to use other conditions for the specific actions.
But it works well enough for a single-action chain, and the code above worked. ![]() Last edited by ownedbycats; 02-24-2021 at 04:25 AM. |
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
[GUI Plugin] KindleUnpack - The Plugin | DiapDealer | Plugins | 468 | 02-07-2021 05:07 PM |
[GUI Plugin] Save Virtual Libraries To Column (GUI) | chaley | Plugins | 12 | 12-27-2020 02:31 PM |
[GUI Plugin] Manga plugin | mastertea | Plugins | 0 | 10-20-2019 03:45 PM |
[GUI Plugin] Wordpress | frescogamba | Plugins | 11 | 04-06-2015 10:09 PM |
[GUI Plugin] Plugin Updater **Deprecated** | kiwidude | Plugins | 159 | 06-19-2011 01:27 PM |