Nikita Leshenko 3458394a6c Use bytes replacement pattern for bytes-based re.sub
In this case data and regex are bytes, so repl argument should be bytes as
well. Before this fix, we would sometimes get this error:

```
calibre, version 7.3.0 (linux, embedded-python: False)
Conversion error: Failed: Convert book 1 of 1 (xxxxxxxxxx)
--- snip ---
2024-03-24 23:43:49 [INFO] Upgrading to EPUB 3...
Traceback (most recent call last):
  File "/usr/bin/calibre-parallel", line 21, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/lib64/calibre/calibre/utils/ipc/worker.py", line 214, in main
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/calibre/calibre/gui2/convert/gui_conversion.py", line 38, in gui_convert_override
    gui_convert(input, output, recommendations, notification=notification,
  File "/usr/lib64/calibre/calibre/gui2/convert/gui_conversion.py", line 25, in gui_convert
    plumber.run()
  File "/usr/lib64/calibre/calibre/ebooks/conversion/plumber.py", line 1281, in run
    self.output_plugin.convert(self.oeb, self.output, self.input_plugin,
  File "calibre_plugins.kepubout.conversion.kepub_output", line 146, in convert
  File "/usr/lib64/calibre/calibre/ebooks/conversion/plugins/epub_output.py", line 275, in convert
    encryption = self.upgrade_to_epub3(tdir, opf, encryption)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/calibre/calibre/ebooks/conversion/plugins/epub_output.py", line 319, in upgrade_to_epub3
    container.commit()
  File "/usr/lib64/calibre/calibre/ebooks/oeb/polish/container.py", line 1360, in commit
    super().commit(keep_parsed=keep_parsed)
  File "/usr/lib64/calibre/calibre/ebooks/oeb/polish/container.py", line 1073, in commit
    self.commit_item(name, keep_parsed=keep_parsed)
  File "/usr/lib64/calibre/calibre/ebooks/oeb/polish/container.py", line 1017, in commit_item
    data = self.serialize_item(name)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/calibre/calibre/ebooks/oeb/polish/container.py", line 1008, in serialize_item
    data = re.sub(br'(<[/]{0,1})opf:', r'\1', data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib64/python3.12/re/__init__.py", line 186, in sub
    return _compile(pattern, flags).sub(repl, string, count)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: sequence item 1: expected str instance, bytes found
```

In my case, the error would show up when converting EPUBs to KEBPUBs.
2024-03-24 23:56:00 +02:00
...
2024-01-03 21:22:10 +05:30
2023-12-28 11:27:24 +05:30
2020-08-22 18:47:55 +05:30
2024-03-19 20:28:18 +08:00
2024-03-24 17:09:58 +05:30
2024-01-04 07:24:39 +01:00
2021-01-24 19:53:30 +09:00
2021-01-24 19:53:30 +09:00

calibre

calibre is an e-book manager. It can view, convert, edit and catalog e-books in all of the major e-book formats. It can also talk to e-book reader devices. It can go out to the internet and fetch metadata for your books. It can download newspapers and convert them into e-books for convenient reading. It is cross platform, running on Linux, Windows and macOS.

For more information, see the calibre About page.

Build Status

Screenshots

Screenshots page

Usage

See the User Manual.

Development

Setting up a development environment for calibre.

A tarball of the source code for the current calibre release.

Bugs

Bug reports and feature requests should be made in the calibre bug tracker at Launchpad. GitHub is only used for code hosting and pull requests.

Support calibre

calibre is a result of the efforts of many volunteers from all over the world. If you find it useful, please consider contributing to support its development. Donate to support calibre development.

Building calibre binaries

See Build instructions for instructions on how to build the calibre binaries and installers for all the platforms calibre supports.

calibre package versions in various repositories

Packaging Status

Description
The official source code repository for the calibre ebook manager
Readme GPL-3.0 365 MiB
Languages
Python 92.5%
C 3.3%
C++ 3.1%
HTML 0.4%
Shell 0.2%
Other 0.2%