Models

Novel

class novelsave_sources.Novel(title: str, url: str, author: Optional[str] = None, synopsis: List[str] = <factory>, thumbnail_url: Optional[str] = None, status: Optional[str] = None, lang: str = 'en', volumes: List[novelsave_sources.models.volume.Volume] = <factory>, metadata: List[novelsave_sources.models.metadata.Metadata] = <factory>)[source]

Data class for parsed novels

title

The name of the novel.

Type

str

url

The url pointing to the webpage of novel.

Type

str

author

The author of the novel.

Type

Optional[str]

synopsis

The description of the novel in lines or paragraphs.

Type

List[str]

thumbnail_url

The url pointing to the thumbnail image of the novel

Type

Optional[str]

status

The status of the novel, can be ongoing, completed, or hiatus

Type

Optional[str]

lang

The language of the novel. This is not the original language, however the language this novel is currently readable in.

Type

str

volumes

List of volumes of the novel

Type

List[Volume]

metadata

List of metadata of the novel

Type

List[Metadata]

add_metadata(*args, **kwargs)[source]

Shorthand for adding metadata

get_default_volume()[source]

Get or create the default volume for the novel

If the novel already has volumes, this method returns the first volume, otherwise creates and adds the default volume to novel and returns that volume.

Volume

class novelsave_sources.Volume(index: int, name: str, chapters: List[novelsave_sources.models.chapter.Chapter] = <factory>)[source]

Data class that identifies a single volume in a novel

index

The order of volume in the novel. Lowest first.

Type

int

name

The name of the volume.

Type

str

chapters

The chapters belonging to volume under novel.

Type

List[Chapter]

add(chapter: novelsave_sources.models.chapter.Chapter)[source]

Shorthand method to add chapter into this volume

static default()[source]

Factory method that returns volume object with values identifying it as default.

This method is used when a particular source does not define any volumes for the novel

Chapter

class novelsave_sources.Chapter(index: int = - 1, title: Optional[str] = None, paragraphs: Optional[str] = None, url: Optional[str] = None, updated: Optional[datetime.datetime] = None)[source]

Data class that identifies a single chapter in a novel

index

The order of chapter in the novel. Lowest first.

Type

int

title

The title of the chapter.

Type

str

paragraphs

The reading content of the chapter in html.

Type

Optional[str]

url

The url pointing to the chapter in the web.

Type

str

updated

The time this chapter was last updated as defined by the source.

Type

str

Metadata

class novelsave_sources.Metadata(name: str, value: str, others: Optional[dict] = None)[source]

Data class that holds a single value of metadata for novels

name

Name of the metadata

Example: subject, tag

Type

str

value

Value of the metadata

Type

str

others

A dictionary value defining other attributes of the metadata

Type

dict

namespace

The namespace of the metadata. This is either Dublin Core (DC) or OPF.

Dublin Core (DC) has the following tags:

title, language, subject, creator, contributor, publisher, rights, coverage, date, description

The __init__() method automatically identifies the namespace.

Type

str

__init__(name: str, value: str, others: Optional[dict] = None)[source]

The namespace attribute is calculated by checking if the name exists in dublin core tags. If so, namespace is set Dublin Core (DC) otherwise it is set OPF.

Refer to name, value, and others for more details on parameters.