# HG changeset patch # User Paper # Date 1775403621 14400 # Node ID 8f71820abe711fe3ece654f72b5fc25c7f363c08 # Parent 26f695129c867351c29d8460f85b30583dd1b35b player: use winepath for URLs this is optional, and it will be automagically disabled if winepath got something invalid or whatever diff -r 26f695129c86 -r 8f71820abe71 Cargo.lock --- a/Cargo.lock Sun Apr 05 02:26:19 2026 -0400 +++ b/Cargo.lock Sun Apr 05 11:40:21 2026 -0400 @@ -195,6 +195,7 @@ "anyhow", "bytes", "dirs", + "hex", "mpris-server", "reqwest", "serde", @@ -204,6 +205,7 @@ "tokio-macros", "urlencoding", "uuid", + "winepath", "zbus", ] @@ -2707,6 +2709,12 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] +name = "winepath" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d52cb21c584b4a8b7aaeab87c335de80c814c0ecf35f39b40587365c99c20237" + +[[package]] name = "winnow" version = "0.7.15" source = "registry+https://github.com/rust-lang/crates.io-index" diff -r 26f695129c86 -r 8f71820abe71 Cargo.toml --- a/Cargo.toml Sun Apr 05 02:26:19 2026 -0400 +++ b/Cargo.toml Sun Apr 05 11:40:21 2026 -0400 @@ -18,3 +18,4 @@ bytes = "1.11.0" urlencoding = "2.1.3" hex = "0.4.3" +winepath = "0.1.1" diff -r 26f695129c86 -r 8f71820abe71 src/player.rs --- a/src/player.rs Sun Apr 05 02:26:19 2026 -0400 +++ b/src/player.rs Sun Apr 05 11:40:21 2026 -0400 @@ -18,6 +18,10 @@ * . */ +/* Fuck off, I don't care. */ +#![allow(nonstandard_style)] +#![allow(unused_variables)] + use crate::beefweb; use zbus::fdo; @@ -29,6 +33,7 @@ /* teehee */ pub struct BeefwebPlayer { bw: beefweb::Beefweb, + wc: Option, artcache: String, /* artmap * key: %path% column from beefweb @@ -42,6 +47,8 @@ { return BeefwebPlayer { bw: beefweb::Beefweb::new(base), + /* teehee */ + wc: winepath::WineConfig::from_env().ok(), artcache: artcache.to_string(), artmap: RefCell::new(HashMap::new()), }; @@ -85,6 +92,32 @@ return Ok(artpath); } */ + + fn win32_path_to_file_url(&self, p: &str) -> fdo::Result + { + match &(self.wc) { + Some(_) => (), + _ => { return Err(fdo::Error::Failed("Wine environment not loaded?".into())) }, + }; + + let nps = self.wc.as_ref().unwrap(); + + println!("{:?}", nps.prefix()); + + match nps.to_native_path(p) { + Ok(v) => { + match v.to_str() { + /* hax: don't kill slashes */ + Some(vv) => return Ok(format!("file://{}", urlencoding::encode(vv).replace("%2F", "/"))), + _ => (), + }; + }, + /* TODO detect if this is a unix path and use it as such */ + Err(x) => { println!("{}", x); }, + }; + + return Err(fdo::Error::Failed("Converting to unix path failed...".into())); + } } fn secs_to_time(x: f64) -> mpris_server::Time @@ -300,6 +333,8 @@ x.set_length(Some(secs_to_time(p.active_item.duration))); if track.columns.len() >= 13 { + let path = track.columns.get(6).unwrap(); + x.set_title(Some(track.columns.get(0).unwrap())); /* XXX musicbrainz has %artists% we can use for a proper list */ x.set_artist(Some([track.columns.get(1).unwrap()])); @@ -313,7 +348,7 @@ _ => (), }; x.set_album_artist(Some([track.columns.get(5).unwrap()])); - x.set_trackid(format!("/org/foobar2000/foobar2000/trackids/{}", hex::encode(track.columns.get(6).unwrap()))); + x.set_trackid(Some(mpris_server::TrackId::from(zbus::zvariant::ObjectPath::from_string_unchecked(format!("/org/foobar2000/foobar2000/trackids/{}", hex::encode(path)))))); /* Why is this an i32 ??? It would make more sense as f32 or f64 */ match track.columns.get(7).unwrap().parse::() { Ok(v) => { x.set_audio_bpm(Some(v)) }, @@ -324,6 +359,14 @@ x.set_content_created(Some(track.columns.get(10).unwrap())); x.set_genre(Some(track.columns.get(11).unwrap().split(";"))); x.set_lyricist(Some([track.columns.get(12).unwrap()])); + + /* add file:// URI */ + match self.win32_path_to_file_url(path) { + Ok(a) => { x.set_url(Some(a)); }, + /* If it failed, it's more than likely a URL already, + * pointing to a stream */ + Err(_) => { x.set_url(Some(path)); }, + }; } /*