Welut是一个电子书转换器

welut的Python项目详细描述


Welut is a ebook converter

要求

  • 电子书转换:$ sudo apt install calibre-将epub&;mobi转换为pdf。
  • pdftocairo:$ sudo apt install -ypoppler-utils-convert pdf to images

安装

欢迎直接从PyPI

  1. 安装软件包。
$ pip install welut
  1. 别忘了把'welut'添加到'INSTALLED_APPS'中。
# settings.py
INSTALLED_APPS = [
    ....
    'welut',
]
  1. 执行makemigration&migrate
./manage.py makemigrations welut
./manage.py migrate welut

配置(settings.py

WELUT_EXTENSIONS = ['.pdf', '.epub', '.mobi']         # support file extensions
WELUT_REMOVED_EXTENSIONS = ['.pdf', '.epub', '.mobi'] # file to remove after uploaded
WELUT_IMAGES_EXTENSION = '.png'                       # format images extension

使用量

您可以使用ForeignKeyOneToOneField

from django.db import models
from welut.models import EbookConverter


class EBook(models.Model):
    title = models.CharField(max_length=200)
    ebook_file = models.ForeignKey(EbookConverter, related_name='ebook_file')
    created = models.DateTimeField(auto_now_add=True)
    modified = models.DateTimeField(auto_now=True)

    def __str__(self):
        return self.title

    def get_files(self):
        """ return list images of ebook per-page """
        return self.ebook_file.get_files()

模板

{% for img_url in object.get_files %}
  <img src="{{ MEDIA_URL }}{{ img_url }}">
{% endfor %}

使用预览

https://raw.githubusercontent.com/agusmakmun/welut/master/welut_demo/media/welut-demo.png

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java使用split函数分割字符串,但没有得到期望的结果   未找到包含derby数据库嵌入架构的sql Java桌面应用程序错误   java elasticsearch vs solr用于定制全文搜索系统   java Android:创建没有startOffset的动画延迟?   java如何查看其他应用程序接收的数据?   java如何在Linux中使用D和classpath选项运行jar文件   java和域设计最佳实践   具有相同内存位置的java数组,将显示为输出   连接到java中的elasticsearch?   Java Playframework重定向到带有Json负载的外部url   java无法在Android平台上使用InputStream为蓝牙socket创建ObjectInputStream   使用POI将Excel日期转换为Java日期,年份未正确显示   oracle从数据库层还是Java层调用webservice?