Update bliss and nerf URI parsing for filepaths

This commit is contained in:
NGnius (Graham) 2023-01-12 22:11:54 -05:00
parent 13ac120ebc
commit 34aa327742
6 changed files with 177 additions and 16 deletions

172
Cargo.lock generated
View file

@ -155,14 +155,16 @@ dependencies = [
[[package]]
name = "bliss-audio-symphonia"
version = "0.5.0"
version = "0.6.5"
dependencies = [
"anyhow",
"bliss-audio-aubio-rs",
"clap 2.34.0",
"crossbeam",
"dirs",
"env_logger",
"glob",
"indicatif",
"lazy_static 1.4.0",
"log",
"mime_guess",
@ -175,12 +177,16 @@ dependencies = [
"rayon",
"rcue",
"ripemd160",
"rustfft",
"rubato",
"rusqlite",
"rustfft 5.1.1",
"serde",
"serde_ini",
"serde_json",
"strum",
"strum_macros",
"symphonia",
"tempdir",
"thiserror",
]
@ -792,6 +798,12 @@ dependencies = [
"regex 0.1.80",
]
[[package]]
name = "fuchsia-cprng"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
[[package]]
name = "generic-array"
version = "0.14.6"
@ -895,6 +907,18 @@ dependencies = [
"hashbrown 0.12.3",
]
[[package]]
name = "indicatif"
version = "0.17.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4295cbb7573c16d310e99e713cf9e75101eb190ab31fccd35f2d2691b4352b19"
dependencies = [
"console",
"number_prefix",
"portable-atomic",
"unicode-width",
]
[[package]]
name = "itertools"
version = "0.10.5"
@ -1020,9 +1044,9 @@ dependencies = [
[[package]]
name = "libsqlite3-sys"
version = "0.23.2"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d2cafc7c74096c336d9d27145f7ebd4f4b6f95ba16aa5a282387267e6925cb58"
checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14"
dependencies = [
"cc",
"pkg-config",
@ -1189,7 +1213,7 @@ dependencies = [
"dirs",
"m3u8-rs",
"mpd",
"rand",
"rand 0.8.5",
"regex 1.6.0",
"rusqlite",
"shellexpand",
@ -1259,7 +1283,7 @@ dependencies = [
"noisy_float",
"num-integer",
"num-traits",
"rand",
"rand 0.8.5",
]
[[package]]
@ -1471,6 +1495,12 @@ dependencies = [
"syn",
]
[[package]]
name = "number_prefix"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3"
[[package]]
name = "oboe"
version = "0.4.6"
@ -1649,6 +1679,12 @@ dependencies = [
"plotters-backend",
]
[[package]]
name = "portable-atomic"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26f6a7b87c2e435a3241addceeeff740ff8b7e76b74c13bf9acb17fa454ea00b"
[[package]]
name = "ppv-lite86"
version = "0.2.16"
@ -1742,6 +1778,19 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.4.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293"
dependencies = [
"fuchsia-cprng",
"libc",
"rand_core 0.3.1",
"rdrand",
"winapi 0.3.9",
]
[[package]]
name = "rand"
version = "0.8.5"
@ -1750,7 +1799,7 @@ checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
dependencies = [
"libc",
"rand_chacha",
"rand_core",
"rand_core 0.6.4",
]
[[package]]
@ -1760,9 +1809,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
dependencies = [
"ppv-lite86",
"rand_core",
"rand_core 0.6.4",
]
[[package]]
name = "rand_core"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b"
dependencies = [
"rand_core 0.4.2",
]
[[package]]
name = "rand_core"
version = "0.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc"
[[package]]
name = "rand_core"
version = "0.6.4"
@ -1817,6 +1881,24 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fca1481d62f18158646de2ec552dd63f8bdc5be6448389b192ba95c939df997e"
[[package]]
name = "rdrand"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2"
dependencies = [
"rand_core 0.3.1",
]
[[package]]
name = "realfft"
version = "3.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30030cf3ea04d9192da88768b8b1b865e08733b5ae3cf1f012041749f4bef28f"
dependencies = [
"rustfft 6.0.1",
]
[[package]]
name = "redox_syscall"
version = "0.2.16"
@ -1879,6 +1961,21 @@ version = "0.6.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244"
[[package]]
name = "remove_dir_all"
version = "0.5.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7"
dependencies = [
"winapi 0.3.9",
]
[[package]]
name = "result"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "194d8e591e405d1eecf28819740abed6d719d1a2db87fc0bcdedee9a26d55560"
[[package]]
name = "ripemd160"
version = "0.9.1"
@ -1905,10 +2002,22 @@ dependencies = [
]
[[package]]
name = "rusqlite"
version = "0.26.3"
name = "rubato"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ba4d3462c8b2e4d7f4fcfcf2b296dc6b65404fbbc7b63daa37fd485c149daf7"
checksum = "cd70209c27d5b08f5528bdc779ea3ffb418954e28987f9f9775c6eac41003f9c"
dependencies = [
"num-complex 0.4.2",
"num-integer",
"num-traits",
"realfft",
]
[[package]]
name = "rusqlite"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85127183a999f7db96d1a976a309eebbfb6ea3b0b400ddd8340190129de6eb7a"
dependencies = [
"bitflags",
"fallible-iterator",
@ -1954,6 +2063,20 @@ dependencies = [
"transpose",
]
[[package]]
name = "rustfft"
version = "6.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1d089e5c57521629a59f5f39bca7434849ff89bd6873b521afe389c1c602543"
dependencies = [
"num-complex 0.4.2",
"num-integer",
"num-traits",
"primal-check",
"strength_reduce",
"transpose",
]
[[package]]
name = "ryu"
version = "1.0.11"
@ -2020,6 +2143,17 @@ dependencies = [
"syn",
]
[[package]]
name = "serde_ini"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eb236687e2bb073a7521c021949be944641e671b8505a94069ca37b656c81139"
dependencies = [
"result",
"serde",
"void",
]
[[package]]
name = "serde_json"
version = "1.0.87"
@ -2366,6 +2500,16 @@ dependencies = [
"unicode-ident",
]
[[package]]
name = "tempdir"
version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "15f2b5fb00ccdf689e0149d1b1b3c03fead81c2b37735d812fa8bddbbf41b6d8"
dependencies = [
"rand 0.4.6",
"remove_dir_all",
]
[[package]]
name = "termcolor"
version = "1.1.3"
@ -2563,6 +2707,12 @@ version = "0.9.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
[[package]]
name = "void"
version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d"
[[package]]
name = "walkdir"
version = "2.3.2"

@ -1 +1 @@
Subproject commit 851da65fcf4ca8f1081d121c27d5bbf919ce4861
Subproject commit 4db79db51f6b931066b0185180d5884f6cdfe935

View file

@ -7,7 +7,7 @@ readme = "README.md"
rust-version = "1.59"
[dependencies]
rusqlite = { version = "0.26", features = ["bundled"], optional = true }
rusqlite = { version = "0.27", features = ["bundled"], optional = true }
sqlparser = { version = "0.23", optional = true }
symphonia = { version = "0.5", optional = true, features = [
"aac", "alac", "flac", "mp3", "pcm", "vorbis", "isomp4", "ogg", "wav"
@ -16,7 +16,7 @@ dirs = { version = "4" }
regex = { version = "1" }
rand = { version = "0.8" }
shellexpand = { version = "2", optional = true }
bliss-audio-symphonia = { version = "0.5", optional = true, path = "../bliss-rs" }
bliss-audio-symphonia = { version = "0.6", optional = true, path = "../bliss-rs" }
mpd = { version = "0.0.12", optional = true }
unidecode = { version = "0.3.0", optional = true }
base64 = { version = "0.13", optional = true }

View file

@ -14,6 +14,10 @@ impl PlayerError {
Self::Playback(PlaybackError::from_err(err))
}
pub(crate) fn from_file_err_playback<E: Display, P: AsRef<std::path::Path>>(err: E, path: P) -> Self {
Self::Playback(PlaybackError { msg: format!("{}: `{}`", err, path.as_ref().display()) })
}
/*pub(crate) fn from_err_uri<E: Display>(err: E) -> Self {
Self::Uri(UriError::from_err(err))
}*/

View file

@ -246,7 +246,7 @@ impl<I: std::iter::Iterator<Item = Result<Item, InterpreterError>>> Player<I> {
Some(s) => match &s.to_lowercase() as &str {
"file:" => {
let file =
fs::File::open(uri.path()).map_err(PlayerError::from_err_playback)?;
fs::File::open(uri.without_scheme()).map_err(|e| PlayerError::from_file_err_playback(e, uri.path()))?;
let stream = io::BufReader::new(file);
let source = Decoder::new(stream).map_err(PlayerError::from_err_playback)?;
self.sink.append(source);
@ -290,7 +290,7 @@ impl<I: std::iter::Iterator<Item = Result<Item, InterpreterError>>> Player<I> {
Some(s) => match &s.to_lowercase() as &str {
"file:" => {
let file =
fs::File::open(uri.path()).map_err(PlayerError::from_err_playback)?;
fs::File::open(uri.without_scheme()).map_err(|e| PlayerError::from_file_err_playback(e, uri.path()))?;
let stream = io::BufReader::new(file);
let source = Decoder::new(stream).map_err(PlayerError::from_err_playback)?;
self.sink.append(modify(source));

View file

@ -27,6 +27,13 @@ impl<'a> Uri<&'a str> {
}
}
pub fn without_scheme(&self) -> &'a str {
match self.0.find("//") {
Some(end) => self.0.get(end + 2..).unwrap(),
None => self.0,
}
}
#[allow(dead_code)]
pub fn uri(&self) -> &'a str {
self.0