GithubHelp home page GithubHelp logo

gryf / ebook-converter Goto Github PK

View Code? Open in Web Editor NEW
38.0 5.0 6.0 2.16 MB

Commandline tool for converting between several e-books formats, based on Calibre project.

License: GNU General Public License v3.0

Python 98.79% C 0.32% CSS 0.16% XSLT 0.69% HTML 0.04%
calibre commandline converter ebook epub lrf mobi

ebook-converter's Introduction

Ebook converter

This is impudent ripoff of the bits from Calibre project, and is aimed only for converter thing.

My motivation is to have only converter for ebooks run from commandline, without all of those bells and whistles Calibre has, and with cleanest more pythonic approach.

Requirements

To build and run ebook converter, you'll need:

  • Python 3.6 or newer
  • Liberation fonts
  • setuptools
  • pdftohtml, pdfinfo and pdftoppm from poppler project for conversion from PDF available in $PATH

No Python2 support. Even if Calibre probably still is able to run on Python2, I do not have an intention to support it.

What's supported

To be able to perform some optimization and make converter more reliable and easy to use, first I need to remove some of the features, which are totally not crucial in my opinion, although they might be re-added later, like, for instance there is no automatic language translations depending on the locale settings.

First of all, I'm in the process of getting rid of strongly coupled things to QT libraries, and GUI code as well. Second, I'll try to minimize all modifications from third parties (external modules copied into Calibre project for instance), and make a huge cleanup. I'm not sure if I find time and strength for doing it completely, but I'll try.

Windows is not currently supported, because of the original spaghetti code. This may change in the future, after cleanup of mentioned pasta would be completed.

So called Kindle periodical format is not supported, since all we do care are local files. If there would be downloaded periodical thing (using Calibre for example), it would be treated as common book.

Input formats

Currently, I've tested following input formats:

  • Microsoft Word 2007 and up (docx)
  • EPUB, both v2 and v3 (epub)
  • LibreOffice (odt)
  • Pure text files (txt)
  • Several PalmOS (pdb) readers support:
    • Plucker
    • Adobe Reader for PalmOS
    • eReader various formats
    • Weasel Reader
    • Haodoo Reader
  • Rich Text Format (rtf)
  • Mobipocket (mobi)
  • Kindle (azw3, azw4, โ€ฆ)
  • FictionBook (fb2)
  • Hyper Text Markup Language (html)
  • Adobe Portable Document Format (pdf)
  • Broadband eBooks (shortened as BBeB) (lrf)

Note, that old Microsoft doc format is not supported, although old documents can be fairly easy converted using text processors programs, like Microsoft Word or LibreOffice to supported formats.

Output formats

Currently, following formats are supported:

  • Broadband eBooks (shortened as BBeB) (lrf)
  • EPUB v2 (epub)
  • Mobipocket (mobi)
  • Microsoft Word (docx)
  • zipped HTML file with additional assets, like images (htmlz)
  • Text (txt)

Installation

Ebook converter is somewhere in between in alpha and beta stage, therefore I didn't place it on pypi yet.

Preferred way for installation is to use virtualenv (or any other virtualenv managers), i.e:

$ python -m venv venv
$ . venv/bin/activate
(venv) $ git clone https://github.com/gryf/ebook-converter
(venv) $ cd ebook-converter
(venv) $ pip install -r requirements.txt .

Simple as that. And from now on, you can issue converter:

(venv) $ ebook-converter book.docx book.lrf

License

This work is licensed on GPL3 license, like the original work. See LICENSE file for details.

ebook-converter's People

Contributors

gryf avatar keshavbhatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ebook-converter's Issues

SyntaxError: invalid syntax Error While trying a conversion

Am getting the following error when trying :

ebook-converter o.docx o.lrf
Traceback (most recent call last):
  File "/home/bulld/ebook-convert/venv/bin/ebook-converter", line 5, in <module>
    from ebook_converter.main import run
  File "/home/bulld/ebook-convert/venv/lib/python3.5/site-packages/ebook_converter/__init__.py", line 16, in <module>
    from ebook_converter.ebooks.html_entities import html5_entities
  File "/home/bulld/ebook-convert/venv/lib/python3.5/site-packages/ebook_converter/ebooks/__init__.py", line 124
    print(f'Failed to render {path_to_html}')
                                           ^
SyntaxError: invalid syntax

Would be perfect to have some options

like to justify the text and also choose a font.
Then if you could convert whole directories with such a script... it would be really, but really awesome.

It doesn't work on Python 3.8.10

It doesn't work, i want convert .txt to .epub/.mobi without gui and use it in Calibre-Web

System: Ubuntu 20.04.2 LTS (GNU/Linux 5.4.0-77-generic x86_64)
Python 3.8.10

type

ebook-converter ebook.txt ebook.epub

return

Traceback (most recent call last):
File "/home/workspace/venv/bin/ebook-converter", line 8, in
sys.exit(run())
TypeError: run() missing 1 required positional argument: 'args'

cat /home/workspace/venv/bin/ebook-converter/ebook-converter

import re
import sys
from ebook_converter.main import run
if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
    sys.exit(run())

Would love to be able to use this on windows

Compiled it on windows and it does not work. Read your comments saying windows not supported. Disappointed to say the least as ebook-convert is a mess on windows. Over 160mbs of garbage I don't need to run the exe, since you got it to work in 7.5mb... Any plans on a Windows version?

Missing module 'ebook_converter.ebooks.docx.dump'

When running conversion using docx module, python throws an exception:

Traceback (most recent call last):
  File "/path/bin/ebook-converter", line 11, in <module>
    load_entry_point('ebook-converter==4.9.1', 'console_scripts', 'ebook-converter')()
  File "/path/lib/python3.7/site-packages/ebook_converter-4.9.1-py3.7.egg/ebook_converter/main.py", line 8, in run
    sys.exit(main())
  File "/path/lib/python3.7/site-packages/ebook_converter-4.9.1-py3.7.egg/ebook_converter/ebooks/conversion/cli.py", line 364, in main
    parser, plumber = create_option_parser(args, log)
  File "/path/lib/python3.7/site-packages/ebook_converter-4.9.1-py3.7.egg/ebook_converter/ebooks/conversion/cli.py", line 311, in create_option_parser
    from ebook_converter.ebooks.conversion.plumber import Plumber
  File "/path/lib/python3.7/site-packages/ebook_converter-4.9.1-py3.7.egg/ebook_converter/ebooks/conversion/plumber.py", line 9, in <module>
    from ebook_converter.customize.ui import input_profiles, output_profiles, \
  File "/path/lib/python3.7/site-packages/ebook_converter-4.9.1-py3.7.egg/ebook_converter/customize/ui.py", line 12, in <module>
    from ebook_converter.customize import builtins
  File "/path/lib/python3.7/site-packages/ebook_converter-4.9.1-py3.7.egg/ebook_converter/customize/builtins.py", line 651, in <module>
    from ebook_converter.ebooks.conversion.plugins.docx_output import DOCXOutput
  File "/path/lib/python3.7/site-packages/ebook_converter-4.9.1-py3.7.egg/ebook_converter/ebooks/conversion/plugins/docx_output.py", line 7, in <module>
    from ebook_converter.ebooks.docx.dump import do_dump
ModuleNotFoundError: No module named 'ebook_converter.ebooks.docx.dump'

from ebook_converter.ebooks.docx.dump import do_dump

In current tree, there is only do_dump call, no dump.py file or any other providing do_dump function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.