Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 01-01-2022, 06:07 PM   #1
MerlinMama
Evangelist
MerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beauty
 
MerlinMama's Avatar
 
Posts: 498
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Sage
S&R RegEx Functions Custom Columns

I cannot seem to wrap my head around constructing a function to bring the rating in the custom column #rating (uses half stars) into my book title page (for fanfiction).

Searching through the documents, I seem to have found several possibilities, but am unsure if I need to use them all, some, just one, and none of my attempts have worked out. This is way more advanced than any other attempt I've made.

If it's necessary to know, I'm searching for
Code:
<br/>(.*?)<div class="h2">
(This may be fine-tuned later as I had been adding some ratings manually, so I want to capture if there is a rating or not, returns or not.)

How can I go about getting the rating from my custom column and including it here? Even if it's just to point me to which areas in the documents I need to focus on (Several areas to work? One or two?) or getting me started

I would greatly appreciate any help.
MerlinMama is offline   Reply With Quote
Old 01-01-2022, 07:56 PM   #2
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
There is no way to update an existing page in the book with the metadata. It would need a plugin written to do it.

The closest you can get is to insert and update a jacket page. Calibre can build that from a template using the metadata and insert it into the book. I don't use them, so can't help. But, there is some help for the jackets, and plenty of discussion about them.
davidfor is offline   Reply With Quote
Advert
Old 01-01-2022, 08:10 PM   #3
MerlinMama
Evangelist
MerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beauty
 
MerlinMama's Avatar
 
Posts: 498
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Sage
Oh, okay. I'll have a look at that then. Thanks.
MerlinMama is offline   Reply With Quote
Old 01-08-2022, 01:24 PM   #4
MerlinMama
Evangelist
MerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beauty
 
MerlinMama's Avatar
 
Posts: 498
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Sage
I haven't been able to figure this out yet, but wondered...is there a way to get the custom rating from the metadata file? If I search for (from the previous example)

Code:
<br/>(.*?)<div class="h2">
and have the regex-function get the custom rating from the metadata file (which is, I think, content.opf), is that very difficult? Well, difficult for someone who understands all this programming stuff, because it's quite beyond me.

How do I direct to get the info from that file? Even letting me know that much might make it easier to figure out...but I of course wouldn't object to being spoon-fed the information LOL.

I enjoy trying to figure this stuff out, but right now it's been about two to three weeks and I'm at the point where even things that used to make sense are starting to seem like gibberish.

Thanks for any help or direction.
MerlinMama is offline   Reply With Quote
Old 01-09-2022, 06:47 AM   #5
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
If you mean the OPF file in the directory with the book, then that is maintained by calibre. And is really just a backup. If you want that data, then it will be in a column in the the library. You can access that from code much easier than attempting to read the OPF file directly. It will be accessible from a template using the lookup name. Or from plugin code.

If this is related to the original question, then you should be able to do it from a template. But, if you are doing something else, we need to know what.
davidfor is offline   Reply With Quote
Advert
Old 01-09-2022, 07:17 AM   #6
MerlinMama
Evangelist
MerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beauty
 
MerlinMama's Avatar
 
Posts: 498
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Sage
Nope still trying to figure out the original question
MerlinMama is offline   Reply With Quote
Old 01-09-2022, 08:37 AM   #7
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
In that case, your best bet is still the jacket. That will get the information you want into the book.

The next method would be dependent on how these books are created. As you mention they are fanfiction, are you using FanFicFare to download them? If so, that can put the rating from the site on the page it generates.

Otherwise, you probably need to write an editor plugin that reads the OPF file and updates the page you want the rating on. The OPF is XML so you can parse that fairly easily. There may be some library functions to get the metadata from the OPF, but, I haven't needed them. Alternatively, you could write a user action plugin that makes the changes without opening them in the editor first. That has the advantage that you can run it across multiple books and get the metadata directly from the database which is much easier to do. I have done something similar that I use for books downloaded using FFF to get them how I like them.
davidfor is offline   Reply With Quote
Old 01-09-2022, 08:44 AM   #8
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
And of course, as soon as I finished that, I thought of two other ways. Both generate covers, but in different ways.

In the metadata editor, there is a button for "Generate cover". That generates an image for the book. Exactly what is on it is configurable. Right-click on the button to do this. There are three configurable lines that can be used to do this.

There is also a plugin called "Generate Cover". That can do a similar thing. I think it is more configurable and can use an image. But, I haven't used it for a while, so I'm not sure.

In either case, the cover image is generated and displayed in calibre, but, will need to be added to the book. There are several ways to do that, but, I would probably use "Polish books".
davidfor is offline   Reply With Quote
Old 01-09-2022, 09:07 AM   #9
MerlinMama
Evangelist
MerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beautyMerlinMama does all things with Zen-like beauty
 
MerlinMama's Avatar
 
Posts: 498
Karma: 32554
Join Date: May 2014
Location: Canada
Device: Kobo Sage
Thank you! I think I just got myself with tunnel vision, especially after I couldn't figure out the jacket. I'm sure I'll be able to get one of the suggestions (or maybe combining some) to work. Thanks again!
MerlinMama is offline   Reply With Quote
Old 01-09-2022, 07:30 PM   #10
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
If you are having issues with the jacket, then ask. It is used by enough people that there will be someone who can make suggestions for the templates.

I also responded to another post after yours about changing books and realised it was a possibility for you as well. There is a plugin called "Editor Chains" which can automate some changes to the contents of books. It can do search-and-replace of text and classes. I haven't used it, so I don't know whether it will handle your case.
davidfor is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Saved Search/Regex Functions eschwartz Editor 86 05-03-2025 04:49 AM
Regex-Functions - getting user input CalibUser Editor 8 09-09-2020 04:26 AM
Custom columns & moving the library CodeVisio Library Management 1 07-05-2020 08:00 AM
Help - Learning to use Regex Functions weberr Editor 1 06-13-2015 01:59 AM
Query re: Custom columns & multiple libraries jackie_w Calibre 4 10-03-2010 02:16 AM


All times are GMT -4. The time now is 02:57 PM.


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