View Single Post
Old 04-29-2019, 06:07 AM   #16
davidfor
Grand Sorcerer
davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.davidfor ought to be getting tired of karma fortunes by now.
 
Posts: 24,905
Karma: 47303824
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
Quote:
Originally Posted by ceridwen View Post
At the moment, I'm using a very crude approach: I've created a custom column, and I have two scripts that literally invoke calibredb repeatedly. The AO3 script handles AO3 tags directly (bypassing the epub) and only calls calibredb to look up the calibre id and then to run calibredb set_metadata. The non-AO3 script looks up the Tags column and then runs calibredb set_metadata to add some of them to the custom column. This is slow and awkward, so I'd really like to write a plugin to do it instead. I spent some time looking through the API documentation for plugins, but I didn't see any discussion of how to write a plugin that does the kinds of things I want here. Does anyone know of a good example plugin that could get me started or some other resource that would help me?
Some of that might be possible with search and replace. It really depends on if the rules are simple enough.

Some more can be done with the tag mapping. Though, it doesn't do custom columns.

A plugin to set custom columns isn't that hard to write. For examples:

The Count Pages plugin is the one I normally point people to (or Modify ePub, but it doesn't fit with what you want). It can apply its function over multiple books and set multiple custom columns. It only does numeric columns, but it isn't much of a stretch to do tag-like colums. It is useful if you want to something in a batch job. Plus, it should be the one that does the updates in the best manner.

Both the Reading List and Goodreads Sync plugins will set the tags or tag-like columns. The former is probably simpler, but is setting a single value. The later is generating the list of tags from Goodreads and then setting the columns. Import List also does multiple updates of columns based on data from CSV files or web sites.

My Kobo Utilities plugin does various things were it updates columns. The collection fetch will update a tag-like custom column with the current collections the books are in. Not sure if I really want to suggest looking at it, as there is some very ugly code in the plugin. But, it does do just about anything you want to in a plugin except actually modify a book.
davidfor is offline   Reply With Quote