8 Commits
2.1.0 ... 2.1.3

Author SHA1 Message Date
7dcaa1436b [2.1.3] Unhardcode window title 2026-01-11 23:44:55 +02:00
c423993a93 myes, forgot to add this 2026-01-11 22:42:02 +02:00
bbffa5dbd3 [2.1.2] Better ui for searching
owo
2026-01-11 22:41:43 +02:00
d6b9d566d2 Save manifest when adding new song 2026-01-11 21:24:29 +02:00
2c2f35ff0a Fix mixed up placeholders for new song window input boxes 2026-01-11 21:18:04 +02:00
2aa0e5a1e8 Change behavour when tool is missing
Dont die when tool is missing
2026-01-11 21:17:36 +02:00
1b0af636df Update readme 2025-12-07 22:17:24 +02:00
f143e7976c [2.1.1] Now with Updates!
Added:
 - A working updater
2025-12-07 22:11:47 +02:00
16 changed files with 288 additions and 28 deletions

0
CHANGELOG.md Normal file
View File

35
Cargo.lock generated
View File

@@ -3898,6 +3898,12 @@ dependencies = [
"tiny-skia",
]
[[package]]
name = "semver"
version = "1.0.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2"
[[package]]
name = "serde"
version = "1.0.214"
@@ -5750,7 +5756,7 @@ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
[[package]]
name = "xmpd-cache"
version = "2.0.0"
version = "2.1.3"
dependencies = [
"anyhow",
"camino",
@@ -5767,7 +5773,7 @@ dependencies = [
[[package]]
name = "xmpd-cliargs"
version = "2.0.0"
version = "2.1.3"
dependencies = [
"camino",
"clap",
@@ -5777,7 +5783,7 @@ dependencies = [
[[package]]
name = "xmpd-core"
version = "2.0.0"
version = "2.1.3"
dependencies = [
"anyhow",
"camino",
@@ -5789,11 +5795,12 @@ dependencies = [
"xmpd-gui",
"xmpd-manifest",
"xmpd-settings",
"xmpd-update",
]
[[package]]
name = "xmpd-gui"
version = "2.0.0"
version = "2.1.3"
dependencies = [
"anyhow",
"camino",
@@ -5816,7 +5823,7 @@ dependencies = [
[[package]]
name = "xmpd-manifest"
version = "2.0.0"
version = "2.1.3"
dependencies = [
"anyhow",
"serde",
@@ -5830,7 +5837,7 @@ dependencies = [
[[package]]
name = "xmpd-player"
version = "2.0.0"
version = "2.1.3"
dependencies = [
"anyhow",
"lazy_static",
@@ -5840,7 +5847,7 @@ dependencies = [
[[package]]
name = "xmpd-settings"
version = "2.0.0"
version = "2.1.3"
dependencies = [
"anyhow",
"camino",
@@ -5853,7 +5860,19 @@ dependencies = [
[[package]]
name = "xmpd-tooling"
version = "2.0.0"
version = "2.1.3"
[[package]]
name = "xmpd-update"
version = "2.1.3"
dependencies = [
"anyhow",
"log",
"reqwest",
"semver",
"serde",
"serde_json",
]
[[package]]
name = "zbus"

View File

@@ -8,12 +8,12 @@ members=[
"xmpd-cache",
"xmpd-settings",
"xmpd-tooling",
"xmpd-player",
"xmpd-player", "xmpd-update",
# "xmpd-tui"
]
[workspace.package]
version="2.0.0"
version="2.1.3"
edition="2024"
repository="https://git.mcorangehq.xyz/XOR64/xmpd/"
license="GPL-3.0"
@@ -36,7 +36,7 @@ lazy_static = "1.4.0"
log = "0.4.21"
# notify-rust = "4.11.3"
# open = "5.3.0"
reqwest = { version = "0.12.3", features = ["blocking", "h2", "http2", "rustls-tls"], default-features = false }
reqwest = { version = "0.12.3", features = ["blocking", "h2", "http2", "rustls-tls", "json"], default-features = false }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
url = { version = "2.5.0", features = ["serde"] }
@@ -50,3 +50,5 @@ rfd = "0.15.1"
rodio = { version = "0.20.1", features = ["symphonia-all"] }
image = "0.25.5"
downcast-rs = "2.0.2"
semver = "1.0.27"
parse-changelog = "0.6.14"

View File

@@ -1,5 +1,9 @@
# (XMPD) Xor64 Music Player/Downloader
# **NOTE** This readme has outdated info, and needs to be updated
An open source music downloader AND player (soon (TM))
## Design

12
scripts/build_release.sh Executable file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/bash
set -x
rm target/xmpd target/xmpd.exe
set -e
cargo build --release --target x86_64-pc-windows-gnu
cargo build --release --target x86_64-unknown-linux-gnu
cp target/x86_64-unknown-linux-gnu/release/xmpd target/xmpd
cp target/x86_64-pc-windows-gnu/release/xmpd.exe target/xmpd.exe

View File

@@ -55,7 +55,9 @@ impl Cache {
}
}
}
anyhow::bail!("Tool {} was not found", tool_path)
// anyhow::bail!("Tool {} was not found", tool_path)
log::error!("Tool {tool_path:?} doesnt exist!");
Ok(())
}
pub fn init(&mut self) -> Result<Receiver<Message>> {
// Check for missing tooling

View File

@@ -25,6 +25,7 @@ xmpd-cliargs.path="../xmpd-cliargs"
xmpd-gui.path="../xmpd-gui"
xmpd-manifest.path="../xmpd-manifest"
xmpd-settings.path = "../xmpd-settings"
xmpd-update.path = "../xmpd-update"
clap.workspace=true
camino.workspace = true
anyhow.workspace = true

View File

@@ -10,12 +10,16 @@ fn main() -> Result<()> {
// NOTE: Parses on first load
let cliargs = &xmpd_cliargs::CLIARGS;
logger::init(&cliargs);
log::debug!("Initialising settings");
log::info!("Initialising settings");
{
xmpd_settings::Settings::get()?.load(Some(cliargs.settings_path().into_std_path_buf()))?;
xmpd_settings::Settings::get()?.load_cli_args(cliargs);
}
log::debug!("Starting gui");
log::info!("Starting updater");
xmpd_update::Update::new().update_xmpd_if_needed()?;
log::info!("Starting gui");
xmpd_gui::start()?;
Ok(())
}

View File

@@ -1,8 +1,10 @@
use eframe::Frame;
use egui::{Align, Align2, Area, Key, Layout, Order, Style};
use uuid::Uuid;
use xmpd_cache::DlStatus;
use xmpd_manifest::{song::Song, store::BaseStore};
use crate::{components::{left_nav::LeftNav, toast::ToastType, CompGetter, CompUi}, windows::WindowId};
use crate::{components::{CompGetter, CompUi, left_nav::LeftNav, toast::ToastType}, utils::SearchType, windows::WindowId};
use super::SongList;
@@ -15,6 +17,8 @@ pub struct Header {
component_register!(Header);
impl CompUi for Header {
fn draw(ui: &mut egui::Ui, state: &mut crate::GuiState) -> crate::Result<()> {
let theme = xmpd_settings::Settings::get()?.theme.clone();
@@ -26,7 +30,53 @@ impl CompUi for Header {
.tint(theme.accent_color);
ui.add(search_icon);
{
ui.text_edit_singleline(&mut handle_error_ui!(Header::get()).search_text);
let resp = ui.text_edit_singleline(&mut handle_error_ui!(Header::get()).search_text);
let popup_id = resp.id.with("mode_popup");
if resp.clicked() {
ui.memory_mut(|m| m.open_popup(popup_id));
}
// NOTE: Genuinely cancerous code incoming
let search_text = handle_error_ui!(Header::get()).search_text.clone();
if !search_text.is_empty() {
if ui.memory(|mem: &egui::Memory| mem.is_popup_open(popup_id)) {
Area::new(popup_id)
.order(Order::Foreground)
.constrain(true)
.fixed_pos(resp.rect.left_bottom())
.pivot(Align2::LEFT_TOP)
.show(ui.ctx(), |ui| {
let tf = crate::main_window::get_themed_frame(&theme)
.stroke(egui::Stroke::new(
1.5,
theme.secondary_bg_color,
));
let frame_margin = tf.total_margin();
tf.show(ui, |ui| {
ui.with_layout(Layout::top_down_justified(Align::LEFT), |ui| {
ui.set_width(resp.rect.width() - frame_margin.sum().x);
let st = SearchType::from_str(&search_text);
let style = ui.style_mut();
style.visuals.selection.bg_fill = theme.secondary_bg_color;
style.visuals.selection.stroke.color = theme.accent_color;
for item in &[SearchType::Author, SearchType::Source, SearchType::Genre] {
if ui.selectable_label(st.0 == *item, item.new_query(&st.1)).clicked() {
{
handle_error_ui!(Header::get()).search_text = item.new_query(&st.1);
}
ui.memory_mut(|m| m.close_popup());
}
}
})
})
});
if ui.input(|i| i.key_pressed(Key::Escape)) || resp.clicked_elsewhere() {
ui.memory_mut(|mem| mem.close_popup());
}
}
}
}
ui.with_layout(egui::Layout::right_to_left(egui::Align::RIGHT), |ui| {

View File

@@ -25,7 +25,7 @@ impl CompUi for SongList {
let mut sl = SongList::get()?;
sl.playable_songs = Self::get_playable_songs(&songs)?;
if let Some((sid, _)) = songs.first() {
if sl.selected_sid == Default::default() {
if sl.selected_sid.eq(&uuid::Uuid::default()) {
sl.selected_sid = (*sid).clone();
}
}
@@ -66,6 +66,7 @@ impl SongList {
let should_display = match &query_type {
SearchType::Normal |
SearchType::Author |
SearchType::Genre |
SearchType::Source if query_text.is_empty() => true,
SearchType::Source => {
@@ -83,6 +84,13 @@ impl SongList {
.to_lowercase()
.contains(&query_text)
},
SearchType::Genre => {
song.genres()
.iter()
.map(|v| v.to_lowercase().contains(&query_text))
.collect::<Vec<bool>>()
.contains(&true)
},
};
if should_display {

View File

@@ -11,7 +11,6 @@ mod components;
mod data;
mod utils;
const W_NAME: &str = "xmpd v2.0.0a";
type Result<T> = anyhow::Result<T>;
@@ -24,7 +23,7 @@ pub fn start() -> Result<()> {
let options = eframe::NativeOptions::default();
let mut state = GuiState::new(&manifest_p)?;
let res = eframe::run_simple_native(W_NAME, options, move |ctx, _frame| {
let res = eframe::run_simple_native(&format!("xmpd v{}", env!("CARGO_PKG_VERSION")), options, move |ctx, _frame| {
#[cfg(debug_assertions)]
let f_start = Instant::now();

View File

@@ -94,7 +94,7 @@ pub fn draw(ctx: &egui::Context, state: &mut GuiState, cache_rx: &Receiver<Messa
Ok(())
}
fn get_themed_frame(theme: &Theme) -> egui::Frame {
pub fn get_themed_frame(theme: &Theme) -> egui::Frame {
egui::Frame::none()
.fill(theme.primary_bg_color)
.stroke(egui::Stroke::new(

View File

@@ -1,9 +1,12 @@
use std::fmt::Display;
#[derive(Debug, Clone)]
#[derive(Debug, Clone, PartialEq, PartialOrd)]
pub enum SearchType {
Normal,
Author,
Source,
Genre
}
impl SearchType {
@@ -13,9 +16,27 @@ impl SearchType {
(Self::Source, i.strip_prefix("source:").unwrap_or("").to_string().to_lowercase()),
i @ _ if i.starts_with("author:") =>
(Self::Author, i.strip_prefix("author:").unwrap_or("").to_string().to_lowercase()),
i @ _ if i.starts_with("genre:") =>
(Self::Author, i.strip_prefix("genre:").unwrap_or("").to_string().to_lowercase()),
i @ _ => (Self::Normal, i.to_string().to_lowercase())
}
}
pub fn new_query(&self, s: &str) -> String {
format!("{self}:{s}")
}
}
impl Display for SearchType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let s = match self {
Self::Normal => "",
Self::Genre => "genre",
Self::Source => "source",
Self::Author => "author"
};
f.write_str(s)?;
Ok(())
}
}
pub fn super_separator(ui: &mut egui::Ui, color: egui::Color32, width: f32, height: f32) {

View File

@@ -99,8 +99,8 @@ impl Window for NewSongW {
ui.horizontal(|ui| {
ui.add_space(3.0);
if ui.button("Close").clicked() {
self.author = String::from("New Song");
self.name = String::from("Unknown");
self.author = String::from("Unknown");
self.name = String::from("New Song");
self.source_t = SourceType::Youtube;
self.source_url = String::default();
state.windows.toggle(&WindowId::NewSong, false);
@@ -111,16 +111,16 @@ impl Window for NewSongW {
s.set_name(&self.name);
s.set_author(&self.author);
state.manifest.store_mut().get_songs_mut().insert(uuid::Uuid::new_v4(), s);
self.author = String::from("New Song");
self.name = String::from("Unknown");
let _ = state.manifest.save();
self.author = String::from("Unknown");
self.name = String::from("New Song");
self.source_t = SourceType::Youtube;
self.source_url = String::default();
}
if ui.button("Cancel").clicked() {
self.author = String::from("New Song");
self.name = String::from("Unknown");
self.author = String::from("Unknown");
self.name = String::from("New Song");
self.source_t = SourceType::Youtube;
self.source_url = String::default();
state.windows.toggle(&WindowId::NewSong, false);

15
xmpd-update/Cargo.toml Normal file
View File

@@ -0,0 +1,15 @@
[package]
name = "xmpd-update"
version.workspace = true
edition.workspace = true
repository.workspace = true
license.workspace = true
authors.workspace = true
[dependencies]
reqwest.workspace = true
anyhow.workspace = true
serde.workspace = true
serde_json.workspace = true
semver.workspace = true
log.workspace = true

123
xmpd-update/src/lib.rs Normal file
View File

@@ -0,0 +1,123 @@
#[cfg(target_family = "unix")]
use std::{fs::Permissions, os::unix::fs::PermissionsExt};
use std::{env::args, path::PathBuf, process::{Stdio, exit}, str::FromStr};
use anyhow::anyhow;
use reqwest::blocking::Client;
use serde::Deserialize;
const CURRENT_VERSION: &'static str = env!("CARGO_PKG_VERSION");
const GIT_HOST: &'static str = "git.mcorangehq.xyz";
const GIT_USER: &'static str = "XOR64";
const GIT_REPO: &'static str = "xmpd";
#[cfg(target_family = "windows")]
const EXT: &'static str = ".exe";
#[cfg(target_family = "unix")]
const EXT: &'static str = "";
pub type Result<T> = anyhow::Result<T>;
#[derive(Debug, Deserialize)]
struct ReleaseInfo {
tag_name: String,
assets: Vec<ReleaseAsset>,
}
#[derive(Debug, Deserialize)]
struct ReleaseAsset {
browser_download_url: String,
name: String,
}
pub struct Update {
}
impl Update {
pub fn new() -> Self {
Self {}
}
pub fn update_xmpd_if_needed(&self) -> Result<()> {
let current = semver::Version::parse(CURRENT_VERSION)?;
log::info!("Current xmpd version: {current}");
let client = Client::new();
let req = client
.get(format!("https://{GIT_HOST}/api/v1/repos/{GIT_USER}/{GIT_REPO}/releases/latest"))
.send();
let Ok(req) = req else {
log::warn!("Unable to check latest release! (No internet?)");
return Ok(());
};
let exec_p = std::env::current_exe()?;
let exec_d = exec_p.parent().unwrap_or(&exec_p);
let release: ReleaseInfo = req.json().map_err(|e| anyhow!("Unable to parse release info: {e}"))?;
let latest = semver::Version::parse(&release.tag_name)?;
log::info!("Latest xmpd version: {latest}");
if latest > current {
log::warn!("Update available, proceeding to update!");
for asset in release.assets {
if asset.name != format!("xmpd{EXT}") {
continue;
}
let tmp_f = exec_d.join(format!("xmpd.update{EXT}"));
let old_f = exec_d.join(format!("xmpd.old{EXT}"));
log::info!("Downloading {}...", asset.browser_download_url);
let mut res;
match reqwest::blocking::get(asset.browser_download_url) {
Ok(r) => res = r,
Err(e) => {
log::error!("Failed to download update: {e}");
return Ok(());
}
}
let mut tmp_h = std::fs::File::create(&tmp_f)?;
if let Err(e) = std::io::copy(&mut res, &mut tmp_h) {
log::error!("Failed to write update to file: {e}");
return Ok(());
}
drop(tmp_h); // close handle (just in case you didnt know)
#[cfg(target_family = "unix")]
{
// set *only* the exec bit, doesnt change other permissions
let meta = std::fs::metadata(&tmp_f)?;
let mut perms = meta.permissions();
perms.set_mode(perms.mode() | 0o111);
std::fs::set_permissions(&tmp_f, perms)?;
}
std::fs::rename(&exec_p, &old_f)?;
std::fs::rename(&tmp_f, &exec_p)?;
log::debug!("{exec_p:?} -> {old_f:?}");
log::debug!("{tmp_f:?} -> {exec_p:?}");
log::info!("Update done, restarting!");
let status = std::process::Command::new(exec_p)
.args(&args().collect::<Vec<String>>().as_slice()[1..])
.stdin(Stdio::inherit())
.stdout(Stdio::inherit())
.stderr(Stdio::inherit())
.status()?;
exit(status.code().unwrap_or(0));
}
} else {
log::info!("Already at latest version, skipping update!");
}
Ok(())
}
}