Meta Editor
NZBMetaEditor
Initialize the NZBMetaEditor instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nzb |
str
|
NZB content as a string. |
required |
encoding |
str
|
Encoding of the NZB content, defaults to |
'utf-8'
|
Raises:
Type | Description |
---|---|
InvalidNZBError
|
Raised if the input is not valid XML. However, being valid XML doesn't guarantee it's a correctly structured NZB. |
Source code in src/nzb/_core.py
append
append(*, title: str | None = None, passwords: Iterable[str] | str | None = None, tags: Iterable[str] | str | None = None, category: str | None = None) -> Self
Append metadata fields to the existing metadata in the NZB.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
The title metadata field. |
None
|
passwords |
Iterable[str] | str
|
Password(s) for the NZB file. |
None
|
tags |
Iterable[str] | str
|
Tag(s) associated with the NZB file. |
None
|
category |
str
|
Category of the NZB file. |
None
|
Returns:
Type | Description |
---|---|
Self
|
Returns itself. |
Source code in src/nzb/_core.py
clear
clear() -> Self
from_file
classmethod
Create an NZBMetaEditor instance from an NZB file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nzb |
StrPath
|
File path to the NZB. |
required |
encoding |
str
|
Encoding of the NZB, defaults to |
'utf-8'
|
Returns:
Type | Description |
---|---|
Self
|
Returns itself. |
Source code in src/nzb/_core.py
remove
Remove a metadata field from the NZB. If the same field is present multiple times, this will remove them all.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
Literal['title', 'password', 'tag', 'category'] | str
|
The metadata field to remove. |
required |
Returns:
Type | Description |
---|---|
Self
|
Returns itself. |
Source code in src/nzb/_core.py
save
Save the edited NZB to a file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filename |
StrPath
|
Destination path for saving the NZB. If not provided, uses the original file path if available. This will also create the path if it doesn't exist already. |
None
|
overwrite |
bool
|
Whether to overwrite the file if it exists, defaults to |
False
|
Returns:
Type | Description |
---|---|
Path
|
The path to the saved file. |
Raises:
Type | Description |
---|---|
FileNotFoundError
|
If no filename is specified and the original file path is unknown. |
FileExistsError
|
If the file exists and overwrite is |
Source code in src/nzb/_core.py
set
set(*, title: str | None = None, passwords: Iterable[str] | str | None = None, tags: Iterable[str] | str | None = None, category: str | None = None) -> Self
Set metadata fields in the NZB. This will also remove all existing metadata fields.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
The title metadata field. |
None
|
passwords |
Iterable[str] | str
|
Password(s) for the NZB file. |
None
|
tags |
Iterable[str] | str
|
Tag(s) associated with the NZB file. |
None
|
category |
str
|
Category of the NZB file. |
None
|
Returns:
Type | Description |
---|---|
Self
|
Returns itself. |