Compare commits

..

21 Commits
0.0.1b ... main

Author SHA1 Message Date
712e918e08
We dont care about formatting THAT much
Some checks failed
Continuous integration / Clippy (push) Failing after 46s
Continuous integration / build (push) Successful in 1m3s
2024-10-11 02:48:32 +03:00
787c01b9dc
More formatting
Some checks failed
Continuous integration / Clippy (push) Failing after 46s
Continuous integration / build (push) Successful in 1m0s
2024-10-11 02:46:27 +03:00
e0201ccb50
Some other formatting changes
Some checks failed
Continuous integration / Clippy (push) Failing after 42s
Continuous integration / build (push) Successful in 54s
2024-10-11 02:43:36 +03:00
7edb257e2f
Fixed clippy errors 2024-10-11 02:33:05 +03:00
dfc55837ee
Added rust-toolchain.toml to use nightly channel by default
Some checks failed
Continuous integration / Clippy (push) Failing after 3m9s
Continuous integration / build (push) Failing after 4m16s
2024-10-11 02:25:23 +03:00
0435d33e58
Remove rustfmt from CI
Some checks failed
Continuous integration / Clippy (push) Failing after 1m47s
Continuous integration / build (push) Has been cancelled
2024-10-11 02:20:32 +03:00
193029d4e1
Added initial CI
Some checks failed
Continuous integration / build (push) Waiting to run
Continuous integration / Rustfmt (push) Failing after 1m28s
Continuous integration / Clippy (push) Has been cancelled
2024-10-11 02:17:27 +03:00
14c53d96c0
Did #0 (added context menu to side_nav), fixed some spelling errors, implemented deleting from manifest for both side_nav and song_list 2024-10-10 22:42:04 +03:00
84ab965b9d
More todos! 2024-10-10 02:25:03 +03:00
2e57642aa3
Typo's, and fix up todo's 2024-10-10 02:20:33 +03:00
2ddb2b8a89
Fix missing links 2024-10-10 02:16:33 +03:00
31a710c6cb
Add licensing, readme, todo file
Fix the cursor showing as the 'edit text' type when hovering over a
playlist in the side nav bar
2024-10-10 02:13:49 +03:00
70b92f4ebf
New icons, new side panel, table no longer shows playlists, as they are selectable seperately 2024-10-09 15:02:24 +03:00
847aa2bb4f
Updated icon 2024-09-22 02:17:34 +03:00
f7008e882c
Clippy pedantic fixes 2024-09-22 02:16:18 +03:00
387a5eaf4a
How did that happen? (Deleted left over file) 2024-09-22 01:12:08 +03:00
f26fd97809
Modularised components, moved everythign there 2024-09-22 01:07:34 +03:00
2cde24e7a8
Rewrite the structure of the gui and cli interfaces
Added a more modular way to add windows
2024-09-22 00:42:50 +03:00
33ca4502e4
Fixed warnings from cargo 2024-09-19 19:12:07 +03:00
6e70d38f7f Added support for windows setup (hopefully) 2024-09-19 18:49:50 +03:00
affafed441
Added scripts for building and release making 2024-09-19 18:09:47 +03:00
47 changed files with 3095 additions and 1518 deletions

2
.cargo/config.toml Normal file
View File

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

37
.gitea/workflows/ci.yml Normal file
View File

@ -0,0 +1,37 @@
on: [push, pull_request]
name: Continuous integration
jobs:
#check:
# name: Check
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions-rust-lang/setup-rust-toolchain@v1
# - run: cargo check
#test:
# name: Test Suite
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions-rust-lang/setup-rust-toolchain@v1
# - run: cargo test
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: rustup component add clippy
- run: cargo clippy
build:
name: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
- run: cargo build

543
Cargo.lock generated
View File

@ -579,6 +579,12 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "base64"
version = "0.21.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
[[package]]
name = "base64"
version = "0.22.1"
@ -924,7 +930,7 @@ dependencies = [
"cocoa-foundation",
"core-foundation",
"core-graphics",
"foreign-types 0.5.0",
"foreign-types",
"libc",
"objc",
]
@ -953,6 +959,12 @@ dependencies = [
"unicode-width",
]
[[package]]
name = "color-hex"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ecdffb913a326b6c642290a0d0ec8e8d6597291acdc07cc4c9cb4b3635d44cf9"
[[package]]
name = "color_quant"
version = "1.1.0"
@ -1046,7 +1058,7 @@ dependencies = [
"bitflags 1.3.2",
"core-foundation",
"core-graphics-types",
"foreign-types 0.5.0",
"foreign-types",
"libc",
]
@ -1101,6 +1113,12 @@ version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96a6ac251f4a2aca6b3f91340350eab87ae57c3f127ffeb585e92bd336717991"
[[package]]
name = "data-url"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c297a1c74b71ae29df00c3e22dd9534821d60eb9af5a0192823fa2acea70c2a"
[[package]]
name = "deranged"
version = "0.3.11"
@ -1190,6 +1208,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20930a432bbd57a6d55e07976089708d4893f3d556cf42a0d79e9e321fa73b10"
dependencies = [
"bytemuck",
"color-hex",
"serde",
]
@ -1283,9 +1302,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b78779f35ded1a853786c9ce0b43fe1053e10a21ea3b23ebea411805ce41593"
dependencies = [
"egui",
"ehttp",
"enum-map",
"image",
"log",
"mime_guess2",
"resvg",
"serde",
]
@ -1305,6 +1327,20 @@ dependencies = [
"winit",
]
[[package]]
name = "ehttp"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "59a81c221a1e4dad06cb9c9deb19aea1193a5eea084e8cd42d869068132bf876"
dependencies = [
"document-features",
"js-sys",
"ureq",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
]
[[package]]
name = "emath"
version = "0.27.2"
@ -1315,15 +1351,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"
@ -1517,21 +1544,18 @@ dependencies = [
"miniz_oxide 0.8.0",
]
[[package]]
name = "float-cmp"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
[[package]]
name = "fnv"
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 +1563,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 +1577,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"
@ -1960,6 +1978,15 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "html-escape"
version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d1ad449764d627e22bfd7cd5e8868264fc9236e07c752972b4080cd351cb476"
dependencies = [
"utf8-width",
]
[[package]]
name = "http"
version = "1.1.0"
@ -2041,22 +2068,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]]
@ -2113,6 +2125,12 @@ dependencies = [
"png",
]
[[package]]
name = "imagesize"
version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "029d73f573d8e8d63e6d5020011d3255b28c3ba85d6cf870a07184ed23de9284"
[[package]]
name = "indexmap"
version = "2.5.0"
@ -2246,6 +2264,15 @@ version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc"
[[package]]
name = "kurbo"
version = "0.9.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd85a5776cd9500c2e2059c8c76c3b01528566b7fcbaf8098b55a33fc298849b"
dependencies = [
"arrayvec",
]
[[package]]
name = "lazy_static"
version = "1.5.0"
@ -2355,33 +2382,6 @@ dependencies = [
"libc",
]
[[package]]
name = "mcmg"
version = "0.1.0"
dependencies = [
"anstyle",
"anyhow",
"camino",
"clap",
"eframe",
"egui",
"egui_extras",
"env_logger",
"futures",
"lazy_static",
"libc",
"log",
"notify-rust",
"open",
"reqwest",
"serde",
"serde_json",
"tokio",
"url",
"windows 0.56.0",
"zip-extensions",
]
[[package]]
name = "memchr"
version = "2.7.4"
@ -2424,7 +2424,7 @@ dependencies = [
"bitflags 2.6.0",
"block",
"core-graphics-types",
"foreign-types 0.5.0",
"foreign-types",
"log",
"objc",
"paste",
@ -2490,30 +2490,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 +2814,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"
@ -2973,6 +2912,12 @@ version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "pico-args"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315"
[[package]]
name = "pin-project"
version = "1.1.5"
@ -3139,6 +3084,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"
@ -3190,6 +3183,12 @@ version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539"
[[package]]
name = "rctree"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b42e27ef78c35d3998403c1d26f3efd9e135d3e5121b0a4845cc5cc27547f4f"
[[package]]
name = "redox_syscall"
version = "0.3.5"
@ -3230,9 +3229,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.10.6"
version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4219d74c6b67a3654a9fbebc4b419e22126d13d2f3c4a07ee0cb61ff79a79619"
checksum = "38200e5ee88914975b69f657f0801b6f6dccafd44fd9326302a4aaeecfacb1d8"
dependencies = [
"aho-corasick",
"memchr",
@ -3242,9 +3241,9 @@ dependencies = [
[[package]]
name = "regex-automata"
version = "0.4.7"
version = "0.4.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df"
checksum = "368758f23274712b504848e9d5a6f010445cc8b87a7cdb4d7cbee666c1288da3"
dependencies = [
"aho-corasick",
"memchr",
@ -3253,9 +3252,9 @@ dependencies = [
[[package]]
name = "regex-syntax"
version = "0.8.4"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "renderdoc-sys"
@ -3269,9 +3268,9 @@ version = "0.12.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8f4955649ef5c38cc7f9e8aa41761d48fb9677197daea9984dc54f56aad5e63"
dependencies = [
"base64",
"base64 0.22.1",
"bytes",
"encoding_rs",
"futures-channel",
"futures-core",
"futures-util",
"h2",
@ -3280,32 +3279,56 @@ 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",
]
[[package]]
name = "resvg"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cadccb3d99a9efb8e5e00c16fbb732cbe400db2ec7fc004697ee7d97d86cf1f4"
dependencies = [
"log",
"pico-args",
"rgb",
"svgtypes",
"tiny-skia",
"usvg",
]
[[package]]
name = "rgb"
version = "0.8.50"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a"
dependencies = [
"bytemuck",
]
[[package]]
name = "ring"
version = "0.17.8"
@ -3321,6 +3344,12 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "roxmltree"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3cd14fd5e3b777a7422cca79358c57a8f6e3a703d9ac187448d0daf220c2407f"
[[package]]
name = "rustc-demangle"
version = "0.1.24"
@ -3333,6 +3362,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"
@ -3366,7 +3401,9 @@ version = "0.23.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2dabaac7466917e566adb06783a81ca48944c6898a1b08b9374106dd671f4c8"
dependencies = [
"log",
"once_cell",
"ring",
"rustls-pki-types",
"rustls-webpki",
"subtle",
@ -3379,7 +3416,7 @@ version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "196fe16b00e106300d3e45ecfcb764fa292a535d7326a29a5875c579c7417425"
dependencies = [
"base64",
"base64 0.22.1",
"rustls-pki-types",
]
@ -3415,15 +3452,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 +3477,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"
@ -3570,6 +3575,21 @@ version = "0.3.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
[[package]]
name = "simplecss"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a11be7c62927d9427e9f40f3444d5499d868648e2edbc4e2116de69e7ec0e89d"
dependencies = [
"log",
]
[[package]]
name = "siphasher"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
[[package]]
name = "slab"
version = "0.4.9"
@ -3710,6 +3730,9 @@ name = "strict-num"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
dependencies = [
"float-cmp",
]
[[package]]
name = "strsim"
@ -3723,6 +3746,16 @@ version = "2.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "svgtypes"
version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e44e288cd960318917cbd540340968b90becc8bc81f171345d706e7a89d9d70"
dependencies = [
"kurbo",
"siphasher",
]
[[package]]
name = "syn"
version = "1.0.109"
@ -3754,27 +3787,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"
@ -3858,6 +3870,7 @@ dependencies = [
"bytemuck",
"cfg-if",
"log",
"png",
"tiny-skia-path",
]
@ -3915,16 +3928,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 +4056,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]]
@ -4127,6 +4130,22 @@ version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "ureq"
version = "2.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b74fc6b57825be3373f7054754755f03ac3a8f5d70015ccad699ba2029956f4a"
dependencies = [
"base64 0.22.1",
"flate2",
"log",
"once_cell",
"rustls",
"rustls-pki-types",
"url",
"webpki-roots",
]
[[package]]
name = "url"
version = "2.5.2"
@ -4138,18 +4157,62 @@ dependencies = [
"percent-encoding",
]
[[package]]
name = "usvg"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38b0a51b72ab80ca511d126b77feeeb4fb1e972764653e61feac30adc161a756"
dependencies = [
"base64 0.21.7",
"log",
"pico-args",
"usvg-parser",
"usvg-tree",
"xmlwriter",
]
[[package]]
name = "usvg-parser"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9bd4e3c291f45d152929a31f0f6c819245e2921bfd01e7bd91201a9af39a2bdc"
dependencies = [
"data-url",
"flate2",
"imagesize",
"kurbo",
"log",
"roxmltree",
"simplecss",
"siphasher",
"svgtypes",
"usvg-tree",
]
[[package]]
name = "usvg-tree"
version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ee3d202ebdb97a6215604b8f5b4d6ef9024efd623cf2e373a6416ba976ec7d3"
dependencies = [
"rctree",
"strict-num",
"svgtypes",
"tiny-skia-path",
]
[[package]]
name = "utf8-width"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "86bd8d4e895da8537e5315b8254664e6b769c4ff3db18321b297a1e7004392e3"
[[package]]
name = "utf8parse"
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 +4488,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 +4539,7 @@ dependencies = [
"parking_lot",
"profiling",
"raw-window-handle 0.6.2",
"rustc-hash",
"rustc-hash 1.1.0",
"smallvec",
"thiserror",
"web-sys",
@ -4507,7 +4579,7 @@ dependencies = [
"profiling",
"raw-window-handle 0.6.2",
"renderdoc-sys",
"rustc-hash",
"rustc-hash 1.1.0",
"smallvec",
"thiserror",
"wasm-bindgen",
@ -5062,6 +5134,41 @@ version = "0.8.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af4e2e2f7cba5a093896c1e150fbfe177d1883e7448200efb81d40b9d339ef26"
[[package]]
name = "xmlwriter"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
[[package]]
name = "xmpd"
version = "0.1.0"
dependencies = [
"anstyle",
"anyhow",
"camino",
"clap",
"eframe",
"egui",
"egui_extras",
"env_logger",
"futures",
"html-escape",
"lazy_static",
"libc",
"log",
"notify-rust",
"open",
"regex",
"reqwest",
"serde",
"serde_json",
"tokio",
"url",
"windows 0.56.0",
"zip-extensions",
]
[[package]]
name = "zbus"
version = "3.15.2"

View File

@ -1,5 +1,5 @@
[package]
name = "mcmg"
name = "xmpd"
version = "0.1.0"
edition = "2021"
@ -11,16 +11,18 @@ anyhow = "1.0.81"
camino = "1.1.6"
clap = { version = "4.5.4", features = ["derive"] }
eframe = "0.27.2"
egui = "0.27.2"
egui_extras = "0.27.2"
egui = { version = "0.27.2", features = ["color-hex"] }
egui_extras = { version = "0.27.2", features = ["all_loaders"] }
env_logger = "0.11.3"
futures = "0.3.30"
html-escape = "0.2.13"
lazy_static = "1.4.0"
libc = "0.2.153"
log = "0.4.21"
notify-rust = "4.11.3"
open = "5.3.0"
reqwest = "0.12.3"
regex = "1.11.0"
reqwest = { version = "0.12.3", features = ["blocking", "h2", "http2", "rustls-tls"], default-features = false }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
# serde_traitobject = "0.2.8"

85
DEV.md Normal file
View File

@ -0,0 +1,85 @@
# Developer notes
## TODO'S
Todo types:
[FEAT] \[loc\](/src/...) - Feature, mandatory location
[BUG] \[loc\](/src/...) - Bugfix, mandatory location
[GIT] \[loc\](/src/...) - Git related feature, optional location
Todos that have been merged have to add `**DONE**` prefix to the type
### #0
**DONE** ~~[FEAT] - [side_nav](/src/ui/gui/components/mod.rs)
Add dropdown menu for `side_nav` playlist~~
### #1
[FEAT] - [gui](/src/ui/gui/)
Move theme selection to a settings panel
### #2
[FEAT] - [gui](/src/ui/gui/)
Better styling
### #3
[FEAT] - [gui](/src/ui/gui/)
Add music player footer
### #4
[FEAT] - [gui](/src/ui/gui/components/song_list/mod.rs)
Add numbers to `song_list` table
### #5
[FEAT] - [NEW](/src/)
Add music player logic
### #6
[FEAT] - [manifest](/src/manifest/mod.rs)
Add support for images by possibly storing the images in json or custom format
### #7
[FEAT] - [*global*](/src/)
Transition application into a globally installed application by default from a
standalone one, moving default paths and using [#10](#10):
| Type | Unix path | Windows path |
|--------------|--------------------------------|--------------------------------|
| config | `~/.config/mcmg/config.json` | `%AppData%/mcmg/config.json` |
| manifest | `~/.config/mcmg/manifest.json` | `%AppData%/mcmg/manifest.json` |
| music-output | `~/Music/mcmg/*` | `%userprofile%/Music/mcmg/*` |
### #8
[FEAT] - [cli](/src/ui/cli/mod.rs)
add missing commands that are available via gui
- Downloading single songs, from the manifest and standalone as an utility
- removing playlists, single songs
### #9
[BUG] - [utils](/src/util.rs)
Fix `isatty` not working correctly on windows
### #10
[FEAT] - [utils](/src/util.rs)
Add an utility to detect if this is ran as a standalone application
### #11
[FEAT] - [downloader](/src/downloader.rs)
Refractor downloader for better readability and usage
### #12
[GIT]
Add ci that runs clippy and builds in release mode
### #13
[FEAT] - [assets](/assets/)
Make new icons for the app, preferably svg, except the app icon must be both svg and png
### #14
[FEAT] - [manifest](/src/manifest/) [downloader](/src/downloader.rs)
Add custom type for downloading, one for simple http downloads, and archived ones (zip, 7z, etc)
### #15
[FEAT] - [dependencies](/Cargo.toml)
Clean up dependencies, remove unneeded features for executable size
### #16
[FEAT] - [song_list](/src/ui/gui/components/song_list/mod.rs)
Add a checkmark or an X depending on if the song is downloaded to disk

675
LICENSE.md Normal file
View File

@ -0,0 +1,675 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<https://www.gnu.org/licenses/why-not-lgpl.html>.

46
README.md Normal file
View File

@ -0,0 +1,46 @@
# (XMPD) Xor64 Music Player/Downloader
An open source music downloader AND player (soon (TM))
## Design
Written in rust, it *tries* to be fast, reliable, and actually useful, as it doesnt stream the music from a server where it could be
deleted and lost forever.
It uses [egui](https://www.egui.rs/) for a crossplatform frontend that makes it possible to run almost anywhere.
The music is downloaded via [ytdlp](#Dependencies) and [spotdl](#Dependencies), and converted to your favorite format via [ffmpeg](#Dependencies)
## Offline usage
Your whole music library is downloaded to your music folder (unless its being ran in standalone mode). Saved in your selected format.
All of the info required to download your songs is stored in 1 file (!). So all you need to backup all of your music is just 1 relatively small file AND you get the added benefit of easily moving your music between devices with just 1 manifest file, 1 executable (and 3 [dependencies](#dependencies)). Just press `download all` and see as all of your playlists appear in your hard drive, powered by Open Source software.
## Dependencies
[ffmpeg](https://ffmpeg.org/): To convert your music files to your desired format.
[spotdl](https://github.com/spotDL/spotify-downloader): To download music from spotify, because ofcourse spotify had to be the special child
[ytdlp](https://github.com/yt-dlp/yt-dlp): To download music from every single other source
The rust dependencies can be found in the [Cargo.toml](/Cargo.toml) file.
## Installation
Just run `xmpd-setup-{version}.sh` for GNU/Linux or `xmpd-setup-{version}.ps1` for Windows!
## Compilation
Building the amazing xmpd executable is really simple:
- make sure rust is installed by running `cargo --help`
- clone the git repo by running `git clone https://git.mcorangehq.xyz/XOR64/xmpd.git` in your desired directory
- run `cargo build --release`
- The executable should be in `./target/release/xmpd`
NOTE: If you run the executable from the terminal it will start downloading all of your songs, to open the gui run `xmpd gui`,
for more info run `xmpd --help`
## Contributing
Fork and clone your repo, you will probably want to use ssh for cloning.
After adding your features or bugfixes push the changes to your fork.
After making sure xmpd works fine, and you havent found any bugs, make a pull request on `https://git.mcorangehq.xyz/XOR64/xmpd/pulls`
If we approve your changes it will be pushed to the main branch, and added to the contributors!
Current todos are stored in [DEV.md](/DEV.md)
## Licensing
See [LICENSE.md](/LICENSE.md) for the licensing terms

BIN
assets/app_icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

19
assets/note.svg Normal file
View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 20 20" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>music [#1005]</title>
<desc>Created with Sketch.</desc>
<defs>
</defs>
<g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Dribbble-Light-Preview" transform="translate(-260.000000, -3759.000000)" fill="#ffffff">
<g id="icons" transform="translate(56.000000, 160.000000)">
<path d="M224,3601.05129 L224,3610.55901 C224,3612.90979 222.17612,3614.95492 219.888035,3614.89646 C217.266519,3614.82877 215.248971,3612.1662 216.234285,3609.31593 C216.777356,3607.74464 218.297755,3606.71797 219.920978,3606.69233 C220.695653,3606.68105 220.976173,3606.88208 222.003416,3607.24105 L222.003416,3604.12822 C222.003416,3603.56207 221.556181,3603.10258 221.005124,3603.10258 L213.018786,3603.10258 C212.467729,3603.10258 212.020494,3603.56207 212.020494,3604.12822 L212.020494,3614.65851 C212.020494,3617.02057 210.179644,3619.07289 207.881575,3618.99801 C205.681339,3618.92622 203.914362,3617.02775 204.00321,3614.73031 C204.090061,3612.51594 205.989811,3610.84209 208.147121,3610.79081 C209.166377,3610.76619 209.352059,3610.92619 210.02391,3611.34363 L210.02391,3601.05129 C210.02391,3599.91795 210.91838,3599 212.020494,3599 L222.003416,3599 C223.106529,3599 224,3599.91795 224,3601.05129" id="music-[#1005]">
</path>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

4
assets/search.svg Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
<svg width="800px" height="800px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11 6C13.7614 6 16 8.23858 16 11M16.6588 16.6549L21 21M19 11C19 15.4183 15.4183 19 11 19C6.58172 19 3 15.4183 3 11C3 6.58172 6.58172 3 11 3C15.4183 3 19 6.58172 19 11Z" stroke="#ffffff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

After

Width:  |  Height:  |  Size: 493 B

File diff suppressed because it is too large Load Diff

2
rust-toolchain.toml Normal file
View File

@ -0,0 +1,2 @@
[toolchain]
channel="nightly"

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

@ -0,0 +1,18 @@
#!/usr/bin/bash
if [[ -z "$1" ]]; then
echo "Please supply 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/xmpd.exe -o ./target/xmpd_win32.exe
strip --strip-unneeded ./target/x86_64-unknown-linux-gnu/release/xmpd -o ./target/xmpd_linux_x86_64
aarch64-linux-gnu-strip --strip-unneeded ./target/aarch64-unknown-linux-gnu/release/xmpd -o ./target/xmpd_linux_aarch64
cp ./scripts/setup-template.sh "./target/xmpd-setup-$1.sh"
cp ./scripts/setup-template.ps1 "./target/xmpd-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,254 +0,0 @@
mod nav_bar;
mod song_edit_window;
use std::collections::HashSet;
use egui::{Button, Color32, Label, RichText, Sense};
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 self::song_edit_window::GuiSongEditor;
#[derive(Debug, Default)]
pub struct Gui {
manifest: Manifest,
song_edit_w: GuiSongEditor,
new_song_w: GuiNewSong,
import_playlist_w: GuiImportPlaylist,
error_w: GuiError,
filter: String,
downloader: Downloader,
cfg: ConfigWrapper,
downloading: bool,
}
impl Gui {
fn new(_: &eframe::CreationContext<'_>, manifest: Manifest, downloader: Downloader, cfg: ConfigWrapper) -> Self {
Self {
manifest,
downloader,
cfg,
..Default::default()
}
}
pub fn start(manifest: Manifest, downloader: Downloader, cfg: ConfigWrapper) -> anyhow::Result<()> {
let native_options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_inner_size([400.0, 300.0])
.with_min_inner_size([300.0, 220.0]),
// .with_icon(
// // NOTE: Adding an icon is optional
// eframe::icon_data::from_png_bytes(&include_bytes!("../assets/icon-256.png")[..])
// .expect("Failed to load icon"),
// ),
..Default::default()
};
if let Err(e) = eframe::run_native(
"eframe template",
native_options,
Box::new(|cc| Box::new(Gui::new(cc, manifest, downloader, cfg))),
) {
log::error!("Failed to create window: {e}");
};
Ok(())
}
pub fn throw_error(&mut self, text: impl ToString) {
self.error_w.is_open = true;
self.error_w.text = text.to_string();
}
}
impl eframe::App for Gui {
fn update(&mut self, ctx: &egui::Context, frame: &mut eframe::Frame) {
self.draw_nav(ctx, frame);
self.draw_song_edit_window(ctx, frame);
self.draw_new_song_window(ctx, frame);
self.draw_import_playlist_window(ctx, frame);
self.draw_error_window(ctx, frame);
egui::CentralPanel::default().show(ctx, |ui| {
// The central panel the region left after adding TopPanel's and SidePanel's
//ui.heading(format!("Songs ({})", self.manifest.get_song_count()));
let fltr_by;
let filter_clean;
if self.filter.starts_with("playlist:") {
fltr_by = "playlist";
filter_clean = self.filter.strip_prefix("playlist:").unwrap_or("").to_string().to_lowercase();
} else if self.filter.starts_with("source:") {
fltr_by = "source";
filter_clean = self.filter.strip_prefix("source:").unwrap_or("").to_string().to_lowercase();
} else if self.filter.starts_with("url:") {
fltr_by = "url";
filter_clean = self.filter.strip_prefix("url:").unwrap_or("").to_string();
} else {
fltr_by = "";
filter_clean = self.filter.clone();
}
ui.vertical(|ui| {
ui.horizontal(|ui| {
ui.colored_label(Color32::from_hex("#4444aa").unwrap(), "Filter: ");
ui.text_edit_singleline(&mut self.filter);
});
});
ui.vertical(|ui| {
let available_height = ui.available_height();
let table = TableBuilder::new(ui)
.striped(true)
.cell_layout(egui::Layout::left_to_right(egui::Align::Center))
.resizable(true)
//.column(Column::auto())
.column(Column::auto())
//.column(
// Column::remainder()
// .at_least(40.0)
// .clip(true)
// .resizable(true),
//)
.column(Column::auto())
.column(Column::remainder())
//.column(Column::remainder())
.min_scrolled_height(0.0)
.max_scroll_height(available_height)
.sense(egui::Sense::click());
let playlists = self.manifest.get_playlists().clone();
let songs = {
let mut songs = Vec::new();
for (pname, p) in playlists {
for (sname, s) in p {
songs.push((pname.clone(), sname, s))
}
}
songs
};
table.header(20.0, |mut header| {
// header.col(|_|{});
header.col(|ui| {
ui.strong("Playlist");
});
header.col(|ui| {
ui.strong("Source");
});
header.col(|ui| {
ui.strong("Name");
});
}).body(|mut body| {
for (pname, sname, s) in songs {
if fltr_by == "playlist" && !filter_clean.is_empty() {
if !pname.to_lowercase().contains(&filter_clean) {
continue;
}
} else if fltr_by == "type" && !filter_clean.is_empty(){
if !s.get_type().to_string().to_lowercase().contains(&filter_clean) {
continue;
}
} else if fltr_by == "url" && !filter_clean.is_empty(){
if !s.get_url_str().contains(&filter_clean) {
continue;
}
} else if !filter_clean.is_empty() {
if !sname.to_lowercase().contains(&filter_clean) {
continue;
}
}
body.row(18.0, |mut row| {
row.col(|ui| {
ui.label(pname.clone())
.context_menu(|ui| context_menu(self, ui, &pname, &sname, &s));
});
row.col(|ui| {
let color =
match s.get_type() {
SongType::Youtube => Color32::from_hex("#FF0000").unwrap(),
SongType::Spotify => Color32::from_hex("#1db954").unwrap(),
SongType::Soundcloud => Color32::from_hex("#F26F23").unwrap()
};
ui.colored_label(color, s.get_type().to_string())
.context_menu(|ui| context_menu(self, ui, &pname, &sname, &s));
});
row.col(|ui| {
ui.hyperlink_to(sname.clone(), s.get_url_str())
.context_menu(|ui| context_menu(self, ui, &pname, &sname, &s));
});
row.response()
.context_menu(|ui| context_menu(self, ui, &pname, &sname, &s));
fn context_menu(this: &mut Gui, ui: &mut egui::Ui, pname: &String, sname: &String, song: &Song) {
if ui.button("Edit").clicked() {
this.song_edit_w.song = (
pname.clone(),
sname.clone(),
);
this.song_edit_w.is_open = true;
this.song_edit_w.ed_name = sname.clone();
this.song_edit_w.ed_url = song.get_url_str().clone();
ui.close_menu()
}
if ui.button("Download").clicked() {
if let Err(e) = this.downloader.download_song_nb(&this.cfg, pname, sname, song, this.manifest.get_format()) {
log::error!("{e}");
this.throw_error(format!("Failed to download song {sname}: {e}"));
}
ui.close_menu()
}
if ui.button("Open Source").clicked() {
if let Err(e) = open::that(song.get_url_str()) {
log::error!("{e}");
this.throw_error(format!("Failed to open song source: {e}"));
}
ui.close_menu()
}
if ui.button("Play").clicked() {
let p = crate::util::get_song_path(pname, sname, this.manifest.get_format());
if !p.exists() {
this.throw_error(format!("Song does not exist on disk"));
} else if let Err(e) = open::that(p) {
log::error!("{e}");
this.throw_error(format!("Failed to play song: {e}"));
}
ui.close_menu()
}
if ui.button("Delete from disk").clicked() {
let p = crate::util::get_song_path(pname, sname, this.manifest.get_format());
if p.exists() {
if let Err(e) = std::fs::remove_file(p) {
this.throw_error(format!("Failed to delete file: {e}"));
}
}
ui.close_menu();
}
if ui.button(RichText::new("Delete").color(Color32::RED)).clicked() {
this.throw_error("TODO");
ui.close_menu()
}
}
})
}
});
});
ui.separator();
ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| {
egui::warn_if_debug_build(ui);
});
});
}
}

View File

@ -1,226 +0,0 @@
use std::sync::Arc;
use egui::{text::{LayoutJob, TextWrapping}, Color32, Label, RichText, Style, TextBuffer, TextFormat, TextStyle};
use crate::manifest::{playlist::Playlist, song::{Song, SongType}};
use super::Gui;
#[derive(Debug, Default)]
pub struct GuiSongEditor {
pub is_open: bool,
pub song: (String, String),
pub ed_url: String,
pub ed_name: String,
}
#[derive(Debug, Default)]
pub struct GuiNewSong {
pub is_open: bool,
ed_type: SongType,
ed_name: String,
ed_playlist: Option<String>,
ed_url: String,
}
#[derive(Debug, Default)]
pub struct GuiImportPlaylist {
pub is_open: bool,
ed_name: String,
ed_url: String,
}
#[derive(Debug, Default)]
pub struct GuiError {
pub is_open: bool,
pub text: String,
}
impl Gui {
pub fn draw_song_edit_window(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
let mut save = false;
let (playlist, song_name) = self.song_edit_w.song.clone();
let Some(song) = self.manifest.get_song(&playlist, &song_name) else {
return;
};
let song = song.clone();
egui::Window::new("Song editor")
.open(&mut self.song_edit_w.is_open)
.show(ctx,
|ui| {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 0.0;
ui.label("[");
ui.hyperlink_to("link", song.get_url().unwrap());
ui.label("] ");
ui.colored_label(Color32::LIGHT_BLUE, &playlist);
ui.label(": ");
ui.label(&song_name)
});
ui.horizontal(|ui| {
ui.label("Type: ");
ui.label(&song.get_type().to_string());
});
ui.horizontal(|ui| {
ui.label("Name: ");
ui.text_edit_singleline(&mut self.song_edit_w.ed_name);
});
ui.horizontal(|ui| {
ui.label("Url: ");
ui.text_edit_singleline(&mut self.song_edit_w.ed_url);
});
if ui.button("Save").clicked() {
save = true;
}
});
if save {
{
let Some(song) = self.manifest.get_song_mut(&playlist, &song_name) else {
return;
};
*song.get_url_str_mut() = self.song_edit_w.ed_url.clone();
}
let Some(playlist) = self.manifest.get_playlist_mut(&playlist) else {
return;
};
playlist.remove_song(&song_name);
playlist.add_song(self.song_edit_w.ed_name.clone(), song);
self.song_edit_w.is_open = false;
let _ = self.manifest.save(None);
}
}
pub fn draw_new_song_window(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
let mut save = false;
egui::Window::new("New song")
.open(&mut self.new_song_w.is_open)
.show(ctx, |ui| {
ui.horizontal(|ui| {
ui.label("Type: ");
egui::ComboBox::from_id_source("new_song_window_type")
.selected_text(format!("{:?}", self.new_song_w.ed_type))
.show_ui(ui, |ui| {
ui.selectable_value(&mut self.new_song_w.ed_type, SongType::Youtube, "Youtube");
ui.selectable_value(&mut self.new_song_w.ed_type, SongType::Spotify, "Spotify");
ui.selectable_value(&mut self.new_song_w.ed_type, SongType::Soundcloud, "Soundcloud");
}
);
});
ui.horizontal(|ui| {
ui.label("Name: ");
ui.text_edit_singleline(&mut self.new_song_w.ed_name);
});
ui.horizontal(|ui| {
ui.label("Playlist: ");
egui::ComboBox::from_id_source("new_song_window_playlist")
.selected_text(format!("{}", self.new_song_w.ed_playlist.clone().unwrap_or("".to_string())))
.show_ui(ui, |ui| {
for p in self.manifest.get_playlists().keys() {
ui.selectable_value(&mut self.new_song_w.ed_playlist, Option::Some(p.clone()), p.as_str());
}
}
);
});
ui.horizontal(|ui| {
ui.label("Url: ");
ui.text_edit_singleline(&mut self.new_song_w.ed_url);
});
if ui.button("Save").clicked() {
save = true;
}
});
if save {
let Some(playlist) = self.manifest.get_playlist_mut(&self.new_song_w.ed_playlist.clone().unwrap()) else {
panic!("couldnt find playlist from a preset playlist list????????????");
};
playlist.add_song(
self.new_song_w.ed_name.clone(),
Song::from_url_str(self.new_song_w.ed_url.clone()).unwrap().set_type(self.new_song_w.ed_type.clone()).clone()
);
let _ = self.manifest.save(None);
self.new_song_w.is_open = false;
}
}
pub fn draw_import_playlist_window(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
let mut save = false;
egui::Window::new("Import Playlist")
.open(&mut self.import_playlist_w.is_open)
.show(ctx, |ui| {
ui.horizontal(|ui| {
ui.label("Type: Youtube");
});
ui.horizontal(|ui| {
ui.label("Name: ");
ui.text_edit_singleline(&mut self.import_playlist_w.ed_name);
});
ui.horizontal(|ui| {
ui.label("Url: ");
ui.text_edit_singleline(&mut self.import_playlist_w.ed_url);
});
if ui.button("Import").clicked() {
save = true;
}
});
if save {
let name = self.import_playlist_w.ed_name.clone();
let url = self.import_playlist_w.ed_url.clone();
if self.manifest.get_playlist(&name).is_some() {
log::error!("Playlist {name} already exists");
self.throw_error(format!("Playlist {name} already exists"));
}
let songs = self.downloader.download_playlist_nb(&self.cfg, &url, &name, &self.manifest.get_format()).unwrap();
self.manifest.add_playlist(name.clone());
let playlist = self.manifest.get_playlist_mut(&name).expect("Unreachable");
for (sname, song) in songs {
log::info!("Added: {sname}");
playlist.add_song(sname, song);
}
let _ = self.manifest.save(None);
self.import_playlist_w.is_open = false;
}
}
pub fn draw_error_window(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
egui::Window::new("ERROR!!!! D:")
.open(&mut self.error_w.is_open)
.show(ctx, |ui| {
ui.vertical(|ui| {
ui.label(RichText::new("Error:").size(30.0).color(Color32::RED));
ui.horizontal(|ui| {
ui.add(Label::new(self.error_w.text.clone()).wrap(true));
})
})
});
}
}

View File

@ -2,6 +2,7 @@ use camino::Utf8PathBuf;
use clap::{Parser, Subcommand};
#[allow(clippy::pedantic)]
#[derive(Debug, Parser, Default, Clone)]
pub struct CliArgs {
/// Show more info
@ -25,6 +26,7 @@ pub struct CliArgs {
}
#[allow(clippy::pedantic)]
#[derive(Debug, Subcommand, Clone)]
pub enum CliCommand {
Download,

View File

@ -11,7 +11,7 @@ use self::cli::CliArgs;
// const YTDLP_DL_URL: &'static str = "https://github.com/yt-dlp/yt-dlp/archive/refs/heads/master.zip";
// const SPOTDL_DL_URL: &'static str = "https://github.com/spotDL/spotify-downloader/archive/refs/heads/master.zip";
#[allow(clippy::pedantic)]
#[derive(Debug, Default, Clone)]
pub struct ConfigWrapper {
pub cfg: Config,
@ -19,17 +19,20 @@ pub struct ConfigWrapper {
pub isatty: bool
}
#[allow(clippy::pedantic)]
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
pub struct Config {
pub ytdlp: ConfigYtdlp,
pub spotdl: ConfigSpotdl,
}
#[allow(clippy::pedantic)]
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
pub struct ConfigYtdlp {
pub path: PathBuf,
}
#[allow(clippy::pedantic)]
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
pub struct ConfigSpotdl {
pub path: PathBuf,
@ -37,21 +40,22 @@ pub struct ConfigSpotdl {
impl ConfigWrapper {
pub async fn parse() -> Result<Self> {
#[allow(clippy::field_reassign_with_default)]
pub fn parse() -> Result<Self> {
let mut s = Self::default();
s.cli = cli::CliArgs::parse();
crate::logger::init_logger(s.cli.debug);
s.cfg = Config::parse(&s.cli).await?;
crate::logger::init(s.cli.debug);
s.cfg = Config::parse(&s.cli)?;
s.isatty = isatty();
Ok(s)
}
}
impl Config {
pub async fn parse(cli: &CliArgs) -> Result<Self> {
pub fn parse(cli: &CliArgs) -> Result<Self> {
if !cli.config.exists() {
log::info!("Config doesnt exist");
return Self::setup_config(&cli).await;
return Self::setup_config(cli);
}
let data = std::fs::read_to_string(&cli.config)?;
@ -59,16 +63,13 @@ impl Config {
Ok(data)
}
async fn setup_config(cli: &CliArgs) -> Result<Self> {
fn setup_config(cli: &CliArgs) -> Result<Self> {
let mut s = Self::default();
let mut error = false;
match util::is_program_in_path("yt-dlp") {
Some(p) => {
if let Some(p) = util::is_program_in_path("yt-dlp") {
s.ytdlp.path = p;
},
None => {
} else {
error = true;
log::error!("could not find yt-dlp, please install it.");
log::info!(" - With winget (Windows only) (recommended):");
@ -80,17 +81,13 @@ impl Config {
log::info!(" - With pip (from python) (Cross platform)");
log::info!(" - Make sure you have python installed");
log::info!(" - pip install yt-dlp");
log::info!(" - Using your distro's package manager (Unix/BSD only) (Not recommended)")
}
log::info!(" - Using your distro's package manager (Unix/BSD only) (Not recommended)");
}
match util::is_program_in_path("spotdl") {
Some(p) => {
if let Some(p) = util::is_program_in_path("spotdl") {
s.spotdl.path = p;
},
None => {
let res = crate::prompt::prompt_bool("Spotdl is not installed but if you dont need to download music from spotify you dont need it, skip it?", None);
} else {
let res = crate::prompt::yes_no("Spotdl is not installed but if you dont need to download music from spotify you dont need it, skip it?", None);
if res {
s.spotdl.path = PathBuf::from("UNUSED");
} else {
@ -101,12 +98,8 @@ impl Config {
log::info!(" - pip install spotdl");
}
}
}
match util::is_program_in_path("ffmpeg") {
Some(_) => (),
None => {
if util::is_program_in_path("ffmpeg").is_none() {
error = true;
log::error!("could not find ffmpeg, please install it.");
log::info!(" - With winget (Windows only) (recommended):");
@ -116,7 +109,6 @@ impl Config {
log::info!(" - Make sure you have chocolatey installed - https://chocolatey.org/install");
log::info!(" - run `choco install ffmpeg` as Admin");
}
}
if !error {
s.save(cli.config.clone().into_std_path_buf())?;

View File

@ -1,15 +1,15 @@
#[cfg(target_family="windows")]
mod constants {
pub const PATH_VAR_SEP: &'static str = ";";
pub const EXEC_EXT: &'static str = "exe";
mod _m {
pub const PATH_VAR_SEP: &str = ";";
pub const EXEC_EXT: &str = "exe";
}
#[cfg(target_family="unix")]
mod constants {
pub const PATH_VAR_SEP: &'static str = ":";
pub const EXEC_EXT: &'static str = "";
mod _m {
pub const PATH_VAR_SEP: &str = ":";
pub const EXEC_EXT: &str = "";
}
pub use constants::*;
pub use _m::*;

5
src/data.rs Normal file
View File

@ -0,0 +1,5 @@
// pub const APP_ICON: egui::ImageSource = egui::include_image!("../assets/app_icon.png");
pub const APP_ICON_BYTES: &[u8] = include_bytes!("../assets/app_icon.png");
pub const NOTE_ICON: egui::ImageSource = egui::include_image!("../assets/note.svg");
pub const SEARCH_ICON: egui::ImageSource = egui::include_image!("../assets/search.svg");

View File

@ -18,7 +18,7 @@ lazy_static!(
static ref PROCESSES: Mutex<RwLock<HashMap<usize, Proc>>> = Mutex::new(RwLock::new(HashMap::new()));
);
#[derive(Debug, Default)]
#[derive(Debug, Default, Clone)]
pub struct Downloader {
count: usize,
nb_initial_song_count: usize,
@ -40,8 +40,8 @@ impl Downloader {
self.nb_cache.len() + crate::process_manager::proc_count()
}
pub fn download_song_nb(&mut self, cfg: &ConfigWrapper, pname: &String, sname: &String, song: &Song, format: &Format) -> anyhow::Result<()> {
self.nb_cache.push((pname.clone(), sname.clone(), song.clone(), format.clone()));
pub fn download_song_nb(&mut self, cfg: &ConfigWrapper, pname: &str, sname: &str, song: &Song, format: &Format) -> anyhow::Result<()> {
self.nb_cache.push((pname.to_string(), sname.to_string(), song.clone(), format.clone()));
self.nb_initial_song_count += 1;
self.download_all_nb_poll(cfg)?;
Ok(())
@ -76,21 +76,21 @@ impl Downloader {
pub async fn download_all(&mut self, manifest: &Manifest, cfg: &ConfigWrapper) -> anyhow::Result<usize> {
pub fn download_all(&mut self, manifest: &Manifest, cfg: &ConfigWrapper) -> anyhow::Result<usize> {
let format = manifest.get_format();
for (name, playlist) in manifest.get_playlists() {
for (song_name, song) in playlist.get_songs() {
self.download_song(cfg, song_name, song, &name, format)?;
self.count += crate::process_manager::wait_for_procs_untill(10)?;
self.download_song(cfg, song_name, song, name, format)?;
self.count += crate::process_manager::wait_for_procs_until(10)?;
}
}
self.count += crate::process_manager::wait_for_procs_untill(0)?;
self.count += crate::process_manager::wait_for_procs_until(0)?;
Ok(self.count)
}
#[allow(dead_code)]
pub fn download_playlist(&mut self, cfg: &ConfigWrapper, url: &String, pname: &String, format: &Format) -> anyhow::Result<usize> {
pub fn download_playlist(&mut self, cfg: &ConfigWrapper, url: &str, pname: &str, format: &Format) -> anyhow::Result<usize> {
self.download_playlist_nb(cfg, url, pname, format)?;
let mut count = 0;
while let Some(c) = self.download_all_nb_poll(cfg)? {
@ -99,14 +99,14 @@ impl Downloader {
Ok(count)
}
pub fn download_playlist_nb(&mut self, cfg: &ConfigWrapper, url: &String, pname: &String, format: &Format) -> anyhow::Result<HashMap<String, Song>> {
pub fn download_playlist_nb(&mut self, cfg: &ConfigWrapper, url: &str, pname: &str, format: &Format) -> anyhow::Result<HashMap<String, Song>> {
log::warn!("This automatically assumes its a youtube link as it is currently the only supported playlist source");
let mut cmd = tokio::process::Command::new(&cfg.cfg.ytdlp.path);
cmd.args([
"--flat-playlist",
"--simulate",
"-O", "%(url)s|%(title)s",
url.as_str()
url
]);
cmd
.stderr(Stdio::null())
@ -119,11 +119,11 @@ impl Downloader {
let out = futures::executor::block_on(ftr)?.stdout;
let out = String::from_utf8(out)?;
for line in out.lines() {
let mut split_text = line.split("|").collect::<Vec<&str>>();
let mut split_text = line.split('|').collect::<Vec<&str>>();
let url = split_text.swap_remove(0).to_string();
let sname = split_text.join("|");
let song = Song::from_url_str(url)?.set_type(SongType::Youtube).clone();
self.nb_cache.push((pname.clone(), sname.clone(), song.clone(), format.clone()));
self.nb_cache.push((pname.to_string(), sname.clone(), song.clone(), format.clone()));
ret.insert(sname, song.clone());
}
self.nb_initial_song_count += out.lines().count();
@ -131,7 +131,7 @@ impl Downloader {
Ok(ret)
}
pub fn download_song(&mut self, cfg: &ConfigWrapper, name: &String, song: &Song, playlist: &String, format: &Format) -> anyhow::Result<()> {
pub fn download_song(&self, cfg: &ConfigWrapper, name: &String, song: &Song, playlist: &String, format: &Format) -> anyhow::Result<()> {
let dl_dir = format!("{}/{playlist}", cfg.cli.output);
let dl_file = format!("{dl_dir}/{}.{}", name, &format);
log::debug!("Checking: {dl_file}");
@ -143,8 +143,8 @@ impl Downloader {
log::debug!("File {dl_file} doesnt exist, downloading");
let mut cmd = match song.get_type() {
&SongType::Youtube => {
log::debug!("Song {} is from yotube", song.get_url_str());
SongType::Youtube | SongType::Soundcloud=> {
log::debug!("Song {} is from youtube or sondclound", song.get_url_str());
let mut cmd = tokio::process::Command::new(&cfg.cfg.ytdlp.path);
cmd.args([
"-x",
@ -168,10 +168,6 @@ impl Downloader {
]);
cmd
}
url => {
log::error!("Unknown or unsupported hostname '{:?}'", url);
return Ok(());
}
};
if log::max_level() < Level::Debug {

View File

@ -1,7 +1,7 @@
use log::LevelFilter;
pub fn init_logger(debug: bool) {
pub fn init(debug: bool) {
let level = if debug {
LevelFilter::Debug
} else {

View File

@ -1,20 +1,24 @@
#![feature(downcast_unchecked)]
#![feature(async_closure)]
use config::ConfigWrapper;
// TODO: Possibly use https://docs.rs/ytextract/latest/ytextract/ instead of ytdlp
mod manifest;
mod logger;
mod downloader;
mod util;
mod commands;
mod prompt;
mod config;
mod constants;
mod process_manager;
mod ui;
mod prompt;
mod data;
#[tokio::main]
async fn main() {
let Ok(cfg) = ConfigWrapper::parse().await else {
let Ok(cfg) = ConfigWrapper::parse() else {
return;
};
@ -27,5 +31,5 @@ async fn main() {
};
let _ = commands::command_run(&cfg, &mut manifest).await;
let _ = ui::cli::command_run(&cfg, &mut manifest);
}

View File

@ -2,6 +2,7 @@
pub mod song;
pub mod playlist;
use playlist::Playlist;
use song::Song;
use std::{collections::HashMap, fmt::{Debug, Display}, path::PathBuf};
@ -10,11 +11,9 @@ use anyhow::{bail, Result};
use serde::{Deserialize, Serialize};
const DEFAULT_MANIFEST: &'static str = include_str!("../../manifest.default.json");
const DEFAULT_MANIFEST: &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 +42,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> {
@ -53,7 +52,7 @@ impl Manifest {
self.get_playlist_mut(playlist_name)?.get_song_mut(name)
}
pub fn add_playlist(&mut self, playlist_name: String) {
self.playlists.insert(playlist_name, Default::default());
self.playlists.insert(playlist_name, Playlist::default());
}
pub fn get_playlist(&self, playlist_name: &String) -> Option<&playlist::Playlist> {
self.playlists.get(playlist_name)
@ -67,9 +66,15 @@ impl Manifest {
pub fn get_playlists_mut(&mut self) -> &mut HashMap<String, playlist::Playlist> {
&mut self.playlists
}
pub fn remove_playlist(&mut self, playlist_name: &String) -> Option<playlist::Playlist> {
self.playlists.remove(playlist_name)
}
pub fn remove_song(&mut self, playlist_name: &String, song_name: &String) -> Option<Song> {
self.get_playlist_mut(playlist_name)?.remove_song(song_name)
}
pub fn get_song_count(&self) -> usize {
let mut count = 0;
for (_, v) in &self.playlists {
for v in self.playlists.values() {
count += v.len();
}
count
@ -100,7 +105,7 @@ impl Manifest {
let mut s = Self::default();
log::debug!("Path: {p:?}");
s.path = p.clone();
s.path.clone_from(p);
s.load(Some(p))?;
Ok(s)
}

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)
@ -33,6 +30,7 @@ impl Playlist {
&self.songs
}
#[allow(dead_code)]
pub fn get_songs_mut(&mut self) -> &mut HashMap<String, Song> {
&mut self.songs
}

View File

@ -1,9 +1,9 @@
use std::str::FromStr;
use std::{fmt::Display, str::FromStr};
use anyhow::{bail, Result};
use serde::{Deserialize, Serialize};
#[allow(clippy::pedantic)]
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq, Eq, Default)]
pub enum SongType {
#[default]
@ -12,14 +12,14 @@ pub enum SongType {
Soundcloud,
}
impl ToString for SongType {
fn to_string(&self) -> String {
let s = match self {
SongType::Youtube => "Youtube",
SongType::Spotify => "Spotify",
SongType::Soundcloud => "Soundcloud",
};
String::from(s)
impl Display for SongType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Soundcloud => write!(f, "SoundCloud")?,
Self::Spotify => write!(f, "Spotify")?,
Self::Youtube => write!(f, "YouTube")?,
}
Ok(())
}
}
@ -31,8 +31,9 @@ pub struct Song {
#[allow(dead_code)]
impl Song {
pub fn from_url_str(url: String) -> Result<Self> {
Self::from_url(url::Url::from_str(url.as_str())?)
#[allow(clippy::needless_pass_by_value)]
pub fn from_url_str<S: ToString>(url: S) -> Result<Self> {
Self::from_url(url::Url::from_str(&url.to_string())?)
}
pub fn from_url(url: url::Url) -> Result<Self> {
Ok(Self {

View File

@ -18,7 +18,6 @@ lazy_static::lazy_static!(
static PROC_INC: AtomicUsize = AtomicUsize::new(0);
pub fn add_proc(mut cmd: Command, msg: String) -> anyhow::Result<()> {
let mut proc = cmd.spawn()?;
let id = PROC_INC.fetch_add(1, Ordering::AcqRel);
@ -65,8 +64,8 @@ pub fn purge_done_procs() -> usize {
finish_count
}
/// Waits for processes to finish untill the proc count is lower or equal to `max`
pub fn wait_for_procs_untill(max: usize) -> anyhow::Result<usize> {
/// Waits for processes to finish until the proc count is lower or equal to `max`
pub fn wait_for_procs_until(max: usize) -> anyhow::Result<usize> {
// NOTE: This looks really fucked because i dont want to deadlock the processes so i lock PROCESSES for as little as possible
// NOTE: So its also kinda really slow
let mut finish_count = 0;

View File

@ -1,109 +1,7 @@
use std::{collections::HashMap, io::Write};
use std::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()
}
#[allow(dead_code)]
pub(crate) fn prompt_with_list(p: &str, options: &[&str]) -> usize {
println!("{c}prompt{r}: {p}",
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.parse::<usize>() {
if num <= options.len() {
return num;
} else {
return prompt_with_list(p, options);
}
} else {
return prompt_with_list(p, options);
}
}
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)]
pub(crate) fn prompt_with_map(p: &str, options: HashMap<&str, &str>) -> String {
println!("{c}prompt{r}: {p}",
c=anstyle::AnsiColor::Cyan.render_fg(),
r=anstyle::Reset.render()
);
let mut keys = Vec::new();
for (k, v) in &options {
println!(" - {}: {}", k, v);
keys.push(k.trim().to_lowercase())
}
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 !keys.contains(&buf.trim().to_lowercase()) {
return prompt_with_map(p, options);
}
buf.trim().to_string()
}
pub fn prompt_bool(p: &str, default: Option<bool>) -> bool {
pub fn yes_no(p: &str, default: Option<bool>) -> bool {
if default == Some(true) {
println!("{c}prompt{r}: {p} (Y/n)",
c=anstyle::AnsiColor::Cyan.render_fg(),
@ -133,7 +31,7 @@ pub fn prompt_bool(p: &str, default: Option<bool>) -> bool {
Some(true) => return true,
Some(false) => return false,
None => {
return prompt_bool(p, default);
return yes_no(p, default);
}
}
}
@ -143,7 +41,7 @@ pub fn prompt_bool(p: &str, default: Option<bool>) -> bool {
"n" => false,
c => {
log::error!("'{c}' is invalid, type y (yes) or n (no)");
return prompt_bool(p, default);
yes_no(p, default)
}
}
}

View File

@ -6,34 +6,34 @@ use crate::{config::ConfigWrapper, downloader::Downloader, manifest::{song::Song
pub async fn add(cfg: &ConfigWrapper, manifest: &mut Manifest, downloader: &mut Downloader, url: &String, name: &String, playlist: &String) -> anyhow::Result<()> {
pub fn song(cfg: &ConfigWrapper, manifest: &mut Manifest, downloader: &mut Downloader, url: &str, name: &String, playlist: &String) -> anyhow::Result<()> {
let mut playlists = manifest.get_playlists().keys().map(|f| f.clone()).collect::<Vec<String>>();
let mut playlists = manifest.get_playlists().keys().cloned().collect::<Vec<String>>();
playlists.sort();
if !is_supported_host(url::Url::from_str(&url)?) {
if !is_supported_host(&url::Url::from_str(url)?) {
log::error!("Invalid or unsupported host name");
return Ok(());
}
let song = Song::from_url_str(url.clone())?;
let song = Song::from_url_str(url.to_string())?;
manifest.add_song(playlist, name.clone(), song.clone());
manifest.save(None)?;
let should_download = crate::prompt::prompt_bool("Download song now?", Some(false));
let should_download = crate::prompt::yes_no("Download song now?", Some(false));
if should_download {
downloader.download_song(cfg, &name, &song, &playlist, manifest.get_format())?;
crate::process_manager::wait_for_procs_untill(0)?;
downloader.download_song(cfg, name, &song, playlist, manifest.get_format())?;
crate::process_manager::wait_for_procs_until(0)?;
}
Ok(())
}
pub async fn add_playlist(cfg: &ConfigWrapper, manifest: &mut Manifest, downloader: &mut Downloader, url: &String, name: &String) -> anyhow::Result<()> {
pub fn playlist(cfg: &ConfigWrapper, manifest: &mut Manifest, downloader: &mut Downloader, url: &str, name: &String) -> anyhow::Result<()> {
let songs = downloader.download_playlist_nb(cfg, url, name, manifest.get_format())?;
if manifest.get_playlist(name).is_some() {

View File

@ -1,18 +1,17 @@
mod add;
pub mod gui;
use crate::{config::{cli::CliCommand, ConfigWrapper}, downloader::Downloader, manifest::Manifest};
use crate::{config::{cli::CliCommand, ConfigWrapper}, downloader::Downloader, manifest::Manifest, ui::gui};
pub async fn command_run(cfg: &ConfigWrapper, manifest: &mut Manifest) -> anyhow::Result<()> {
pub fn command_run(cfg: &ConfigWrapper, manifest: &mut Manifest) -> anyhow::Result<()> {
log::info!("Is in term: {}", cfg.isatty);
//std::fs::write("./isatty", format!("{}\n", cfg.isatty))?;
let mut downloader = Downloader::new();
match (&cfg.cli.command, cfg.isatty) {
(None | Some(CliCommand::Download), true) => {
match downloader.download_all(manifest, &cfg).await {
match downloader.download_all(manifest, cfg) {
Ok(count) => log::info!("Downloaded {count} songs"),
Err(e) => {
log::error!("Failed to download songs: {e}");
@ -24,12 +23,12 @@ pub async fn command_run(cfg: &ConfigWrapper, manifest: &mut Manifest) -> anyhow
match c {
CliCommand::Download => unreachable!(),
CliCommand::AddPlaylist { url, name } => {
if let Err(e) = add::add_playlist(cfg, manifest, &mut downloader, url, name).await {
if let Err(e) = add::playlist(cfg, manifest, &mut downloader, url, name) {
log::error!("Failed to run 'add-playlist' commmand: {e}");
}
}
CliCommand::Add { url, name, playlist } => {
if let Err(e) = add::add(cfg, manifest, &mut downloader, url, name, playlist).await {
if let Err(e) = add::song(cfg, manifest, &mut downloader, url, name, playlist) {
log::error!("Failed to run 'add' command: {e}");
}
}

View File

@ -0,0 +1,24 @@
use super::Gui;
pub mod nav;
pub mod song_list;
pub mod side_nav;
pub mod search_bar;
pub trait Component {
fn ui(gui: &mut Gui, ctx: &egui::Context);
}
pub trait ComponentUi {
fn ui(gui: &mut Gui, ui: &mut egui::Ui);
}
pub trait ComponentUiMut {
fn ui(&mut self, gui: &mut Gui, ui: &mut egui::Ui);
}
pub trait ComponentContextMenu {
type Data;
fn ui(gui: &mut Gui, ui: &mut egui::Ui, data: &Self::Data);
}

View File

@ -1,11 +1,11 @@
use egui::Hyperlink;
use crate::ui::gui::{windows::WindowIndex, Gui};
use super::Gui;
use super::Component;
pub struct NavBar;
impl Gui {
pub fn draw_nav(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
impl Component for NavBar {
fn ui(gui: &mut Gui, ctx: &egui::Context) {
egui::TopBottomPanel::top("top_panel").show(ctx, |ui| {
// The top panel is often a good place for a menu bar:
egui::menu::bar(ui, |ui| {
@ -14,7 +14,7 @@ impl Gui {
ctx.open_url(egui::OpenUrl::new_tab("https://git.mcorangehq.xyz/XOR64/music"));
}
if ui.button("Save").clicked() {
if let Err(e) = self.manifest.save(None) {
if let Err(e) = gui.manifest.save(None) {
log::error!("Failed to save manifest: {e}");
}
}
@ -25,19 +25,19 @@ impl Gui {
ui.menu_button("Song", |ui| {
if ui.button("Add New").clicked() {
self.new_song_w.is_open = true;
gui.windows.open(WindowIndex::SongNew, true);
}
});
ui.menu_button("Playlist", |ui| {
if ui.button("Import").clicked() {
self.import_playlist_w.is_open = true;
gui.windows.open(WindowIndex::ImportPlaylist, true);
}
});
ui.menu_button("Downloader", |ui| {
if ui.button("Download All").clicked() {
if let Err(e) = self.downloader.download_all_nb(&self.manifest, &self.cfg) {
if let Err(e) = gui.downloader.download_all_nb(&gui.manifest, &gui.cfg) {
log::error!("Err: {e}");
}
}
@ -45,21 +45,22 @@ impl Gui {
ui.add_space(16.0);
ui.with_layout(egui::Layout::bottom_up(egui::Align::RIGHT), |ui| {
ui.horizontal(|ui| {
if self.downloader.get_songs_left_nb() > 0 {
self.downloading = true;
ui.label(format!("Downloading: {}/{}", self.downloader.get_songs_left_nb(), self.downloader.get_initial_song_count_nb()));
} else if self.downloading {
if gui.downloader.get_songs_left_nb() > 0 {
gui.downloading = true;
ui.label(format!("Downloading: {}/{}", gui.downloader.get_songs_left_nb(), gui.downloader.get_initial_song_count_nb()));
} else if gui.downloading {
let _ = notify_rust::Notification::new()
.summary("Done downloading")
.body("Your music has been downloaded")
.show();
self.downloading = false;
gui.downloading = false;
}
let _ = self.downloader.download_all_nb_poll(&self.cfg);
let _ = gui.downloader.download_all_nb_poll(&gui.cfg);
egui::widgets::global_dark_light_mode_buttons(ui);
});
});
});
});
}
}

View File

@ -0,0 +1,53 @@
use egui::Color32;
use super::ComponentUiMut;
#[derive(Debug, Default, Clone)]
pub struct SearchBar {
text: String
}
pub enum SearchType {
Generic,
Song,
Url,
Source,
}
impl SearchBar {
pub fn get_search(&self) -> (SearchType, String) {
if self.text.starts_with("source:") {
(
SearchType::Source,
self.text.strip_prefix("source:").unwrap_or("").to_string().to_lowercase()
)
} else if self.text.starts_with("song:") {
(
SearchType::Song,
self.text.strip_prefix("song:").unwrap_or("").to_string().to_lowercase()
)
} else if self.text.starts_with("url:") {
(
SearchType::Url,
self.text.strip_prefix("url:").unwrap_or("").to_string().to_lowercase()
)
} else {
(
SearchType::Generic,
self.text.clone()
)
}
}
}
impl ComponentUiMut for SearchBar {
fn ui(&mut self, _: &mut crate::ui::gui::Gui, ui: &mut egui::Ui) {
ui.vertical(|ui| {
ui.horizontal(|ui| {
let tint = Color32::from_hex("#333377").unwrap();
ui.add(egui::Image::new(crate::data::SEARCH_ICON).tint(tint));
ui.text_edit_singleline(&mut self.text);
});
});
}
}

View File

@ -0,0 +1,55 @@
use egui::{Color32, RichText};
use crate::ui::gui::{components::ComponentContextMenu, windows::{self, WindowIndex}};
#[derive(Debug)]
pub struct ContextMenu;
impl ComponentContextMenu for ContextMenu {
type Data = String; // Playlist name
fn ui(gui: &mut crate::ui::gui::Gui, ui: &mut egui::Ui, playlist_name: &Self::Data) {
if ui.button("Edit").clicked() {
ui.close_menu();
}
if ui.button("Download all").clicked() {
let Some(playlist) = gui.manifest.get_playlist(playlist_name) else {
gui.throw_error(format!("Playlist not found: {}", playlist_name));
ui.close_menu();
return;
};
for (song_name, song) in playlist.get_songs() {
if let Err(e) = gui.downloader.download_song_nb(&gui.cfg, playlist_name, song_name, song, gui.manifest.get_format()) {
gui.throw_error(format!("Could not download song: {e}"));
ui.close_menu();
return;
}
}
ui.close_menu();
}
if ui.button("Delete from disk").clicked() {
let p = crate::util::get_playlist_path(playlist_name);
if p.exists() {
if let Err(e) = std::fs::remove_dir_all(p) {
gui.throw_error(format!("Failed to delete directory: {e}"));
}
}
ui.close_menu();
}
if ui.button(RichText::new("Delete").color(Color32::RED)).clicked() {
let w = gui.windows.get_window::<windows::confirm::ConfirmW>(WindowIndex::Confirm);
w.set_message(
"side_nav_playlist_manifest_delete",
"This will delete the playlist from the manifest file. This is NOT reversible",
&[playlist_name.clone()]
);
gui.windows.open(WindowIndex::Confirm, true);
ui.close_menu();
}
}
}

View File

@ -0,0 +1,72 @@
use egui::{Color32, Label, RichText, Sense};
use crate::ui::gui::windows::{self, WindowIndex};
use super::{ComponentContextMenu, ComponentUi};
mod context_menu;
pub struct SideNav;
impl ComponentUi for SideNav {
fn ui(gui: &mut crate::ui::gui::Gui, ui: &mut egui::Ui) {
let mut playlist_names = gui.manifest
.get_playlists()
.keys().cloned().collect::<Vec<String>>();
playlist_names.sort_by_key(|name| name.to_lowercase());
ui.with_layout(egui::Layout::top_down(egui::Align::TOP), |ui| {
for pname in playlist_names {
if gui.current_playlist.is_empty() {
gui.current_playlist = pname.to_string();
}
ui.horizontal(|ui| {
let tint = Color32::from_hex("#333377").unwrap();
ui.add(egui::Image::new(crate::data::NOTE_ICON).tint(tint))
.context_menu(|ui| context_menu::ContextMenu::ui(gui, ui, &pname));
ui.horizontal(|ui| {
let text = if gui.current_playlist == *pname {
RichText::new(&pname).color(tint)
} else {
RichText::new(&pname)
};
let button = Label::new(text).sense(Sense::click()).selectable(false);
let button = ui.add(button);
if button.clicked() {
gui.current_playlist = pname.to_string();
}
button.context_menu(|ui| context_menu::ContextMenu::ui(gui, ui, &pname));
});
});
}
});
check_if_needs_delete(gui);
}
// #333377
}
fn check_if_needs_delete(gui: &mut crate::ui::gui::Gui) {
// Check for items that need to be deleted
let (id, resp, data) = gui.windows.get_window::<windows::confirm::ConfirmW>(WindowIndex::Confirm).get_response();
match (id.as_str(), resp) {
("side_nav_playlist_manifest_delete", Some(true)) => {
gui.manifest.remove_playlist(&data[0]);
let _ = gui.manifest.save(None);
gui.windows.get_window::<windows::confirm::ConfirmW>(WindowIndex::Confirm).reset();
}
("side_nav_playlist_manifest_delete", Some(false)) => {
log::debug!("FALSE");
gui.windows.get_window::<windows::confirm::ConfirmW>(WindowIndex::Confirm).reset();
}
_ => ()
}
}

View File

@ -0,0 +1,96 @@
use egui::{Color32, RichText};
use crate::{manifest::song::{Song, SongType}, ui::gui::windows::{self, song_edit::GuiSongEditor, WindowIndex}};
use super::ComponentContextMenu;
pub struct ContextMenu;
pub struct SongInfo {
pname: String,
sname: String,
song: Song,
}
impl SongInfo {
pub fn new(pname: &str, sname: &str, song: &Song) -> Self {
Self {
pname: pname.to_string(),
sname: sname.to_string(),
song: song.clone()
}
}
pub fn playlist_name(&self) -> &String {
&self.pname
}
pub fn song_name(&self) -> &String {
&self.sname
}
pub fn song_url(&self) -> &String {
self.song.get_url_str()
}
pub fn song_type(&self) -> &SongType {
self.song.get_type()
}
pub fn song(&self) -> &Song {
&self.song
}
}
impl ComponentContextMenu for ContextMenu {
type Data = SongInfo;
fn ui(gui: &mut crate::ui::gui::Gui, ui: &mut egui::Ui, data: &Self::Data) {
if ui.button("Edit").clicked() {
let w = gui.windows.get_window::<GuiSongEditor>(WindowIndex::SongEdit);
w.set_active_song(data.playlist_name(), data.song_name(), data.song_url(), data.song_type());
gui.windows.open(WindowIndex::SongEdit, true);
ui.close_menu();
}
if ui.button("Download").clicked() {
if let Err(e) = gui.downloader.download_song_nb(&gui.cfg, data.playlist_name(), data.song_name(), data.song(), gui.manifest.get_format()) {
log::error!("{e}");
gui.throw_error(format!("Failed to download song {}: {e}", data.song_name()));
}
ui.close_menu();
}
if ui.button("Open Source").clicked() {
if let Err(e) = open::that(data.song_url()) {
log::error!("{e}");
gui.throw_error(format!("Failed to open song source: {e}"));
}
ui.close_menu();
}
if ui.button("Play").clicked() {
let p = crate::util::get_song_path(data.playlist_name(), data.song_name(), gui.manifest.get_format());
if !p.exists() {
gui.throw_error("Song does not exist on disk".to_string());
} else if let Err(e) = open::that(p) {
log::error!("{e}");
gui.throw_error(format!("Failed to play song: {e}"));
}
ui.close_menu();
}
if ui.button("Delete from disk").clicked() {
let p = crate::util::get_song_path(data.playlist_name(), data.song_name(), gui.manifest.get_format());
if p.exists() {
if let Err(e) = std::fs::remove_file(p) {
gui.throw_error(format!("Failed to delete file: {e}"));
}
}
ui.close_menu();
}
if ui.button(RichText::new("Delete").color(Color32::RED)).clicked() {
let w = gui.windows.get_window::<windows::confirm::ConfirmW>(WindowIndex::Confirm);
w.set_message(
"song_list_song_manifest_delete",
"This will delete the song from the manifest file. This is NOT reversible",
&[data.playlist_name().clone(), data.song_name().clone()]
);
gui.windows.open(WindowIndex::Confirm, true);
ui.close_menu();
ui.close_menu();
}
}
}

View File

@ -0,0 +1,136 @@
use egui::Color32;
use egui_extras::{Column, TableBuilder};
use crate::{manifest::song::SongType, ui::gui::windows::{self, WindowIndex}};
use super::{search_bar::SearchType, ComponentContextMenu, ComponentUi};
mod context_menu;
#[derive(Debug, Default)]
pub struct SongList;
impl ComponentUi for SongList {
fn ui(gui: &mut crate::ui::gui::Gui, ui: &mut egui::Ui) {
ui.vertical(|ui| {
{
use crate::ui::gui::components::ComponentUiMut;
let mut search = gui.search.clone();
search.ui(gui, ui);
gui.search = search;
}
ui.vertical(|ui| {
let available_height = ui.available_height();
let table = TableBuilder::new(ui)
.striped(true)
.cell_layout(egui::Layout::left_to_right(egui::Align::Center))
.resizable(true)
.column(Column::auto())
.column(Column::remainder())
.min_scrolled_height(0.0)
.max_scroll_height(available_height)
.sense(egui::Sense::click());
let playlists = gui.manifest.get_playlists().clone();
let songs = {
let mut songs = Vec::new();
for (pname, p) in playlists {
for (sname, s) in p {
songs.push((pname.clone(), sname, s));
}
}
songs.sort_by_key(|song| song.1.to_lowercase());
songs
};
table.header(20.0, |mut header| {
header.col(|ui| {
ui.strong("Source");
});
header.col(|ui| {
ui.strong("Name");
});
}).body(|mut body| {
for (pname, sname, s) in songs {
if pname != gui.current_playlist {
continue;
}
match gui.search.get_search() {
(SearchType::Generic, filter) if !filter.is_empty() => {
if !pname.to_lowercase().contains(&filter) {
continue;
}
}
(SearchType::Song, filter) if !filter.is_empty() => {
if !sname.to_lowercase().contains(&filter) {
continue;
}
}
(SearchType::Source, filter) if !filter.is_empty() => {
if !s.get_type().to_string().to_lowercase().contains(&filter) {
continue;
}
}
(SearchType::Url, filter) if !filter.is_empty() => {
if !s.get_url_str().contains(&filter) {
continue;
}
}
(SearchType::Source, _) => (),
(SearchType::Song, _) => (),
(SearchType::Generic, _) => (),
(SearchType::Url, _) => (),
}
body.row(18.0, |mut row| {
let song_info = context_menu::SongInfo::new(&pname, &sname, &s);
row.col(|ui| {
let color =
match s.get_type() {
SongType::Youtube => Color32::from_hex("#FF0000").unwrap(),
SongType::Spotify => Color32::from_hex("#1db954").unwrap(),
SongType::Soundcloud => Color32::from_hex("#F26F23").unwrap()
};
ui.colored_label(color, s.get_type().to_string())
.context_menu(|ui| context_menu::ContextMenu::ui(gui, ui, &song_info));
});
row.col(|ui| {
ui.hyperlink_to(sname.clone(), s.get_url_str())
.context_menu(|ui| context_menu::ContextMenu::ui(gui, ui, &song_info));
});
row.response()
.context_menu(|ui| context_menu::ContextMenu::ui(gui, ui, &song_info));
});
}
});
});
});
check_if_needs_delete(gui);
}
}
fn check_if_needs_delete(gui: &mut crate::ui::gui::Gui) {
// Check for items that need to be deleted
let (id, resp, data) = gui.windows.get_window::<windows::confirm::ConfirmW>(WindowIndex::Confirm).get_response();
match (id.as_str(), resp) {
("song_list_song_manifest_delete", Some(true)) => {
gui.manifest.remove_song(&data[0], &data[1]);
let _ = gui.manifest.save(None);
gui.windows.get_window::<windows::confirm::ConfirmW>(WindowIndex::Confirm).reset();
}
("song_list_song_manifest_delete", Some(false)) => {
log::debug!("FALSE");
gui.windows.get_window::<windows::confirm::ConfirmW>(WindowIndex::Confirm).reset();
}
_ => ()
}
}

99
src/ui/gui/mod.rs Normal file
View File

@ -0,0 +1,99 @@
mod windows;
mod components;
use components::{Component, ComponentUi};
use egui_extras::install_image_loaders;
use windows::{State, WindowIndex, WindowManager};
use crate::{config::ConfigWrapper, downloader::Downloader, manifest::Manifest};
#[derive(Debug, Default)]
pub struct Gui {
windows: WindowManager,
manifest: Manifest,
downloader: Downloader,
cfg: ConfigWrapper,
downloading: bool,
search: components::search_bar::SearchBar,
current_playlist: String,
}
impl Gui {
fn new(_: &eframe::CreationContext<'_>, manifest: Manifest, downloader: Downloader, cfg: ConfigWrapper) -> Self {
Self {
manifest,
downloader,
cfg,
windows: windows::WindowManager::new(),
..Default::default()
}
}
pub fn start(manifest: Manifest, downloader: Downloader, cfg: ConfigWrapper) -> anyhow::Result<()> {
let native_options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_inner_size([400.0, 300.0])
.with_min_inner_size([300.0, 220.0])
.with_icon(
eframe::icon_data::from_png_bytes(crate::data::APP_ICON_BYTES)?,
),
..Default::default()
};
if let Err(e) = eframe::run_native(
"McMG",
native_options,
Box::new(|cc| Box::new(Gui::new(cc, manifest, downloader, cfg))),
) {
log::error!("Failed to create window: {e}");
};
Ok(())
}
pub fn throw_error<S: ToString>(&mut self, text: S) {
let w = self.windows.get_window::<windows::error::GuiError>(WindowIndex::Error);
w.set_error_message(text);
self.windows.open(WindowIndex::Error, true);
}
}
impl eframe::App for Gui {
fn update(&mut self, ctx: &egui::Context, _: &mut eframe::Frame) {
install_image_loaders(ctx);
{
let mut state = State {
cfg: self.cfg.clone(),
downloader: self.downloader.clone(),
manifest: self.manifest.clone(),
};
self.windows.ui(&mut state, ctx);
self.cfg = state.cfg;
self.downloader = state.downloader;
self.manifest = state.manifest;
}
components::nav::NavBar::ui(self, ctx);
egui::CentralPanel::default().show(ctx, |ui| {
let avail_height = ui.available_height();
// The central panel the region left after adding TopPanel's and SidePanel's
//ui.heading(format!("Songs ({})", self.manifest.get_song_count()));
ui.vertical_centered_justified(|ui| {
ui.with_layout(egui::Layout::top_down_justified(egui::Align::TOP), |ui| {
ui.horizontal(|ui| {
ui.set_height(avail_height);
components::side_nav::SideNav::ui(self, ui);
components::song_list::SongList::ui(self, ui);
});
ui.separator();
ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| {
egui::warn_if_debug_build(ui);
});
});
});
});
// Make sure we dont wait for any updates cause we depend on the gui code for downloads
ctx.request_repaint();
}
}

View File

@ -0,0 +1,57 @@
use egui::{Color32, Label, RichText};
use super::{State, Window};
#[allow(clippy::pedantic)]
#[derive(Debug, Default)]
pub struct ConfirmW {
id: String,
text: String,
response: Option<bool>,
data: Vec<String>
}
impl Window for ConfirmW {
fn ui(&mut self, _: &mut State, ctx: &egui::Context, open: &mut bool) -> anyhow::Result<()> {
let mut should_close = false;
egui::Window::new("Are you sure?").open(open).show(ctx, |ui| {
ui.vertical(|ui| {
ui.label(RichText::new("Are you sure you want to do this?").size(15.0).color(Color32::BLUE));
ui.horizontal(|ui| {
ui.add(Label::new(self.text.clone()).wrap(true));
});
ui.horizontal(|ui| {
if ui.button("Cancel").clicked() {
self.response = Some(false);
should_close = true;
} else if ui.button("Continue").clicked() {
self.response = Some(true);
should_close = true;
}
})
})
});
if should_close {
*open = false;
}
Ok(())
}
}
impl ConfirmW {
pub fn set_message<S: ToString>(&mut self, new_id: S, text: S, data: &[String]) {
self.text = text.to_string();
self.id = new_id.to_string();
self.data = data.to_vec();
}
pub fn get_response(&self) -> (&String, &Option<bool>, &Vec<String>) {
(&self.id, &self.response, &self.data)
}
pub fn reset(&mut self) {
self.id.clear();
self.text.clear();
self.response = None;
}
}

View File

@ -0,0 +1,33 @@
use egui::{Color32, Label, RichText};
use super::{State, Window};
#[allow(clippy::pedantic)]
#[derive(Debug, Default)]
pub struct GuiError {
text: String,
}
impl Window for GuiError {
fn ui(&mut self, _: &mut State, ctx: &egui::Context, open: &mut bool) -> anyhow::Result<()> {
egui::Window::new("ERROR!!!! D:")
.open(open)
.show(ctx, |ui| {
ui.vertical(|ui| {
ui.label(RichText::new("Error:").size(15.0).color(Color32::RED));
ui.horizontal(|ui| {
ui.add(Label::new(self.text.clone()).wrap(true));
})
})
});
Ok(())
}
}
impl GuiError {
pub fn set_error_message<S: ToString>(&mut self, text: S) {
self.text = text.to_string();
}
}

View File

@ -0,0 +1,93 @@
use crate::manifest::song::SongType;
use super::{State, Window};
#[allow(clippy::pedantic)]
#[derive(Debug, Default)]
pub struct GuiImportPlaylist {
ed_type: SongType,
ed_name: String,
ed_url: String,
//urls_to_add: Vec<String>,
// playlist_name: String,
}
impl Window for GuiImportPlaylist {
fn ui(&mut self, state: &mut State, ctx: &egui::Context, open: &mut bool) -> anyhow::Result<()> {
let mut save = false;
egui::Window::new("Import Playlist")
.open(open)
.show(ctx, |ui| {
ui.horizontal(|ui| {
ui.label("Type: ");
egui::ComboBox::from_id_source("new_playlist_window_type")
.selected_text(format!("{:?}", self.ed_type))
.show_ui(ui, |ui| {
ui.selectable_value(&mut self.ed_type, SongType::Youtube, "Youtube");
ui.selectable_value(&mut self.ed_type, SongType::Spotify, "Spotify");
// ui.selectable_value(&mut self.ed_type, SongType::Soundcloud, "Soundcloud");
}
);
});
ui.horizontal(|ui| {
ui.label("Name: ");
ui.text_edit_singleline(&mut self.ed_name);
});
ui.horizontal(|ui| {
ui.label("Url: ");
ui.text_edit_singleline(&mut self.ed_url);
});
if ui.button("Import").clicked() {
save = true;
}
});
//if let Some(_) = self.urls_to_add.pop() {
// todo!();
//let client = reqwest::blocking::Client::new();
// let song_name = crate::crawler::spotify::get_song_name(&client, url.clone())?;
//if let Some(playlist) = state.manifest.get_playlist_mut(&self.playlist_name) {
// let mut song = Song::from_url_str(url)?;
// song.set_type(SongType::Spotify);
// playlist.add_song(song_name, song);
//}
//let _ = state.manifest.save(None);
//}
if save {
let name = self.ed_name.clone();
let url = self.ed_url.clone();
if state.manifest.get_playlist(&name).is_some() {
log::error!("Playlist {name} already exists");
}
if self.ed_type == SongType::Spotify {
todo!()
//let client = reqwest::blocking::Client::new();
//self.urls_to_add = crate::crawler::spotify::get_playlist_song_urls(&client, self.ed_url.clone())?;
//self.playlist_name = self.ed_name.clone();
//state.manifest.add_playlist(name.clone());
} else if self.ed_type == SongType::Youtube {
let songs = state.downloader.download_playlist_nb(&state.cfg, &url, &name, state.manifest.get_format()).unwrap();
state.manifest.add_playlist(name.clone());
let playlist = state.manifest.get_playlist_mut(&name).expect("Unreachable");
for (sname, song) in songs {
log::info!("Added: {sname}");
playlist.add_song(sname, song);
}
}
let _ = state.manifest.save(None);
*open = false;
}
Ok(())
}
}

77
src/ui/gui/windows/mod.rs Normal file
View File

@ -0,0 +1,77 @@
use std::collections::HashMap;
use crate::{config::ConfigWrapper, downloader::Downloader, manifest::Manifest};
pub mod song_edit;
pub mod error;
pub mod import_playlist;
pub mod song_new;
pub mod confirm;
pub trait Window: std::fmt::Debug {
fn ui(&mut self, state: &mut State, ctx: &egui::Context, open: &mut bool) -> anyhow::Result<()>;
}
#[derive(Debug, Hash, Eq, PartialEq, Clone, Copy)]
pub enum WindowIndex {
Error,
ImportPlaylist,
SongEdit,
SongNew,
Confirm
}
#[derive(Debug,Default)]
pub struct WindowManager {
opened: HashMap<WindowIndex, bool>,
windows: HashMap<WindowIndex, Box<dyn Window>>
}
pub struct State {
pub downloader: Downloader,
pub manifest: Manifest,
pub cfg: ConfigWrapper,
}
impl WindowManager {
pub fn new() -> Self {
let mut windows: HashMap<WindowIndex, Box<dyn Window>> = HashMap::new();
windows.insert(WindowIndex::Error, Box::<error::GuiError>::default());
windows.insert(WindowIndex::ImportPlaylist, Box::<import_playlist::GuiImportPlaylist>::default());
windows.insert(WindowIndex::SongEdit, Box::<song_edit::GuiSongEditor>::default());
windows.insert(WindowIndex::SongNew, Box::<song_new::GuiNewSong>::default());
windows.insert(WindowIndex::Confirm, Box::<confirm::ConfirmW>::default());
Self {
windows,
..Default::default()
}
}
#[allow(dead_code)]
pub fn is_open(&self, id: WindowIndex) -> bool {
*self.opened.get(&id).unwrap()
}
pub fn open(&mut self, id: WindowIndex, open: bool) {
self.opened.insert(id, open);
}
pub fn ui(&mut self, state: &mut State, ctx: &egui::Context) {
for (id, window) in &mut self.windows {
if !self.opened.contains_key(id) {
self.opened.insert(*id, false);
}
let open = self.opened.get_mut(id).unwrap();
if let Err(e) = window.ui(state, ctx, open) {
log::error!("Window {id:?} errored: {e}");
}
}
}
pub fn get_window<T: Window + 'static>(&mut self, id: WindowIndex) -> &mut Box<T> {
let w = self.windows.get_mut(&id).unwrap();
unsafe {
crate::util::as_any_mut(w).downcast_mut_unchecked()
}
}
}

View File

@ -0,0 +1,108 @@
use anyhow::bail;
use egui::Color32;
use crate::manifest::song::SongType;
use super::{State, Window};
#[derive(Debug, Default)]
pub struct GuiSongEditor {
song: (String, String),
ed_url: String,
ed_name: String,
ed_type: SongType
}
impl Window for GuiSongEditor {
fn ui(&mut self, state: &mut State, ctx: &egui::Context, open: &mut bool) -> anyhow::Result<()> {
let mut save = false;
let (playlist_name, song_name) = self.song.clone();
if playlist_name.is_empty() {
return Ok(());
}
let Some(song) = state.manifest.get_song(&playlist_name, &song_name) else {
bail!("Failed to get song (1)");
};
let song = song.clone();
egui::Window::new("Song editor")
.open(open)
.show(ctx,
|ui| {
ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 0.0;
ui.label("[");
ui.hyperlink_to("link", song.get_url().unwrap());
ui.label("] ");
ui.colored_label(Color32::LIGHT_BLUE, &playlist_name);
ui.label(": ");
ui.label(&song_name)
});
ui.horizontal(|ui| {
ui.label("Type: ");
ui.label(song.get_type().to_string());
egui::ComboBox::from_id_source("song_edit_window_type")
.selected_text(format!("{:?}", self.ed_type))
.show_ui(ui, |ui| {
ui.selectable_value(&mut self.ed_type, SongType::Youtube, "Youtube");
ui.selectable_value(&mut self.ed_type, SongType::Spotify, "Spotify");
ui.selectable_value(&mut self.ed_type, SongType::Soundcloud, "Soundcloud");
}
);
});
ui.horizontal(|ui| {
ui.label("Name: ");
ui.text_edit_singleline(&mut self.ed_name);
});
ui.horizontal(|ui| {
ui.label("Url: ");
ui.text_edit_singleline(&mut self.ed_url);
});
if ui.button("Save").clicked() {
save = true;
}
});
if save {
let song = {
let Some(song) = state.manifest.get_song_mut(&playlist_name, &song_name) else {
bail!("Failed to get song (2)");
};
song.get_url_str_mut().clone_from(&self.ed_url);
song.get_type_mut().clone_from(&self.ed_type);
song.clone()
};
let Some(playlist) = state.manifest.get_playlist_mut(&playlist_name) else {
bail!("Failed to get playlist");
};
playlist.remove_song(&song_name);
playlist.add_song(self.ed_name.clone(), song.clone());
*open = false;
let _ = state.manifest.save(None);
}
Ok(())
}
}
impl GuiSongEditor {
pub fn set_active_song(&mut self, pname: &str, sname: &str, url: &str, typ: &SongType) {
self.song.0 = pname.to_string();
self.song.1 = sname.to_string();
self.ed_name = sname.to_string();
self.ed_url = url.to_string();
self.ed_type = typ.clone();
}
}

View File

@ -0,0 +1,72 @@
use crate::manifest::song::{Song, SongType};
use super::{State, Window};
#[derive(Debug, Default)]
pub struct GuiNewSong {
typ: SongType,
name: String,
playlist: Option<String>,
url: String,
}
impl Window for GuiNewSong {
fn ui(&mut self, state: &mut State, ctx: &egui::Context, open: &mut bool) -> anyhow::Result<()> {
let mut save = false;
egui::Window::new("New song")
.open(open)
.show(ctx, |ui| {
ui.horizontal(|ui| {
ui.label("Type: ");
egui::ComboBox::from_id_source("new_song_window_type")
.selected_text(format!("{:?}", self.typ))
.show_ui(ui, |ui| {
ui.selectable_value(&mut self.typ, SongType::Youtube, "Youtube");
ui.selectable_value(&mut self.typ, SongType::Spotify, "Spotify");
ui.selectable_value(&mut self.typ, SongType::Soundcloud, "Soundcloud");
}
);
});
ui.horizontal(|ui| {
ui.label("Name: ");
ui.text_edit_singleline(&mut self.name);
});
ui.horizontal(|ui| {
ui.label("Playlist: ");
egui::ComboBox::from_id_source("new_song_window_playlist")
.selected_text(self.playlist.clone().unwrap_or_default())
.show_ui(ui, |ui| {
for p in state.manifest.get_playlists().keys() {
ui.selectable_value(&mut self.playlist, Option::Some(p.clone()), p.as_str());
}
}
);
});
ui.horizontal(|ui| {
ui.label("Url: ");
ui.text_edit_singleline(&mut self.url);
});
if ui.button("Save").clicked() {
save = true;
}
});
if save {
let Some(playlist) = state.manifest.get_playlist_mut(&self.playlist.clone().unwrap()) else {
panic!("couldnt find playlist from a preset playlist list????????????");
};
playlist.add_song(
self.name.clone(),
Song::from_url_str(self.url.clone()).unwrap().set_type(self.typ.clone()).clone()
);
let _ = state.manifest.save(None);
*open = false;
}
Ok(())
}
}

2
src/ui/mod.rs Normal file
View File

@ -0,0 +1,2 @@
pub mod gui;
pub mod cli;

View File

@ -2,16 +2,12 @@ use std::{any::Any, path::PathBuf};
use crate::{constants, manifest::Format};
pub(crate) fn is_supported_host(url: url::Url) -> bool {
pub(crate) fn is_supported_host(url: &url::Url) -> bool {
let host = url.host_str();
if host.is_none() {
return false;
}
match host.unwrap() {
"youtube.com" | "youtu.be" |
"open.spotify.com" => true,
_ => false
}
matches!(host.unwrap(), "youtube.com" | "youtu.be" | "open.spotify.com")
}
pub(crate) fn is_program_in_path(program: &str) -> Option<PathBuf> {
@ -52,21 +48,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 {
@ -76,7 +62,7 @@ pub fn get_song_path/*<P: TryInto<PathBuf>>*/(/*basepath: Option<P>,*/ pname: &S
path = std::env::current_dir().unwrap_or(PathBuf::new());
}
} else {*/
let mut path = std::env::current_dir().unwrap_or(PathBuf::new());
let mut path = std::env::current_dir().unwrap_or_default();
//}
// TODO: Get this from cfg
path.push("out");
@ -85,3 +71,11 @@ pub fn get_song_path/*<P: TryInto<PathBuf>>*/(/*basepath: Option<P>,*/ pname: &S
path.set_extension(format.to_string());
path
}
pub fn get_playlist_path(pname: &String) -> PathBuf {
let mut path = std::env::current_dir().unwrap_or_default();
// TODO: Get this from cfg
path.push("out");
path.push(pname);
path
}