From 3626db3c1a517239ad9029026cd7d26c37714b0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Jaenisch?= Date: Sat, 30 Apr 2022 15:25:09 +0200 Subject: [PATCH] Add Calibre importer for CSV exports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Jaenisch --- bookwyrm/importers/__init__.py | 1 + bookwyrm/importers/calibre_import.py | 8 ++++++++ bookwyrm/templates/import/import.html | 3 +++ bookwyrm/views/imports/import_data.py | 3 +++ 4 files changed, 15 insertions(+) create mode 100644 bookwyrm/importers/calibre_import.py diff --git a/bookwyrm/importers/__init__.py b/bookwyrm/importers/__init__.py index dd3d62e8..6ce50f16 100644 --- a/bookwyrm/importers/__init__.py +++ b/bookwyrm/importers/__init__.py @@ -1,6 +1,7 @@ """ import classes """ from .importer import Importer +from .calibre_import import CalibreImporter from .goodreads_import import GoodreadsImporter from .librarything_import import LibrarythingImporter from .openlibrary_import import OpenLibraryImporter diff --git a/bookwyrm/importers/calibre_import.py b/bookwyrm/importers/calibre_import.py new file mode 100644 index 00000000..a0d71263 --- /dev/null +++ b/bookwyrm/importers/calibre_import.py @@ -0,0 +1,8 @@ +""" handle reading a csv from calibre """ +from . import Importer + + +class CalibreImporter(Importer): + """csv downloads from OpenLibrary""" + + service = "Calibre" diff --git a/bookwyrm/templates/import/import.html b/bookwyrm/templates/import/import.html index 6df7c084..fc00389c 100644 --- a/bookwyrm/templates/import/import.html +++ b/bookwyrm/templates/import/import.html @@ -32,6 +32,9 @@ + diff --git a/bookwyrm/views/imports/import_data.py b/bookwyrm/views/imports/import_data.py index 6e50a14c..06354589 100644 --- a/bookwyrm/views/imports/import_data.py +++ b/bookwyrm/views/imports/import_data.py @@ -11,6 +11,7 @@ from django.views import View from bookwyrm import forms, models from bookwyrm.importers import ( + CalibreImporter, LibrarythingImporter, GoodreadsImporter, StorygraphImporter, @@ -52,6 +53,8 @@ class Import(View): importer = StorygraphImporter() elif source == "OpenLibrary": importer = OpenLibraryImporter() + elif source == "Calibre": + importer = CalibreImporter() else: # Default : Goodreads importer = GoodreadsImporter()