Skip to content

Models

NZB

Bases: ParentModel

Represents a complete NZB file.

file cached property

file: File

The main content file (episode, movie, etc) in the NZB.

files instance-attribute

files: tuple[File, ...]

File objects representing the files included in the NZB.

groups cached property

groups: tuple[str, ...]

Tuple of unique groups across all the files in the NZB.

metadata class-attribute instance-attribute

metadata: Metadata = Metadata()

Optional creator-definable metadata for the contents of the NZB.

names cached property

names: tuple[str, ...]

Tuple of unique file names across all the files in the NZB. May return an empty tuple if it fails to extract the name for every file.

posters cached property

posters: tuple[str, ...]

Tuple of unique posters across all the files in the NZB.

size cached property

size: ByteSize

Total size of all the files in the NZB.

stems cached property

stems: tuple[str, ...]

Tuple of unique file stems (basename) across all the files in the NZB. May return an empty tuple if it fails to extract the stem for every file.

suffixes cached property

suffixes: tuple[str, ...]

Tuple of unique file extensions across all the files in the NZB. May return an empty tuple if it fails to extract the extension for every file.

get_par2_percentage

get_par2_percentage() -> float

Percentage of recovery based on the total .par2 size divided by the total size of all files.

Source code in src/nzb/_models.py
def get_par2_percentage(self) -> float:
    """
    Percentage of recovery based on the total `.par2` size divided by the total size of all files.
    """
    return (sum(file.size for file in self.files if file.is_par2()) / self.size) * 100

has_par2

has_par2() -> bool

Return True if there's at least one .par2 file in the NZB, False otherwise.

Source code in src/nzb/_models.py
def has_par2(self) -> bool:
    """
    Return `True` if there's at least one `.par2` file in the NZB, `False` otherwise.
    """
    return any(file.is_par2() for file in self.files)

has_rar

has_rar() -> bool

Return True if any file in the NZB is a .rar file, False otherwise.

Source code in src/nzb/_models.py
def has_rar(self) -> bool:
    """
    Return `True` if any file in the NZB is a `.rar` file, `False` otherwise.
    """
    return any(file.is_rar() for file in self.files)

is_obfuscated

is_obfuscated() -> bool

Return True if any file in the NZB is obfuscated, False otherwise.

Source code in src/nzb/_models.py
def is_obfuscated(self) -> bool:
    """
    Return `True` if any file in the NZB is obfuscated, `False` otherwise.
    """
    return any(file.is_obfuscated() for file in self.files)

is_rar

is_rar() -> bool

Return True if all files in the NZB are .rar files, False otherwise.

Source code in src/nzb/_models.py
def is_rar(self) -> bool:
    """
    Return `True` if all files in the NZB are `.rar` files, `False` otherwise.
    """
    return all(file.is_rar() for file in self.files)

Metadata

Bases: ParentModel

Optional creator-definable metadata for the contents of the NZB.

category class-attribute instance-attribute

category: str | None = None

Category.

password cached property

password: str | None

Return the first password from Metadata.passwords if it exists, None otherwise.

This is essentially just syntactic sugar for password = passwords[0] if passwords else None because although the spec allows multiple passwords, single passwords are far more common.

passwords class-attribute instance-attribute

passwords: tuple[str, ...] | None = None

Password(s).

tag cached property

tag: str | None

The first tag from Metadata.tags if it exists, None otherwise.

This is essentially just syntactic sugar for tag = tags[0] if tags else None because although the spec allows multiple tags, single tags are far more common.

tags class-attribute instance-attribute

tags: tuple[str, ...] | None = None

Tag(s).

title class-attribute instance-attribute

title: str | None = None

Title.

Segment

Bases: ParentModel

One part segment of a file.

message_id instance-attribute

message_id: str

Message ID of the segment.

number instance-attribute

number: int

Number of the segment.

size instance-attribute

size: ByteSize

Size of the segment.

File

Bases: ParentModel

Represents a complete file, consisting of segments that make up a file.

datetime instance-attribute

datetime: UTCDateTime

The date and time when the file was posted, in UTC.

groups instance-attribute

groups: tuple[str, ...]

Groups that reference the file.

name cached property

name: str

Complete name of the file with it's extension extracted from the subject. May return an empty string if it fails to extract the name.

poster instance-attribute

poster: str

The poster of the file.

segments instance-attribute

segments: tuple[Segment, ...]

Segments that make up the file.

size cached property

size: ByteSize

Size of the file calculated from the sum of segment sizes.

stem cached property

stem: str

Base name of the file without it's extension extracted from the File.name. May return an empty string if it fails to extract the stem.

subject instance-attribute

subject: str

The subject of the file.

suffix cached property

suffix: str

Extension of the file extracted from the File.name. May return an empty string if it fails to extract the extension.

is_obfuscated

is_obfuscated() -> bool

Return True if the file is obfuscated, False otherwise.

Source code in src/nzb/_models.py
def is_obfuscated(self) -> bool:
    """
    Return `True` if the file is obfuscated, `False` otherwise.
    """
    return _is_obfuscated(self.stem)

is_par2

is_par2() -> bool

Return True if the file is a .par2 file, False otherwise.

Source code in src/nzb/_models.py
def is_par2(self) -> bool:
    """
    Return `True` if the file is a `.par2` file, `False` otherwise.
    """
    return _is_par2(self.name)

is_rar

is_rar() -> bool

Return True if the file is a .rar file, False otherwise.

Source code in src/nzb/_models.py
def is_rar(self) -> bool:
    """
    Return `True` if the file is a `.rar` file, `False` otherwise.
    """
    return _is_rar(self.name)