API Reference
Warning
This API is considered unstable and might change in the future. If you're using this, pin your install to a specific version
juicenet
juicenet(path: StrPath, /, *, config: Union[StrPath, JuicenetConfig], public: bool = False, bdmv_naming: bool = False, resume: bool = True, skip_raw: bool = False, debug: bool = False) -> JuiceBox
Upload a file or folder to usenet. This will always produce one NZB for one input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str or Path
|
The path to an existing file. This can either be a string representing the path or a pathlib.Path object. |
required |
config |
str or Path or JuicenetConfig
|
The configuration to use when processing the file or directory.
This can either be a string representing the path to a YAML configuration file,
a |
required |
public |
bool
|
Whether the upload is meant to be public or not. Uses the public config if specified, falls back to using the private one if not. Default is False. |
False
|
bdmv_naming |
bool
|
Whether to use an alternate naming for BDMVs.
This will try to fix the awful BDMV disc naming in some cases, i.e, if you pass |
False
|
resume |
bool
|
Whether to enable resumability. Files uploaded by previous runs will be skipped if True. Default is True. |
True
|
skip_raw |
bool
|
Skip checking and reposting failed raw articles. Default is False. |
False
|
debug |
bool
|
Whether to enable debug logs. Default is False. |
False
|
Returns:
Type | Description |
---|---|
JuiceBox
|
Dataclass used to represent the output of Juicenet. |
Raises:
Type | Description |
---|---|
JuicenetInputError
|
Invalid input. |
Notes
-
You should never upload an entire directory consisting of several files as a single NZB. Use
juicenet.get_files
orjuicenet.get_glob_matches
to first get the relevant files and then pass each one to juicenet. -
You should never upload an entire BDMV consisting of several discs as a single NZB. Use
juicenet.get_bdmv_discs
to first get each individual disc and then pass each one to juicenet.
Examples:
from pathlib import Path
from juicenet import JuicenetConfig, juicenet
file = Path("C:/Users/raven/Videos/Big Buck Bunny.mkv") # Path works
config = "D:/data/usenet/config/juicenet.yaml" # string also works
# Convenient config class instead of a config file
config = JuicenetConfig(
nyuu_config_private="D:/data/usenet/juicenetConfig/nyuu-config.json",
nzb_output_path=Path("D:/data/usenet/nzbs"),
)
upload = juicenet(file, config=config)
print(upload.nyuu.nzb)
# D:/data/usenet/nzbs/private/Videos/Big Buck Bunny.mkv.nzb
Source code in src/juicenet/api/main.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
|
get_files
Get a list of files with specified extensions from the given path. This is recursive.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str or Path
|
The path to an existing file. This can either be a string representing the path or a pathlib.Path object. |
required |
exts |
list[str]
|
List of file extensions to match. Default will match all |
['mkv']
|
Returns:
Type | Description |
---|---|
list[Path]
|
A list of Path objects representing the files with the specified extensions. |
Raises:
Type | Description |
---|---|
JuicenetInputError
|
Invalid input. |
Examples:
>>> get_files(Path('/path/to/directory'))
[PosixPath('/path/to/directory/Big Buck Bunny S01E01.mkv'), PosixPath('/path/to/directory/Big Buck Bunny S01E02.mkv')]
>>> get_files(Path('/path/to/directory'), ['txt', 'csv'])
[PosixPath('/path/to/directory/file1.txt'), PosixPath('/path/to/directory/file2.csv')]
Source code in src/juicenet/api/utils.py
get_glob_matches
Get a list of files which match at least one of the given glob patterns in the specified path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Path or str
|
The path to an existing directory. This can either be a string representing the path or a pathlib.Path object. |
required |
globs |
list[str]
|
List of glob patterns to match. Default will match all |
['*.mkv']
|
Returns:
Type | Description |
---|---|
list[Path]
|
A list of Path objects representing the files matching the given glob patterns. |
Raises:
Type | Description |
---|---|
JuicenetInputError
|
Invalid input. |
Examples:
>>> get_glob_matches(Path('/path/to/directory'))
[PosixPath('/path/to/directory/Big Buck Bunny S01E01.mkv'), PosixPath('/path/to/directory/Big Buck Bunny S01E02.mkv')]
>>> get_glob_matches(Path('/path/to/directory'), globs=['*.txt', '*.csv'])
[PosixPath('/path/to/directory/file1.txt'), PosixPath('/path/to/directory/file2.csv')]
Source code in src/juicenet/api/utils.py
get_bdmv_discs
Finds individual discs in BDMVs by looking for BDMV/index.bdmv
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
str or Path
|
The path to an existing file. This can either be a string representing the path or a pathlib.Path object. |
required |
globs |
list[str]
|
List of glob patterns to match. Default will match all sub folders in base path. |
['*/']
|
Returns:
Type | Description |
---|---|
list[Path]
|
List of paths where each path is a BDMV disc. |
Raises:
Type | Description |
---|---|
JuicenetInputError
|
Invalid input. |
Notes
The choice to use BDMV/index.bdmv
is arbitrary,
I just needed something unique enough.
There's two aspects to it, if the BDMV has multiple BDMV/index.bdmv
files
it means it's got multiple discs and each disc will be returned seperately
and if there's only one BDMV/index.bdmv
then return the folder as is
because it's likely a movie BDMV
A typical BDMV might look like this:
[BDMV] Big Buck Bunny [US]
├── Big Buck Bunny [Vol.1]
│ └── DISC_01
│ └── BDMV
│ ├── BACKUP
│ ├── CLIPINF
│ ├── META
│ ├── PLAYLIST
│ ├── index.bdmv
│ └── MovieObject.bdmv
└── Big Buck Bunny [Vol.2]
└── DISC_01
└── BDMV
├── BACKUP
├── CLIPINF
├── META
├── PLAYLIST
├── index.bdmv
└── MovieObject.bdmv
BDMV/index.bdmv
file and then goes 1 directory up
relative to BDMV/index.bdmv
which ends up being DISC_01
Something like:
-
Found:
Big Buck Bunny [Vol.1]/DISC_01/BDMV/index.bdmv
Big Buck Bunny [Vol.2]/DISC_01/BDMV/index.bdmv
-
Returns:
Big Buck Bunny [Vol.1]/DISC_01
Big Buck Bunny [Vol.2]/DISC_01
Examples:
from pathlib import Path
from juicenet import get_bdmv_discs
folder = Path("C:/Users/raven/BDMVs")
bdmvs = get_bdmv_discs(folder)
print(bdmvs)
# [
# WindowsPath('C:/Users/raven/BDMVs/[BDMV] Big Buck Bunny [US]/Big Buck Bunny [Vol.1]/DISC_01'),
# WindowsPath('C:/Users/raven/BDMVs/[BDMV] Big Buck Bunny [US]/Big Buck Bunny [Vol.2]/DISC_01'),
# WindowsPath('C:/Users/raven/BDMVs/[BDMV] Big Buck Bunny [US]/Big Buck Bunny [Vol.3]/DISC_01'),
# WindowsPath('C:/Users/raven/BDMVs/[BDMV] Big Buck Bunny [US]/Big Buck Bunny [Vol.4]/DISC_01'),
# WindowsPath('C:/Users/raven/BDMVs/[BDMV] Big Buck Bunny [US]/Big Buck Bunny [Vol.5]/DISC_01'),
# WindowsPath('C:/Users/raven/BDMVs/[BDMV] Big Buck Bunny [US]/Big Buck Bunny [Vol.6]/DISC_01'),
# ]
Source code in src/juicenet/api/utils.py
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
JuicenetConfig
Bases: BaseModel
Pydantic model for setting defaults and validating Juicenet's config
Attributes:
Name | Type | Description |
---|---|---|
parpar |
FilePath
|
The path to the ParPar executable |
nyuu |
FilePath
|
The path to the Nyuu executable |
nyuu_config_private |
FilePath
|
The path to the private Nyuu configuration file |
nzb_output_path |
DirectoryPath
|
The path where output NZBs will be saved |
nyuu_config_public |
(FilePath, optional)
|
The path to the public Nyuu configuration file |
extensions |
(list[str], optional)
|
The list of file extensions to be processed. Default is |
related_extensions |
(list[str], optional)
|
The list of file extensions associated with an input file.
For example, if you have a file named |
parpar_args |
(list[str], optional)
|
The arguments to be passed to the ParPar executable
Ddefault is |
use_temp_dir |
(bool, optional)
|
Whether or not to use a temporary directory for processing. Default is |
temp_dir_path |
(DirectoryPath, optional)
|
Path to a specific temporary directory if |
appdata_dir_path |
(Path, optional)
|
The path to the folder where Juicenet will store its data. Default is |
Source code in src/juicenet/model.py
JuiceBox
dataclass
A class used to represent the output of juicenet.
Each attribute in this class is an instance of the corresponding output class (NyuuOutput
, ParParOutput
, RawOutput
) and
captures the output of the respective subprocess.
Attributes:
Name | Type | Description |
---|---|---|
nyuu |
NyuuOutput
|
|
parpar |
ParParOutput
|
|
raw |
dict[ArticleFilePath, RawOutput]
|
Dictionary where each key is an article and the value is |
skipped |
bool
|
True if the upload process was skipped because the file was already uploaded |
Source code in src/juicenet/types.py
NyuuOutput
dataclass
A class used to represent the output of Nyuu.
Attributes:
Name | Type | Description |
---|---|---|
nzb |
(NZBFilePath, optional)
|
Absolute pathlib.Path to the resulting |
success |
bool
|
|
args |
list[str]
|
List of arguments passed to Nyuu. |
returncode |
int
|
Nyuu's exit code. |
stdout |
str
|
Nyuu's stdout. |
stderr |
str
|
Nyuu's stderr. |
Notes
Nyuu exits with a code 0 if the process completes successfully or 32 if the process completes successfully after skipping the skippable errors.
Refer to Nyuu's help-full.txt
for more details.
Source code in src/juicenet/types.py
ParParOutput
dataclass
A class used to represent the output of ParPar.
Attributes:
Name | Type | Description |
---|---|---|
par2files |
list[PAR2FilePath]
|
List of absolute pathlib.Path objects pointing to the generated |
filepathformat |
Literal['basename', 'path']
|
The |
filepathbase |
Path
|
The |
success |
bool
|
|
args |
list[str]
|
List of arguments passed to ParPar. |
returncode |
int
|
ParPar's exit code. |
stdout |
str
|
ParPar's stdout. |
stderr |
str
|
ParPar's stderr. |
Source code in src/juicenet/types.py
RawOutput
dataclass
A class used to represent the output of Nyuu's raw article upload process.
Attributes:
Name | Type | Description |
---|---|---|
article |
ArticleFilePath
|
Absolute pathlib.Path to the raw article. |
success |
bool
|
|
args |
list[str]
|
List of arguments passed to Nyuu. |
returncode |
int
|
Nyuu's exit code. |
stdout |
str
|
Nyuu's stdout. |
stderr |
str
|
Nyuu's stderr. |
Notes
Nyuu exits with a code 0 if the process completes successfully or 32 if the process completes successfully after skipping the skippable errors.
Refer to Nyuu's help-full.txt
for more details.