1
0
Fork 0
bookwyrm/bookwyrm/activitypub/book.py
Jascha Urbach ac8b060d58
Isfdb ID for books and authors (#2482)
* New ID: Audible ASIN

Audible belongs to Amazon BUT they do not share the same IDs. The Audible ASIN of an audiobook is never the same as the Amazon ASIN.

Yeah, I know, Amazon is great. The fact that the ASIN is a good distinction for different works and editions bothers me more than I will ever be willing to admint.

* New ID "ISFDB"

Internet Speculative Ficiton Database ID for books and authors.
Links to the entry if set.

* Added aasin to test

Added aasin to test

* the answer expects more emptxy fields...
2022-12-11 11:33:33 -08:00

94 lines
2.3 KiB
Python

""" book and author data """
from dataclasses import dataclass, field
from typing import List
from .base_activity import ActivityObject
from .image import Document
# pylint: disable=invalid-name
@dataclass(init=False)
class BookData(ActivityObject):
"""shared fields for all book data and authors"""
openlibraryKey: str = None
inventaireId: str = None
librarythingKey: str = None
goodreadsKey: str = None
bnfId: str = None
viaf: str = None
wikidata: str = None
asin: str = None
aasin: str = None
isfdb: str = None
lastEditedBy: str = None
links: List[str] = field(default_factory=lambda: [])
fileLinks: List[str] = field(default_factory=lambda: [])
# pylint: disable=invalid-name
@dataclass(init=False)
class Book(BookData):
"""serializes an edition or work, abstract"""
title: str
sortTitle: str = None
subtitle: str = None
description: str = ""
languages: List[str] = field(default_factory=lambda: [])
series: str = ""
seriesNumber: str = ""
subjects: List[str] = field(default_factory=lambda: [])
subjectPlaces: List[str] = field(default_factory=lambda: [])
authors: List[str] = field(default_factory=lambda: [])
firstPublishedDate: str = ""
publishedDate: str = ""
cover: Document = None
type: str = "Book"
# pylint: disable=invalid-name
@dataclass(init=False)
class Edition(Book):
"""Edition instance of a book object"""
work: str
isbn10: str = ""
isbn13: str = ""
oclcNumber: str = ""
pages: int = None
physicalFormat: str = ""
physicalFormatDetail: str = ""
publishers: List[str] = field(default_factory=lambda: [])
editionRank: int = 0
type: str = "Edition"
# pylint: disable=invalid-name
@dataclass(init=False)
class Work(Book):
"""work instance of a book object"""
lccn: str = ""
editions: List[str] = field(default_factory=lambda: [])
type: str = "Work"
# pylint: disable=invalid-name
@dataclass(init=False)
class Author(BookData):
"""author of a book"""
name: str
isni: str = None
viafId: str = None
gutenbergId: str = None
born: str = None
died: str = None
aliases: List[str] = field(default_factory=lambda: [])
bio: str = ""
wikipediaLink: str = ""
type: str = "Author"