Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set custom metadata? #138

Open
bbugh opened this issue Feb 1, 2024 · 1 comment
Open

How to set custom metadata? #138

bbugh opened this issue Feb 1, 2024 · 1 comment

Comments

@bbugh
Copy link

bbugh commented Feb 1, 2024

Hello, 馃憢 thanks for the gem, it's been helpful for some projects!

I want to add some series and series index metadata information for calibre, but after some hours pouring over the code and digging around with pry, I've still not found a good way to set custom metadata. It needs to look like this:

    <meta name="calibre:series" content="Book Series" />
    <meta name="calibre:series_index" content="6.0" />

The best I came up with was manually hacking it in, which works but isn't pretty:

  book.metadata.add_metadata("meta", "") do |metadata|
    metadata.instance_variable_set(:@attributes, { name:"calibre:series", content: book_series })
  end

  book.metadata.add_metadata("meta", "") do |metadata|
    metadata.instance_variable_set(:@attributes, { name:"calibre:series_index", content: book_number.to_f.to_s })
  end

I would have thought add_metadata would work, but it seems to be very strictly defined to whatever format the refine and output is.

Is there some nicer way to do this via the publicly exposed API?

Thank you!

@hfabre
Copy link

hfabre commented Apr 10, 2024

I was wondering the same, but after digging into the tests to see how this lib handle cover to get inspiration for my own tool i stumbled across this

So i bet something like this should work :

book.metadata.add_oldstyle_meta(nil, { name: "calibre:series", content: book_series })

Sorry if i'm wrong, i'm not using this gem for now but i probably will, it looks awesome !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants