Compare commits

...

3 Commits

13 changed files with 214 additions and 258 deletions

2
.cargo/config.toml Normal file
View File

@ -0,0 +1,2 @@
[target.aarch64-unknown-linux-gnu]
linker="aarch64-linux-gnu-gcc"

261
Cargo.lock generated
View File

@ -924,7 +924,7 @@ dependencies = [
"cocoa-foundation",
"core-foundation",
"core-graphics",
"foreign-types 0.5.0",
"foreign-types",
"libc",
"objc",
]
@ -1046,7 +1046,7 @@ dependencies = [
"bitflags 1.3.2",
"core-foundation",
"core-graphics-types",
"foreign-types 0.5.0",
"foreign-types",
"libc",
]
@ -1315,15 +1315,6 @@ dependencies = [
"serde",
]
[[package]]
name = "encoding_rs"
version = "0.8.34"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b45de904aa0b010bce2ab45264d0631681847fa7b6f2eaa7dab7619943bc4f59"
dependencies = [
"cfg-if",
]
[[package]]
name = "endi"
version = "1.1.0"
@ -1523,15 +1514,6 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "foreign-types"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1"
dependencies = [
"foreign-types-shared 0.1.1",
]
[[package]]
name = "foreign-types"
version = "0.5.0"
@ -1539,7 +1521,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
dependencies = [
"foreign-types-macros",
"foreign-types-shared 0.3.1",
"foreign-types-shared",
]
[[package]]
@ -1553,12 +1535,6 @@ dependencies = [
"syn 2.0.77",
]
[[package]]
name = "foreign-types-shared"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b"
[[package]]
name = "foreign-types-shared"
version = "0.3.1"
@ -2041,22 +2017,7 @@ dependencies = [
"tokio",
"tokio-rustls",
"tower-service",
]
[[package]]
name = "hyper-tls"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
dependencies = [
"bytes",
"http-body-util",
"hyper",
"hyper-util",
"native-tls",
"tokio",
"tokio-native-tls",
"tower-service",
"webpki-roots",
]
[[package]]
@ -2424,7 +2385,7 @@ dependencies = [
"bitflags 2.6.0",
"block",
"core-graphics-types",
"foreign-types 0.5.0",
"foreign-types",
"log",
"objc",
"paste",
@ -2490,30 +2451,13 @@ dependencies = [
"indexmap",
"log",
"num-traits",
"rustc-hash",
"rustc-hash 1.1.0",
"spirv",
"termcolor",
"thiserror",
"unicode-xid",
]
[[package]]
name = "native-tls"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8614eb2c83d59d1c8cc974dd3f920198647674a0a035e1af1fa58707e317466"
dependencies = [
"libc",
"log",
"openssl",
"openssl-probe",
"openssl-sys",
"schannel",
"security-framework",
"security-framework-sys",
"tempfile",
]
[[package]]
name = "ndk"
version = "0.8.0"
@ -2831,50 +2775,6 @@ dependencies = [
"pathdiff",
]
[[package]]
name = "openssl"
version = "0.10.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9529f4786b70a3e8c61e11179af17ab6188ad8d0ded78c5529441ed39d4bd9c1"
dependencies = [
"bitflags 2.6.0",
"cfg-if",
"foreign-types 0.3.2",
"libc",
"once_cell",
"openssl-macros",
"openssl-sys",
]
[[package]]
name = "openssl-macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.77",
]
[[package]]
name = "openssl-probe"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf"
[[package]]
name = "openssl-sys"
version = "0.9.103"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6"
dependencies = [
"cc",
"libc",
"pkg-config",
"vcpkg",
]
[[package]]
name = "orbclient"
version = "0.3.47"
@ -3139,6 +3039,54 @@ dependencies = [
"memchr",
]
[[package]]
name = "quinn"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b22d8e7369034b9a7132bc2008cac12f2013c8132b45e0554e6e20e2617f2156"
dependencies = [
"bytes",
"pin-project-lite",
"quinn-proto",
"quinn-udp",
"rustc-hash 2.0.0",
"rustls",
"socket2 0.5.7",
"thiserror",
"tokio",
"tracing",
]
[[package]]
name = "quinn-proto"
version = "0.11.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba92fb39ec7ad06ca2582c0ca834dfeadcaf06ddfc8e635c80aa7e1c05315fdd"
dependencies = [
"bytes",
"rand",
"ring",
"rustc-hash 2.0.0",
"rustls",
"slab",
"thiserror",
"tinyvec",
"tracing",
]
[[package]]
name = "quinn-udp"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285"
dependencies = [
"libc",
"once_cell",
"socket2 0.5.7",
"tracing",
"windows-sys 0.52.0",
]
[[package]]
name = "quote"
version = "1.0.37"
@ -3271,7 +3219,6 @@ checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63"
dependencies = [
"base64",
"bytes",
"encoding_rs",
"futures-core",
"futures-util",
"h2",
@ -3280,29 +3227,30 @@ dependencies = [
"http-body-util",
"hyper",
"hyper-rustls",
"hyper-tls",
"hyper-util",
"ipnet",
"js-sys",
"log",
"mime",
"native-tls",
"once_cell",
"percent-encoding",
"pin-project-lite",
"quinn",
"rustls",
"rustls-pemfile",
"rustls-pki-types",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"system-configuration",
"tokio",
"tokio-native-tls",
"tokio-rustls",
"tower-service",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"webpki-roots",
"windows-registry",
]
@ -3333,6 +3281,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc-hash"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
[[package]]
name = "rustix"
version = "0.37.27"
@ -3367,6 +3321,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8"
dependencies = [
"once_cell",
"ring",
"rustls-pki-types",
"rustls-webpki",
"subtle",
@ -3415,15 +3370,6 @@ dependencies = [
"winapi-util",
]
[[package]]
name = "schannel"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e9aaafd5a2b6e3d657ff009d82fbd630b6bd54dd4eb06f21693925cdf80f9b8b"
dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "scoped-tls"
version = "1.0.1"
@ -3449,29 +3395,6 @@ dependencies = [
"tiny-skia",
]
[[package]]
name = "security-framework"
version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
dependencies = [
"bitflags 2.6.0",
"core-foundation",
"core-foundation-sys",
"libc",
"security-framework-sys",
]
[[package]]
name = "security-framework-sys"
version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "serde"
version = "1.0.210"
@ -3754,27 +3677,6 @@ dependencies = [
"futures-core",
]
[[package]]
name = "system-configuration"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
dependencies = [
"bitflags 2.6.0",
"core-foundation",
"system-configuration-sys",
]
[[package]]
name = "system-configuration-sys"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
dependencies = [
"core-foundation-sys",
"libc",
]
[[package]]
name = "tauri-winrt-notification"
version = "0.2.1"
@ -3915,16 +3817,6 @@ dependencies = [
"syn 2.0.77",
]
[[package]]
name = "tokio-native-tls"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2"
dependencies = [
"native-tls",
"tokio",
]
[[package]]
name = "tokio-rustls"
version = "0.26.0"
@ -4053,7 +3945,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "deb68604048ff8fa93347f02441e4487594adc20bb8a084f9e564d2b827a0a9f"
dependencies = [
"rustc-hash",
"rustc-hash 1.1.0",
]
[[package]]
@ -4144,12 +4036,6 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]]
name = "version_check"
version = "0.9.5"
@ -4425,6 +4311,15 @@ dependencies = [
"web-sys",
]
[[package]]
name = "webpki-roots"
version = "0.26.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bd24728e5af82c6c4ec1b66ac4844bdf8156257fccda846ec58b42cd0cdbe6a"
dependencies = [
"rustls-pki-types",
]
[[package]]
name = "wgpu"
version = "0.19.4"
@ -4467,7 +4362,7 @@ dependencies = [
"parking_lot",
"profiling",
"raw-window-handle 0.6.2",
"rustc-hash",
"rustc-hash 1.1.0",
"smallvec",
"thiserror",
"web-sys",
@ -4507,7 +4402,7 @@ dependencies = [
"profiling",
"raw-window-handle 0.6.2",
"renderdoc-sys",
"rustc-hash",
"rustc-hash 1.1.0",
"smallvec",
"thiserror",
"wasm-bindgen",

View File

@ -20,7 +20,7 @@ libc = "0.2.153"
log = "0.4.21"
notify-rust = "4.11.3"
open = "5.3.0"
reqwest = "0.12.3"
reqwest = { version = "0.12.3", features = ["h2", "http2", "rustls-tls"], default-features = false }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
# serde_traitobject = "0.2.8"

18
scripts/build-release.sh Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/bash
if [[ -z "$1" ]]; then
echo "Please suppy a version: 0.0.0[a | b | rc-0]"
exit
fi
set -e
cargo build --release --target x86_64-pc-windows-gnu
cargo build --release --target x86_64-unknown-linux-gnu
cargo build --release --target aarch64-unknown-linux-gnu
strip --strip-unneeded ./target/x86_64-pc-windows-gnu/release/mcmg.exe -o ./target/mcmg_win32.exe
strip --strip-unneeded ./target/x86_64-unknown-linux-gnu/release/mcmg -o ./target/mcmg_linux_x86_64
aarch64-linux-gnu-strip --strip-unneeded ./target/aarch64-unknown-linux-gnu/release/mcmg -o ./target/mcmg_linux_aarch64
cp ./scripts/setup-template.sh "./target/mcmg-setup-$1.sh"
cp ./scripts/setup-template.ps1 "./target/mcmg-setup-$1.ps1"

View File

@ -0,0 +1,23 @@
$MyInvocation.MyCommand.Name -match '([0-9]+\.[0-9]+\.[0-9]+([ab]|(rc[-]*[0-9]*)))'
$Ver = $Matches[1]
if (-not (Get-Command ffmpeg -ErrorAction SilentlyContinue)) {
winget install Gyan.FFmpeg
}
if (-not (Get-Command "yt-dlp" -ErrorAction SilentlyContinue)) {
winget install "yt-dlp.yt-dlp"
}
if (-not (Get-Command spotdl -ErrorAction SilentlyContinue)) {
if (-not (Get-Command python -ErrorAction SilentlyContinue)) {
winget install "Python.Python.3.12"
}
python -m pip install spotdl
}
$url = "https://git.mcorangehq.xyz/XOR64/music/releases/download/$Ver/mcmg_win32.exe"
Invoke-WebRequest -Uri $url -OutFile "mcmg.exe"

42
scripts/setup-template.sh Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/bash
set -e
PROG_VER=$(echo $0 | grep -o -E "[0-9]+\.[0-9]+\.[0-9]+([ab]|(rc[-]*[0-9]*))")
echo $PROG_VER
function cmd_exists() {
if ! command -v $1 &> /dev/null
then
return 1
else
return 0
fi
}
if cmd_exists "pacman"; then
if cmd_exists "yay"; then
yay -Sy --needed ffmpeg yt-dlp spotdl curl
else
sudo pacman -Sy --needed ffmpeg yt-dlp python python-pip python-pipx curl
pipx install spotdl
fi
fi
if cmd_exists "apt"; then
sudo apt-get update
sudo apt-get install python3 python3-pip ffmpeg curl
# updates all python packages, uncomment if you get errors for packages
# pip3 freeze | grep -v '^\-e' | cut -d = -f 1 | xargs -n1 pip3 install -U
python3 -m pip install --upgrade pip
python3 -m pip install spotdl
python3 -m pip install yt-dlp
fi
curl "https://git.mcorangehq.xyz/XOR64/music/releases/download/${PROG_VER}/mcmg_linux_x86_64" -o mcmg

View File

@ -1,14 +1,11 @@
mod nav_bar;
mod song_edit_window;
use std::collections::HashSet;
use egui::{Button, Color32, Label, RichText, Sense};
use egui::{Color32, RichText};
use egui_extras::{Column, TableBuilder};
use song_edit_window::{GuiError, GuiImportPlaylist, GuiNewSong};
use crate::{config::{Config, ConfigWrapper}, downloader::Downloader, manifest::{song::{Song, SongType}, Manifest}};
use crate::{config::ConfigWrapper, downloader::Downloader, manifest::{song::{Song, SongType}, Manifest}};
use self::song_edit_window::GuiSongEditor;

View File

@ -1,8 +1,5 @@
use egui::Hyperlink;
use super::Gui;
impl Gui {
pub fn draw_nav(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {

View File

@ -1,10 +1,7 @@
use std::sync::Arc;
use egui::{text::{LayoutJob, TextWrapping}, Color32, Label, RichText, Style, TextBuffer, TextFormat, TextStyle};
use egui::{Color32, Label, RichText};
use crate::manifest::{playlist::Playlist, song::{Song, SongType}};
use crate::manifest::song::{Song, SongType};
use super::Gui;

View File

@ -13,8 +13,6 @@ use serde::{Deserialize, Serialize};
const DEFAULT_MANIFEST: &'static str = include_str!("../../manifest.default.json");
pub type SongName = String;
pub type Genre = HashMap<SongName, song::Song>;
#[allow(non_camel_case_types)]
#[derive(Debug, Serialize, Deserialize, Clone, Default)]
@ -43,7 +41,7 @@ impl Manifest {
pub fn get_format(&self) -> &Format {
&self.format
}
pub fn add_song(&mut self, playlist_name: &String, name: SongName, song: Song) -> Option<Song> {
pub fn add_song(&mut self, playlist_name: &String, name: String, song: Song) -> Option<Song> {
self.get_playlist_mut(playlist_name)?.add_song(name, song)
}
pub fn get_song(&self, playlist_name: &String, name: &String) -> Option<&Song> {

View File

@ -13,9 +13,6 @@ pub struct Playlist {
impl Playlist {
pub fn new() -> Self {
Self { ..Default::default() }
}
pub fn add_song(&mut self, name: String, song: Song) -> Option<Song> {
self.songs.insert(name, song)
@ -32,7 +29,8 @@ impl Playlist {
pub fn get_songs(&self) -> &HashMap<String, Song> {
&self.songs
}
#[allow(dead_code)]
pub fn get_songs_mut(&mut self) -> &mut HashMap<String, Song> {
&mut self.songs
}

View File

@ -1,22 +1,21 @@
use std::{collections::HashMap, io::Write};
pub(crate) fn simple_prompt(p: &str) -> String {
print!("{c}prompt{r}: {p} > ",
c=anstyle::AnsiColor::Cyan.render_fg(),
r=anstyle::Reset.render()
);
// I dont care if it fails
let _ = std::io::stdout().flush();
let mut buf = String::new();
let _ = std::io::stdin().read_line(&mut buf);
buf.trim().to_string()
}
//pub(crate) fn simple_prompt(p: &str) -> String {
//
// print!("{c}prompt{r}: {p} > ",
// c=anstyle::AnsiColor::Cyan.render_fg(),
// r=anstyle::Reset.render()
// );
//
// // I dont care if it fails
// let _ = std::io::stdout().flush();
//
// let mut buf = String::new();
// let _ = std::io::stdin().read_line(&mut buf);
//
// buf.trim().to_string()
//}
#[allow(dead_code)]
pub(crate) fn prompt_with_list(p: &str, options: &[&str]) -> usize {
@ -47,33 +46,33 @@ pub(crate) fn prompt_with_list(p: &str, options: &[&str]) -> usize {
}
}
pub(crate) fn prompt_with_list_or_str(p: &str, options: &[String]) -> String {
println!("{c}prompt{r}: {p} (select with number or input text)",
c=anstyle::AnsiColor::Cyan.render_fg(),
r=anstyle::Reset.render()
);
for (i, op) in options.iter().enumerate() {
println!(" - {}: {}", i, op);
}
print!("> ");
// I dont care if it fails
let _ = std::io::stdout().flush();
let mut buf = String::new();
let _ = std::io::stdin().read_line(&mut buf);
if let Ok(num) = buf.trim().parse::<usize>() {
if let Some(g) = options.get(num) {
return g.clone();
} else {
return prompt_with_list_or_str(p, options);
}
} else {
return buf.trim().to_string();
}
}
// pub(crate) fn prompt_with_list_or_str(p: &str, options: &[String]) -> String {
// println!("{c}prompt{r}: {p} (select with number or input text)",
// c=anstyle::AnsiColor::Cyan.render_fg(),
// r=anstyle::Reset.render()
// );
//
// for (i, op) in options.iter().enumerate() {
// println!(" - {}: {}", i, op);
// }
//
// print!("> ");
// // I dont care if it fails
// let _ = std::io::stdout().flush();
//
// let mut buf = String::new();
// let _ = std::io::stdin().read_line(&mut buf);
//
// if let Ok(num) = buf.trim().parse::<usize>() {
// if let Some(g) = options.get(num) {
// return g.clone();
// } else {
// return prompt_with_list_or_str(p, options);
// }
// } else {
// return buf.trim().to_string();
// }
// }
#[allow(dead_code)]

View File

@ -52,21 +52,11 @@ pub(crate) fn isatty() -> bool {
}
}
#[allow(dead_code)]
pub fn as_any_mut<T: Any>(val: &mut T) -> &mut dyn Any {
val as &mut dyn Any
}
// pub async fn dl_to_file(url: &str, p: PathBuf) -> anyhow::Result<()> {
// log::info!("Downloading {} -> {:?}", url, p);
// let ytdlp_req = reqwest::get(url).await?.bytes().await?;
// log::debug!("Downloading {:?} finished, writing to file", p);
// let mut fd = std::fs::File::create(&p)?;
// fd.write(&ytdlp_req)?;
// log::debug!("Finished writing {:?}", p);
// Ok(())
// }
pub fn get_song_path/*<P: TryInto<PathBuf>>*/(/*basepath: Option<P>,*/ pname: &String, sname: &String, format: &Format) -> PathBuf {
// let mut path: PathBuf;
/*if let Some(bp) = basepath {