An open API service indexing awesome lists of open source software.

https://github.com/ravencentric/nzb-rs

A spec compliant parser for NZB files
https://github.com/ravencentric/nzb-rs

nzb parser usenet

Last synced: over 1 year ago
JSON representation

A spec compliant parser for NZB files

Awesome Lists containing this project

README

          

nzb-rs
========

[![Tests](https://img.shields.io/github/actions/workflow/status/Ravencentric/nzb-rs/tests.yml?label=tests)](https://github.com/Ravencentric/nzb-rs/actions/workflows/tests.yml)
[![Latest Version](https://img.shields.io/crates/v/nzb-rs)](https://crates.io/crates/nzb-rs)
[![Documentation](https://docs.rs/nzb-rs/badge.svg)](https://docs.rs/nzb-rs)
![License](https://img.shields.io/crates/l/nzb-rs)

`nzb-rs` is a [spec](https://sabnzbd.org/wiki/extra/nzb-spec) compliant parser for [NZB](https://en.wikipedia.org/wiki/NZB) files.

## Installation

`nzb-rs` is available on [crates.io](https://crates.io/crates/nzb-rs), so you can simply use [cargo](https://github.com/rust-lang/cargo) to install it.

```console
cargo add nzb-rs
```

Optional features:

- `serde`: Enables serialization and deserialization via [serde](https://crates.io/crates/serde).

## Example

```rust
use nzb_rs::{Nzb, ParseNzbError};

fn main() -> Result<(), ParseNzbError> {
let xml = r#"





alt.binaries.boneless


9cacde4c986547369becbf97003fb2c5-9483514693959@example
70a3a038ce324e618e2751e063d6a036-7285710986748@example



"#;
let nzb = Nzb::parse(xml)?;
println!("{:#?}", nzb);
assert_eq!(nzb.file().name(), Some("Big Buck Bunny - S01E01.mkv"));
Ok(())
}
```

## Safety

- This library must not panic. Any panic should be considered a bug and reported.
- This library uses [`roxmltree`](https://crates.io/crates/roxmltree) for parsing the NZB. `roxmltree` is written entirely in safe Rust, so by Rust's guarantees the worst that a malicious NZB can do is to cause a panic.

## License

Licensed under either of

* Apache License, Version 2.0
([LICENSE-APACHE](https://github.com/Ravencentric/nzb-rs/blob/main/LICENSE-APACHE) or )
* MIT license
([LICENSE-MIT](https://github.com/Ravencentric/nzb-rs/blob/main/LICENSE-MIT) or )

at your option.

## Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.