From dae7daaf25a7fa3a73e8b87b82cfc64510880560 Mon Sep 17 00:00:00 2001 From: Mark Date: Thu, 16 Apr 2026 00:27:03 +0200 Subject: [PATCH] feat: musicdb-shuffle-all-songs tool --- musicdb-shuffle-all-songs/.gitignore | 1 + musicdb-shuffle-all-songs/Cargo.toml | 9 ++++++ musicdb-shuffle-all-songs/src/main.rs | 43 +++++++++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100755 musicdb-shuffle-all-songs/.gitignore create mode 100644 musicdb-shuffle-all-songs/Cargo.toml create mode 100755 musicdb-shuffle-all-songs/src/main.rs diff --git a/musicdb-shuffle-all-songs/.gitignore b/musicdb-shuffle-all-songs/.gitignore new file mode 100755 index 0000000..ea8c4bf --- /dev/null +++ b/musicdb-shuffle-all-songs/.gitignore @@ -0,0 +1 @@ +/target diff --git a/musicdb-shuffle-all-songs/Cargo.toml b/musicdb-shuffle-all-songs/Cargo.toml new file mode 100644 index 0000000..66ae7a9 --- /dev/null +++ b/musicdb-shuffle-all-songs/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "musicdb-shuffle-all-songs" +version = "0.1.0" +edition = "2024" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +musicdb-lib = { path = "../musicdb-lib" } diff --git a/musicdb-shuffle-all-songs/src/main.rs b/musicdb-shuffle-all-songs/src/main.rs new file mode 100755 index 0000000..aa74c9f --- /dev/null +++ b/musicdb-shuffle-all-songs/src/main.rs @@ -0,0 +1,43 @@ +use std::{io::Write, net::TcpStream}; + +use musicdb_lib::{ + data::{ + database::Database, + queue::{QueueContent, QueueFolder}, + }, + load::ToFromBytes, + server::{Action, Command, Req}, +}; + +fn main() { + let mut con = TcpStream::connect( + std::env::args() + .nth(1) + .expect("required argument: server address and port"), + ) + .unwrap(); + writeln!(con, "main").unwrap(); + let mut db = Database::new_clientside(); + while !db.is_client_init() { + db.apply_action_unchecked_seq(Command::from_bytes(&mut con).unwrap().action, None); + } + db.seq + .pack(Action::Multiple(vec![ + Action::QueueUpdate( + vec![], + QueueContent::Folder(QueueFolder { + content: db + .songs() + .keys() + .map(|id| QueueContent::Song(*id).into()) + .collect(), + ..Default::default() + }) + .into(), + Req::none(), + ), + Action::QueueShuffle(vec![], 0), + ])) + .to_bytes(&mut con) + .unwrap(); +}