moviewyrm/bookwyrm/activitypub/book.py

68 lines
1.6 KiB
Python
Raw Normal View History

''' book and author data '''
from dataclasses import dataclass, field
from typing import List
2020-03-28 02:52:05 +00:00
2020-11-28 01:58:21 +00:00
from .base_activity import ActivityObject
from .image import Image
2020-03-28 02:52:05 +00:00
@dataclass(init=False)
class Book(ActivityObject):
''' serializes an edition or work, abstract '''
title: str
sortTitle: str = ''
subtitle: str = ''
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: [])
2020-03-28 04:28:52 +00:00
authors: List[str] = field(default_factory=lambda: [])
firstPublishedDate: str = ''
publishedDate: str = ''
openlibraryKey: str = ''
librarythingKey: str = ''
goodreadsKey: str = ''
2020-03-28 02:52:05 +00:00
2020-11-28 01:58:21 +00:00
cover: Image = field(default_factory=lambda: {})
type: str = 'Book'
2020-03-28 02:52:05 +00:00
@dataclass(init=False)
class Edition(Book):
''' Edition instance of a book object '''
work: str
isbn10: str = ''
isbn13: str = ''
oclcNumber: str = ''
asin: str = ''
pages: str = ''
physicalFormat: str = ''
publishers: List[str] = field(default_factory=lambda: [])
type: str = 'Edition'
2020-03-28 02:52:05 +00:00
2020-05-10 04:52:13 +00:00
@dataclass(init=False)
class Work(Book):
''' work instance of a book object '''
lccn: str = ''
2020-11-29 01:41:57 +00:00
defaultEdition: str = ''
editions: List[str]
type: str = 'Work'
2020-05-10 04:52:13 +00:00
@dataclass(init=False)
class Author(ActivityObject):
''' author of a book '''
name: str
born: str = ''
died: str = ''
aliases: str = ''
bio: str = ''
openlibraryKey: str = ''
wikipediaLink: str = ''
type: str = 'Person'