pre-publish

This commit is contained in:
Djkáťo 2024-04-19 21:54:33 +02:00
parent 276e26d7e2
commit 9e82673aca
3 changed files with 58 additions and 128 deletions

98
Cargo.lock generated
View file

@ -71,12 +71,6 @@ version = "1.0.75"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6"
[[package]]
name = "autocfg"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]] [[package]]
name = "backtrace" name = "backtrace"
version = "0.3.69" version = "0.3.69"
@ -92,17 +86,11 @@ dependencies = [
"rustc-demangle", "rustc-demangle",
] ]
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]] [[package]]
name = "bytes" name = "bytes"
version = "1.4.0" version = "1.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
[[package]] [[package]]
name = "cc" name = "cc"
@ -198,9 +186,9 @@ checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
[[package]] [[package]]
name = "hermit-abi" name = "hermit-abi"
version = "0.3.2" version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024"
[[package]] [[package]]
name = "indicatif" name = "indicatif"
@ -236,16 +224,6 @@ version = "0.2.148"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b" checksum = "9cdc71e17332e86d2e1d38c1f99edcb6288ee11b815fb1a4b049eaa2114d369b"
[[package]]
name = "lock_api"
version = "0.4.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]] [[package]]
name = "memchr" name = "memchr"
version = "2.6.3" version = "2.6.3"
@ -308,29 +286,6 @@ dependencies = [
"memchr", "memchr",
] ]
[[package]]
name = "parking_lot"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93f00c865fe7cabf650081affecd3871070f26767e7b2070a3ffae14c654b447"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets 0.48.5",
]
[[package]] [[package]]
name = "pbr" name = "pbr"
version = "1.1.1" version = "1.1.1"
@ -356,43 +311,28 @@ checksum = "31114a898e107c51bb1609ffaf55a0e011cf6a4d7f1170d0015a165082c0338b"
[[package]] [[package]]
name = "proc-macro2" name = "proc-macro2"
version = "1.0.67" version = "1.0.81"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3d433d9f1a3e8c1263d9456598b16fec66f4acc9a74dacffd35c7bb09b3a1328" checksum = "3d1597b0c024618f09a9c3b8655b7e430397a36d23fdafec26d6965e9eec3eba"
dependencies = [ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]] [[package]]
name = "quote" name = "quote"
version = "1.0.33" version = "1.0.36"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
] ]
[[package]]
name = "redox_syscall"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29"
dependencies = [
"bitflags",
]
[[package]] [[package]]
name = "rustc-demangle" name = "rustc-demangle"
version = "0.1.23" version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76" checksum = "d626bb9dae77e28219937af045c257c28bfd3f69333c512553507f5f9798cb76"
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]] [[package]]
name = "signal-hook-registry" name = "signal-hook-registry"
version = "1.4.1" version = "1.4.1"
@ -402,22 +342,6 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "smallvec"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62bb4feee49fdd9f707ef802e22365a35de4b7b299de4763d44bfea899442ff9"
[[package]]
name = "socket2"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2538b18701741680e0322a2302176d3253a35388e2e62f172f64f4f16605f877"
dependencies = [
"libc",
"windows-sys 0.48.0",
]
[[package]] [[package]]
name = "strsim" name = "strsim"
version = "0.10.0" version = "0.10.0"
@ -426,9 +350,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.37" version = "2.0.60"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7303ef2c05cd654186cb250d29049a24840ca25d2747c25c0381c8d9e2f582e8" checksum = "909518bc7b1c9b779f1bbf07f2929d35af9f0f37e47c6e9ef7f9dddc1e1821f3"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -446,10 +370,8 @@ dependencies = [
"libc", "libc",
"mio", "mio",
"num_cpus", "num_cpus",
"parking_lot",
"pin-project-lite", "pin-project-lite",
"signal-hook-registry", "signal-hook-registry",
"socket2",
"tokio-macros", "tokio-macros",
"windows-sys 0.48.0", "windows-sys 0.48.0",
] ]

View file

@ -16,7 +16,15 @@ anyhow = "1.0.75"
clap = { version = "4.4.4", features = ["cargo"] } clap = { version = "4.4.4", features = ["cargo"] }
indicatif = "0.17.7" indicatif = "0.17.7"
pbr = "1.1.1" pbr = "1.1.1"
tokio = { version = "1.32.0", features = ["full"] } tokio = { version = "1.32.0", features = [
"macros",
"rt-multi-thread",
"process",
"io-std",
"sync",
"time",
"io-util",
] }
[[bin]] [[bin]]
name = "nmb" name = "nmb"

View file

@ -365,7 +365,7 @@ async fn parse_ffprobe(path: &PathBuf) -> anyhow::Result<MediaData> {
let mem = text.split(',').collect::<Vec<_>>(); let mem = text.split(',').collect::<Vec<_>>();
let width = mem.get(0).and_then(|v| v.parse::<u16>().ok()); let width = mem.first().and_then(|v| v.parse::<u16>().ok());
let height = mem.get(1).and_then(|v| v.parse::<u16>().ok()); let height = mem.get(1).and_then(|v| v.parse::<u16>().ok());
let duration = mem let duration = mem
.get(2) .get(2)
@ -373,7 +373,7 @@ async fn parse_ffprobe(path: &PathBuf) -> anyhow::Result<MediaData> {
.context("missing duration")?; .context("missing duration")?;
let old_kbit_rate = mem let old_kbit_rate = mem
.get(3) .get(3)
.and_then(|v| v.parse::<u32>().ok().and_then(|v| Some(v / 1000))); .and_then(|v| v.parse::<u32>().ok().map(|v| v / 1000));
let resolution = width.zip(height); let resolution = width.zip(height);
// if let Ok(dur) = parse_duration(text) { // if let Ok(dur) = parse_duration(text) {
@ -422,40 +422,40 @@ fn parse_duration(text: &str) -> anyhow::Result<f32> {
Ok(h * 60. * 60. + m * 60. + s) Ok(h * 60. * 60. + m * 60. + s)
} }
fn parse_bitrate(text: &str) -> anyhow::Result<u16> { // fn parse_bitrate(text: &str) -> anyhow::Result<u16> {
let text = text[text.find("bitrate").unwrap()..].to_owned(); // let text = text[text.find("bitrate").unwrap()..].to_owned();
let bitrate_text = text[9..text.find('/').unwrap() - 2].to_owned(); // let bitrate_text = text[9..text.find('/').unwrap() - 2].to_owned();
//
Ok(bitrate_text.parse::<u16>()?) // Ok(bitrate_text.parse::<u16>()?)
} // }
//
fn parse_resolution(text: &str) -> anyhow::Result<(u16, u16)> { // fn parse_resolution(text: &str) -> anyhow::Result<(u16, u16)> {
let text = text[text.find("Stream").unwrap()..].to_owned(); // let text = text[text.find("Stream").unwrap()..].to_owned();
let sar_i = text // let sar_i = text
.find("[SAR ") // .find("[SAR ")
.context("something wrong with the ffprobe output")? // .context("something wrong with the ffprobe output")?
- 1; // - 1;
//
let rb_b4_sar_i = text[..sar_i] // let rb_b4_sar_i = text[..sar_i]
.rfind(',') // .rfind(',')
.context("something wrong with the ffprobe output")? // .context("something wrong with the ffprobe output")?
+ 1; // + 1;
//
let res_text = text[rb_b4_sar_i..sar_i].to_owned(); // let res_text = text[rb_b4_sar_i..sar_i].to_owned();
let res_text = res_text.trim().to_owned(); // let res_text = res_text.trim().to_owned();
//
let width = res_text[..res_text // let width = res_text[..res_text
.find('x') // .find('x')
.context("something wrong with ffprobe output")?] // .context("something wrong with ffprobe output")?]
.to_owned() // .to_owned()
.parse::<u16>()?; // .parse::<u16>()?;
//
let height = res_text[res_text // let height = res_text[res_text
.find('x') // .find('x')
.context("something wrong with ffprobe output")? // .context("something wrong with ffprobe output")?
+ 1..] // + 1..]
.to_owned() // .to_owned()
.parse::<u16>()?; // .parse::<u16>()?;
//
Ok((width, height)) // Ok((width, height))
} // }