Skip to content

[Feature]: setup plugin with working metadataTab - #6

Merged
MonkeyDo merged 18 commits into
bookbrainz:gsoc-2026from
Waqibsk:setup-plugin
Aug 30, 2026
Merged

MonkeyDo merged 18 commits into
bookbrainz:gsoc-2026from
Waqibsk:setup-plugin

Conversation

@Waqibsk

@Waqibsk Waqibsk commented Jun 25, 2026

Copy link
Copy Markdown

No description provided.

@MonkeyDo

MonkeyDo commented Jul 8, 2026

Copy link
Copy Markdown

Hello,
I am still unable to load the plugin. I tried zipping the folder myself, but also using the calibre-customize command suggested in #7

No luck with either.
I do see this debug trace when I open calibre from the command line:

Traceback (most recent call last):
  File "calibre/gui2/ui.py", line 134, in __init__
  File "calibre/gui2/ui.py", line 152, in init_iaction
  File "calibre/customize/__init__.py", line 678, in load_actual_plugin
  File "importlib/__init__.py", line 88, in import_module
  File "<frozen importlib._bootstrap>", line 1406, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
  File "calibre/customize/zipplugin.py", line 219, in exec_module
  File "calibre_plugins.calibbre.main", line 3, in <module>
    from .plugin import BookBrainzPlugin
  File "calibre/customize/zipplugin.py", line 219, in exec_module
  File "calibre_plugins.calibbre.plugin", line 3, in <module>
    from .ui import Ui_Dialog
  File "calibre/customize/zipplugin.py", line 219, in exec_module
  File "calibre_plugins.calibbre.ui.__init__", line 5, in <module>
    from .metadata_tab import MetadataTabMixin
  File "calibre/customize/zipplugin.py", line 219, in exec_module
  File "calibre_plugins.calibbre.ui.metadata_tab", line 6, in <module>
    from ..workers import (
    ...<2 lines>...
    )
  File "calibre/customize/zipplugin.py", line 219, in exec_module
  File "calibre_plugins.calibbre.workers", line 3, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

@Waqibsk

Waqibsk commented Jul 10, 2026 •

Copy link
Copy Markdown
Author

Hmm it seems the requests library by default is not supported by calibre ( but apperantly it was working just fine for me during development while i used calibre-customize -b . && calibre-debug -g, maybe some environment issue ).

Replaced the implementation using the standard python library urllib.
it should work now.

would like to know if it fixes the issue

Comment thread ui/metadata_tab.py Outdated
retranslate_placeholder(self, _translate)

self.pushButton_update_metadataTab.setText(
_translate("Dialog", "Update Book Metadata")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalization

Comment thread ui/metadata_tab.py Outdated
book_name = self.mi.title
if not book_name:
QMessageBox.warning(
self, "Input Error", "The book should have a valid Name"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"name" here shouldn't be capitalized}
Same for "error"

Comment thread ui/metadata_tab.py
Comment thread ui/metadata_tab.py Outdated
if not bbid:
continue
bookTitle = item.get("defaultAlias", {}).get("name", "Unknown")
bookLang = item.get("defaultAlias", {}).get("language", "eng")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This represents the language of the title rather than the language of the edition.
It's a bit confusing, I know, but the book language should be queried from item.get("languages", []) whichj is an array of language codes (there can be more than one, although that is rare)

"languages": [
    "eng",
    "fra"
  ],

should display "eng, fra" as a composited string

Is there a built-in way to translate those codes to a language name such as "English, French" or something like that?

Comment thread ui/metadata_tab.py Outdated
self.pushButton_fetch_metadataTab.setEnabled(False)
self.pushButton_update_metadataTab.setEnabled(False)
self.stackedWidget_noResults_metadataTab.setCurrentIndex(1)
self.label_noMetadata_metadataTab_2.setText("Network Error")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalization

Comment thread ui/metadata_tab.py Outdated
Comment on lines +215 to +218
languages = results.get("languages") or []
self.label_data_language_metadataTab.setText(
", ".join(languages) if languages else "Unknown"
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that the languages here are correct, pulled from the languages array and joined with a comma, contrarily to the search results
This probably warrants creating a utility functiion to extract languages and return a string, that can be reused.

Comment thread ui/metadata_tab.py Outdated
Comment on lines +233 to +249
cleaned = release_date.lstrip("+00")[:10]
parsed = None
for fmt in ("%Y-%m-%d", "%Y-%m", "%Y"):
try:
parsed = datetime.strptime(cleaned, fmt)
break
except ValueError:
pass
if parsed:
if fmt == "%Y-%m-%d":
release_date = parsed.strftime("%B %d, %Y")
elif fmt == "%Y-%m":
release_date = parsed.strftime("%B %Y")
else:
release_date = str(parsed.year)
else:
release_date = release_date.lstrip("+")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this whole date parsing routine can be improved.
I put together another approach using regepxs to handle the extended date representation (that +/-YY at the beginning, which is not necessarily "+00", although for Editions they should be very rare), and format it, defaulting to a locale-aware date-only format:
https://www.onlineide.pro/playground/share/cf958f35-b91a-412b-9d63-a4c8dd21bab2

That being said, There might be other options like using a library.

Comment thread ui/metadata_tab.py Outdated
authors.append(name)

if not authors:
authors = ["Unknown Author"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capitalization

Comment thread ui/metadata_tab.py Outdated

release_date = bb_data.get("releaseEventDate") or ""
if release_date:
cleaned = release_date.lstrip("+00")[:10]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment about dates as above.
Whatever the solution chosen, it should be implemented in a reusable method to avoid code duplication.

@Waqibsk

Waqibsk commented Aug 8, 2026

Copy link
Copy Markdown
Author

Hi @MonkeyDo, added the suggested changes. Let me know if there is anything else

@Waqibsk

Waqibsk commented Aug 8, 2026

Copy link
Copy Markdown
Author

Also a point to note: the /search api endpoint still does not return author names, so the authors column will be empty for now

@MonkeyDo MonkeyDo left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the purposes of reviewing, clumping in 3 PRs into this one made things much more complicated.
I would much, much have prefered that fixes and improivements were applied directly to each PR, especially if the feedback was left in another PR.

Understand that a PR that add 1,488 line sof code and removes 689 lines is absolutely awful to review.

That beign said, I think this is ready to merge.

@MonkeyDo
MonkeyDo merged commit ee40009 into bookbrainz:gsoc-2026 Aug 30, 2026
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

Successfully merging this pull request may close these issues.

2 participants