Adds support for openlibrary csv shelf name format

This commit is contained in:
Mouse Reeve
2021-12-14 11:58:56 -08:00
parent 79af354dfd
commit bb69c32a6c
6 changed files with 106 additions and 6 deletions

View File

@ -3,4 +3,5 @@
from .importer import Importer
from .goodreads_import import GoodreadsImporter
from .librarything_import import LibrarythingImporter
from .openlibrary_import import OpenLibraryImporter
from .storygraph_import import StorygraphImporter

View File

@ -26,7 +26,7 @@ class Importer:
("authors", ["author", "authors", "primary author"]),
("isbn_10", ["isbn10", "isbn"]),
("isbn_13", ["isbn13", "isbn", "isbns"]),
("shelf", ["shelf", "exclusive shelf", "read status"]),
("shelf", ["shelf", "exclusive shelf", "read status", "bookshelf"]),
("review_name", ["review name"]),
("review_body", ["my review", "review"]),
("rating", ["my rating", "rating", "star rating"]),
@ -36,9 +36,9 @@ class Importer:
]
date_fields = ["date_added", "date_started", "date_finished"]
shelf_mapping_guesses = {
"to-read": ["to-read"],
"read": ["read"],
"reading": ["currently-reading", "reading"],
"to-read": ["to-read", "want to read"],
"read": ["read", "already read"],
"reading": ["currently-reading", "reading", "currently reading"],
}
def create_job(self, user, csv_file, include_reviews, privacy):
@ -90,7 +90,7 @@ class Importer:
def get_shelf(self, normalized_row):
"""determine which shelf to use"""
shelf_name = normalized_row["shelf"]
shelf_name = normalized_row["shelf"].lower()
shelf = [
s for (s, gs) in self.shelf_mapping_guesses.items() if shelf_name in gs
]

View File

@ -0,0 +1,8 @@
""" handle reading a csv from openlibrary"""
from . import Importer
class OpenLibraryImporter(Importer):
"""csv downloads from OpenLibrary"""
service = "OpenLibrary"

View File

@ -3,6 +3,6 @@ from . import Importer
class StorygraphImporter(Importer):
"""csv downloads from librarything"""
"""csv downloads from Storygraph"""
service = "Storygraph"