Compare commits

..

1 Commits

Author SHA1 Message Date
dc01b36771
:3 2024-09-19 01:06:34 +03:00
16 changed files with 408 additions and 217 deletions

View File

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

262
Cargo.lock generated
View File

@ -924,7 +924,7 @@ dependencies = [
"cocoa-foundation", "cocoa-foundation",
"core-foundation", "core-foundation",
"core-graphics", "core-graphics",
"foreign-types", "foreign-types 0.5.0",
"libc", "libc",
"objc", "objc",
] ]
@ -1046,7 +1046,7 @@ dependencies = [
"bitflags 1.3.2", "bitflags 1.3.2",
"core-foundation", "core-foundation",
"core-graphics-types", "core-graphics-types",
"foreign-types", "foreign-types 0.5.0",
"libc", "libc",
] ]
@ -1315,6 +1315,15 @@ dependencies = [
"serde", "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]] [[package]]
name = "endi" name = "endi"
version = "1.1.0" version = "1.1.0"
@ -1514,6 +1523,15 @@ version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 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]] [[package]]
name = "foreign-types" name = "foreign-types"
version = "0.5.0" version = "0.5.0"
@ -1521,7 +1539,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965"
dependencies = [ dependencies = [
"foreign-types-macros", "foreign-types-macros",
"foreign-types-shared", "foreign-types-shared 0.3.1",
] ]
[[package]] [[package]]
@ -1535,6 +1553,12 @@ dependencies = [
"syn 2.0.77", "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]] [[package]]
name = "foreign-types-shared" name = "foreign-types-shared"
version = "0.3.1" version = "0.3.1"
@ -2017,7 +2041,22 @@ dependencies = [
"tokio", "tokio",
"tokio-rustls", "tokio-rustls",
"tower-service", "tower-service",
"webpki-roots", ]
[[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",
] ]
[[package]] [[package]]
@ -2385,7 +2424,7 @@ dependencies = [
"bitflags 2.6.0", "bitflags 2.6.0",
"block", "block",
"core-graphics-types", "core-graphics-types",
"foreign-types", "foreign-types 0.5.0",
"log", "log",
"objc", "objc",
"paste", "paste",
@ -2451,13 +2490,30 @@ dependencies = [
"indexmap", "indexmap",
"log", "log",
"num-traits", "num-traits",
"rustc-hash 1.1.0", "rustc-hash",
"spirv", "spirv",
"termcolor", "termcolor",
"thiserror", "thiserror",
"unicode-xid", "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]] [[package]]
name = "ndk" name = "ndk"
version = "0.8.0" version = "0.8.0"
@ -2775,6 +2831,50 @@ dependencies = [
"pathdiff", "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]] [[package]]
name = "orbclient" name = "orbclient"
version = "0.3.47" version = "0.3.47"
@ -3039,54 +3139,6 @@ dependencies = [
"memchr", "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]] [[package]]
name = "quote" name = "quote"
version = "1.0.37" version = "1.0.37"
@ -3219,6 +3271,8 @@ checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63"
dependencies = [ dependencies = [
"base64", "base64",
"bytes", "bytes",
"encoding_rs",
"futures-channel",
"futures-core", "futures-core",
"futures-util", "futures-util",
"h2", "h2",
@ -3227,30 +3281,29 @@ dependencies = [
"http-body-util", "http-body-util",
"hyper", "hyper",
"hyper-rustls", "hyper-rustls",
"hyper-tls",
"hyper-util", "hyper-util",
"ipnet", "ipnet",
"js-sys", "js-sys",
"log", "log",
"mime", "mime",
"native-tls",
"once_cell", "once_cell",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
"quinn",
"rustls",
"rustls-pemfile", "rustls-pemfile",
"rustls-pki-types",
"serde", "serde",
"serde_json", "serde_json",
"serde_urlencoded", "serde_urlencoded",
"sync_wrapper", "sync_wrapper",
"system-configuration",
"tokio", "tokio",
"tokio-rustls", "tokio-native-tls",
"tower-service", "tower-service",
"url", "url",
"wasm-bindgen", "wasm-bindgen",
"wasm-bindgen-futures", "wasm-bindgen-futures",
"web-sys", "web-sys",
"webpki-roots",
"windows-registry", "windows-registry",
] ]
@ -3281,12 +3334,6 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc-hash"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "583034fd73374156e66797ed8e5b0d5690409c9226b22d87cb7f19821c05d152"
[[package]] [[package]]
name = "rustix" name = "rustix"
version = "0.37.27" version = "0.37.27"
@ -3321,7 +3368,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8" checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8"
dependencies = [ dependencies = [
"once_cell", "once_cell",
"ring",
"rustls-pki-types", "rustls-pki-types",
"rustls-webpki", "rustls-webpki",
"subtle", "subtle",
@ -3370,6 +3416,15 @@ dependencies = [
"winapi-util", "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]] [[package]]
name = "scoped-tls" name = "scoped-tls"
version = "1.0.1" version = "1.0.1"
@ -3395,6 +3450,29 @@ dependencies = [
"tiny-skia", "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]] [[package]]
name = "serde" name = "serde"
version = "1.0.210" version = "1.0.210"
@ -3677,6 +3755,27 @@ dependencies = [
"futures-core", "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]] [[package]]
name = "tauri-winrt-notification" name = "tauri-winrt-notification"
version = "0.2.1" version = "0.2.1"
@ -3817,6 +3916,16 @@ dependencies = [
"syn 2.0.77", "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]] [[package]]
name = "tokio-rustls" name = "tokio-rustls"
version = "0.26.0" version = "0.26.0"
@ -3945,7 +4054,7 @@ version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "deb68604048ff8fa93347f02441e4487594adc20bb8a084f9e564d2b827a0a9f" checksum = "deb68604048ff8fa93347f02441e4487594adc20bb8a084f9e564d2b827a0a9f"
dependencies = [ dependencies = [
"rustc-hash 1.1.0", "rustc-hash",
] ]
[[package]] [[package]]
@ -4036,6 +4145,12 @@ version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "vcpkg"
version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426"
[[package]] [[package]]
name = "version_check" name = "version_check"
version = "0.9.5" version = "0.9.5"
@ -4311,15 +4426,6 @@ dependencies = [
"web-sys", "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]] [[package]]
name = "wgpu" name = "wgpu"
version = "0.19.4" version = "0.19.4"
@ -4362,7 +4468,7 @@ dependencies = [
"parking_lot", "parking_lot",
"profiling", "profiling",
"raw-window-handle 0.6.2", "raw-window-handle 0.6.2",
"rustc-hash 1.1.0", "rustc-hash",
"smallvec", "smallvec",
"thiserror", "thiserror",
"web-sys", "web-sys",
@ -4402,7 +4508,7 @@ dependencies = [
"profiling", "profiling",
"raw-window-handle 0.6.2", "raw-window-handle 0.6.2",
"renderdoc-sys", "renderdoc-sys",
"rustc-hash 1.1.0", "rustc-hash",
"smallvec", "smallvec",
"thiserror", "thiserror",
"wasm-bindgen", "wasm-bindgen",

View File

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

View File

@ -1,18 +0,0 @@
#!/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

@ -1,23 +0,0 @@
$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"

View File

@ -1,42 +0,0 @@
#!/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,11 +1,14 @@
mod nav_bar; mod nav_bar;
mod song_edit_window; mod song_edit_window;
use egui::{Color32, RichText};
use std::collections::HashSet;
use egui::{Button, Color32, Label, RichText, Sense};
use egui_extras::{Column, TableBuilder}; use egui_extras::{Column, TableBuilder};
use song_edit_window::{GuiError, GuiImportPlaylist, GuiNewSong}; use song_edit_window::{GuiError, GuiImportPlaylist, GuiNewSong};
use crate::{config::ConfigWrapper, downloader::Downloader, manifest::{song::{Song, SongType}, Manifest}}; use crate::{config::{Config, ConfigWrapper}, downloader::Downloader, manifest::{song::{Song, SongType}, Manifest}};
use self::song_edit_window::GuiSongEditor; use self::song_edit_window::GuiSongEditor;

View File

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

View File

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

View File

@ -0,0 +1,37 @@
#[cfg(all(target_os="windows", target_arch="x86_64"))]
pub const YTDLP: &str = "https://github.com/yt-dlp/yt-dlp/releases/download/2024.08.06/yt-dlp_min.exe";
#[cfg(all(target_os="linux", target_arch="x86_64"))]
pub const YTDLP: &str = "https://github.com/yt-dlp/yt-dlp/releases/download/2024.08.06/yt-dlp_linux";
#[cfg(all(target_os="linux", target_arch="aarch64"))]
pub const YTDLP: &str = "https://github.com/yt-dlp/yt-dlp/releases/download/2024.08.06/yt-dlp_linux_aarch64";
#[cfg(all(target_os="windows", target_arch="x86_64"))]
pub const SPOTDL: &str = "https://github.com/spotDL/spotify-downloader/releases/download/v4.2.8/spotdl-4.2.8-win32.exe";
#[cfg(all(target_os="linux", target_arch="x86_64"))]
pub const SPOTDL: &str = "https://github.com/spotDL/spotify-downloader/releases/download/v4.2.8/spotdl-4.2.8-linux";
#[cfg(all(target_os="linux", target_arch="aarch64"))]
pub const SPOTDL: &str = "";
#[cfg(all(target_os="windows", target_arch="x86_64"))]
pub const FFMPEG: &str = "https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip";
#[cfg(all(target_os="linux", target_arch="x86_64"))]
pub const FFMPEG: &str = "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz";
#[cfg(all(target_os="linux", target_arch="aarch64"))]
pub const FFMPEG: &str = "https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-arm64-static.tar.xz";
#[cfg(not(any(
all(target_os="windows", target_arch="x86_64"),
all(target_os="linux", target_arch="x86_64"),
all(target_os="linux", target_arch="aarch64"),
)))]
compile_error!("Target and or Architecture is not supported");

View File

@ -0,0 +1,111 @@
use std::path::{Path, PathBuf};
use crate::constants::EXEC_EXT;
mod links;
pub struct DepDownloader {
ytdlp: PathBuf,
spotdl: PathBuf,
ffmpeg: PathBuf,
}
impl DepDownloader {
pub fn new() -> anyhow::Result<Self> {
if !Path::new(".dep").exists() {
std::fs::create_dir(".dep")?;
}
let ytdlp = Self::download_ytdlp()?;
todo!()
}
fn download_ytdlp() -> anyhow::Result<PathBuf> {
if let Some(p) = crate::util::is_program_in_path("yt-dlp") {
return Ok(p); // Already exists on pc
}
let mut fp = PathBuf::new();
fp.push(".dep");
fp.push("yt-dlp");
fp.set_extension(EXEC_EXT);
if fp.exists() {
return Ok(fp);
}
let mut f = std::fs::OpenOptions::new()
.create_new(true)
.write(true)
.open(&fp)?;
let mut req = reqwest::blocking::get(links::YTDLP)?;
req.copy_to(&mut f)?;
Ok(fp)
}
fn download_spotdl() -> anyhow::Result<PathBuf> {
if let Some(p) = crate::util::is_program_in_path("spotdl") {
return Ok(p); // already exists on pc
}
let mut fp = PathBuf::new();
fp.push(".dep");
fp.push("spotdl");
fp.set_extension(EXEC_EXT);
if fp.exists() {
return Ok(fp);
}
if links::SPOTDL.is_empty() {
log::error!("spotdl doesnt support this architecture (probably aarch64)");
log::error!("please install it manually, if you have installed it, make sure its accessible in path");
anyhow::bail!("");
}
let mut f = std::fs::OpenOptions::new()
.create_new(true)
.write(true)
.open(&fp)?;
let mut req = reqwest::blocking::get(links::SPOTDL)?;
req.copy_to(&mut f)?;
Ok(fp)
}
fn download_ffmpeg() -> anyhow::Result<PathBuf> {
if let Some(p) = crate::util::is_program_in_path("ffmpeg") {
return Ok(p); // already exists on pc
}
let mut fp = PathBuf::new();
fp.push(".dep");
fp.push("ffmpeg");
fp.set_extension(EXEC_EXT);
if fp.exists() {
return Ok(fp);
}
if links::FFMPEG.is_empty() {
log::error!("spotdl doesnt support this architecture (probably aarch64)");
log::error!("please install it manually, if you have installed it, make sure its accessible in path");
anyhow::bail!("");
}
let mut f = std::fs::OpenOptions::new()
.create_new(true)
.write(true)
.open(&fp)?;
let mut req = reqwest::blocking::get(links::FFMPEG)?;
req.copy_to(&mut f)?;
Ok(fp)
}
}

View File

@ -1,12 +1,10 @@
pub mod cli; pub mod cli;
pub mod downloader;
use std::path::PathBuf; use std::path::PathBuf;
use clap::Parser; use clap::Parser;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use anyhow::Result; use anyhow::Result;
use crate::util::{self, isatty}; use crate::util::{self, isatty};
use self::cli::CliArgs; use self::cli::CliArgs;
// const YTDLP_DL_URL: &'static str = "https://github.com/yt-dlp/yt-dlp/archive/refs/heads/master.zip"; // const YTDLP_DL_URL: &'static str = "https://github.com/yt-dlp/yt-dlp/archive/refs/heads/master.zip";

View File

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

View File

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

View File

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

View File

@ -52,11 +52,21 @@ pub(crate) fn isatty() -> bool {
} }
} }
#[allow(dead_code)]
pub fn as_any_mut<T: Any>(val: &mut T) -> &mut dyn Any { pub fn as_any_mut<T: Any>(val: &mut T) -> &mut dyn Any {
val as &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 { pub fn get_song_path/*<P: TryInto<PathBuf>>*/(/*basepath: Option<P>,*/ pname: &String, sname: &String, format: &Format) -> PathBuf {
// let mut path: PathBuf; // let mut path: PathBuf;
/*if let Some(bp) = basepath { /*if let Some(bp) = basepath {