commit df744e47d5916c3322efbf098a0a55cff22ab066 Author: astar76 Date: Sat Oct 24 17:58:16 2026 -0500 Audiphi in Rust: egui port of the Python app, Spotify API fix Co-Authored-By: Claude Sonnet 5.5 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4d40931 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/target/ +/releases/ +*.AppImage +.directory diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..4665465 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,3911 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "accesskit" +version = "0.25.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad442f58ee04714aaa0ba0a2768c1ea1935b29507bb22ddece8cbbc76db02932" +dependencies = [ + "uuid", +] + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "ahash" +version = "0.8.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a15f179cd60c4584b8a8c596927aadc462e27f2ca70c04e0071964a73ba7a75" +dependencies = [ + "cfg-if", + "getrandom 0.3.4", + "once_cell", + "version_check", + "zerocopy", +] + +[[package]] +name = "aho-corasick" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c982642fa9e8606056828ee9a8505737230110bb1099153c79efe865c59d12ba" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-activity" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0f2a1bb052857d5dd49572219344a7332b31b76405648eabac5bc68978251bcd" +dependencies = [ + "android-properties", + "bitflags 2.13.2", + "cc", + "jni", + "libc", + "log", + "ndk", + "ndk-context", + "ndk-sys", + "num_enum", + "thiserror 2.0.21", +] + +[[package]] +name = "android-properties" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc7eb209b1518d6bb87b283c20095f5228ecda460da70b44f0802523dea6da04" + +[[package]] +name = "arboard" +version = "3.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aeb9553e62312c8756a5979254fc6d7da8bbeb5986a1e17037fab932f7037917" +dependencies = [ + "clipboard-win", + "image", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", + "parking_lot", + "percent-encoding", + "windows-sys 0.61.2", + "wl-clipboard-rs", + "x11rb", +] + +[[package]] +name = "arrayref" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb" + +[[package]] +name = "arrayvec" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56" + +[[package]] +name = "as-raw-xcb-connection" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "175571dd1d178ced59193a6fc02dde1b972eb0bc56c892cde9beeceac5bf0f6b" + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "audiphi" +version = "0.2.0" +dependencies = [ + "base64 0.22.1", + "dirs", + "eframe", + "image", + "libmpv2", + "lofty", + "regex", + "resvg", + "rfd", + "rustfft", + "serde", + "serde_json", + "unicode-normalization", + "ureq", + "urlencoding", +] + +[[package]] +name = "autocfg" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "base64" +version = "0.23.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5" + +[[package]] +name = "bit-set" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2f926cc3060f09db9ebc5b52823d85268d24bb917e472c0c4bea35780a7d" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b71798fca2c1fe1086445a7258a4bc81e6e49dcd24c8d0dd9a1e57395b603f51" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06" + +[[package]] +name = "block2" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" +dependencies = [ + "objc2 0.5.3", +] + +[[package]] +name = "block2" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdeb9d870516001442e364c5220d3574d2da8dc765554b4a617230d33fa58ef5" +dependencies = [ + "objc2 0.6.5", +] + +[[package]] +name = "bumpalo" +version = "3.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649" + +[[package]] +name = "bytemuck" +version = "1.25.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6a1f896587b6f2c069c73d2f0913e2d590c3990285cd2f0b6aa02b786b4c679c" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "byteorder-lite" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495" + +[[package]] +name = "bytes" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04" + +[[package]] +name = "calloop" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b99da2f8558ca23c71f4fd15dc57c906239752dd27ff3c00a1d56b685b7cbfec" +dependencies = [ + "bitflags 2.13.2", + "log", + "polling", + "rustix 0.38.44", + "slab", + "thiserror 1.0.69", +] + +[[package]] +name = "calloop-wayland-source" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95a66a987056935f7efce4ab5668920b5d0dac4a7c99991a67395f13702ddd20" +dependencies = [ + "calloop", + "rustix 0.38.44", + "wayland-backend", + "wayland-client", +] + +[[package]] +name = "cc" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0" +dependencies = [ + "find-msvc-tools", + "jobserver", + "libc", + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7648175b45a9a48536d676f68d918270699102aa8dab5496df06904c914600" + +[[package]] +name = "cfg_aliases" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527" + +[[package]] +name = "cgl" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ced0551234e87afee12411d535648dd89d2e7f34c78b753395567aff3d447ff" +dependencies = [ + "libc", +] + +[[package]] +name = "clipboard-win" +version = "5.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "052af7878466feccda12ba7a6a67d019d712f296809559b47c12c8cc196d3a9a" +dependencies = [ + "error-code", +] + +[[package]] +name = "codespan-reporting" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af491d569909a7e4dee0ad7db7f5341fef5c614d5b8ec8cf765732aba3cff681" +dependencies = [ + "unicode-width", +] + +[[package]] +name = "color" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ec7c5eb7a16992b1904d76c517d170ab353b0e0b3d5a0c81a8a0cd1037893cf" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + +[[package]] +name = "combine" +version = "4.6.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4356eba6976435498d05a311ee9fc486da3bc81c200d3f0d7dd9703b41913f92" +dependencies = [ + "bytes", + "memchr", +] + +[[package]] +name = "concurrent-queue" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ca0197aee26d1ae37445ee532fefce43251d24cc7c166799f4d46817f1d3973" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "cookie" +version = "0.18.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a373e3602691c3cdea496d2f0ee5935151e6168fe87739483c463db1b2f2f87" +dependencies = [ + "percent-encoding", + "time", + "version_check", +] + +[[package]] +name = "cookie_store" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15b2c103cf610ec6cae3da84a766285b42fd16aad564758459e6ecf128c75206" +dependencies = [ + "cookie", + "document-features", + "idna", + "indexmap", + "log", + "serde", + "serde_derive", + "serde_json", + "time", + "url", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "core-graphics" +version = "0.23.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c07782be35f9e1140080c6b96f0d44b739e2278479f64e02fdab4e32dfd8b081" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "core-graphics-types", + "foreign-types", + "libc", +] + +[[package]] +name = "core-graphics-types" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "libc", +] + +[[package]] +name = "crc32fast" +version = "1.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ba106e844045ddc02c20768ac4b0b7cb45f2cc2ecbd833ac9f5dacb183c2055" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31eee39dddec8330830986fcd7625edb5a24ec90ea038215273bbc3adb08ac6" + +[[package]] +name = "crunchy" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "460fbee9c2c2f33933d720630a6a0bac33ba7053db5344fac858d4b8952d77d5" + +[[package]] +name = "cursor-icon" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f27ae1dd37df86211c42e150270f82743308803d90a6f6e6651cd730d5e1732f" + +[[package]] +name = "data-encoding" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4583a4551df46e2792f82ceeac45e850d2e2d5debba0b91f102385cda5b11f06" + +[[package]] +name = "data-url" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376" + +[[package]] +name = "deranged" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e9de72ce2ad1f90dc62fa25f0f430ef85eb4b0d8fa0be4f30373bc40a21d28e" + +[[package]] +name = "dirs" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e" +dependencies = [ + "dirs-sys", +] + +[[package]] +name = "dirs-sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab" +dependencies = [ + "libc", + "option-ext", + "redox_users", + "windows-sys 0.61.2", +] + +[[package]] +name = "dispatch" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd0c93bb4b0c6d9b77f4435b0ae98c24d17f1c45b2ff844c6151a07256ca923b" + +[[package]] +name = "dispatch2" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e0e367e4e7da84520dedcac1901e4da967309406d1e51017ae1abfb97adbd38" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "libc", + "objc2 0.6.5", +] + +[[package]] +name = "displaydoc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6232dd377dcc64799954cbd3a9bb882e9cdc1308ccd87b1c098f1fb2eaf82a8" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "dlib" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab8ecd87370524b461f8557c119c405552c396ed91fc0a8eec68679eab26f94a" +dependencies = [ + "libloading", +] + +[[package]] +name = "document-features" +version = "0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4b8a88685455ed29a21542a33abd9cb6510b6b129abadabdcef0f4c55bc8f61" +dependencies = [ + "litrs", +] + +[[package]] +name = "downcast-rs" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75b325c5dbd37f80359721ad39aca5a29fb04c89279657cffdda8736d0c0b9d2" + +[[package]] +name = "dpi" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8b14ccef22fc6f5a8f4d7d768562a182c04ce9a3b3157b91390b52ddfdf1a76" + +[[package]] +name = "ecolor" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31bcbef0d4263a63eb32c4834e5d711613035ce1333468e107d928923e21e6e2" +dependencies = [ + "bytemuck", + "emath", +] + +[[package]] +name = "eframe" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c5642501a65ca657d05f00c643a5c14ff2346cb3818032bfe23d58e1f8e5f84" +dependencies = [ + "ahash", + "bytemuck", + "document-features", + "egui", + "egui-wgpu", + "egui-winit", + "egui_glow", + "glow", + "glutin", + "glutin-winit", + "image", + "js-sys", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "parking_lot", + "percent-encoding", + "profiling", + "raw-window-handle", + "send_wrapper", + "static_assertions", + "wasm-bindgen", + "web-sys", + "web-time", + "windows-sys 0.61.2", + "winit", +] + +[[package]] +name = "egui" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bec9144f49b7a28b5f395d3147e325b4fe3e77ba686eac11d1bdf0a7da3f375f" +dependencies = [ + "accesskit", + "ahash", + "bitflags 2.13.2", + "emath", + "epaint", + "itertools", + "log", + "nohash-hasher", + "profiling", + "smallvec", + "unicode-segmentation", + "web-sys", +] + +[[package]] +name = "egui-wgpu" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0309cbe1febed48af5b974e4bcc424b35e9664863a4d402697147b57a488c864" +dependencies = [ + "ahash", + "bytemuck", + "document-features", + "egui", + "epaint", + "log", + "profiling", + "thiserror 2.0.21", + "type-map", + "web-time", + "wgpu", + "winit", +] + +[[package]] +name = "egui-winit" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e449f4c4a2a60c7ccb4ba7fa4078417bfe1f9ddc03b5e05ce75748e33a70de" +dependencies = [ + "arboard", + "block2 0.6.2", + "bytemuck", + "egui", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-foundation 0.3.2", + "objc2-ui-kit 0.3.2", + "profiling", + "raw-window-handle", + "web-time", + "windows-sys 0.61.2", + "winit", +] + +[[package]] +name = "egui_glow" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9275ca5cc35a6b7c94e0e8cedf22542f66cb0cf45ed8ab2657c78ff49fec7268" +dependencies = [ + "bytemuck", + "egui", + "glow", + "log", + "profiling", + "winit", +] + +[[package]] +name = "either" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" + +[[package]] +name = "emath" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e73ce90f54750be8672c02be0743fe47530e6f251e066f0ee2869b59eb297af5" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "epaint" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97bac86ae3dde93fc3951e790951caea739ff39a6c89d909cdaf1d9278dbb1bd" +dependencies = [ + "ahash", + "bytemuck", + "ecolor", + "emath", + "epaint_default_fonts", + "font-types", + "harfrust", + "log", + "nohash-hasher", + "parking_lot", + "profiling", + "self_cell", + "skrifa", + "smallvec", + "unicode-general-category", + "unicode-properties", + "unicode-segmentation", + "vello_cpu", +] + +[[package]] +name = "epaint_default_fonts" +version = "0.37.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfc1cc505827f4c23eedc297975a0fd038268d41293f389dd8ff3b574aefab19" + +[[package]] +name = "equivalent" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826" + +[[package]] +name = "errno" +version = "0.3.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "error-code" +version = "3.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b5343afd4a8365a643ac588dab4cf234a190c7f6c88c9f6dd6ffe00837661b7" + +[[package]] +name = "euclid" +version = "0.22.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1a05365e3b1c6d1650318537c7460c6923f1abdd272ad6842baa2b509957a06" +dependencies = [ + "num-traits", +] + +[[package]] +name = "fax" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caf1079563223d5d59d83c85886a56e586cfd5c1a26292e971a0fa266531ac5a" + +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "fearless_simd" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b97b65636e5b9ef369943878ac74335ba1c55c1cb6adbf1e2c293c624248d693" + +[[package]] +name = "find-msvc-tools" +version = "0.1.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48" + +[[package]] +name = "fixedbitset" +version = "0.5.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99" + +[[package]] +name = "flate2" +version = "1.1.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e634e2e0ebac1ee034020da1ca582e17ffe4e0f5e985823721e168928136dcb" +dependencies = [ + "crc32fast", + "miniz_oxide 0.9.1", + "zlib-rs", +] + +[[package]] +name = "float-cmp" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4" + +[[package]] +name = "foldhash" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d9c4f5dac5e15c24eb999c26181a6ca40b39fe946cbe4c263c7209467bc83af2" + +[[package]] +name = "foldhash" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" + +[[package]] +name = "font-types" +version = "0.12.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "835ae9d781464a79026cde387f9cbc650c9a4909d7cf7e658b127e3c35d2f35d" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea5190182e6915eb873ddbc16e23b711b6eb1f9c00a0d0a3a91b5f6228475225" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + +[[package]] +name = "form_urlencoded" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-core" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e" + +[[package]] +name = "futures-task" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd" + +[[package]] +name = "futures-util" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "slab", +] + +[[package]] +name = "gethostname" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1bd49230192a3797a9a4d6abe9b3eed6f7fa4c8a8a4947977c6f80025f92cbd8" +dependencies = [ + "rustix 1.1.5", + "windows-link", +] + +[[package]] +name = "getrandom" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff2abc00be7fca6ebc474524697ae276ad847ad0a6b3faa4bcb027e9a4614ad0" +dependencies = [ + "cfg-if", + "libc", + "wasi", +] + +[[package]] +name = "getrandom" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd" +dependencies = [ + "cfg-if", + "libc", + "r-efi 5.3.0", + "wasip2", +] + +[[package]] +name = "getrandom" +version = "0.4.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099" +dependencies = [ + "cfg-if", + "libc", + "r-efi 6.0.0", +] + +[[package]] +name = "gif" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee8cfcc411d9adbbaba82fb72661cc1bcca13e8bba98b364e62b2dba8f960159" +dependencies = [ + "color_quant", + "weezl", +] + +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "glifo" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282a26c1e23de04bdab3e34a21b6f877a479b96737792516b9b8b8f69b6661be" +dependencies = [ + "bytemuck", + "foldhash 0.2.0", + "hashbrown 0.17.1", + "log", + "peniko", + "skrifa", + "smallvec", + "vello_common", +] + +[[package]] +name = "glow" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29038e1c483364cc6bb3cf78feee1816002e127c331a1eec55a4d202b9e1adb5" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glutin" +version = "0.32.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12124de845cacfebedff80e877bb37b5b75c34c5a4c89e47e1cdd67fb6041325" +dependencies = [ + "bitflags 2.13.2", + "cfg_aliases", + "cgl", + "dispatch2", + "glutin_egl_sys", + "glutin_glx_sys", + "glutin_wgl_sys", + "libloading", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "once_cell", + "raw-window-handle", + "wayland-sys", + "windows-sys 0.52.0", + "x11-dl", +] + +[[package]] +name = "glutin-winit" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85edca7075f8fc728f28cb8fbb111a96c3b89e930574369e3e9c27eb75d3788f" +dependencies = [ + "cfg_aliases", + "glutin", + "raw-window-handle", + "winit", +] + +[[package]] +name = "glutin_egl_sys" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c4680ba6195f424febdc3ba46e7a42a0e58743f2edb115297b86d7f8ecc02d2" +dependencies = [ + "gl_generator", + "windows-sys 0.52.0", +] + +[[package]] +name = "glutin_glx_sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7bb2938045a88b612499fbcba375a77198e01306f52272e692f8c1f3751185" +dependencies = [ + "gl_generator", + "x11-dl", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c4ee00b289aba7a9e5306d57c2d05499b2e5dc427f84ac708bd2c090212cf3e" +dependencies = [ + "gl_generator", +] + +[[package]] +name = "guillotiere" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b17e70c989c36bad147b27a58d148c0741c51448aa5653436547323e524d0ab" +dependencies = [ + "euclid", +] + +[[package]] +name = "half" +version = "2.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ea2d84b969582b4b1864a92dc5d27cd2b77b622a8d79306834f1be5ba20d84b" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", + "zerocopy", +] + +[[package]] +name = "harfrust" +version = "0.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c03d949a14aa089bbb282f7dd76a498a7f684428e4257202efc119ec010376f9" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "read-fonts", + "smallvec", +] + +[[package]] +name = "hashbrown" +version = "0.15.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9229cfe53dfd69f0609a49f65461bd93001ea1ef889cd5529dd176593f5338a1" +dependencies = [ + "foldhash 0.1.5", +] + +[[package]] +name = "hashbrown" +version = "0.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a" +dependencies = [ + "foldhash 0.2.0", +] + +[[package]] +name = "hermit-abi" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284" + +[[package]] +name = "http" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "918d3568bebf352712bc2ef3d46a8bcf1a75b373be6539de198e9105cbbf9ce0" +dependencies = [ + "bytes", + "itoa", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "icu_collections" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe090a42a0d3140fed8c63263ed1fecc02422cb2f4bfe55cd8de2de1b8e105dd" +dependencies = [ + "displaydoc", + "potential_utf", + "utf8_iter", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25d29b57c17c6528d0dc4c2141cfa2d08200465acb537a3909c8b9b8a4a984c0" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "404a3b8c486f205c87fe7f23ab6894d84a4ad76d6e4671ae1981ba7def87c599" +dependencies = [ + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20f0088bfb7441f7a37fa0c9e20cb1e9cba1cac6b9ce8cd2a6dc44294f8e8cbc" + +[[package]] +name = "icu_properties" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ea83d991c56158f7cf898bf86436c1dfe7c07ee82fe88951f2695c9f37a379f" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b98f29af82d02b163fe50161388350e743bb3107cc8e8c2f7314cb505faddfcf" + +[[package]] +name = "icu_provider" +version = "2.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "413099315636c588ee8f011190b329b971a09a8fae9d157e01dcae8379468514" +dependencies = [ + "displaydoc", + "icu_locale_core", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b0875f23caa03898994f6ddc501886a45c7d3d62d04d2d90788d47be1b1e4de" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb68373c0d6620ef8105e855e7745e18b0d00d3bdb07fb532e434244cdb9a714" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "image" +version = "0.25.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85ab80394333c02fe689eaf900ab500fbd0c2213da414687ebf995a65d5a6104" +dependencies = [ + "bytemuck", + "byteorder-lite", + "color_quant", + "gif", + "image-webp", + "moxcms", + "num-traits", + "png 0.18.1", + "tiff", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "image-webp" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" +dependencies = [ + "byteorder-lite", + "quick-error", +] + +[[package]] +name = "imagesize" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edcd27d72f2f071c64249075f42e205ff93c9a4c5f6c6da53e79ed9f9832c285" + +[[package]] +name = "indexmap" +version = "2.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855" +dependencies = [ + "equivalent", + "hashbrown 0.17.1", +] + +[[package]] +name = "itertools" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc" +dependencies = [ + "either", +] + +[[package]] +name = "itoa" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682" + +[[package]] +name = "jni" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5efd9a482cf3a427f00d6b35f14332adc7902ce91efb778580e180ff90fa3498" +dependencies = [ + "cfg-if", + "combine", + "jni-macros", + "jni-sys 0.4.1", + "log", + "simd_cesu8", + "thiserror 2.0.21", + "walkdir", + "windows-link", +] + +[[package]] +name = "jni-macros" +version = "0.22.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00109accc170f0bdb141fed3e393c565b6f5e072365c3bd58f5b062591560a3" +dependencies = [ + "proc-macro2", + "quote", + "rustc_version", + "simd_cesu8", + "syn 2.0.119", +] + +[[package]] +name = "jni-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "41a652e1f9b6e0275df1f15b32661cf0d4b78d4d87ddec5e0c3c20f097433258" +dependencies = [ + "jni-sys 0.4.1", +] + +[[package]] +name = "jni-sys" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6377a88cb3910bee9b0fa88d4f42e1d2da8e79915598f65fb0c7ee14c878af2" +dependencies = [ + "jni-sys-macros", +] + +[[package]] +name = "jni-sys-macros" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c0b942f458fe50cdac086d2f946512305e5631e720728f2a61aabcd47a6264" +dependencies = [ + "quote", + "syn 2.0.119", +] + +[[package]] +name = "jobserver" +version = "0.1.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3" +dependencies = [ + "getrandom 0.4.3", + "libc", +] + +[[package]] +name = "js-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7883d941dae510fb2d978fc3fe018c71c9e2892fd38854de3e8b92c2e5ad9cc5" +dependencies = [ + "cfg-if", + "futures-util", + "wasm-bindgen", +] + +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + +[[package]] +name = "kurbo" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c62026ae44756f8a599ba21140f350303d4f08dcdcc71b5ad9c9bb8128c13c62" +dependencies = [ + "arrayvec", + "euclid", + "smallvec", +] + +[[package]] +name = "kurbo" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4b60dfc32f652b926df6192e55525b16d186c69d47876c3ead4da5cc9f8450e2" +dependencies = [ + "arrayvec", + "euclid", + "polycool", + "smallvec", +] + +[[package]] +name = "libc" +version = "0.2.191" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a" + +[[package]] +name = "libloading" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d7c4b02199fee7c5d21a5ae7d8cfa79a6ef5bb2fc834d6e9058e89c825efdc55" +dependencies = [ + "cfg-if", + "windows-link", +] + +[[package]] +name = "libm" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981" + +[[package]] +name = "libmpv2" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f3d44c1c29b866d44453249d1d8b2822d891fdabd08359a5b85bb6944445e70" +dependencies = [ + "libmpv2-sys", +] + +[[package]] +name = "libmpv2-sys" +version = "4.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edb32cabe7176b7d270b0dca6ff418b75187ae8d3854423e3d06fbff376841e4" + +[[package]] +name = "libredox" +version = "0.1.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d" +dependencies = [ + "bitflags 2.13.2", + "libc", + "plain", + "redox_syscall 0.9.5", +] + +[[package]] +name = "linebender_resource_handle" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "linux-raw-sys" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a66949e030da00e8c7d4434b251670a91556f4144941d37452769c25d58a53" + +[[package]] +name = "litemap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae" + +[[package]] +name = "litrs" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4744e383959f0db86ede514b809b1c53251889093803c05267acc7d4e7030d70" + +[[package]] +name = "lock_api" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965" +dependencies = [ + "scopeguard", +] + +[[package]] +name = "lofty" +version = "0.25.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb21dd79145b0781f2423fda92dd807fcd3911e44b66044d86db3b11ec7accf9" +dependencies = [ + "byteorder", + "data-encoding", + "flate2", + "lofty_attr", + "log", + "ogg_pager", + "paste", +] + +[[package]] +name = "lofty_attr" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdbca1b60ba7cea959ffc84ac27f3dbdbacd6dfda168c7eabbc00e48654bb9fd" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "log" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6" + +[[package]] +name = "memchr" +version = "2.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" + +[[package]] +name = "memmap2" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b0ca1155a9ecc25aa12e8313a119f32edf0255fea2f44839c4ac0a12b2ac157" +dependencies = [ + "libc", +] + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "miniz_oxide" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c" +dependencies = [ + "adler2", + "simd-adler32", +] + +[[package]] +name = "moxcms" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb85c154ba489f01b25c0d36ae69a87e4a1c73a72631fc6c0eb6dde34a73e44b" +dependencies = [ + "num-traits", + "pxfm", +] + +[[package]] +name = "naga" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a616d2fb8c89516ac2723a581f69d6c18576046bed761bd6b305e5618e6ae130" +dependencies = [ + "arrayvec", + "bit-set", + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "codespan-reporting", + "half", + "hashbrown 0.17.1", + "indexmap", + "libm", + "log", + "naga-types", + "num-traits", + "once_cell", + "rustc-hash 1.1.0", + "thiserror 2.0.21", + "unicode-ident", +] + +[[package]] +name = "naga-types" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "590afbf58a6f4f62873cd5cff4468061844bafa1cdf399cc954537c22d768d49" +dependencies = [ + "hashbrown 0.17.1", + "indexmap", + "rustc-hash 1.1.0", + "thiserror 2.0.21", +] + +[[package]] +name = "ndk" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3f42e7bbe13d351b6bead8286a43aac9534b82bd3cc43e47037f012ebfd62d4" +dependencies = [ + "bitflags 2.13.2", + "jni-sys 0.3.1", + "log", + "ndk-sys", + "num_enum", + "raw-window-handle", + "thiserror 1.0.69", +] + +[[package]] +name = "ndk-context" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" + +[[package]] +name = "ndk-sys" +version = "0.6.0+11769913" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee6cda3051665f1fb8d9e08fc35c96d5a244fb1be711a03b71118828afc9a873" +dependencies = [ + "jni-sys 0.3.1", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "8.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405" +dependencies = [ + "memchr", +] + +[[package]] +name = "num-complex" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73f88a1307638156682bada9d7604135552957b7818057dcef22705b4d509495" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-conv" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "521739c6d2bac4aa25192232afe6841231376b2b26d4d9fae5ecf8ca5772e441" + +[[package]] +name = "num-integer" +version = "0.1.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ce2d95d4b3734dc35aa2f45e1aa22cd416814592a4f9d9205e11affd5b8e10b" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "num_enum" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0bca838442ec211fa11de3a8b0e0e8f3a4522575b5c4c06ed722e005036f26" +dependencies = [ + "num_enum_derive", + "rustversion", +] + +[[package]] +name = "num_enum_derive" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "680998035259dcfcafe653688bf2aa6d3e2dc05e98be6ab46afb089dc84f1df8" +dependencies = [ + "proc-macro-crate", + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "objc-sys" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" + +[[package]] +name = "objc2" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19d5490aaf8f1d7cf7688dfa9b0ce07900e168852c45cd2c03f534dfd27cfd0b" +dependencies = [ + "objc-sys", + "objc2-encode", +] + +[[package]] +name = "objc2" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08849bbd4767dfae9457696856ae1c84fe4e0281bbe4a7abff2d0e06fb7981f8" +dependencies = [ + "objc2-encode", +] + +[[package]] +name = "objc2-app-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4e89ad9e3d7d297152b17d39ed92cd50ca8063a89a9fa569046d41568891eff" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "libc", + "objc2 0.5.3", + "objc2-core-data", + "objc2-core-image", + "objc2-foundation 0.2.2", + "objc2-quartz-core", +] + +[[package]] +name = "objc2-app-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d49e936b501e5c5bf01fda3a9452ff86dc3ea98ad5f283e1455153142d97518c" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-core-graphics", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-cloud-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74dd3b56391c7a0596a295029734d3c1c5e7e510a4cb30245f8221ccea96b009" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-core-location", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-contacts" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5ff520e9c33812fd374d8deecef01d4a840e7b41862d849513de77e44aa4889" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-data" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "617fbf49e071c178c0b24c080767db52958f716d9eabdf0890523aeae54773ef" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-core-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a180dd8642fa45cdb7dd721cd4c11b1cadd4929ce112ebd8b9f5803cc79d536" +dependencies = [ + "bitflags 2.13.2", + "dispatch2", + "objc2 0.6.5", +] + +[[package]] +name = "objc2-core-graphics" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e022c9d066895efa1345f8e33e584b9f958da2fd4cd116792e15e07e4720a807" +dependencies = [ + "bitflags 2.13.2", + "dispatch2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-io-surface", +] + +[[package]] +name = "objc2-core-image" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "55260963a527c99f1819c4f8e3b47fe04f9650694ef348ffd2227e8196d34c80" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-metal", +] + +[[package]] +name = "objc2-core-location" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "000cfee34e683244f284252ee206a27953279d370e309649dc3ee317b37e5781" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-contacts", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-encode" +version = "4.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef25abbcd74fb2609453eb695bd2f860d389e457f67dc17cafc8b8cbc89d0c33" + +[[package]] +name = "objc2-foundation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "dispatch", + "libc", + "objc2 0.5.3", +] + +[[package]] +name = "objc2-foundation" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3e0adef53c21f888deb4fa59fc59f7eb17404926ee8a6f59f5df0fd7f9f3272" +dependencies = [ + "bitflags 2.13.2", + "block2 0.6.2", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-io-surface" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180788110936d59bab6bd83b6060ffdfffb3b922ba1396b312ae795e1de9d81d" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", +] + +[[package]] +name = "objc2-link-presentation" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1a1ae721c5e35be65f01a03b6d2ac13a54cb4fa70d8a5da293d7b0020261398" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-metal" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd0cba1276f6023976a406a14ffa85e1fdd19df6b0f737b063b95f6c8c7aadd6" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-quartz-core" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e42bee7bff906b14b167da2bac5efe6b6a07e6f7c0a21a7308d40c960242dc7a" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", + "objc2-metal", +] + +[[package]] +name = "objc2-symbols" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a684efe3dec1b305badae1a28f6555f6ddd3bb2c2267896782858d5a78404dc" +dependencies = [ + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8bb46798b20cd6b91cbd113524c490f1686f4c4e8f49502431415f3512e2b6f" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-cloud-kit", + "objc2-core-data", + "objc2-core-image", + "objc2-core-location", + "objc2-foundation 0.2.2", + "objc2-link-presentation", + "objc2-quartz-core", + "objc2-symbols", + "objc2-uniform-type-identifiers", + "objc2-user-notifications", +] + +[[package]] +name = "objc2-ui-kit" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d87d638e33c06f577498cbcc50491496a3ed4246998a7fbba7ccb98b1e7eab22" +dependencies = [ + "bitflags 2.13.2", + "objc2 0.6.5", + "objc2-core-foundation", + "objc2-foundation 0.3.2", +] + +[[package]] +name = "objc2-uniform-type-identifiers" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44fa5f9748dbfe1ca6c0b79ad20725a11eca7c2218bceb4b005cb1be26273bfe" +dependencies = [ + "block2 0.5.1", + "objc2 0.5.3", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "objc2-user-notifications" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76cfcbf642358e8689af64cee815d139339f3ed8ad05103ed5eaf73db8d84cb3" +dependencies = [ + "bitflags 2.13.2", + "block2 0.5.1", + "objc2 0.5.3", + "objc2-core-location", + "objc2-foundation 0.2.2", +] + +[[package]] +name = "ogg_pager" +version = "0.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d36b1d6964c3ac92b7aea701057e02b6b91143d70d83b20abf75a231a3c0216" +dependencies = [ + "byteorder", +] + +[[package]] +name = "once_cell" +version = "1.21.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50" + +[[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] +name = "orbclient" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5df339f526ea9a60e371768d50efc2f2508c7203290731565d1f7a6f71d21747" +dependencies = [ + "libc", + "libredox", +] + +[[package]] +name = "os_pipe" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967" +dependencies = [ + "libc", + "windows-sys 0.61.2", +] + +[[package]] +name = "parking_lot" +version = "0.12.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93857453250e3077bd71ff98b6a65ea6621a19bb0f559a85248955ac12c45a1a" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall 0.5.18", + "smallvec", + "windows-link", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "peniko" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "839c8299360d2e998bdb106dc0a6cd71dcc5f4df51df1b620361bf50e283cca6" +dependencies = [ + "bytemuck", + "color", + "kurbo 0.13.1", + "linebender_resource_handle", + "smallvec", +] + +[[package]] +name = "percent-encoding" +version = "2.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b4f627cb1b25917193a259e49bdad08f671f8d9708acfd5fe0a8c1455d87220" + +[[package]] +name = "petgraph" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8701b58ea97060d5e5b155d383a69952a60943f0e6dfe30b04c287beb0b27455" +dependencies = [ + "fixedbitset", + "hashbrown 0.15.5", + "indexmap", +] + +[[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.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924" +dependencies = [ + "pin-project-internal", +] + +[[package]] +name = "pin-project-internal" +version = "1.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "pin-project-lite" +version = "0.2.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" + +[[package]] +name = "pkg-config" +version = "0.3.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548" + +[[package]] +name = "plain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4596b6d070b27117e987119b4dac604f3c58cfb0b191112e24771b2faeac1a6" + +[[package]] +name = "png" +version = "0.17.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526" +dependencies = [ + "bitflags 1.3.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "png" +version = "0.18.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60769b8b31b2a9f263dae2776c37b1b28ae246943cf719eb6946a1db05128a61" +dependencies = [ + "bitflags 2.13.2", + "crc32fast", + "fdeflate", + "flate2", + "miniz_oxide 0.8.9", +] + +[[package]] +name = "polling" +version = "3.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d0e4f59085d47d8241c88ead0f274e8a0cb551f3625263c05eb8dd897c34218" +dependencies = [ + "cfg-if", + "concurrent-queue", + "hermit-abi", + "pin-project-lite", + "rustix 1.1.5", + "windows-sys 0.61.2", +] + +[[package]] +name = "pollster" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f3a9f18d041e6d0e102a0a46750538147e5e8992d3b4873aaafee2520b00ce3" + +[[package]] +name = "polycool" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50596ddc09eb5ad5f75cacd40209568e66df71baf86e1499a0e99c4cff12a5a6" +dependencies = [ + "arrayvec", +] + +[[package]] +name = "portable-atomic" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85" + +[[package]] +name = "portable-atomic-util" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10ab3eb7f3becc3a1cbc4f2c6f20267996cfc1a6467a873763411b136a122715" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "potential_utf" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d83eb9bc6d8e5cf568e7a1101d60ee05e81ed50ea106026f3d18deeb046d7661" +dependencies = [ + "zerovec", +] + +[[package]] +name = "powerfmt" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a6394b9e965e73d0a289ee54f589087e2c676aedf60885baf52c76b771e4958" + +[[package]] +name = "primal-check" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc0d895b311e3af9902528fbb8f928688abbd95872819320517cc24ca6b2bd08" +dependencies = [ + "num-integer", +] + +[[package]] +name = "proc-macro-crate" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f" +dependencies = [ + "toml_edit", +] + +[[package]] +name = "proc-macro2" +version = "1.0.107" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "profiling" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5" + +[[package]] +name = "pxfm" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d55d956fa96f5ec02be2e13af0e20391a5aa83d6a074e3ad368959d0fab299ea" + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + +[[package]] +name = "quick-xml" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e660451e55124f798a69a5af3f49ccfbefbd41910eefd25caf2393e1f3473ec1" +dependencies = [ + "memchr", +] + +[[package]] +name = "quote" +version = "1.0.47" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "r-efi" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "read-fonts" +version = "0.41.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046a7d674daf459825b32f5062056d6882db0d2f5a479fbd76ccfc870ac18709" +dependencies = [ + "bytemuck", + "font-types", + "once_cell", +] + +[[package]] +name = "redox_syscall" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" +dependencies = [ + "bitflags 1.3.2", +] + +[[package]] +name = "redox_syscall" +version = "0.5.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "redox_syscall" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "580c875845b41ecb1564ad1ae4703044cef774145e3d7a94dc2b3fa7c97868fd" +dependencies = [ + "bitflags 2.13.2", +] + +[[package]] +name = "redox_users" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60dc65c0ff1a7ae1294b0c67b9f14baf70b644404010370171787bfac1038fc0" +dependencies = [ + "libredox", + "thiserror 2.0.21", +] + +[[package]] +name = "regex" +version = "1.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" + +[[package]] +name = "renderdoc-sys" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" + +[[package]] +name = "resvg" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8928798c0a55e03c9ca6c4c6846f76377427d2c1e1f7e6de3c06ae57942df43" +dependencies = [ + "log", + "pico-args", + "rgb", + "svgtypes", + "tiny-skia", + "usvg", +] + +[[package]] +name = "rfd" +version = "0.17.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20dafead71c16a34e1ff357ddefc8afc11e7d51d6d2b9fbd07eaa48e3e540220" +dependencies = [ + "block2 0.6.2", + "dispatch2", + "js-sys", + "libc", + "log", + "objc2 0.6.5", + "objc2-app-kit 0.3.2", + "objc2-core-foundation", + "objc2-foundation 0.3.2", + "percent-encoding", + "pollster", + "raw-window-handle", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "windows-sys 0.61.2", +] + +[[package]] +name = "rgb" +version = "0.8.53" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.17", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "roxmltree" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustc-hash" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b1e7f9a428571be2dc5bc0505c13fb6bf936822b894ec87abf8a08a4e51742d" + +[[package]] +name = "rustc_version" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" +dependencies = [ + "semver", +] + +[[package]] +name = "rustfft" +version = "6.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21db5f9893e91f41798c88680037dba611ca6674703c1a18601b01a72c8adb89" +dependencies = [ + "num-complex", + "num-integer", + "num-traits", + "primal-check", + "strength_reduce", + "transpose", +] + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.4.15", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustix" +version = "1.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "891efababe418670775f199f0d233d84843c227a0949a883ce15b37c78d6629d" +dependencies = [ + "bitflags 2.13.2", + "errno", + "libc", + "linux-raw-sys 0.12.1", + "windows-sys 0.61.2", +] + +[[package]] +name = "rustls" +version = "0.23.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48e13bd8c0e9365c43cfa5c9e8f9ad49d3c8444926c9aac819e0e4dc503c8fdf" +dependencies = [ + "log", + "once_cell", + "ring", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f4925028c7eb5d1fcdaf196971378ed9d2c1c4efc7dc5d011256f76c99c0a96" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443b1b6d39d7c663139942cc4558262562d2c84123bb6282ef177009ca8b281" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf54715a573b99ac80df0bc206da022bcd442c974952c7b9720069370852e21f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "scoped-tls" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1cf6437eb19a8f4a6cc0f7dca544973b0b78843adbfeb3683d1a94a0024a294" + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "self_cell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ab42ca02749e120097e328d91d415325bdf43b1c72c4c8badf37375fe40a813" + +[[package]] +name = "semver" +version = "1.0.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" + +[[package]] +name = "send_wrapper" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd0b0ec5f1c1ca621c432a25813d8d60c88abe6d3e08a3eb9cf37d97a0fe3d73" + +[[package]] +name = "serde" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" +dependencies = [ + "serde_core", + "serde_derive", +] + +[[package]] +name = "serde_core" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.229" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "serde_json" +version = "1.0.154" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7e9cc8b1b85264074fbcc02a88680c4096b1e47df8f739dceb03bf482f04bd6" +dependencies = [ + "itoa", + "memchr", + "serde", + "serde_core", + "zmij", +] + +[[package]] +name = "shlex" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba" + +[[package]] +name = "simd-adler32" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea" + +[[package]] +name = "simd_cesu8" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11031e251abf8611c80f460e19dbdeb54a66db918e49c65a7065b46ac7aec520" +dependencies = [ + "rustc_version", + "simdutf8", +] + +[[package]] +name = "simdutf8" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e" + +[[package]] +name = "simplecss" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c" +dependencies = [ + "log", +] + +[[package]] +name = "siphasher" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33f4fe9184a62d842c9ef383018f3306d8ba224fd9d836f56d7288308847c256" + +[[package]] +name = "skrifa" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819ab7d62b1d3e72d9d9dea5650bac30424f9111364bb94928dbf5ecad1baa68" +dependencies = [ + "bytemuck", + "read-fonts", +] + +[[package]] +name = "slab" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" + +[[package]] +name = "slotmap" +version = "1.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bdd58c3c93c3d278ca835519292445cb4b0d4dc59ccfdf7ceadaab3f8aeb4038" +dependencies = [ + "version_check", +] + +[[package]] +name = "smallvec" +version = "1.16.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8" + +[[package]] +name = "smithay-client-toolkit" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3457dea1f0eb631b4034d61d4d8c32074caa6cd1ab2d59f2327bd8461e2c0016" +dependencies = [ + "bitflags 2.13.2", + "calloop", + "calloop-wayland-source", + "cursor-icon", + "libc", + "log", + "memmap2", + "rustix 0.38.44", + "thiserror 1.0.69", + "wayland-backend", + "wayland-client", + "wayland-csd-frame", + "wayland-cursor", + "wayland-protocols", + "wayland-protocols-wlr", + "wayland-scanner", + "xkeysym", +] + +[[package]] +name = "smol_str" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dd538fb6910ac1099850255cf94a94df6551fbdd602454387d0adb2d1ca6dead" +dependencies = [ + "serde", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596" + +[[package]] +name = "static_assertions" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" + +[[package]] +name = "strength_reduce" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82" + +[[package]] +name = "strict-num" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731" +dependencies = [ + "float-cmp", +] + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "svgtypes" +version = "0.15.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68c7541fff44b35860c1a7a47a7cadf3e4a304c457b58f9870d9706ece028afc" +dependencies = [ + "kurbo 0.11.3", + "siphasher", +] + +[[package]] +name = "syn" +version = "2.0.119" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "synstructure" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "901704edd0dfe137f1987838ee4f259e4e063c31371bdb423f7ae38ec6f77f02" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "thiserror" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6aaf5339b578ea85b50e080feb250a3e8ae8cfcdff9a461c9ec2904bc923f52" +dependencies = [ + "thiserror-impl 1.0.69", +] + +[[package]] +name = "thiserror" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e" +dependencies = [ + "thiserror-impl 2.0.21", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fee6c4efc90059e10f81e6d42c60a18f76588c3d74cb83a0b242a2b6c7504c1" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "thiserror-impl" +version = "2.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "tiff" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b63feaf3343d35b6ca4d50483f94843803b0f51634937cc2ec519fc32232bc52" +dependencies = [ + "fax", + "flate2", + "half", + "quick-error", + "weezl", + "zune-jpeg", +] + +[[package]] +name = "time" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cdb87b95ec50ddfa440816d227a17b2ccbdda963a316a727fda0fc4334f7d134" +dependencies = [ + "deranged", + "num-conv", + "powerfmt", + "serde_core", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9e1c906769ad99c88eaa54e728060edef082f8e358ff32030cb7c7d315e81109" + +[[package]] +name = "time-macros" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e689342a48d2ea927c87ea50cabf8594854bf940e9310208848d680d668ed85" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tiny-skia" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "83d13394d44dae3207b52a326c0c85a8bf87f1541f23b0d143811088497b09ab" +dependencies = [ + "arrayref", + "arrayvec", + "bytemuck", + "cfg-if", + "log", + "png 0.17.16", + "tiny-skia-path", +] + +[[package]] +name = "tiny-skia-path" +version = "0.11.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93" +dependencies = [ + "arrayref", + "bytemuck", + "strict-num", +] + +[[package]] +name = "tinystr" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abc840c238154d58f9e86b2792261edfde565a17696e1cda1a449de27979801a" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tinyvec" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3ca314f692efd6c868f8408f53fe444634a845f96c028b97d35f6a1f79f0ee" + +[[package]] +name = "tokio" +version = "1.54.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b52fd3255258d26fac7264ab5a76b53c13367136dc011d3d6ad4f8ed070396a3" +dependencies = [ + "pin-project-lite", +] + +[[package]] +name = "toml_datetime" +version = "1.1.2+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b86d767906c6c42421dcba507eb9d203e779497710a47782a224bb871653053" +dependencies = [ + "serde_core", +] + +[[package]] +name = "toml_edit" +version = "0.25.17+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3641d5bbb5349a79e1020a242d251efbc546ad8048d133958323ce9c40a9c9c" +dependencies = [ + "indexmap", + "toml_datetime", + "toml_parser", + "winnow", +] + +[[package]] +name = "toml_parser" +version = "1.1.5+spec-1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c" +dependencies = [ + "winnow", +] + +[[package]] +name = "tracing" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "63e71662fa4b2a2c3a26f570f037eb95bb1f85397f3cd8076caed2f026a6d100" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "db97caf9d906fbde555dd62fa95ddba9eecfd14cb388e4f491a66d74cd5fb79a" + +[[package]] +name = "transpose" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ad61aed86bc3faea4300c7aee358b4c6d0c8d6ccc36524c96e4c92ccf26e77e" +dependencies = [ + "num-integer", + "strength_reduce", +] + +[[package]] +name = "tree_magic_mini" +version = "3.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8765b90061cba6c22b5831f675da109ae5561588290f9fa2317adab2714d5a6" +dependencies = [ + "memchr", + "nom", + "petgraph", +] + +[[package]] +name = "type-map" +version = "0.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb30dbbd9036155e74adad6812e9898d03ec374946234fbcebd5dfc7b9187b90" +dependencies = [ + "rustc-hash 2.1.3", +] + +[[package]] +name = "unicode-general-category" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b993bddc193ae5bd0d623b49ec06ac3e9312875fdae725a975c51db1cc1677f" + +[[package]] +name = "unicode-ident" +version = "1.0.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563" + +[[package]] +name = "unicode-normalization" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75cd3fb03d5288b3ba9a1ee103ac7e9cbb59f0b03d64f8ddfcc04dd42758a85d" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-properties" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7df058c713841ad818f1dc5d3fd88063241cc61f49f5fbea4b951e8cf5a8d71d" + +[[package]] +name = "unicode-segmentation" +version = "1.13.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c6f5d3c3b1bf09027a88a6bc961fc00497d651009560b5463668dc81b0fa87a8" + +[[package]] +name = "unicode-width" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "ureq" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cde93ff05758a36a851a398a772b0b79a82fbe3c186a46f2696baaeaf84c966b" +dependencies = [ + "base64 0.23.1", + "cookie_store", + "flate2", + "log", + "percent-encoding", + "rustls", + "rustls-pki-types", + "serde", + "serde_json", + "ureq-proto", + "utf8-zero", + "webpki-roots", +] + +[[package]] +name = "ureq-proto" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "841583fc36089d7d59419568ae157f43a5a03a2e5a81ba87c77d1596ef46e922" +dependencies = [ + "base64 0.23.1", + "http", + "httparse", + "log", +] + +[[package]] +name = "url" +version = "2.5.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", + "serde", +] + +[[package]] +name = "urlencoding" +version = "2.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da" + +[[package]] +name = "usvg" +version = "0.45.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80be9b06fbae3b8b303400ab20778c80bbaf338f563afe567cf3c9eea17b47ef" +dependencies = [ + "base64 0.22.1", + "data-url", + "flate2", + "imagesize", + "kurbo 0.11.3", + "log", + "pico-args", + "roxmltree", + "simplecss", + "siphasher", + "strict-num", + "svgtypes", + "tiny-skia-path", + "xmlwriter", +] + +[[package]] +name = "utf8-zero" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b8c0a043c9540bae7c578c88f91dda8bd82e59ae27c21baca69c8b191aaf5a6e" + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "uuid" +version = "1.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a0e2d11620c50695fe12bbbfde96b3477fe606e7284c22d505c12ce51214514" + +[[package]] +name = "vello_common" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbb2141a2bca6e6d598e471fd4d1d7eed8e020aad6a28187edda07f091a325dd" +dependencies = [ + "bytemuck", + "fearless_simd", + "guillotiere", + "log", + "peniko", + "smallvec", + "thiserror 2.0.21", +] + +[[package]] +name = "vello_cpu" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace506ca414548966fcf3c283be94eb1cad8254de488791ee698bf438b0890a9" +dependencies = [ + "bytemuck", + "glifo", + "hashbrown 0.17.1", + "vello_common", +] + +[[package]] +name = "version_check" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasip2" +version = "1.0.4+wasi-0.2.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487" +dependencies = [ + "wit-bindgen", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb54f33acc68fd454578d9820b0bde1a1a3d17aa17bb7b6595806d02886d409" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3cbab34de2d982e9b48e18d216d04c4a6f641066ff19ffb699980f591ee3610e" +dependencies = [ + "js-sys", + "tokio", + "wasm-bindgen", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2e29d0c35b16e224a7eeb5cd2d25e3e1968fbd65604117b44d3b789d00ee8535" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f501a8bc3719dba86ef8ae4728879c08001bea749eb1333ac5b91e040e2a6b7" +dependencies = [ + "bumpalo", + "proc-macro2", + "quote", + "syn 3.0.9", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.129" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23f0c9c52aa7cd7d77769a4cfe2a9adb1b331f489a41d912ce14513d5ab995c6" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "wayland-backend" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38a91b4eaddff87b1cd1074985e3713da4af2c49742d1b356b2c01670a67a078" +dependencies = [ + "cc", + "downcast-rs", + "rustix 1.1.5", + "scoped-tls", + "smallvec", + "wayland-sys", +] + +[[package]] +name = "wayland-client" +version = "0.31.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c36a0f861ad76d0901f2800b46321410d9f73f2ea88aac0650d86c32688073" +dependencies = [ + "bitflags 2.13.2", + "rustix 1.1.5", + "wayland-backend", + "wayland-scanner", +] + +[[package]] +name = "wayland-csd-frame" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "625c5029dbd43d25e6aa9615e88b829a5cad13b2819c4ae129fdbb7c31ab4c7e" +dependencies = [ + "bitflags 2.13.2", + "cursor-icon", + "wayland-backend", +] + +[[package]] +name = "wayland-cursor" +version = "0.31.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a52d18780be9b1314328a3de5f930b73d2200112e3849ca6cb11822793fb34d" +dependencies = [ + "rustix 1.1.5", + "wayland-client", + "xcursor", +] + +[[package]] +name = "wayland-protocols" +version = "0.32.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23d0c813de3daa2ed6520af85a3bd49b0e722a3078506899aa9686fea58dc4b6" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-plasma" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b6d8cf1eb2c1c31ed1f5643c88a6e53538129d4af80030c8cabd1f9fa884d91" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-protocols-wlr" +version = "0.3.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eb04e52f7836d7c7976c78ca0250d61e33873c34156a2a1fc9474828ec268234" +dependencies = [ + "bitflags 2.13.2", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-scanner", +] + +[[package]] +name = "wayland-scanner" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "338e30461b3a2b67d70eb30a6d89f8e0c93a833e07d2ae89085cd070c4a00ac0" +dependencies = [ + "proc-macro2", + "quick-xml", + "quote", +] + +[[package]] +name = "wayland-sys" +version = "0.31.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8eab23fefc9e41f8e841df4a9c707e8a8c4ed26e944ef69297184de2785e3be" +dependencies = [ + "dlib", + "log", + "once_cell", + "pkg-config", +] + +[[package]] +name = "web-sys" +version = "0.3.106" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "88261b9deccee56594c11a3460c462c41f58d148598fe70ad77070126a68aba4" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "web-time" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a6580f308b1fad9207618087a65c04e7a10bc77e02c8e84e9b00dd4b12fa0bb" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "webpki-roots" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5f280bbb2b287bc8e7de7e3852945a0ff50d1bbcb5ed42b6c7a568c546df171" +dependencies = [ + "rustls-pki-types", +] + +[[package]] +name = "weezl" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88" + +[[package]] +name = "wgpu" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "527ccdf43dd5b2e8676eed9984ce00e2bbb0a1b85b70c1969dcb6cd2eb55ab9e" +dependencies = [ + "arrayvec", + "bitflags 2.13.2", + "bytemuck", + "cfg-if", + "cfg_aliases", + "document-features", + "hashbrown 0.17.1", + "js-sys", + "log", + "portable-atomic", + "profiling", + "raw-window-handle", + "smallvec", + "static_assertions", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "wgpu-core", + "wgpu-hal", + "wgpu-types", +] + +[[package]] +name = "wgpu-core" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14c018fce9b6270aa203c2fdd56f3cce996713534bd757e4ea58c8560b121f14" +dependencies = [ + "arrayvec", + "bit-set", + "bit-vec", + "bitflags 2.13.2", + "bytemuck", + "cfg_aliases", + "document-features", + "hashbrown 0.17.1", + "indexmap", + "log", + "naga", + "naga-types", + "once_cell", + "parking_lot", + "portable-atomic", + "profiling", + "raw-window-handle", + "rustc-hash 1.1.0", + "smallvec", + "thiserror 2.0.21", + "wgpu-core-deps-windows-linux-android", + "wgpu-hal", + "wgpu-naga-bridge", + "wgpu-types", +] + +[[package]] +name = "wgpu-core-deps-windows-linux-android" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7586165fd5f6d881cb9ce4bb71f40d6caab2c0f1837e3fc1d9788a197fb6004f" +dependencies = [ + "wgpu-hal", +] + +[[package]] +name = "wgpu-hal" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6b7fb58561a792bc237628ba0792e332de418fefe145f13b5ed8201e6d52f58" +dependencies = [ + "bitflags 2.13.2", + "cfg-if", + "cfg_aliases", + "hashbrown 0.17.1", + "libloading", + "log", + "naga", + "naga-types", + "portable-atomic", + "portable-atomic-util", + "raw-window-handle", + "renderdoc-sys", + "static_assertions", + "thiserror 2.0.21", + "wgpu-naga-bridge", + "wgpu-types", +] + +[[package]] +name = "wgpu-naga-bridge" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2f62e73117bb7a62bfd9c5a5841438a823f6566c6442a808ee269d2d055c081" +dependencies = [ + "naga", + "wgpu-types", +] + +[[package]] +name = "wgpu-types" +version = "30.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99dad6f1fbdbbdb4c278a6508b059d44688f5cebddf78d005a46a31340269286" +dependencies = [ + "bitflags 2.13.2", + "bytemuck", + "js-sys", + "log", + "naga-types", + "raw-window-handle", + "static_assertions", + "web-sys", +] + +[[package]] +name = "winapi-util" +version = "0.1.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22" +dependencies = [ + "windows-sys 0.61.2", +] + +[[package]] +name = "windows-link" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "winit" +version = "0.30.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a6755fa58a9f8350bd1e472d4c3fcc25f824ec358933bba33306d0b63df5978d" +dependencies = [ + "ahash", + "android-activity", + "atomic-waker", + "bitflags 2.13.2", + "block2 0.5.1", + "bytemuck", + "calloop", + "cfg_aliases", + "concurrent-queue", + "core-foundation", + "core-graphics", + "cursor-icon", + "dpi", + "js-sys", + "libc", + "memmap2", + "ndk", + "objc2 0.5.3", + "objc2-app-kit 0.2.2", + "objc2-foundation 0.2.2", + "objc2-ui-kit 0.2.2", + "orbclient", + "percent-encoding", + "pin-project", + "raw-window-handle", + "redox_syscall 0.4.1", + "rustix 0.38.44", + "smithay-client-toolkit", + "smol_str", + "tracing", + "unicode-segmentation", + "wasm-bindgen", + "wasm-bindgen-futures", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-plasma", + "web-sys", + "web-time", + "windows-sys 0.52.0", + "x11-dl", + "x11rb", + "xkbcommon-dl", +] + +[[package]] +name = "winnow" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" +dependencies = [ + "memchr", +] + +[[package]] +name = "wit-bindgen" +version = "0.57.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e" + +[[package]] +name = "wl-clipboard-rs" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4d7888ccd4896447b2d14d3a9350a85df2aeb6f181e2e7a31349d104ac46cac1" +dependencies = [ + "libc", + "log", + "os_pipe", + "rustix 1.1.5", + "thiserror 2.0.21", + "tree_magic_mini", + "wayland-backend", + "wayland-client", + "wayland-protocols", + "wayland-protocols-wlr", +] + +[[package]] +name = "writeable" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3ad82d2a33cdc9674dc7465672f271e096168fcdbe0f799d9e6db8c5892679dc" + +[[package]] +name = "x11-dl" +version = "2.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38735924fedd5314a6e548792904ed8c6de6636285cb9fec04d5b1db85c1516f" +dependencies = [ + "libc", + "once_cell", + "pkg-config", +] + +[[package]] +name = "x11rb" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9993aa5be5a26815fe2c3eacfc1fde061fc1a1f094bf1ad2a18bf9c495dd7414" +dependencies = [ + "as-raw-xcb-connection", + "gethostname", + "libc", + "libloading", + "once_cell", + "rustix 1.1.5", + "x11rb-protocol", +] + +[[package]] +name = "x11rb-protocol" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea6fc2961e4ef194dcbfe56bb845534d0dc8098940c7e5c012a258bfec6701bd" + +[[package]] +name = "xcursor" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "163b33ed8786455e2fa5d72f554057ce3f3182425434f756cd39c99839d88e23" + +[[package]] +name = "xkbcommon-dl" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039de8032a9a8856a6be89cea3e5d12fdd82306ab7c94d74e6deab2460651c5" +dependencies = [ + "bitflags 2.13.2", + "dlib", + "log", + "once_cell", + "xkeysym", +] + +[[package]] +name = "xkeysym" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9cc00251562a284751c9973bace760d86c0276c471b4be569fe6b068ee97a56" + +[[package]] +name = "xml-rs" +version = "0.8.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e450f9b2ed1dff33c94c12589a87338689467b9c4f5d8a5710bd09a847d2c8a7" + +[[package]] +name = "xmlwriter" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9" + +[[package]] +name = "yoke" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "417ef3fcf6c300b7dbd25c85531a746931c02ad536f3cf4786ed1e88223340b3" +dependencies = [ + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec8ebde2db3681e8c9980cc27822030e68752690ddfa9473e739aeb4dbde6d71" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zerocopy" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5fe1f8f1b06191a00962174c61aa5005e0bb391a6d80d07e24d115c01a92ed8" +dependencies = [ + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.8.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "863ad3ac83293fb4d740aedbfdc9240dd8d1a50c1099acd76ce80ce7c7230c7f" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.119", +] + +[[package]] +name = "zerofrom" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ec05a11813ea801ff6d75110ad09cd0824ddba17dfe17128ea0d5f68e6c5272" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f75b4683f6c7f45248d4d64056a24298c6281e0993356d7d1b4a1a962ef10d4a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" + +[[package]] +name = "zerotrie" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ea269c3bd32f0a32c321907a2ae912ba6f4649bb0fc764a15627e99a7095a3f" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f58a2799cfe9a1670c7ea8edbd52ef8edb93cb37a7f83bf31ba9e35d9dae6a40" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3743ddbf47738d929cd1ae2e199d40d0162979dfe31aef8ae646d2bf00bf97a" +dependencies = [ + "proc-macro2", + "quote", + "syn 3.0.9", +] + +[[package]] +name = "zlib-rs" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112" + +[[package]] +name = "zmij" +version = "1.0.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b" + +[[package]] +name = "zune-core" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d56377fd46368984a170bc5aac5567e52ca5da874caa60bea39fcbca78fb658b" + +[[package]] +name = "zune-jpeg" +version = "0.5.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27bc9d5b815bc103f142aa054f561d9187d191692ec7c2d1e2b4737f8dbd7296" +dependencies = [ + "zune-core", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..0905b94 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,37 @@ +[package] +name = "audiphi" +version = "0.2.0" +edition = "2021" +description = "A Material 3 music downloader and quick player for any music service" +license = "MIT" + +[dependencies] +eframe = { version = "0.37", default-features = false, features = ["glow", "wayland", "x11", "default_fonts"] } +lofty = "0.25" +libmpv2 = "6" +image = { version = "0.25", default-features = false, features = ["jpeg", "png", "webp", "gif", "bmp"] } +ureq = { version = "3", features = ["json"] } +serde = { version = "1", features = ["derive"] } +serde_json = "1" +rustfft = "6" +resvg = { version = "0.45", default-features = false } +regex = "1" +urlencoding = "2" +base64 = "0.22" +dirs = "6" +rfd = { version = "0.17", default-features = false, features = ["xdg-portal", "pollster"] } +unicode-normalization = "0.1" + +[profile.release] +opt-level = 3 +lto = "thin" +codegen-units = 4 +strip = true + +[lib] +name = "audiphi" +path = "src/lib.rs" + +[[bin]] +name = "audiphi" +path = "src/main.rs" diff --git a/README.md b/README.md new file mode 100644 index 0000000..ae4585a --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Audiphi + +A Material 3 music downloader and quick player, written in Rust (egui). Paste a link from almost any +music service (or type a song name) and Audiphi downloads it in the format and quality you pick, with +proper tags, cover art and synced lyrics. This is the Rust port of the Python/PyQt6 version +(`audiphi-python`); settings carry over (`~/.config/audiphi/settings.json`). + +- **Any service.** YouTube Music, YouTube, SoundCloud, Bandcamp, Mixcloud, Audiomack and the other ~1,800 + sites yt-dlp supports download directly. Spotify, Apple Music, Deezer, Tidal, Amazon Music, Qobuz and + other music pages are read for the song details and matched on YouTube Music (by ISRC when available). +- **Whole collections:** songs, albums, playlists, and artists (top songs or whole discography). +- **Any format:** MP3 (CBR or V0/V2/V4), M4A/AAC, Opus, OGG Vorbis, FLAC, ALAC, WAV, or the original stream. +- **Tags** from Deezer, iTunes and MusicBrainz, per field; **lyrics** from LRCLIB (synced or plain); + cover art; file name templates like `{album_artist}/{album}/{track:02} - {title}`. +- **Quick player** (libmpv) with a spectrum ring around the cover, wavy seek bar and click-to-seek lyrics. +- **Colours** from Caelestia's scheme, your desktop accent, the album art, or a colour you pick. + +## Requirements + +`yt-dlp`, `ffmpeg`, `mpv` (libmpv) and, for YouTube, a JavaScript runtime (`deno` recommended). + +```bash +sudo pacman -S yt-dlp ffmpeg mpv deno # Arch +./install.sh # builds and installs to ~/.local +``` + +`audiphi 'https://…'` fetches the link straight away. + +## Spotify + +Without keys Spotify's public page lists the first 100 songs of a playlist. With free app keys +(, pasted in **Settings › Spotify**) Audiphi uses the Web API. +Since Spotify's February 2026 changes the API only shows playlists the app owner owns or collaborates +on, has no artist top songs, and needs the owner to have Premium — whenever the API can't answer (or the +keys are wrong) Audiphi falls back to the public page instead of failing. + +## Development + +`src/core` is the engine (resolvers, matcher, metadata, lyrics, tagger, downloader); `src/ui` the widgets and +pages; `examples/probe.rs` exercises the engine from the command line +(`cargo run --example probe -- resolve ` / `download ` / `meta <artist>`). +Setting `AUDIPHI_SHOTS=/dir` (and `AUDIPHI_SHOT_URL=<link>`) makes the app walk its tabs and save screenshots. + +Built on yt-dlp, ffmpeg, mpv, lofty and egui. Tags from Deezer, iTunes and MusicBrainz; lyrics from LRCLIB. +Bundled fonts: Material Symbols (Apache 2.0) and Rubik (SIL OFL 1.1), licenses in `assets/fonts/`. diff --git a/assets/audiphi.svg b/assets/audiphi.svg new file mode 100644 index 0000000..6ce6dfe --- /dev/null +++ b/assets/audiphi.svg @@ -0,0 +1,20 @@ +<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256"> + <defs> + <linearGradient id="bg" x1="0" y1="0" x2="1" y2="1"> + <stop offset="0" stop-color="#cdbdff"/> + <stop offset="1" stop-color="#6b52c8"/> + </linearGradient> + <linearGradient id="shine" x1="0" y1="0" x2="0" y2="1"> + <stop offset="0" stop-color="#ffffff" stop-opacity="0.35"/> + <stop offset="1" stop-color="#ffffff" stop-opacity="0"/> + </linearGradient> + </defs> + <!-- 9-lobed "cookie" shape from Material 3 Expressive --> + <path fill="url(#bg)" d="M128 10c14 0 22 12 34 15s25-3 35 5 8 21 14 32 19 15 22 28-7 22-7 38 10 25 7 38-16 17-22 28-4 24-14 32-23 2-35 5-20 15-34 15-22-12-34-15-25 3-35-5-8-21-14-32-19-15-22-28 7-22 7-38-10-25-7-38 16-17 22-28 4-24 14-32 23-2 35-5 20-15 34-15z"/> + <path fill="url(#shine)" d="M128 10c14 0 22 12 34 15s25-3 35 5 8 21 14 32 19 15 22 28c-30-18-66-28-105-28S58 72 28 90c3-13 16-17 22-28s4-24 14-32 23-2 35-5 20-15 29-15z"/> + <!-- music note --> + <path fill="#1d1236" d="M150 58v86.5a26 26 0 1 1-14-23V82l-34 8v66.5a26 26 0 1 1-14-23V78z" transform="translate(-6 -2)"/> + <!-- download arrow badge --> + <circle cx="178" cy="178" r="40" fill="#1d1236"/> + <path fill="#e9ddff" d="M170 156h16v24h12l-20 22-20-22h12z"/> +</svg> diff --git a/assets/fonts/LICENSE-MaterialSymbols.txt b/assets/fonts/LICENSE-MaterialSymbols.txt new file mode 100644 index 0000000..7a4a3ea --- /dev/null +++ b/assets/fonts/LICENSE-MaterialSymbols.txt @@ -0,0 +1,202 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/assets/fonts/LICENSE-Rubik-OFL.txt b/assets/fonts/LICENSE-Rubik-OFL.txt new file mode 100644 index 0000000..03af63b --- /dev/null +++ b/assets/fonts/LICENSE-Rubik-OFL.txt @@ -0,0 +1,93 @@ +Copyright 2015 The Rubik Project Authors (https://github.com/googlefonts/rubik) + +This Font Software is licensed under the SIL Open Font License, Version 1.1. +This license is copied below, and is also available with a FAQ at: +https://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/assets/fonts/Rubik.ttf b/assets/fonts/Rubik.ttf new file mode 100644 index 0000000..a59aeb6 Binary files /dev/null and b/assets/fonts/Rubik.ttf differ diff --git a/examples/probe.rs b/examples/probe.rs new file mode 100644 index 0000000..a7df966 --- /dev/null +++ b/examples/probe.rs @@ -0,0 +1,53 @@ +//! Command-line probe of the core: `cargo run --example probe -- resolve <url|text> [top|discography]` +//! or `... download <url|text>` to run the whole pipeline into /tmp. +use audiphi::core::{downloader::*, models::*, resolvers, settings::Settings}; +use std::sync::{mpsc, Arc}; + +fn main() { + let args: Vec<String> = std::env::args().skip(1).collect(); + let mut snap = Settings::load().snapshot(); + if let Ok(id) = std::env::var("SPOT_ID") { snap["spotify"]["client_id"] = id.into(); snap["spotify"]["client_secret"] = std::env::var("SPOT_SECRET").unwrap_or_default().into(); } + let log = |k: &str, t: &str| eprintln!("[{k}] {t}"); + match args[0].as_str() { + "resolve" | "download" => { + let mode = args.get(2).map(|s| s.as_str()).unwrap_or("top"); + let r = match resolvers::resolve(&args[1], &snap, &log, mode) { + Ok(r) => r, + Err(e) => { println!("ERROR: {e}"); std::process::exit(1) } + }; + println!("{} | {} | {} | {} tracks | service {} | note: {}", r.kind, r.title, r.subtitle, r.tracks.len(), r.service, r.note); + for t in r.tracks.iter().take(6) { + println!(" - {} – {} [{}] {:?}s isrc={} dl={} cover={}", t.artist(), t.title, t.album, t.duration, t.isrc, !t.download_url.is_empty(), !t.cover_url.is_empty()); + } + if args[0] == "download" { + let (tx, rx) = mpsc::channel(); + let mut m = Manager::new(2, tx, Arc::new(|| {})); + let o = DownloadOptions { output_dir: "/tmp/audiphi-test".into(), template: "{artist} - {title}".into(), format: args.get(3).cloned().unwrap_or("mp3".into()), bitrate: "192".into(), sample_rate: "source".into(), bit_depth: "16".into(), lyrics: "synced".into(), save_lrc: true, collection_folder: false }; + let n = r.tracks.len().min(1); + m.enqueue(&r.tracks[..n], &o, &snap); + loop { + while let Ok(l) = rx.try_recv() { if l.kind != "progress" { eprintln!("[{}] {}", l.kind, l.text); } } + if m.counts().0 == 0 { break; } + std::thread::sleep(std::time::Duration::from_millis(200)); + } + while let Ok(l) = rx.try_recv() { eprintln!("[{}] {}", l.kind, l.text); } + for h in &m.jobs { let j = h.job.lock().unwrap(); println!("{:?} {} {}", j.state, j.status, j.output_path); } + } + } + "meta" => { + let mut t = Track::new(); + t.title = args[1].clone(); + t.artists = vec![args[2].clone()]; + let r = audiphi::core::metadata::search_all(&t, &["deezer".into(), "itunes".into(), "musicbrainz".into()], 1200, &log); + for (k, v) in r { + println!("{k}: {} candidates", v.len()); + for c in v.iter().take(2) { + println!(" {:.2} {} – {} [{}] {} #{:?}/{:?} {} cover={}", c.score, c.artist(), c.title, c.album, c.year, c.track_number, c.track_total, c.genre, !c.cover_url.is_empty()); + } + } + let l = audiphi::core::lyrics::fetch(&args[1], &args[2], "", Some(213.0)); + println!("lyrics: {:?}", l.map(|l| (l.plain.len(), l.synced.len(), l.instrumental))); + } + _ => {} + } +} diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..af11ea0 --- /dev/null +++ b/install.sh @@ -0,0 +1,10 @@ +#!/bin/sh +# Builds Audiphi and installs it for the current user (~/.local), with an app-menu entry. +set -e +cd "$(dirname "$0")" +PREFIX="${PREFIX:-$HOME/.local}" +cargo build --release +install -Dm755 target/release/audiphi "$PREFIX/bin/audiphi" +install -Dm644 assets/audiphi.svg "$PREFIX/share/icons/hicolor/scalable/apps/audiphi.svg" +install -Dm644 packaging/audiphi.desktop "$PREFIX/share/applications/audiphi.desktop" +echo "Installed to $PREFIX/bin/audiphi (needs yt-dlp, ffmpeg, mpv's libmpv and, for YouTube, deno)." diff --git a/packaging/audiphi.desktop b/packaging/audiphi.desktop new file mode 100644 index 0000000..22a453b --- /dev/null +++ b/packaging/audiphi.desktop @@ -0,0 +1,9 @@ +[Desktop Entry] +Type=Application +Name=Audiphi +Comment=Music downloader and quick player for any music service +Exec=audiphi %U +Icon=audiphi +Categories=AudioVideo;Audio;Player;Network; +Terminal=false +StartupWMClass=audiphi diff --git a/src/app.rs b/src/app.rs new file mode 100644 index 0000000..7314859 --- /dev/null +++ b/src/app.rs @@ -0,0 +1,692 @@ +//! The application: state, background events, and the window chrome (tabs, banners, snackbar). + +use crate::core::downloader::{LogLine, Manager}; +use crate::core::library::{self, LibraryItem}; +use crate::core::lyrics::Lyrics; +use crate::core::metadata::Candidate; +use crate::core::models::ResolveResult; +use crate::core::settings::Settings; +use crate::core::{paths, ytdlp}; +use crate::player::Player; +use crate::ui::controls::*; +use crate::ui::gfx::*; +use crate::ui::icons::Icons; +use crate::ui::images::Images; +use crate::ui::pages::{download, editor, player_page, queue, settings_page}; +use crate::ui::theme::{with_alpha, Theme}; +use crate::ui::widgets::*; +use eframe::egui::{self, Align2, Color32, Pos2, Rect, RichText, Sense, Vec2}; +use std::collections::BTreeMap; +use std::sync::mpsc::{channel, Receiver, Sender}; +use std::sync::Arc; +use std::time::{Duration, Instant}; + +pub const TAB_DOWNLOAD: usize = 0; +pub const TAB_QUEUE: usize = 1; +pub const TAB_PLAYER: usize = 2; +pub const TAB_SETTINGS: usize = 3; + +pub enum Ev { + Resolved(u64, Result<ResolveResult, String>), + FetchInfo(u64, String), + Library(Vec<LibraryItem>), + LyricsFound(String, Result<Option<String>, String>), + Candidates(Result<BTreeMap<String, Vec<Candidate>>, String>), + EditorLyrics(Result<Lyrics, String>), + EditorCover(Option<Vec<u8>>), + SpotifyTest(String), + YtdlpUpdate(String), + Toast(String), + Log(u64, String, String), +} + +pub struct LogEntry { + pub job: u64, + pub kind: String, + pub text: String, +} + +pub struct Toast { + pub text: String, + pub action: Option<(String, usize)>, + pub at: Instant, +} + +pub struct Confirm { + pub title: String, + pub text: String, + pub ok: String, +} + +pub struct App { + pub ctx: egui::Context, + pub g: Gfx, + pub settings: Settings, + pub images: Images, + pub tab: usize, + pub tx: Sender<Ev>, + rx: Receiver<Ev>, + pub manager: Manager, + log_rx: Receiver<LogLine>, + pub logs: Vec<LogEntry>, + pub dl: download::State, + pub q: queue::State, + pub pl: player_page::State, + pub st: settings_page::State, + pub player: Player, + pub editor: Option<editor::Editor>, + pub confirm: Option<Confirm>, + pub toast: Option<Toast>, + cover_seed: Option<Color32>, + seed_key: String, + theme_rev: u64, + sys_mtime: Option<std::time::SystemTime>, + last_check: Instant, + last_frame: Instant, + pub quit_asked: bool, + pub quitting: bool, + pub ffmpeg_ok: bool, + pub ytdlp_ok: bool, + shots: Option<Shots>, +} + +pub fn apply_visuals(ctx: &egui::Context, t: &Theme) { + let mut v = if t.dark { egui::Visuals::dark() } else { egui::Visuals::light() }; + v.panel_fill = t.surface; + v.window_fill = t.surface_container; + v.extreme_bg_color = t.surface_container_highest; + v.faint_bg_color = t.surface_container_low; + v.code_bg_color = t.surface_container_high; + v.override_text_color = Some(t.on_surface); + v.hyperlink_color = t.primary; + v.selection.bg_fill = t.primary; + v.selection.stroke = egui::Stroke::new(1.0, t.on_primary); + v.window_stroke = egui::Stroke::new(1.0, with_alpha(t.outline_variant, 0.6)); + v.window_corner_radius = cr(24.0); + v.menu_corner_radius = cr(14.0); + v.popup_shadow = egui::Shadow { offset: [0, 6], blur: 24, spread: 0, color: Color32::from_black_alpha(90) }; + v.window_shadow = egui::Shadow { offset: [0, 10], blur: 40, spread: 0, color: Color32::from_black_alpha(110) }; + let w = &mut v.widgets; + for (wd, bg) in [(&mut w.noninteractive, t.surface), (&mut w.inactive, t.surface_container_high), (&mut w.hovered, t.surface_container_highest), (&mut w.active, t.surface_container_highest), (&mut w.open, t.surface_container_highest)] { + wd.bg_fill = bg; + wd.weak_bg_fill = bg; + wd.fg_stroke.color = t.on_surface; + wd.corner_radius = cr(10.0); + wd.bg_stroke = egui::Stroke::NONE; + } + w.noninteractive.bg_stroke = egui::Stroke::new(1.0, t.outline_variant); + ctx.set_visuals(v); + ctx.global_style_mut(|s| { + s.spacing.item_spacing = egui::vec2(8.0, 6.0); + s.spacing.button_padding = egui::vec2(14.0, 7.0); + s.spacing.scroll = egui::style::ScrollStyle { floating: true, bar_width: 8.0, floating_width: 4.0, floating_allocated_width: 0.0, foreground_color: false, dormant_background_opacity: 0.0, active_background_opacity: 0.2, interact_background_opacity: 0.35, dormant_handle_opacity: 0.35, active_handle_opacity: 0.55, interact_handle_opacity: 0.8, ..egui::style::ScrollStyle::floating() }; + s.interaction.tooltip_delay = 0.4; + }); +} + +impl App { + pub fn new(cc: &eframe::CreationContext<'_>, url: Option<String>) -> App { + let ctx = cc.egui_ctx.clone(); + ctx.set_missing_glyph_policy(eframe::epaint::text::MissingGlyphPolicy::Tofu); + crate::ui::fonts::install(&ctx); + let settings = Settings::load(); + let snap = settings.snapshot(); + let theme = Theme::build(&snap, None); + apply_visuals(&ctx, &theme); + let g = Gfx { theme, icons: Icons::default(), ctx: ctx.clone() }; + let (tx, rx) = channel(); + let (log_tx, log_rx) = channel(); + let repaint_ctx = ctx.clone(); + let manager = Manager::new(settings.get_i64("download.concurrent").max(1) as usize, log_tx, Arc::new(move || repaint_ctx.request_repaint())); + let player = Player::new(&ctx, &settings); + let mut app = App { + images: Images::new(&ctx), + tab: (settings.get_i64("ui.last_tab").clamp(0, 3)) as usize, + dl: download::State::new(&settings), + q: queue::State::default(), + pl: player_page::State::default(), + st: settings_page::State::default(), + player, + editor: None, + confirm: None, + toast: None, + cover_seed: None, + seed_key: String::new(), + theme_rev: settings.revision, + sys_mtime: crate::ui::theme::system_mtime(), + last_check: Instant::now(), + last_frame: Instant::now(), + quit_asked: false, + quitting: false, + ffmpeg_ok: paths::find_ffmpeg(&settings.get_str("download.ffmpeg_path")).is_some(), + ytdlp_ok: paths::find_ytdlp().is_some(), + shots: std::env::var_os("AUDIPHI_SHOTS").map(|d| Shots { dir: d.into(), step: 0, started: Instant::now(), wait_until: 0.0, pending: None }), + logs: vec![], + manager, + log_rx, + tx, + rx, + settings, + g, + ctx, + }; + app.rescan_library(); + if let Some(u) = url { + app.open_url(&u); + } + app + } + + // ---- helpers used by the pages -------------------------------------------------- + + pub fn toast(&mut self, text: impl Into<String>) { + self.toast = Some(Toast { text: text.into(), action: None, at: Instant::now() }); + } + + pub fn toast_action(&mut self, text: impl Into<String>, label: &str, tab: usize) { + self.toast = Some(Toast { text: text.into(), action: Some((label.into(), tab)), at: Instant::now() }); + } + + pub fn open_url(&mut self, url: &str) { + self.tab = TAB_DOWNLOAD; + self.dl.query = url.to_string(); + download::fetch(self, "top"); + } + + pub fn rescan_library(&mut self) { + let dir = self.settings.library_dir(); + let tx = self.tx.clone(); + let ctx = self.ctx.clone(); + self.pl.scanning = true; + std::thread::spawn(move || { + let _ = tx.send(Ev::Library(library::scan(&dir))); + ctx.request_repaint(); + }); + } + + pub fn log(&mut self, job: u64, kind: &str, text: &str) { + self.logs.push(LogEntry { job, kind: kind.into(), text: text.into() }); + if self.logs.len() > 6000 { + self.logs.drain(..1000); + } + } + + pub fn play_file(&mut self, path: &str) { + self.tab = TAB_PLAYER; + let items = self.pl.visible_items(); + self.player.set_queue(&items); + self.player.play_path(path); + } + + pub fn edit_file(&mut self, path: &str) { + if !std::path::Path::new(path).is_file() { + self.toast("That file isn't there anymore"); + return; + } + self.editor = Some(editor::Editor::for_file(path)); + } + + /// Run `work` on a thread and deliver its result as an event. + pub fn spawn<T: Send + 'static>(&self, work: impl FnOnce() -> T + Send + 'static, wrap: impl FnOnce(T) -> Ev + Send + 'static) { + let (tx, ctx) = (self.tx.clone(), self.ctx.clone()); + std::thread::spawn(move || { + let v = work(); + let _ = tx.send(wrap(v)); + ctx.request_repaint(); + }); + } + + // ---- events ---------------------------------------------------------------------- + + fn pump(&mut self) { + self.images.pump(); + while let Ok(l) = self.log_rx.try_recv() { + self.log(l.job, &l.kind, &l.text); + } + while let Ok(ev) = self.rx.try_recv() { + match ev { + Ev::Resolved(token, r) => download::resolved(self, token, r), + Ev::FetchInfo(token, text) => { + if token == self.dl.token { + self.dl.detail = text; + } + } + Ev::Library(items) => { + self.pl.scanning = false; + self.pl.set_items(items); + let v = self.pl.visible_items(); + self.player.set_queue(&v); + } + Ev::LyricsFound(path, r) => player_page::lyrics_found(self, &path, r), + Ev::Candidates(r) => { + if let Some(e) = &mut self.editor { + e.lookup_busy = false; + match r { + Ok(c) => e.candidates = Some(c), + Err(m) => e.error = m, + } + } + } + Ev::EditorLyrics(r) => { + if let Some(e) = &mut self.editor { + e.lyrics_busy = false; + match r { + Ok(l) if l.instrumental => e.lyrics_state = "LRCLIB lists this as instrumental".into(), + Ok(l) if l.found() => { + e.lyrics = if l.synced.is_empty() { l.plain } else { l.synced }; + e.lyrics_touched = true; + } + Ok(_) => e.lyrics_state = "Nothing on LRCLIB for this song".into(), + Err(m) => e.lyrics_state = format!("Lookup failed: {m}"), + } + } + } + Ev::EditorCover(bytes) => { + if let Some(e) = &mut self.editor { + if let Some(b) = bytes { + e.set_cover(&mut self.images, b, true); + } + } + } + Ev::SpotifyTest(m) => { + self.st.spotify_status = m; + self.st.spotify_busy = false; + } + Ev::YtdlpUpdate(m) => { + self.st.ytdlp_note = m; + self.st.ytdlp_busy = false; + self.ytdlp_ok = paths::find_ytdlp().is_some(); + } + Ev::Toast(t) => self.toast(t), + Ev::Log(job, kind, text) => self.log(job, &kind, &text), + } + } + } + + fn check_theme(&mut self) { + let mut rebuild = false; + if self.theme_rev != self.settings.revision { + self.theme_rev = self.settings.revision; + rebuild = true; + } + if self.last_check.elapsed() > Duration::from_secs(2) { + self.last_check = Instant::now(); + let m = crate::ui::theme::system_mtime(); + if m != self.sys_mtime { + self.sys_mtime = m; + rebuild = true; + } + } + // follow the album art of what's playing + let key = self.player.cover_key.clone(); + if key != self.seed_key { + if let Some(c) = self.images.accent(&key) { + self.seed_key = key; + self.cover_seed = Some(c); + rebuild = true; + } else if self.images.get(&key).is_some() { + self.seed_key = key; + } + } + if rebuild { + let t = Theme::build(&self.settings.snapshot(), self.cover_seed); + if !t.same_colors(&self.g.theme) || t.source != self.g.theme.source { + apply_visuals(&self.ctx, &t); + self.g.theme = t; + } + } + } + + fn shortcuts(&mut self, ctx: &egui::Context) { + let typing = ctx.egui_wants_keyboard_input(); + let (ctrl, keys, pasted): (bool, Vec<egui::Key>, Option<String>) = ctx.input(|i| { + let keys = i.events.iter().filter_map(|e| if let egui::Event::Key { key, pressed: true, modifiers, .. } = e { if modifiers.command || !modifiers.any() { Some(*key) } else { None } } else { None }).collect(); + let pasted = i.events.iter().find_map(|e| if let egui::Event::Paste(s) = e { Some(s.clone()) } else { None }); + (i.modifiers.command, keys, pasted) + }); + for k in keys { + if ctrl { + match k { + egui::Key::Num1 => self.tab = 0, + egui::Key::Num2 => self.tab = 1, + egui::Key::Num3 => self.tab = 2, + egui::Key::Num4 => self.tab = 3, + egui::Key::L | egui::Key::F => { + self.tab = TAB_DOWNLOAD; + self.dl.focus_query = true; + } + egui::Key::Backtick => { + let v = !self.settings.get_bool("ui.show_terminal"); + self.settings.set_bool("ui.show_terminal", v); + } + _ => {} + } + } else if k == egui::Key::Space && !typing && !self.player.path.is_empty() { + self.player.toggle(); + } + } + if let (Some(text), false) = (pasted, typing) { + let t = text.trim(); + if !t.is_empty() { + self.tab = TAB_DOWNLOAD; + self.dl.query = t.to_string(); + download::fetch(self, "top"); + } + } + } + + fn handle_drops(&mut self, ctx: &egui::Context) { + let dropped = ctx.input(|i| i.raw.dropped_files.clone()); + for f in dropped { + let p = f.path(); + if paths::is_audio(p) { + self.play_file(&p.to_string_lossy()); + return; + } + } + } +} + +impl eframe::App for App { + fn logic(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { + let now = Instant::now(); + let dt = now.duration_since(self.last_frame).as_secs_f32().clamp(1.0 / 240.0, 0.1); + self.last_frame = now; + self.pump(); + self.drive_shots(ctx); + self.handle_drops(ctx); + self.shortcuts(ctx); + self.check_theme(); + self.settings.save_if_due(); + let moving = self.player.tick(); + if self.settings.get_bool("player.visualizer") && self.tab == TAB_PLAYER { + let n = self.settings.get_i64("player.visualizer_bars").clamp(16, 128) as usize; + let (pos, active) = (self.player.pos, self.player.playing); + self.player.spectrum.update(pos, n, active, dt); + } + if self.player.track_changed { + self.player.track_changed = false; + let key = self.player.cover_key.clone(); + self.images.forget(&key); + self.images.request(&key, || crate::ui::images::Source::File(self.player.path.clone()), 900); + player_page::on_track_changed(self); + } + if let Some((done, failed)) = self.manager.poll_all_done() { + let text = format!("Downloads finished: {done} saved{}", if failed > 0 { format!(", {failed} failed") } else { String::new() }); + self.toast_action(text.clone(), "Show", TAB_QUEUE); + if !ctx.input(|i| i.focused) { + let _ = std::process::Command::new("notify-send").args(["-a", crate::APP_NAME, &format!("{}", crate::APP_NAME), &text]).spawn(); + } + self.rescan_library(); + } + if let Some(t) = &self.toast { + if t.at.elapsed() > Duration::from_secs(6) { + self.toast = None; + } + } + if ctx.input(|i| i.viewport().close_requested()) && !self.quitting { + let active = self.manager.counts().0; + if active > 0 && !self.quit_asked { + ctx.send_viewport_cmd(egui::ViewportCommand::CancelClose); + self.confirm = Some(Confirm { title: "Quit while downloading?".into(), text: format!("{active} download{} still running and will stop.", if active == 1 { " is" } else { "s are" }), ok: "Quit".into() }); + } else { + self.quitting = true; + self.manager.cancel_all(); + self.settings.set("ui.last_tab", serde_json::json!(self.tab)); + self.settings.save(); + self.player.stop(); + } + } + if moving { + ctx.request_repaint_after(Duration::from_millis(16)); + } + } + + fn ui(&mut self, ui: &mut egui::Ui, _frame: &mut eframe::Frame) { + let ctx = ui.ctx().clone(); + let t = self.g.theme.clone(); + + egui::Panel::top("tabs").frame(egui::Frame::NONE.fill(t.surface).inner_margin(egui::Margin { left: 16, right: 16, top: 10, bottom: 4 })).show_separator_line(false).show(ui, |ui| { + self.draw_tabs(ui); + self.draw_banners(ui); + }); + egui::CentralPanel::default().frame(egui::Frame::NONE.fill(t.surface)).show(ui, |ui| { + match self.tab { + TAB_DOWNLOAD => download::draw(self, ui), + TAB_QUEUE => queue::draw(self, ui), + TAB_PLAYER => player_page::draw(self, ui), + _ => settings_page::draw(self, ui), + } + }); + self.draw_toast(&ctx); + self.draw_confirm(&ctx); + editor::show(self, &ctx); + if self.images.loading() { + ctx.request_repaint_after(Duration::from_millis(100)); + } + } + + fn on_exit(&mut self, _gl: Option<&eframe::glow::Context>) { + self.manager.cancel_all(); + self.settings.set("ui.last_tab", serde_json::json!(self.tab)); + self.settings.save(); + self.player.stop(); + } +} + +impl App { + fn draw_tabs(&mut self, ui: &mut egui::Ui) { + let labels = [("download", "Download"), ("downloading", "Downloads"), ("play_circle", "Player"), ("settings", "Settings")]; + let active = self.manager.counts().0; + ui.horizontal(|ui| { + let (rect, _) = ui.allocate_exact_size(Vec2::new(150.0, 40.0), Sense::hover()); + let t = self.g.theme.clone(); + self.g.icon_at(ui.painter(), Pos2::new(rect.left() + 16.0, rect.center().y), 26.0, "library_music_fill", t.primary); + ui.painter().text(Pos2::new(rect.left() + 38.0, rect.center().y), Align2::LEFT_CENTER, crate::APP_NAME, disp_semi(21.0), t.on_surface); + let total: f32 = 4.0 * 128.0; + let left = ((ui.available_width() - total) / 2.0).max(0.0); + ui.add_space(left); + for (i, (icon, label)) in labels.iter().enumerate() { + let sel = self.tab == i; + let (rect, resp) = ui.allocate_exact_size(Vec2::new(122.0, 40.0), Sense::click()); + let t = &self.g.theme; + let hover = ui.ctx().animate_bool_with_time(resp.id.with("h"), resp.hovered(), 0.12); + let anim = ui.ctx().animate_bool_with_time(resp.id.with("s"), sel, 0.18); + let bg = mix_c(with_alpha(t.on_surface, hover * 0.06), t.secondary_container, anim); + ui.painter().rect_filled(rect, cr(20.0), bg); + let fg = mix_c(t.on_surface_variant, t.on_secondary_container, anim); + let fnt = if sel { font_semi(14.5) } else { font(14.5) }; + let tw = ui.painter().layout_no_wrap(label.to_string(), fnt.clone(), Color32::WHITE).size().x; + let x0 = rect.center().x - (tw + 28.0) / 2.0; + self.g.icon(ui.painter(), Rect::from_center_size(Pos2::new(x0 + 10.0, rect.center().y), Vec2::splat(20.0)), if sel && i == 2 { "play_circle_fill" } else { icon }, fg); + ui.painter().text(Pos2::new(x0 + 28.0, rect.center().y), Align2::LEFT_CENTER, label, fnt, fg); + if i == TAB_QUEUE && active > 0 { + let c = Pos2::new(rect.right() - 12.0, rect.top() + 9.0); + ui.painter().circle_filled(c, 9.0, self.g.theme.primary); + ui.painter().text(c, Align2::CENTER_CENTER, active.min(99).to_string(), font_semi(11.0), self.g.theme.on_primary); + } + if resp.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + if resp.clicked() { + self.tab = i; + } + } + }); + } + + fn draw_banners(&mut self, ui: &mut egui::Ui) { + let mut msgs = vec![]; + if !self.ffmpeg_ok { + msgs.push("ffmpeg wasn't found. Downloads need it to convert audio — install it (e.g. “sudo pacman -S ffmpeg”) or set its location in Settings."); + } + if !self.ytdlp_ok { + msgs.push("yt-dlp wasn't found. Install it (e.g. “sudo pacman -S yt-dlp”) so Audiphi can download."); + } + for m in msgs { + let t = self.g.theme.clone(); + ui.add_space(6.0); + let mut go = false; + egui::Frame::NONE.fill(t.error_container).corner_radius(cr(16.0)).inner_margin(egui::Margin::symmetric(16, 10)).show(ui, |ui| { + ui.horizontal(|ui| { + let (r, _) = ui.allocate_exact_size(Vec2::splat(22.0), Sense::hover()); + self.g.icon(ui.painter(), r, "warning", t.on_error_container); + ui.label(RichText::new(m).color(t.on_error_container)); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + go = button_h(ui, &mut self.g, None, "Settings", Kind::Text, 32.0).clicked(); + }); + }); + }); + if go { + self.tab = TAB_SETTINGS; + } + } + } + + fn draw_toast(&mut self, ctx: &egui::Context) { + let Some(t) = self.toast.as_ref().map(|t| (t.text.clone(), t.action.clone())) else { return }; + let th = self.g.theme.clone(); + let mut act = None; + let mut close = false; + egui::Area::new(egui::Id::new("toast")).order(egui::Order::Foreground).anchor(Align2::CENTER_BOTTOM, Vec2::new(0.0, -86.0)).show(ctx, |ui| { + egui::Frame::NONE.fill(th.inverse_surface).corner_radius(cr(12.0)).inner_margin(egui::Margin::symmetric(18, 8)).shadow(egui::Shadow { offset: [0, 4], blur: 14, spread: 0, color: Color32::from_black_alpha(80) }).show(ui, |ui| { + ui.horizontal(|ui| { + ui.label(RichText::new(&t.0).color(th.inverse_on_surface).size(14.0)); + if let Some((label, tab)) = &t.1 { + if ui.add(egui::Button::new(RichText::new(label).color(th.primary_container).strong()).frame(false)).clicked() { + act = Some(*tab); + } + } + if ui.add(egui::Button::new(RichText::new("✕").color(th.inverse_on_surface)).frame(false)).clicked() { + close = true; + } + }); + }); + }); + if let Some(tab) = act { + self.tab = tab; + self.toast = None; + } + if close { + self.toast = None; + } + ctx.request_repaint_after(Duration::from_millis(500)); + } + + fn draw_confirm(&mut self, ctx: &egui::Context) { + let Some(c) = self.confirm.as_ref().map(|c| (c.title.clone(), c.text.clone(), c.ok.clone())) else { return }; + let (mut ok, mut cancel) = (false, ctx.input(|i| i.key_pressed(egui::Key::Escape))); + let fr = egui::Frame::NONE.fill(self.g.theme.surface_container_high).corner_radius(cr(28.0)).inner_margin(egui::Margin::same(24)); + egui::Modal::new(egui::Id::new("confirm")).frame(fr).backdrop_color(Color32::from_black_alpha(130)).show(ctx, |ui| { + ui.set_width(380.0); + ui.label(RichText::new(&c.0).font(disp_semi(20.0)).color(self.g.theme.on_surface)); + ui.add_space(6.0); + ui.label(RichText::new(&c.1).color(self.g.theme.on_surface_variant)); + ui.add_space(14.0); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + ok = button(ui, &mut self.g, None, &c.2, Kind::Danger).clicked(); + cancel |= button(ui, &mut self.g, None, "Cancel", Kind::Text).clicked(); + }); + }); + if ok { + self.confirm = None; + self.quit_asked = true; + self.ctx.send_viewport_cmd(egui::ViewportCommand::Close); + } else if cancel { + self.confirm = None; + } + } + + pub fn check_ytdlp_now(&mut self) -> Option<String> { + ytdlp::version() + } +} + + +/// Hidden test harness: `AUDIPHI_SHOTS=/dir AUDIPHI_SHOT_URL=<link>` walks the tabs, saving screenshots. +struct Shots { + dir: std::path::PathBuf, + step: usize, + started: Instant, + wait_until: f64, + pending: Option<Arc<std::sync::atomic::AtomicBool>>, +} + +impl App { + fn drive_shots(&mut self, ctx: &egui::Context) { + let Some(mut sh) = self.shots.take() else { return }; + let now = sh.started.elapsed().as_secs_f64(); + if let Some(flag) = &sh.pending { + if flag.load(std::sync::atomic::Ordering::Relaxed) { + sh.pending = None; + } + } + if sh.pending.is_none() && now >= sh.wait_until { + let shoot = |sh: &mut Shots, name: &str| { + let flag = Arc::new(std::sync::atomic::AtomicBool::new(false)); + sh.pending = Some(flag.clone()); + let path = sh.dir.join(format!("{name}.png")); + let _ = std::fs::create_dir_all(&sh.dir); + let name = name.to_string(); + ctx.send_viewport_cmd(egui::ViewportCommand::Screenshot(egui::ScreenshotCallback::new(move |img| { + let mut out = image::RgbaImage::new(img.width() as u32, img.height() as u32); + for (i, p) in img.pixels.iter().enumerate() { + out.put_pixel((i % img.width()) as u32, (i / img.width()) as u32, image::Rgba([p.r(), p.g(), p.b(), 255])); + } + let _ = out.save(&path); + eprintln!("shot {name}"); + flag.store(true, std::sync::atomic::Ordering::Relaxed); + }))); + }; + match sh.step { + 0 => { if now > 2.0 { shoot(&mut sh, "1-download-empty"); sh.step = 1; } } + 1 => { + if let Ok(u) = std::env::var("AUDIPHI_SHOT_URL") { + self.dl.query = u; + download::fetch(self, "top"); + } + sh.step = 2; + sh.wait_until = now + 1.0; + } + 2 => { + if self.dl.result.is_some() || self.dl.error.is_some() || now > 60.0 { + sh.wait_until = now + 1.5; + sh.step = 3; + } + } + 3 => { shoot(&mut sh, "2-download-result"); sh.step = 4; } + 4 => { + if self.dl.result.is_some() { + self.editor = Some(editor::Editor::for_track(self.dl.result.as_ref().unwrap(), None)); + sh.wait_until = now + 1.5; + } + sh.step = 5; + } + 5 => { shoot(&mut sh, "3-editor"); sh.step = 6; } + 6 => { + self.editor = None; + download::start_download_pub(self); + self.tab = TAB_QUEUE; + self.settings.set_bool("ui.show_terminal", true); + sh.wait_until = now + 25.0; + sh.step = 7; + } + 7 => { shoot(&mut sh, "4-queue"); sh.step = 8; } + 8 => { + self.tab = TAB_PLAYER; + if let Some(p) = self.pl.visible_items().first().map(|i| i.path.clone()) { + self.play_file(&p); + } + sh.wait_until = now + 4.0; + sh.step = 9; + } + 9 => { shoot(&mut sh, "5-player"); sh.step = 10; } + 10 => { self.tab = TAB_SETTINGS; sh.wait_until = now + 1.0; sh.step = 11; } + 11 => { shoot(&mut sh, "6-settings"); sh.step = 12; } + _ => { if sh.pending.is_none() { ctx.send_viewport_cmd(egui::ViewportCommand::Close); self.quit_asked = true; } } + } + } + self.shots = Some(sh); + ctx.request_repaint_after(Duration::from_millis(100)); + } +} diff --git a/src/core/covers.rs b/src/core/covers.rs new file mode 100644 index 0000000..7183f46 --- /dev/null +++ b/src/core/covers.rs @@ -0,0 +1,65 @@ +//! Cover art: download, crop video thumbnails to a square, resize, re-encode as JPEG. + +use super::http; +use image::{DynamicImage, GenericImageView}; + +pub fn fetch(url: &str) -> Option<Vec<u8>> { + if url.is_empty() { + return None; + } + match http::get_bytes(url) { + Ok(b) => Some(b), + // YouTube's maxres thumbnail is missing for some videos; try the smaller one. + Err(_) if url.contains("maxresdefault") => http::get_bytes(&url.replace("maxresdefault", "hqdefault")).ok(), + Err(_) => None, + } +} + +/// hqdefault thumbnails are 4:3 with black bars around a 16:9 picture. +fn trim_letterbox(img: DynamicImage) -> DynamicImage { + let (w, h) = img.dimensions(); + if w == 0 || h == 0 || ((w as f64 / h as f64) - 4.0 / 3.0).abs() > 0.02 { + return img; + } + let bar = ((h as f64 - w as f64 * 9.0 / 16.0) / 2.0).round() as u32; + if bar <= 2 || bar * 2 >= h { + return img; + } + let rgb = img.to_rgb8(); + let bright = |x: u32, y: u32| { + let p = rgb.get_pixel(x, y); + p[0].max(p[1]).max(p[2]) + }; + let step = (w / 16).max(1) as usize; + let dark = (0..w).step_by(step).all(|x| bright(x, 1) < 24 && bright(x, bar - 2) < 24); + if dark { + img.crop_imm(0, bar, w, h - 2 * bar) + } else { + img + } +} + +pub fn jpeg(img: &DynamicImage, quality: u8) -> Vec<u8> { + let mut out = Vec::new(); + let enc = image::codecs::jpeg::JpegEncoder::new_with_quality(&mut out, quality); + let _ = img.to_rgb8().write_with_encoder(enc); + out +} + +/// (jpeg_bytes, mime), or None when the data isn't an image. +pub fn process(data: &[u8], max_size: u32, square: bool) -> Option<(Vec<u8>, String)> { + let mut img = image::load_from_memory(data).ok()?; + img = trim_letterbox(img); + let (w, h) = img.dimensions(); + if square && w != h { + let side = w.min(h); + // Only crop pictures that are clearly not square (video thumbnails). + if w.max(h) as f64 / side as f64 > 1.05 { + img = img.crop_imm((w - side) / 2, (h - side) / 2, side, side); + } + } + if max_size > 0 && img.width().max(img.height()) > max_size { + img = img.resize(max_size, max_size, image::imageops::FilterType::Lanczos3); + } + Some((jpeg(&img, 92), "image/jpeg".into())) +} diff --git a/src/core/downloader.rs b/src/core/downloader.rs new file mode 100644 index 0000000..ba42160 --- /dev/null +++ b/src/core/downloader.rs @@ -0,0 +1,777 @@ +//! The download pipeline and the queue that runs it. +//! +//! For each job: get full info -> find a match if the service can't be downloaded -> look up tags -> +//! pick the final name -> download with yt-dlp -> convert with ffmpeg -> cover art -> lyrics -> +//! write tags -> move into place. + +use super::models::*; +use super::resolvers::{service_name, track_from_info}; +use super::settings::{get_bool, get_i64, get_str}; +use super::template::{render, track_values}; +use super::textutil::*; +use super::{covers, lyrics, matcher, metadata, paths, tagger, ytdlp}; +use serde_json::Value; +use std::collections::VecDeque; +use std::io::{BufRead, BufReader}; +use std::path::{Path, PathBuf}; +use std::process::{Command, Stdio}; +use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; +use std::sync::mpsc::Sender; +use std::sync::{Arc, Condvar, Mutex}; +use std::time::{Duration, Instant}; + +pub type Choices = &'static [(&'static str, &'static str)]; + +/// (key, label, bitrate choices). Numbers above 10 are kbps, 0-9 are VBR quality levels. +pub const FORMATS: &[(&str, &str, Choices)] = &[ + ("mp3", "MP3", &[("320", "320 kbps"), ("256", "256 kbps"), ("224", "224 kbps"), ("192", "192 kbps"), ("160", "160 kbps"), ("128", "128 kbps"), ("96", "96 kbps"), ("64", "64 kbps"), ("0", "V0 · VBR ~245 kbps"), ("2", "V2 · VBR ~190 kbps"), ("4", "V4 · VBR ~165 kbps")]), + ("m4a", "M4A · AAC", &[("256", "256 kbps"), ("192", "192 kbps"), ("160", "160 kbps"), ("128", "128 kbps"), ("96", "96 kbps")]), + ("opus", "Opus", &[("256", "256 kbps"), ("192", "192 kbps"), ("160", "160 kbps"), ("128", "128 kbps"), ("96", "96 kbps"), ("64", "64 kbps"), ("48", "48 kbps")]), + ("vorbis", "OGG Vorbis", &[("320", "320 kbps"), ("256", "256 kbps"), ("192", "192 kbps"), ("160", "160 kbps"), ("128", "128 kbps"), ("96", "96 kbps")]), + ("flac", "FLAC · lossless", &[]), + ("alac", "ALAC · Apple lossless", &[]), + ("wav", "WAV · uncompressed", &[]), + ("best", "Original · no re-encode", &[]), +]; +pub const SAMPLE_RATES: Choices = &[("source", "Same as source"), ("44100", "44.1 kHz"), ("48000", "48 kHz"), ("96000", "96 kHz")]; +pub const BIT_DEPTHS: Choices = &[("16", "16-bit"), ("24", "24-bit")]; +pub const LOSSLESS: &[&str] = &["flac", "alac", "wav"]; + +pub fn format_ext(fmt: &str) -> Option<&'static str> { + Some(match fmt { + "mp3" => "mp3", + "m4a" | "alac" => "m4a", + "opus" => "opus", + "vorbis" => "ogg", + "flac" => "flac", + "wav" => "wav", + _ => return None, + }) +} + +pub fn bitrates_for(fmt: &str) -> Choices { + FORMATS.iter().find(|f| f.0 == fmt).map(|f| f.2).unwrap_or(&[]) +} + +pub fn quality_label(fmt: &str, bitrate: &str, sample_rate: &str, bit_depth: &str) -> String { + if LOSSLESS.contains(&fmt) { + let sr = SAMPLE_RATES.iter().find(|s| s.0 == sample_rate).map(|s| s.1).unwrap_or(""); + return format!("{bit_depth}-bit{}", if sample_rate == "source" { String::new() } else { format!(" · {sr}") }); + } + if fmt == "best" { + return "original".into(); + } + let label = bitrates_for(fmt).iter().find(|b| b.0 == bitrate).map(|b| b.1).unwrap_or(bitrate); + label.split(" · ").next().unwrap_or(label).replace(" kbps", "k") +} + +/// ffmpeg output options that turn any source into the chosen format and quality. +pub fn encode_args(o: &DownloadOptions) -> Vec<String> { + let (mut codec, muxer) = match o.format.as_str() { + "m4a" => ("aac", "ipod"), + "opus" => ("libopus", "opus"), + "vorbis" => ("libvorbis", "ogg"), + "flac" => ("flac", "flac"), + "alac" => ("alac", "ipod"), + "wav" => ("pcm_s16le", "wav"), + _ => ("libmp3lame", "mp3"), + }; + let deep = o.bit_depth == "24"; + let mut a: Vec<String> = ["-map", "0:a:0", "-vn", "-sn", "-dn", "-map_metadata", "-1"].iter().map(|s| s.to_string()).collect(); + if o.format == "wav" && deep { + codec = "pcm_s24le"; + } + a.extend(["-c:a".into(), codec.into()]); + let rate = if o.sample_rate.is_empty() || o.sample_rate == "source" { "" } else { &o.sample_rate }; + if !rate.is_empty() && (o.format != "opus" || ["8000", "12000", "16000", "24000", "48000"].contains(&rate)) { + a.extend(["-ar".into(), rate.into()]); + } + match o.format.as_str() { + "flac" => a.extend(if deep { vec!["-sample_fmt", "s32", "-bits_per_raw_sample", "24"] } else { vec!["-sample_fmt", "s16"] }.into_iter().map(String::from)), + "alac" => a.extend(["-sample_fmt".into(), if deep { "s32p" } else { "s16p" }.into()]), + f if !LOSSLESS.contains(&f) => { + let q: i64 = o.bitrate.parse().unwrap_or(0); + if f == "mp3" && (0..=9).contains(&q) && !o.bitrate.is_empty() { + a.extend(["-q:a".into(), q.to_string()]); // LAME VBR level + } else { + let mut kbps = if q > 10 { q } else { match f { "mp3" => 320, "m4a" => 256, "opus" => 160, "vorbis" => 256, _ => 192 } }; + if f == "m4a" { + kbps = kbps.min(256); // FFmpeg's AAC encoder can't go meaningfully higher + } + a.extend(["-b:a".into(), format!("{kbps}k")]); + match f { + "mp3" => a.extend(["-abr".into(), "0".into()]), // constant bitrate + "opus" => a.extend(["-vbr".into(), "constrained".into()]), + "vorbis" => a.extend(["-minrate".into(), format!("{}k", kbps / 2), "-maxrate".into(), format!("{}k", kbps * 2)]), + _ => {} + } + } + } + _ => {} + } + a.extend(["-f".into(), muxer.into()]); + a +} + +#[derive(Clone)] +pub struct JobHandle { + pub uid: u64, + pub job: Arc<Mutex<Job>>, + pub cancel: Arc<AtomicBool>, +} + +pub struct LogLine { + pub job: u64, + pub kind: String, + pub text: String, +} + +struct Shared { + queue: Mutex<VecDeque<(JobHandle, Arc<Value>)>>, + cv: Condvar, + running: AtomicUsize, + limit: AtomicUsize, +} + +pub struct Manager { + pub jobs: Vec<JobHandle>, + shared: Arc<Shared>, + log_tx: Sender<LogLine>, + notify: Arc<dyn Fn() + Send + Sync>, + was_busy: bool, +} + +impl Manager { + pub fn new(concurrent: usize, log_tx: Sender<LogLine>, notify: Arc<dyn Fn() + Send + Sync>) -> Manager { + let shared = Arc::new(Shared { queue: Mutex::new(VecDeque::new()), cv: Condvar::new(), running: AtomicUsize::new(0), limit: AtomicUsize::new(concurrent.max(1)) }); + for _ in 0..8 { + let (sh, tx, nf) = (shared.clone(), log_tx.clone(), notify.clone()); + std::thread::spawn(move || worker_loop(sh, tx, nf)); + } + Manager { jobs: vec![], shared, log_tx, notify, was_busy: false } + } + + pub fn set_concurrent(&self, n: usize) { + self.shared.limit.store(n.clamp(1, 8), Ordering::Relaxed); + self.shared.cv.notify_all(); + } + + pub fn enqueue(&mut self, tracks: &[Track], options: &DownloadOptions, snap: &Value) -> usize { + let snap = Arc::new(snap.clone()); + for t in tracks { + let job = Job { uid: next_id(), track: t.clone(), options: options.clone(), state: JobState::Queued, progress: 0.0, speed: None, eta: None, status: "Waiting".into(), error: String::new(), output_path: String::new() }; + let h = JobHandle { uid: job.uid, job: Arc::new(Mutex::new(job)), cancel: Arc::new(AtomicBool::new(false)) }; + self.jobs.push(h.clone()); + self.shared.queue.lock().unwrap().push_back((h, snap.clone())); + } + self.shared.cv.notify_all(); + (self.notify)(); + tracks.len() + } + + pub fn cancel(&self, uid: u64) { + if let Some(h) = self.jobs.iter().find(|h| h.uid == uid) { + let mut j = h.job.lock().unwrap(); + if !j.state.finished() { + h.cancel.store(true, Ordering::Relaxed); + if j.state == JobState::Queued { + j.state = JobState::Cancelled; + j.status = "Cancelled".into(); + } + } + } + (self.notify)(); + } + + pub fn cancel_all(&self) { + for h in &self.jobs { + self.cancel(h.uid); + } + } + + pub fn retry(&self, uid: u64, snap: &Value) { + let Some(h) = self.jobs.iter().find(|h| h.uid == uid) else { return }; + { + let mut j = h.job.lock().unwrap(); + if !j.state.finished() { + return; + } + h.cancel.store(false, Ordering::Relaxed); + j.state = JobState::Queued; + j.status = "Waiting".into(); + j.error.clear(); + j.progress = 0.0; + } + self.shared.queue.lock().unwrap().push_back((h.clone(), Arc::new(snap.clone()))); + self.shared.cv.notify_all(); + (self.notify)(); + } + + pub fn remove(&mut self, uid: u64) { + self.jobs.retain(|h| !(h.uid == uid && h.job.lock().unwrap().state.finished())); + } + + pub fn clear_finished(&mut self) { + self.jobs.retain(|h| !matches!(h.job.lock().unwrap().state, JobState::Done | JobState::Skipped | JobState::Cancelled)); + } + + /// (active incl. queued, done, failed) + pub fn counts(&self) -> (usize, usize, usize) { + let (mut a, mut d, mut f) = (0, 0, 0); + for h in &self.jobs { + match h.job.lock().unwrap().state { + JobState::Done | JobState::Skipped => d += 1, + JobState::Failed => f += 1, + s if !s.finished() => a += 1, + _ => {} + } + } + (a, d, f) + } + + /// Returns (done, failed) once when the queue empties. + pub fn poll_all_done(&mut self) -> Option<(usize, usize)> { + let (a, d, f) = self.counts(); + let fire = self.was_busy && a == 0; + self.was_busy = a > 0; + fire.then_some((d, f)) + } + + pub fn log(&self, job: u64, kind: &str, text: &str) { + let _ = self.log_tx.send(LogLine { job, kind: kind.into(), text: text.into() }); + } +} + +fn worker_loop(sh: Arc<Shared>, log_tx: Sender<LogLine>, notify: Arc<dyn Fn() + Send + Sync>) { + loop { + let item = { + let mut q = sh.queue.lock().unwrap(); + loop { + if sh.running.load(Ordering::Relaxed) < sh.limit.load(Ordering::Relaxed) { + if let Some(i) = q.pop_front() { + sh.running.fetch_add(1, Ordering::Relaxed); + break i; + } + } + q = sh.cv.wait_timeout(q, Duration::from_millis(500)).unwrap().0; + } + }; + let (h, snap) = item; + run_job(&h, &snap, &log_tx, ¬ify); + sh.running.fetch_sub(1, Ordering::Relaxed); + sh.cv.notify_all(); + } +} + +enum Fail { + Cancelled, + Error(String), +} +impl From<String> for Fail { + fn from(s: String) -> Fail { + Fail::Error(s) + } +} +impl From<&str> for Fail { + fn from(s: &str) -> Fail { + Fail::Error(s.into()) + } +} + +struct Ctx<'a> { + h: &'a JobHandle, + snap: &'a Value, + tx: &'a Sender<LogLine>, + notify: &'a Arc<dyn Fn() + Send + Sync>, + last_emit: Mutex<Instant>, +} + +impl Ctx<'_> { + fn log(&self, kind: &str, text: &str) { + let _ = self.tx.send(LogLine { job: self.h.uid, kind: kind.into(), text: text.into() }); + (self.notify)(); + } + fn update(&self, state: Option<JobState>, status: Option<&str>, force: bool) { + { + let mut j = self.h.job.lock().unwrap(); + if let Some(s) = state { + j.state = s; + } + if let Some(s) = status { + j.status = s.into(); + } + } + let mut last = self.last_emit.lock().unwrap(); + if force || last.elapsed() > Duration::from_millis(120) { + *last = Instant::now(); + (self.notify)(); + } + } + fn check(&self) -> Result<(), Fail> { + if self.h.cancel.load(Ordering::Relaxed) { + Err(Fail::Cancelled) + } else { + Ok(()) + } + } +} + +fn short_error(msg: &str) -> String { + let first = msg.lines().next().unwrap_or("Unknown error"); + if first.contains("Sign in to confirm") { + return "YouTube wants a sign-in: set “Cookies from browser” in Settings".into(); + } + if first.contains("Video unavailable") || first.contains("Private video") { + return "This video is unavailable".into(); + } + let l = first.to_lowercase(); + if l.contains("ffmpeg") && (l.contains("not found") || l.contains("not installed")) { + return "ffmpeg is missing".into(); + } + first.chars().take(160).collect() +} + +fn retryable(msg: &str) -> bool { + ["HTTP Error 403", "HTTP Error 5", "timed out", "Connection reset", "IncompleteRead", "fragment", "Read timed out"].iter().any(|s| msg.contains(s)) +} + +fn run_job(h: &JobHandle, snap: &Value, tx: &Sender<LogLine>, notify: &Arc<dyn Fn() + Send + Sync>) { + let ctx = Ctx { h, snap, tx, notify, last_emit: Mutex::new(Instant::now()) }; + if h.cancel.load(Ordering::Relaxed) { + ctx.update(Some(JobState::Cancelled), Some("Cancelled"), true); + return; + } + let opts = h.job.lock().unwrap().options.clone(); + let out_dir = PathBuf::from(paths::shellexpand(&opts.output_dir)); + let tmp_dir = out_dir.join(".audiphi-partial"); + let result = pipeline(&ctx, &out_dir, &tmp_dir); + // clean up this job's partial files + if let Ok(rd) = std::fs::read_dir(&tmp_dir) { + for e in rd.flatten() { + if e.file_name().to_string_lossy().starts_with(&format!("{}.", h.uid)) { + let _ = std::fs::remove_file(e.path()); + } + } + } + let _ = std::fs::remove_dir(&tmp_dir); // only succeeds once every worker is done with it + match result { + Ok(()) => {} + Err(Fail::Cancelled) => { + ctx.log("warning", "Cancelled"); + ctx.update(Some(JobState::Cancelled), Some("Cancelled"), true); + } + Err(Fail::Error(msg)) => { + h.job.lock().unwrap().error = msg.clone(); + ctx.log("error", &msg); + ctx.update(Some(JobState::Failed), Some(&short_error(&msg)), true); + } + } +} + +fn final_path(ctx: &Ctx, out_dir: &Path, ext: &str) -> PathBuf { + let j = ctx.h.job.lock().unwrap(); + let (t, o) = (&j.track, &j.options); + let sep = get_str(ctx.snap, "download.artist_separator"); + let sep = if sep.is_empty() { ", ".to_string() } else { sep }; + let values = track_values(t, ext, &quality_label(&o.format, &o.bitrate, &o.sample_rate, &o.bit_depth), &sep); + let mut rel = render(&o.template, &values); + if o.collection_folder && !t.folder.is_empty() && !o.template.contains("{album") { + let f: Vec<String> = t.folder.iter().filter(|f| !f.is_empty()).map(|f| safe_component(f)).collect(); + rel = format!("{}/{}", f.join("/"), rel); + } else if o.collection_folder && !t.playlist.is_empty() && t.folder.is_empty() && !o.template.contains("{playlist") { + rel = format!("{}/{}", safe_component(&t.playlist), rel); + } + out_dir.join(format!("{rel}.{ext}")) +} + +fn resolve_collision(path: PathBuf, policy: &str) -> PathBuf { + if !path.exists() || policy == "overwrite" { + return path; + } + let stem = path.file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or_default(); + let ext = path.extension().map(|e| format!(".{}", e.to_string_lossy())).unwrap_or_default(); + (2..).map(|n| path.with_file_name(format!("{stem} ({n}){ext}"))).find(|c| !c.exists()).unwrap() +} + +fn pipeline(ctx: &Ctx, out_dir: &Path, tmp_dir: &Path) -> Result<(), Fail> { + let uid = ctx.h.uid; + std::fs::create_dir_all(tmp_dir).map_err(|e| format!("Can't write to {}: {e}", out_dir.display()))?; + let log = |k: &str, t: &str| ctx.log(k, t); + let (title, artist) = { let j = ctx.h.job.lock().unwrap(); (j.track.display_title(), j.track.display_artist()) }; + ctx.log("info", &format!("▶ {} – {}", if artist.is_empty() { "?" } else { &artist }, title)); + let opts = ctx.h.job.lock().unwrap().options.clone(); + let source = Some(get_str(ctx.snap, "download.search_source")).filter(|s| !s.is_empty()).unwrap_or_else(|| "ytmusic".into()); + + // 1. Services yt-dlp can't download from: find the same song on YouTube Music. + let needs_match = ctx.h.job.lock().unwrap().track.download_url.is_empty(); + if needs_match { + ctx.update(Some(JobState::Matching), Some(&format!("Finding “{title}” on {}", service_name(&source))), true); + let t = ctx.h.job.lock().unwrap().track.clone(); + let m = matcher::find_match(ctx.snap, &t, &source, &log).ok_or("Couldn't find this song on YouTube Music or YouTube")?; + let mut j = ctx.h.job.lock().unwrap(); + j.track.download_url = m.download_url.clone(); + j.track.matched = Some(MatchInfo { service: m.service.clone(), title: m.title.clone(), artist: m.artist(), url: m.download_url.clone(), score: m.score }); + j.track.match_cover = m.cover_url.clone(); + if j.track.album.is_empty() && !m.album.is_empty() && m.authoritative { + j.track.album = m.album.clone(); + } + if j.track.duration.is_none() { + j.track.duration = m.duration; + } + } + ctx.check()?; + + // 2. Full info from yt-dlp (one extraction, reused for the download). + ctx.update(Some(JobState::Resolving), Some("Getting stream info"), true); + let url = ctx.h.job.lock().unwrap().track.download_url.clone(); + let mut info = extract_info(ctx, &url)?; + merge_info(ctx, &info); + ctx.check()?; + + // 3. Tags from Deezer / iTunes / MusicBrainz, per the settings. + if !ctx.h.job.lock().unwrap().track.enriched { + ctx.update(Some(JobState::Metadata), Some("Looking up tags"), true); + let mut t = ctx.h.job.lock().unwrap().track.clone(); + metadata::enrich(&mut t, ctx.snap, &log); + let mut j = ctx.h.job.lock().unwrap(); + // keep anything the user edited while we were looking + let overrides = std::mem::take(&mut j.track.overrides); + j.track = Track { overrides, ..t }; + } + ctx.check()?; + + // 4. Final name; skip, rename or overwrite an existing file. + let policy = Some(get_str(ctx.snap, "download.existing")).filter(|s| !s.is_empty()).unwrap_or_else(|| "rename".into()); + let probe_ext = format_ext(&opts.format).map(String::from).unwrap_or_else(|| js_str(&info, "ext", "m4a")); + let target = final_path(ctx, out_dir, &probe_ext); + if target.exists() && policy == "skip" { + { + let mut j = ctx.h.job.lock().unwrap(); + j.output_path = target.to_string_lossy().into_owned(); + j.progress = 1.0; + } + ctx.log("info", &format!("Already have {}, skipping", target.file_name().unwrap_or_default().to_string_lossy())); + ctx.update(Some(JobState::Skipped), Some(&format!("Already in {}", target.parent().and_then(|p| p.file_name()).map(|n| n.to_string_lossy().into_owned()).unwrap_or_else(|| "library".into()))), true); + return Ok(()); + } + + // 5. Download. YouTube sometimes answers 403 on a stream URL; fresh URLs from a second extraction usually work. + ctx.update(Some(JobState::Downloading), Some("Starting download"), true); + let mut downloaded = None; + for attempt in 0..3 { + match download(ctx, &info, tmp_dir, &opts) { + Ok(p) => { + downloaded = Some(p); + break; + } + Err(Fail::Error(e)) if attempt < 2 && retryable(&e) && !ctx.h.cancel.load(Ordering::Relaxed) => { + ctx.log("warning", &format!("Download failed ({}); retrying with fresh links", short_error(&e))); + ctx.update(Some(JobState::Resolving), Some("Retrying with fresh links"), true); + std::thread::sleep(Duration::from_millis(1500 * (attempt + 1))); + info = extract_info(ctx, &url)?; + } + Err(e) => return Err(e), + } + } + let mut downloaded = downloaded.ok_or("The download didn't finish")?; + ctx.check()?; + if opts.format != "best" { + let dur = info.get("duration").and_then(|d| d.as_f64()).or(ctx.h.job.lock().unwrap().track.duration); + downloaded = encode(ctx, &downloaded, dur, &opts, tmp_dir)?; + } + ctx.check()?; + + // 6. Cover art. + let skip: Vec<String> = ctx.h.job.lock().unwrap().track.skip_fields.clone(); + let cover = if get_bool(ctx.snap, "metadata.embed_cover") && !skip.contains(&"cover".to_string()) { cover_art(ctx) } else { None }; + + // 7. Lyrics. + let (lyric_text, synced_text) = fetch_lyrics(ctx, &opts); + + // 8. Tags. + ctx.update(Some(JobState::Tagging), Some("Writing tags"), true); + let tags = build_tags(ctx, cover.as_ref().map(|c| c.0.clone()), &lyric_text, &skip); + if let Err(e) = tagger::write(&downloaded.to_string_lossy(), &tags, if opts.lyrics != "off" { &opts.lyrics } else { "off" }) { + ctx.log("warning", &format!("Couldn't write tags: {e}")); // a tagging hiccup shouldn't lose the download + } + + // 9. Move into place. + let ext = downloaded.extension().map(|e| e.to_string_lossy().into_owned()).unwrap_or_default(); + let final_p = resolve_collision(final_path(ctx, out_dir, &ext), &policy); + if let Some(p) = final_p.parent() { + std::fs::create_dir_all(p).map_err(|e| format!("Can't create {}: {e}", p.display()))?; + } + if std::fs::rename(&downloaded, &final_p).is_err() { + std::fs::copy(&downloaded, &final_p).map_err(|e| format!("Couldn't move the file into place: {e}"))?; + let _ = std::fs::remove_file(&downloaded); + } + ctx.h.job.lock().unwrap().output_path = final_p.to_string_lossy().into_owned(); + if opts.save_lrc && (!synced_text.is_empty() || !lyric_text.is_empty()) { + let text = if synced_text.is_empty() { &lyric_text } else { &synced_text }; + let _ = std::fs::write(final_p.with_extension("lrc"), text); + } + if let (Some(c), true) = (&cover, get_bool(ctx.snap, "metadata.save_cover_file")) { + if final_p.parent() != Some(out_dir) { + let cf = final_p.parent().unwrap().join("cover.jpg"); + if !cf.exists() { + let _ = std::fs::write(cf, &c.0); + } + } + } + let size = std::fs::metadata(&final_p).map(|m| format_size(m.len() as f64)).unwrap_or_default(); + ctx.h.job.lock().unwrap().progress = 1.0; + ctx.log("success", &format!("✓ Saved {} ({size})", final_p.display())); + ctx.update(Some(JobState::Done), Some(&format!("Saved · {size}")), true); + Ok(()) +} + +fn js_str(v: &Value, k: &str, d: &str) -> String { + v.get(k).and_then(|x| x.as_str()).filter(|s| !s.is_empty()).unwrap_or(d).to_string() +} + +fn extract_info(ctx: &Ctx, url: &str) -> Result<Value, Fail> { + let log = |k: &str, t: &str| ctx.log(k, t); + let mut info = ytdlp::extract(ctx.snap, url, false, &[], &log)?; + if info.get("_type").and_then(|t| t.as_str()) == Some("playlist") { + info = info.get("entries").and_then(|e| e.as_array()).and_then(|e| e.iter().find(|x| x.is_object())).cloned().ok_or("Nothing to download at that link")?; + } + Ok(info) +} + +fn merge_info(ctx: &Ctx, info: &Value) { + let mut j = ctx.h.job.lock().unwrap(); + let url = j.track.download_url.clone(); + let full = track_from_info(info, &url); + let t = &mut j.track; + if t.matched.is_none() { + if !full.title.is_empty() && (t.weak || t.title.is_empty()) { + t.title = full.title.clone(); + } + if !full.artists.is_empty() && (t.weak || t.artists.is_empty()) { + t.artists = full.artists.clone(); + } + macro_rules! fill { + ($f:ident) => { + if !full.$f.is_empty() && (t.weak || t.$f.is_empty()) { + t.$f = full.$f.clone(); + } + }; + } + fill!(album); + fill!(album_artist); + fill!(year); + fill!(genre); + if full.track_number.is_some() && (t.weak || t.track_number.is_none()) { + t.track_number = full.track_number; + } + if full.disc_number.is_some() && (t.weak || t.disc_number.is_none()) { + t.disc_number = full.disc_number; + } + t.authoritative = t.authoritative || full.authoritative; + if t.service.is_empty() { + t.service = full.service.clone(); + } + if t.source_id.is_empty() { + t.source_id = full.source_id.clone(); + } + } + if t.duration.is_none() { + t.duration = full.duration; + } + if t.cover_url.is_empty() || t.weak { + if !full.cover_url.is_empty() { + t.cover_url = full.cover_url.clone(); + } + } + t.thumbnail = full.cover_url; + t.weak = false; +} + +fn download(ctx: &Ctx, info: &Value, tmp_dir: &Path, opts: &DownloadOptions) -> Result<PathBuf, Fail> { + let uid = ctx.h.uid; + let info_file = tmp_dir.join(format!("{uid}.info.json")); + std::fs::write(&info_file, serde_json::to_vec(info).unwrap_or_default()).map_err(|e| e.to_string())?; + let mut args = ytdlp::base_args(ctx.snap); + args.extend(["--load-info-json".into(), info_file.to_string_lossy().into_owned(), "-f".into(), "bestaudio/best".into(), "--newline".into(), "--no-warnings".into(), "--force-overwrites".into(), + "-o".into(), tmp_dir.join(format!("{uid}.%(ext)s")).to_string_lossy().into_owned(), + "--progress-template".into(), "download:[dl] %(progress.downloaded_bytes)s %(progress.total_bytes)s %(progress.total_bytes_estimate)s %(progress.speed)s %(progress.eta)s".into()]); + if opts.format == "best" { + args.extend(["-x".into(), "--audio-format".into(), "best".into()]); + } + let log = |k: &str, t: &str| ctx.log(k, t); + let num = |s: &str| s.parse::<f64>().ok(); + let out = ytdlp::run(&args, Some(&ctx.h.cancel), &log, |line| { + if let Some(rest) = line.strip_prefix("[dl] ") { + let p: Vec<&str> = rest.split_whitespace().collect(); + if p.len() >= 5 { + let done = num(p[0]).unwrap_or(0.0); + let total = num(p[1]).or(num(p[2])).unwrap_or(0.0); + let mut j = ctx.h.job.lock().unwrap(); + if total > 0.0 { + j.progress = (done / total).min(1.0) as f32; + } + j.speed = num(p[3]); + j.eta = num(p[4]); + let mut parts = vec![format!("{:4.1}%", j.progress * 100.0)]; + if total > 0.0 { + parts.push(format!("of {}", format_size(total))); + } + if let Some(s) = j.speed { + parts.push(format!("at {}/s", format_size(s))); + } + if let Some(e) = j.eta { + parts.push(format!("ETA {}", format_duration(Some(e)))); + } + j.status = parts.join(" "); + j.state = JobState::Downloading; + drop(j); + ctx.update(None, None, false); + } + } else if line.contains("[ExtractAudio]") { + ctx.update(Some(JobState::Converting), Some("Remuxing"), true); + } else if !line.trim().is_empty() { + ctx.log("yt", line); + } + })?; + ctx.check()?; + if out.cancelled { + return Err(Fail::Cancelled); + } + if !out.ok { + return Err(Fail::Error(ytdlp::error_text(&out))); + } + ctx.h.job.lock().unwrap().progress = 1.0; + let mut found: Vec<PathBuf> = std::fs::read_dir(tmp_dir) + .map_err(|e| e.to_string())? + .flatten() + .map(|e| e.path()) + .filter(|p| { + let n = p.file_name().unwrap_or_default().to_string_lossy().into_owned(); + n.starts_with(&format!("{uid}.")) && !n.ends_with(".part") && !n.ends_with(".ytdl") && !n.ends_with(".json") + }) + .collect(); + found.sort_by_key(|p| std::cmp::Reverse(std::fs::metadata(p).and_then(|m| m.modified()).ok())); + found.into_iter().next().ok_or_else(|| Fail::Error("yt-dlp finished but the audio file is missing".into())) +} + +fn encode(ctx: &Ctx, src: &Path, duration: Option<f64>, o: &DownloadOptions, tmp_dir: &Path) -> Result<PathBuf, Fail> { + let ffmpeg = paths::find_ffmpeg(&get_str(ctx.snap, "download.ffmpeg_path")).ok_or("ffmpeg wasn't found; install it or set its path in Settings")?; + let uid = ctx.h.uid; + let label = super::downloader::FORMATS.iter().find(|f| f.0 == o.format).map(|f| f.1.split(" · ").next().unwrap_or(f.1)).unwrap_or(&o.format).to_string(); + let q = quality_label(&o.format, &o.bitrate, &o.sample_rate, &o.bit_depth); + let base = format!("Converting to {label} {q}").trim().to_string(); + ctx.update(Some(JobState::Converting), Some(&base), true); + let ext = format_ext(&o.format).unwrap_or("mp3"); + let dst = tmp_dir.join(format!("{uid}.out.{ext}")); + let mut cmd = Command::new(ffmpeg); + cmd.args(["-hide_banner", "-nostdin", "-y", "-loglevel", "error", "-progress", "pipe:1", "-i"]).arg(src).args(encode_args(o)).arg(&dst).stdout(Stdio::piped()).stderr(Stdio::piped()); + let mut child = cmd.spawn().map_err(|e| format!("couldn't start ffmpeg: {e}"))?; + let stdout = child.stdout.take().unwrap(); + let stderr = child.stderr.take().unwrap(); + let child = Arc::new(Mutex::new(child)); + let done = Arc::new(AtomicBool::new(false)); + let (c2, d2, cancel) = (child.clone(), done.clone(), ctx.h.cancel.clone()); + let watcher = std::thread::spawn(move || { + while !d2.load(Ordering::Relaxed) { + if cancel.load(Ordering::Relaxed) { + let _ = c2.lock().unwrap().kill(); + break; + } + std::thread::sleep(Duration::from_millis(100)); + } + }); + let err_thread = std::thread::spawn(move || BufReader::new(stderr).lines().map_while(Result::ok).collect::<Vec<_>>().join("\n")); + for line in BufReader::new(stdout).lines().map_while(Result::ok) { + if let (Some(us), Some(d)) = (line.strip_prefix("out_time_us="), duration.filter(|d| *d > 0.0)) { + if let Ok(us) = us.trim().parse::<f64>() { + let pct = (us / 1e4 / d).min(100.0); + ctx.update(None, Some(&format!("{base} · {pct:.0}%")), false); + } + } + } + let status = child.lock().unwrap().wait(); + done.store(true, Ordering::Relaxed); + let _ = watcher.join(); + let err = err_thread.join().unwrap_or_default(); + ctx.check()?; + if !status.map(|s| s.success()).unwrap_or(false) || !dst.exists() { + return Err(Fail::Error(format!("ffmpeg failed: {}", err.lines().last().unwrap_or("unknown error")))); + } + let _ = std::fs::remove_file(src); + let final_p = tmp_dir.join(format!("{uid}.{ext}")); + std::fs::rename(&dst, &final_p).map_err(|e| e.to_string())?; + Ok(final_p) +} + +fn cover_art(ctx: &Ctx) -> Option<(Vec<u8>, String)> { + let size = get_i64(ctx.snap, "metadata.cover_size").max(0) as u32; + let square = get_bool(ctx.snap, "metadata.cover_square"); + let t = ctx.h.job.lock().unwrap().track.clone(); + if let Some(d) = &t.cover_override { + return covers::process(d, size, false); + } + let mut seen = vec![]; + for url in [&t.cover_url, &t.match_cover, &t.thumbnail] { + if url.is_empty() || seen.contains(&url) { + continue; + } + seen.push(url); + if let Some(data) = covers::fetch(url) { + if let Some(r) = covers::process(&data, size, square) { + return Some(r); + } + } + } + ctx.log("warning", "No cover art found"); + None +} + +fn fetch_lyrics(ctx: &Ctx, o: &DownloadOptions) -> (String, String) { + let t = ctx.h.job.lock().unwrap().track.clone(); + if let Some(text) = &t.lyrics_override { + return (text.clone(), if lyrics::is_synced(text) { text.clone() } else { String::new() }); + } + if o.lyrics == "off" && !o.save_lrc { + return Default::default(); + } + ctx.update(Some(JobState::Lyrics), Some("Fetching lyrics"), true); + let found = match lyrics::fetch(&t.value("title"), &t.value("artist"), &t.value("album"), t.duration) { + Ok(f) => f, + Err(e) => { + ctx.log("warning", &format!("Lyrics lookup failed: {e}")); + return Default::default(); + } + }; + if found.instrumental { + ctx.log("info", "LRCLIB says it's instrumental"); + return Default::default(); + } + if !found.found() { + ctx.log("info", "No lyrics on LRCLIB"); + return Default::default(); + } + ctx.log("info", &format!("Lyrics found ({})", if found.synced.is_empty() { "plain text" } else { "synced" })); + let fallback = ctx.snap.pointer("/lyrics/fallback_plain").and_then(|v| v.as_bool()).unwrap_or(true); + let embed = match o.lyrics.as_str() { + "synced" => if !found.synced.is_empty() { found.synced.clone() } else if fallback { found.plain.clone() } else { String::new() }, + "plain" => if !found.plain.is_empty() { found.plain.clone() } else { lyrics::lrc_to_plain(&found.synced) }, + _ => String::new(), + }; + (embed, found.synced) +} + +fn build_tags(ctx: &Ctx, cover: Option<Vec<u8>>, lyric_text: &str, skip: &[String]) -> tagger::Tags { + let t = ctx.h.job.lock().unwrap().track.clone(); + let sep = Some(get_str(ctx.snap, "download.artist_separator")).filter(|s| !s.is_empty()).unwrap_or_else(|| ", ".into()); + let artist = t.overrides.get("artist").filter(|s| !s.is_empty()).cloned().unwrap_or_else(|| t.artists.join(&sep)); + let mut comment = t.value("comment"); + if comment.is_empty() && get_bool(ctx.snap, "download.write_source_comment") { + comment = if t.page_url.is_empty() { t.download_url.clone() } else { t.page_url.clone() }; + } + tagger::Tags { + title: t.value("title"), artist, album: t.value("album"), album_artist: t.value("album_artist"), + track_number: to_int(&t.value("track_number")), track_total: to_int(&t.value("track_total")), disc_number: to_int(&t.value("disc_number")), + year: t.value("year"), genre: t.value("genre"), isrc: t.value("isrc"), comment, lyrics: lyric_text.into(), cover, + skip: skip.iter().cloned().collect(), ..Default::default() + } +} diff --git a/src/core/http.rs b/src/core/http.rs new file mode 100644 index 0000000..bd544d1 --- /dev/null +++ b/src/core/http.rs @@ -0,0 +1,195 @@ +//! One shared ureq agent with sane timeouts and retries, plus the helpers the resolvers use. + +use serde_json::Value; +use std::sync::{Mutex, OnceLock}; +use std::time::{Duration, Instant}; +use ureq::ResponseExt; + +pub const BROWSER_UA: &str = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0 Safari/537.36"; +pub const TIMEOUT: Duration = Duration::from_secs(20); + +pub fn app_ua() -> String { + format!("{}/{} ( {} )", crate::APP_NAME, crate::VERSION, crate::HOMEPAGE) +} + +#[derive(Debug, Clone)] +pub struct HttpError { + /// 0 for transport errors (DNS, TLS, timeout). + pub status: u16, + pub msg: String, +} + +impl std::fmt::Display for HttpError { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + if self.status > 0 { + write!(f, "HTTP {}: {}", self.status, self.msg) + } else { + write!(f, "{}", self.msg) + } + } +} + +impl From<HttpError> for String { + fn from(e: HttpError) -> String { + e.to_string() + } +} + +fn agent() -> &'static ureq::Agent { + static A: OnceLock<ureq::Agent> = OnceLock::new(); + A.get_or_init(|| { + let cfg = ureq::Agent::config_builder().timeout_global(Some(TIMEOUT)).http_status_as_error(false).build(); + ureq::Agent::new_with_config(cfg) + }) +} + +pub struct Reply { + pub status: u16, + pub url: String, + pub body: Vec<u8>, + pub headers: Vec<(String, String)>, +} + +impl Reply { + pub fn text(&self, force_utf8: bool) -> String { + let _ = force_utf8; + String::from_utf8_lossy(&self.body).into_owned() + } + pub fn json(&self) -> Result<Value, HttpError> { + serde_json::from_slice(&self.body).map_err(|e| HttpError { status: self.status, msg: format!("bad JSON: {e}") }) + } + pub fn header(&self, name: &str) -> Option<&str> { + self.headers.iter().find(|(k, _)| k.eq_ignore_ascii_case(name)).map(|(_, v)| v.as_str()) + } + pub fn ok(&self) -> bool { + (200..300).contains(&self.status) + } + fn check(self) -> Result<Reply, HttpError> { + if self.ok() { + Ok(self) + } else { + let snippet: String = String::from_utf8_lossy(&self.body).chars().take(200).collect(); + Err(HttpError { status: self.status, msg: snippet }) + } + } +} + +pub fn query_string(params: &[(&str, String)]) -> String { + params.iter().map(|(k, v)| format!("{}={}", urlencoding::encode(k), urlencoding::encode(v))).collect::<Vec<_>>().join("&") +} + +pub fn with_params(url: &str, params: &[(&str, String)]) -> String { + if params.is_empty() { + return url.to_string(); + } + format!("{}{}{}", url, if url.contains('?') { "&" } else { "?" }, query_string(params)) +} + +fn finish(mut resp: ureq::http::Response<ureq::Body>) -> Result<Reply, HttpError> { + let status = resp.status().as_u16(); + let url = resp.get_uri().to_string(); + let headers = resp.headers().iter().map(|(k, v)| (k.to_string(), v.to_str().unwrap_or("").to_string())).collect(); + let body = resp.body_mut().with_config().limit(64 * 1024 * 1024).read_to_vec().map_err(|e| HttpError { status: 0, msg: e.to_string() })?; + Ok(Reply { status, url, body, headers }) +} + +fn terr(e: ureq::Error) -> HttpError { + HttpError { status: 0, msg: e.to_string() } +} + +/// GET with up to three tries on transport errors and 429/5xx. +pub fn get(url: &str, headers: &[(&str, &str)]) -> Result<Reply, HttpError> { + let mut last = HttpError { status: 0, msg: "no attempt".into() }; + for attempt in 0..3u32 { + if attempt > 0 { + std::thread::sleep(Duration::from_millis(600 * (1 << (attempt - 1)))); + } + let mut req = agent().get(url); + for (k, v) in headers { + req = req.header(*k, *v); + } + match req.call().map_err(terr).and_then(finish) { + Ok(r) if r.status == 429 || (500..600).contains(&r.status) => { + last = HttpError { status: r.status, msg: String::from_utf8_lossy(&r.body).chars().take(200).collect() }; + if r.status == 429 { + if let Some(s) = r.header("retry-after").and_then(|s| s.parse::<u64>().ok()) { + std::thread::sleep(Duration::from_secs(s.min(5))); + } + } + } + Ok(r) => return Ok(r), + Err(e) => last = e, + } + } + Err(last) +} + +pub fn get_json(url: &str, params: &[(&str, String)], browser: bool, extra: &[(&str, &str)]) -> Result<Value, HttpError> { + let ua = if browser { BROWSER_UA.to_string() } else { app_ua() }; + let mut h: Vec<(&str, &str)> = vec![("User-Agent", ua.as_str()), ("Accept", "application/json")]; + h.extend_from_slice(extra); + get(&with_params(url, params), &h)?.check()?.json() +} + +/// (final_url, body) +pub fn get_text(url: &str) -> Result<(String, String), HttpError> { + let r = get(url, &[("User-Agent", BROWSER_UA), ("Accept-Language", "en-US,en;q=0.8")])?.check()?; + let text = r.text(true); + Ok((r.url, text)) +} + +pub fn get_bytes(url: &str) -> Result<Vec<u8>, HttpError> { + Ok(get(url, &[("User-Agent", BROWSER_UA)])?.check()?.body) +} + +/// Follow redirects and return the final URL (short links). +pub fn final_url(url: &str) -> Result<String, HttpError> { + Ok(get(url, &[("User-Agent", BROWSER_UA)])?.url) +} + +pub fn post_json(url: &str, body: &Value, headers: &[(&str, &str)]) -> Result<Value, HttpError> { + let mut req = agent().post(url); + for (k, v) in headers { + req = req.header(*k, *v); + } + let resp = req.send_json(body).map_err(terr)?; + finish(resp)?.check()?.json() +} + +/// Form POST; returns the raw reply so callers can read the status. +pub fn post_form(url: &str, form: &[(&str, &str)], headers: &[(&str, &str)]) -> Result<Reply, HttpError> { + let mut req = agent().post(url); + for (k, v) in headers { + req = req.header(*k, *v); + } + let resp = req.send_form(form.iter().map(|(k, v)| (*k, *v))).map_err(terr)?; + finish(resp) +} + +/// At most one call per `interval` across threads (MusicBrainz asks for 1/s). +pub struct RateLimiter { + interval: Duration, + last: Mutex<Option<Instant>>, +} + +impl RateLimiter { + pub const fn new(ms: u64) -> Self { + RateLimiter { interval: Duration::from_millis(ms), last: Mutex::new(None) } + } + pub fn wait(&self) { + let mut g = self.last.lock().unwrap(); + if let Some(t) = *g { + let due = t + self.interval; + let now = Instant::now(); + if due > now { + std::thread::sleep(due - now); + } + } + *g = Some(Instant::now()); + } +} + +pub fn b64(s: &str) -> String { + use base64::Engine; + base64::engine::general_purpose::STANDARD.encode(s) +} diff --git a/src/core/library.rs b/src/core/library.rs new file mode 100644 index 0000000..1e0e547 --- /dev/null +++ b/src/core/library.rs @@ -0,0 +1,88 @@ +//! Scanning the music folder for the player's library, with a small cache so rescans are quick. + +use super::{paths, tagger}; +use serde::{Deserialize, Serialize}; +use std::collections::HashMap; +use std::path::{Path, PathBuf}; + +#[derive(Clone, Debug, Serialize, Deserialize)] +pub struct LibraryItem { + pub path: String, + pub title: String, + pub artist: String, + pub album: String, + pub duration: f64, + pub mtime: f64, + pub size: u64, +} + +fn cache_file() -> PathBuf { + paths::cache_dir().join("library-rs.json") +} + +fn load_cache() -> HashMap<String, LibraryItem> { + std::fs::read_to_string(cache_file()).ok().and_then(|s| serde_json::from_str(&s).ok()).unwrap_or_default() +} + +fn walk(dir: &Path, out: &mut Vec<PathBuf>) { + let Ok(rd) = std::fs::read_dir(dir) else { return }; + for e in rd.flatten() { + let p = e.path(); + let name = e.file_name().to_string_lossy().into_owned(); + if name.starts_with('.') { + continue; + } + if p.is_dir() { + walk(&p, out); + } else if paths::is_audio(&p) { + out.push(p); + } + } +} + +pub fn scan(folder: &str) -> Vec<LibraryItem> { + let root = PathBuf::from(paths::shellexpand(folder)); + if !root.is_dir() { + return vec![]; + } + let cache = load_cache(); + let mut files = vec![]; + walk(&root, &mut files); + let mut fresh = HashMap::new(); + let mut items = vec![]; + for p in files { + let Ok(md) = std::fs::metadata(&p) else { continue }; + let mtime = md.modified().ok().and_then(|m| m.duration_since(std::time::UNIX_EPOCH).ok()).map(|d| d.as_secs_f64()).unwrap_or(0.0); + let key = p.to_string_lossy().into_owned(); + let item = match cache.get(&key) { + Some(h) if (h.mtime - mtime).abs() < 1e-3 && h.size == md.len() => h.clone(), + _ => { + let t = tagger::read(&key, false); + LibraryItem { + title: if t.title.is_empty() { p.file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or_default() } else { t.title }, + artist: t.artist, + album: t.album, + duration: t.duration.unwrap_or(0.0), + mtime, + size: md.len(), + path: key.clone(), + } + } + }; + fresh.insert(key, item.clone()); + items.push(item); + } + if let Ok(s) = serde_json::to_string(&fresh) { + let _ = std::fs::write(cache_file(), s); + } + items +} + +pub fn forget(path: &str) { + let mut c = load_cache(); + if c.remove(path).is_some() { + if let Ok(s) = serde_json::to_string(&c) { + let _ = std::fs::write(cache_file(), s); + } + } +} diff --git a/src/core/lyrics.rs b/src/core/lyrics.rs new file mode 100644 index 0000000..467da79 --- /dev/null +++ b/src/core/lyrics.rs @@ -0,0 +1,131 @@ +//! Lyrics from LRCLIB (free, no key) and an LRC parser for the player. + +use super::http; +use super::textutil::{clean_title, match_score, strip_feat}; +use super::Res; +use regex::Regex; +use serde_json::Value; +use std::sync::LazyLock; + +const API: &str = "https://lrclib.net/api"; +static TS: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"\[(\d{1,3}):(\d{1,2})(?:[.:](\d{1,3}))?\]").unwrap()); +static OFFSET: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"(?im)^\[offset:\s*([+-]?\d+)\]").unwrap()); +static WORD_TS: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"<\d+:\d+(?:\.\d+)?>").unwrap()); +static ANY_BRACKET: LazyLock<Regex> = LazyLock::new(|| Regex::new(r"\[[^\]]*\]").unwrap()); + +#[derive(Clone, Debug, Default)] +pub struct Lyrics { + pub plain: String, + pub synced: String, + pub instrumental: bool, +} + +impl Lyrics { + pub fn found(&self) -> bool { + !self.plain.is_empty() || !self.synced.is_empty() || self.instrumental + } +} + +fn from_record(r: &Value) -> Lyrics { + let s = |k: &str| r.get(k).and_then(|v| v.as_str()).unwrap_or("").to_string(); + Lyrics { plain: s("plainLyrics"), synced: s("syncedLyrics"), instrumental: r.get("instrumental").and_then(|v| v.as_bool()).unwrap_or(false) } +} + +/// LRCLIB has junk records (e.g. a lone "[00:00.00]probe"); real lyrics have a few lines. +fn usable(r: &Value) -> bool { + if r.get("instrumental").and_then(|v| v.as_bool()).unwrap_or(false) { + return true; + } + let text = r.get("syncedLyrics").and_then(|v| v.as_str()).filter(|s| !s.is_empty()).or_else(|| r.get("plainLyrics").and_then(|v| v.as_str())).unwrap_or(""); + text.lines().filter(|l| !ANY_BRACKET.replace_all(l, "").trim().is_empty()).count() >= 3 +} + +pub fn fetch(title: &str, artist: &str, album: &str, duration: Option<f64>) -> Res<Lyrics> { + let title_q = strip_feat(&clean_title(title)); + let artist_q = artist.split(',').next().unwrap_or("").trim().to_string(); + let ua = http::app_ua(); + let hdr = [("Lrclib-Client", ua.as_str())]; + let base = [("track_name", title_q.clone()), ("artist_name", artist_q.clone())]; + let mut attempts: Vec<Vec<(&str, String)>> = vec![]; + if let Some(d) = duration.filter(|d| *d > 0.0) { + let d = format!("{}", d.round() as i64); + if !album.is_empty() { + let mut a = base.to_vec(); + a.push(("album_name", album.to_string())); + a.push(("duration", d.clone())); + attempts.push(a); + } + let mut a = base.to_vec(); + a.push(("duration", d)); + attempts.push(a); + } + for params in attempts { + match http::get_json(&format!("{API}/get"), ¶ms, false, &hdr) { + Ok(r) if usable(&r) => return Ok(from_record(&r)), + Ok(_) => {} + Err(e) if e.status == 404 => {} + Err(e) => return Err(e.to_string()), + } + } + let mut results = http::get_json(&format!("{API}/search"), &base, false, &hdr)?; + if results.as_array().map(|a| a.is_empty()).unwrap_or(true) { + results = http::get_json(&format!("{API}/search"), &[("q", format!("{artist_q} {title_q}"))], false, &hdr)?; + } + let mut best: Option<&Value> = None; + let mut best_score = 0.0; + for r in results.as_array().into_iter().flatten() { + if !usable(r) { + continue; + } + let name = r.get("trackName").and_then(|v| v.as_str()).unwrap_or(""); + let art = r.get("artistName").and_then(|v| v.as_str()).unwrap_or(""); + let mut score = match_score(&title_q, &[artist_q.clone()], duration, name, &[art.to_string()], r.get("duration").and_then(|v| v.as_f64())); + if r.get("syncedLyrics").and_then(|v| v.as_str()).map(|s| !s.is_empty()).unwrap_or(false) { + score += 0.05; + } + if score > best_score { + best = Some(r); + best_score = score; + } + } + Ok(match best { + Some(r) if best_score >= 0.6 => from_record(r), + _ => Lyrics::default(), + }) +} + +pub fn is_synced(text: &str) -> bool { + !text.is_empty() && TS.find_iter(text).count() >= 3 +} + +/// [(milliseconds, line)] sorted by time. Lines with several stamps appear once per stamp. +pub fn parse_lrc(text: &str) -> Vec<(i64, String)> { + let offset = OFFSET.captures(text).and_then(|c| c[1].parse::<i64>().ok()).unwrap_or(0); + let mut out = vec![]; + for raw in text.lines() { + let stamps: Vec<_> = TS.captures_iter(raw).collect(); + if stamps.is_empty() { + continue; + } + let line = TS.replace_all(raw, ""); + let line = WORD_TS.replace_all(&line, "").trim().to_string(); + for s in stamps { + let m: i64 = s[1].parse().unwrap_or(0); + let sec: i64 = s[2].parse().unwrap_or(0); + let frac = s.get(3).map(|f| f.as_str()).unwrap_or("0"); + let ms: i64 = format!("{frac:0<3}")[..3].parse().unwrap_or(0); + out.push(((m * 60000 + sec * 1000 + ms - offset).max(0), line.clone())); + } + } + out.sort_by_key(|x| x.0); + out +} + +pub fn lrc_to_plain(text: &str) -> String { + let lines: Vec<String> = parse_lrc(text).into_iter().map(|x| x.1).collect(); + if lines.is_empty() { + text.to_string() + } else { + lines.join("\n") + } +} diff --git a/src/core/matcher.rs b/src/core/matcher.rs new file mode 100644 index 0000000..4739ce5 --- /dev/null +++ b/src/core/matcher.rs @@ -0,0 +1,101 @@ +//! Finding a downloadable recording for tracks from services yt-dlp can't download from +//! (Spotify, Apple Music, Deezer, Tidal, Amazon Music...): search YouTube Music, YouTube or +//! SoundCloud and keep the closest match by name, artist and length. + +use super::metadata::{jarr, js}; +use super::models::Track; +use super::textutil::*; +use super::{ytdlp, ytmusic, Log}; +use serde_json::Value; + +pub fn search_ytdlp(snap: &Value, query: &str, site: &str, limit: usize, log: Log) -> Result<Vec<Track>, String> { + let info = ytdlp::extract(snap, &format!("{site}{limit}:{query}"), true, &[], log)?; + let mut out = vec![]; + for e in jarr(&info, "entries") { + let url = js(e, "url"); + if url.is_empty() { + continue; + } + let uploader = Some(js(e, "channel")).filter(|s| !s.is_empty()).unwrap_or_else(|| js(e, "uploader")); + let (artist, title) = split_artist_title(&js(e, "title"), &uploader); + let mut t = Track::new(); + t.title = title; + t.artists = if artist.is_empty() { vec![] } else { vec![artist.clone()] }; + t.duration = e.get("duration").and_then(|d| d.as_f64()); + t.download_url = url.clone(); + t.page_url = url; + t.source_id = js(e, "id"); + t.service = if site == "ytsearch" { "youtube".into() } else { "soundcloud".into() }; + t.cover_url = jarr(e, "thumbnails").last().map(|t| js(t, "url")).unwrap_or_default(); + t.official = uploader.ends_with(" - Topic") || uploader.to_lowercase() == artist.to_lowercase(); + t.uploader = uploader; + out.push(t); + } + Ok(out) +} + +/// The best downloadable candidate for `track`, or None. +pub fn find_match(snap: &Value, track: &Track, source: &str, log: Log) -> Option<Track> { + let title = strip_feat(&clean_title(&track.value("title"))); + let artist = track.value("artist"); + let artists: Vec<String> = if track.artists.is_empty() { vec![artist] } else { track.artists.clone() }.iter().filter(|a| !a.is_empty()).map(|a| clean_artist(a)).collect(); + let query = format!("{} {}", artists.first().cloned().unwrap_or_default(), title).trim().to_string(); + + let mut candidates: Vec<Track> = vec![]; + if source == "ytmusic" { + // An ISRC search pins the exact recording when we have one. + if !track.isrc.is_empty() { + match ytmusic::search_songs(&track.isrc, 3) { + Ok(list) => { + for mut c in list { + if track.duration.is_none() || c.duration.is_none() || (c.duration.unwrap() - track.duration.unwrap()).abs() <= 4.0 { + c.isrc_hit = true; + candidates.push(c); + } + } + } + Err(e) => log("warning", &format!("ISRC search failed: {e}")), + } + } + match ytmusic::search_songs(&query, 10) { + Ok(list) => candidates.extend(list), + Err(e) => log("warning", &format!("YouTube Music search failed: {e}")), + } + } + if source == "soundcloud" { + match search_ytdlp(snap, &query, "scsearch", 8, log) { + Ok(l) => candidates.extend(l), + Err(e) => log("warning", &format!("SoundCloud search failed: {e}")), + } + } + let score = |c: &Track| { + let mut s = match_score(&title, &artists, track.duration, &c.title, &c.artists, c.duration); + if c.isrc_hit { + s += 0.1; + } + if c.official { + s += 0.05; + } + s + }; + let mut scored: Vec<(f64, Track)> = candidates.into_iter().map(|c| (score(&c), c)).collect(); + let sort = |v: &mut Vec<(f64, Track)>| v.sort_by(|a, b| b.0.partial_cmp(&a.0).unwrap_or(std::cmp::Ordering::Equal)); + sort(&mut scored); + if scored.first().map(|s| s.0 < 0.7).unwrap_or(true) { + // Songs search came up short: try plain YouTube. + match search_ytdlp(snap, &format!("{query} audio"), "ytsearch", 8, log) { + Ok(extra) => { + scored.extend(extra.into_iter().map(|c| (score(&c), c))); + sort(&mut scored); + } + Err(e) => log("warning", &format!("YouTube search failed: {e}")), + } + } + let (best_score, mut best) = scored.into_iter().next()?; + log("match", &format!("Matched “{} – {}” on {} ({:.0}%) {}", best.artist(), best.title, best.service, best_score * 100.0, best.download_url)); + if best_score < 0.45 { + return None; + } + best.score = best_score; + Some(best) +} diff --git a/src/core/metadata.rs b/src/core/metadata.rs new file mode 100644 index 0000000..8208c85 --- /dev/null +++ b/src/core/metadata.rs @@ -0,0 +1,509 @@ +//! Free, keyless metadata lookups (Deezer, iTunes, MusicBrainz) and choosing tags per field. + +use super::http::{self, RateLimiter}; +use super::models::Track; +use super::settings::{get_bool, get_f64, get_i64, lookup}; +use super::textutil::*; +use super::Log; +use regex::Regex; +use serde_json::Value; +use std::collections::BTreeMap; + +static MB_LIMIT: RateLimiter = RateLimiter::new(1100); + +pub fn provider_name(p: &str) -> &'static str { + match p { + "deezer" => "Deezer", + "itunes" => "iTunes", + "musicbrainz" => "MusicBrainz", + _ => "Source", + } +} + +#[derive(Clone, Debug, Default)] +pub struct Candidate { + pub provider: String, + pub title: String, + pub artists: Vec<String>, + pub album: String, + pub album_artist: String, + pub track_number: Option<i64>, + pub track_total: Option<i64>, + pub disc_number: Option<i64>, + pub year: String, + pub genre: String, + pub isrc: String, + pub cover_url: String, + pub duration: Option<f64>, + pub score: f64, + pub id: String, + pub url: String, + pub album_id: Option<i64>, +} + +impl Candidate { + pub fn artist(&self) -> String { + self.artists.join(", ") + } +} + +pub fn js(v: &Value, k: &str) -> String { + match v.get(k) { + Some(Value::String(s)) => s.clone(), + Some(Value::Number(n)) => n.to_string(), + _ => String::new(), + } +} +pub fn ji(v: &Value, k: &str) -> Option<i64> { + v.get(k).and_then(|x| x.as_i64().or_else(|| x.as_f64().map(|f| f as i64))) +} +pub fn jf(v: &Value, k: &str) -> Option<f64> { + v.get(k).and_then(|x| x.as_f64()) +} +pub fn jarr<'a>(v: &'a Value, k: &str) -> &'a [Value] { + v.get(k).and_then(|x| x.as_array()).map(|a| a.as_slice()).unwrap_or(&[]) +} + +fn score(track: &Track, title: &str, artists: &[String], c: &Candidate) -> f64 { + let mut s = match_score(title, artists, track.duration, &c.title, &c.artists, c.duration); + s -= album_penalty(&track.album, &c.album); + // Between equally good matches, prefer the album release over a single. + static SINGLE: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| Regex::new(r"(?i)-\s*(single|ep)$").unwrap()); + if !c.album.is_empty() && normalize(&c.album) != normalize(&c.title) && !SINGLE.is_match(&c.album) { + s += 0.02; + } + s.max(0.0) +} + +fn query_parts(track: &Track) -> (String, Vec<String>) { + let title = strip_feat(&clean_title(&track.value("title"))); + let artist = track.value("artist"); + static SPLIT: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| Regex::new(r"(?i),|&| x | feat\.? ").unwrap()); + let artists = if artist.is_empty() { vec![] } else { SPLIT.split(&artist).map(|a| a.trim().to_string()).filter(|a| !a.is_empty()).collect() }; + (title, artists) +} + +fn sort(mut v: Vec<Candidate>) -> Vec<Candidate> { + v.sort_by(|a, b| b.score.partial_cmp(&a.score).unwrap_or(std::cmp::Ordering::Equal)); + v +} + +// ---- iTunes -------------------------------------------------------------------- + +pub fn itunes_cover(url: &str, size: i64) -> String { + static R: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| Regex::new(r"/\d+x\d+bb\.").unwrap()); + if url.is_empty() { + return String::new(); + } + R.replace(url, format!("/{size}x{size}bb.")).into_owned() +} + +fn itunes_candidate(r: &Value, cover_size: i64) -> Candidate { + let artist = js(r, "artistName"); + Candidate { + provider: "itunes".into(), + title: js(r, "trackName"), + artists: vec![artist.clone()], + album: js(r, "collectionName"), + album_artist: Some(js(r, "collectionArtistName")).filter(|s| !s.is_empty()).unwrap_or(artist), + track_number: ji(r, "trackNumber"), + track_total: ji(r, "trackCount"), + disc_number: ji(r, "discNumber"), + year: parse_year(&js(r, "releaseDate")), + genre: js(r, "primaryGenreName"), + cover_url: itunes_cover(&js(r, "artworkUrl100"), cover_size), + duration: ji(r, "trackTimeMillis").filter(|m| *m > 0).map(|m| m as f64 / 1000.0), + id: js(r, "trackId"), + url: js(r, "trackViewUrl"), + ..Default::default() + } +} + +pub fn search_itunes(track: &Track, cover_size: i64) -> Result<Vec<Candidate>, String> { + let (title, artists) = query_parts(track); + let term = format!("{} {}", artists.first().cloned().unwrap_or_default(), title).trim().to_string(); + let data = http::get_json("https://itunes.apple.com/search", &[("term", term), ("entity", "song".into()), ("limit", "15".into()), ("media", "music".into())], false, &[])?; + let out = jarr(&data, "results") + .iter() + .map(|r| { + let mut c = itunes_candidate(r, cover_size); + c.score = score(track, &title, &artists, &c); + c + }) + .collect(); + Ok(sort(out)) +} + +pub fn itunes_lookup(id: &str, country: &str, entity: Option<&str>) -> Result<Vec<Value>, String> { + let mut p = vec![("id", id.to_string()), ("country", country.to_string())]; + if let Some(e) = entity { + p.push(("entity", e.to_string())); + } + Ok(jarr(&http::get_json("https://itunes.apple.com/lookup", &p, false, &[])?, "results").to_vec()) +} + +// ---- Deezer -------------------------------------------------------------------- + +pub fn deezer_cover(url: &str, size: i64) -> String { + static R: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| Regex::new(r"/\d+x\d+-").unwrap()); + if url.is_empty() { + return String::new(); + } + let s = size.min(1900); + R.replace(url, format!("/{s}x{s}-")).into_owned() +} + +pub fn search_deezer(track: &Track, cover_size: i64) -> Result<Vec<Candidate>, String> { + let (title, artists) = query_parts(track); + let q = format!("{} {}", artists.first().cloned().unwrap_or_default(), title).trim().to_string(); + let data = http::get_json("https://api.deezer.com/search", &[("q", q), ("limit", "15".into())], false, &[])?; + if let Some(e) = data.get("error") { + return Err(js(e, "message")); + } + let out = jarr(&data, "data") + .iter() + .map(|r| { + let album = r.get("album").cloned().unwrap_or(Value::Null); + let mut c = Candidate { + provider: "deezer".into(), + title: js(r, "title"), + artists: vec![js(r.get("artist").unwrap_or(&Value::Null), "name")], + album: js(&album, "title"), + cover_url: deezer_cover(&js(&album, "cover_xl"), cover_size), + duration: jf(r, "duration"), + isrc: js(r, "isrc"), + id: js(r, "id"), + url: js(r, "link"), + album_id: ji(&album, "id"), + ..Default::default() + }; + c.score = score(track, &title, &artists, &c); + c + }) + .collect(); + Ok(sort(out)) +} + +/// Search results lack track numbers, dates and genres; fetch them for the chosen one. +pub fn deezer_details(mut c: Candidate, cover_size: i64) -> Candidate { + let go = |c: &mut Candidate| -> Result<(), String> { + let t = http::get_json(&format!("https://api.deezer.com/track/{}", c.id), &[], false, &[])?; + if t.get("error").is_some() { + return Ok(()); + } + c.track_number = ji(&t, "track_position").or(c.track_number); + c.disc_number = ji(&t, "disk_number").or(c.disc_number); + let y = parse_year(&js(&t, "release_date")); + if !y.is_empty() { + c.year = y; + } + if !js(&t, "isrc").is_empty() { + c.isrc = js(&t, "isrc"); + } + let main: Vec<String> = jarr(&t, "contributors").iter().filter(|x| js(x, "role") == "Main").map(|x| js(x, "name")).collect(); + if !main.is_empty() { + c.artists = main; + } + let album_id = t.get("album").and_then(|a| ji(a, "id")).or(c.album_id); + if let Some(id) = album_id { + let a = http::get_json(&format!("https://api.deezer.com/album/{id}"), &[], false, &[])?; + if a.get("error").is_none() { + if !js(&a, "title").is_empty() { + c.album = js(&a, "title"); + } + c.album_artist = js(a.get("artist").unwrap_or(&Value::Null), "name"); + c.track_total = ji(&a, "nb_tracks"); + c.genre = a.get("genres").map(|g| jarr(g, "data")).and_then(|g| g.first()).map(|g| js(g, "name")).unwrap_or_default(); + let y = parse_year(&js(&a, "release_date")); + if !y.is_empty() { + c.year = y; + } + let cv = deezer_cover(&js(&a, "cover_xl"), cover_size); + if !cv.is_empty() { + c.cover_url = cv; + } + } + } + Ok(()) + }; + let _ = go(&mut c); // details are a bonus + c +} + +// ---- MusicBrainz --------------------------------------------------------------- + +fn lucene(t: &str) -> String { + static R: std::sync::LazyLock<Regex> = std::sync::LazyLock::new(|| Regex::new(r#"([+\-!(){}\[\]^"~*?:\\/]|&&|\|\|)"#).unwrap()); + R.replace_all(t, r"\$1").into_owned() +} + +pub fn search_musicbrainz(track: &Track, cover_size: i64) -> Result<Vec<Candidate>, String> { + let (title, artists) = query_parts(track); + let mut q = format!("recording:\"{}\"", lucene(&title)); + if let Some(a) = artists.first() { + q += &format!(" AND artist:\"{}\"", lucene(a)); + } + MB_LIMIT.wait(); + let data = http::get_json("https://musicbrainz.org/ws/2/recording", &[("query", q), ("fmt", "json".into()), ("limit", "10".into())], false, &[])?; + let mut out = vec![]; + for r in jarr(&data, "recordings") { + let credit = jarr(r, "artist-credit"); + let names: Vec<String> = credit.iter().map(|x| js(x, "name")).collect(); + let rank = |rel: &&Value| { + let group = rel.get("release-group").cloned().unwrap_or(Value::Null); + ( + js(rel, "status") == "Official", + js(&group, "primary-type") == "Album", + jarr(&group, "secondary-types").is_empty(), + -(parse_year(&js(rel, "date")).parse::<i64>().unwrap_or(9999)), + ) + }; + let rel = jarr(r, "releases").iter().max_by_key(rank).cloned().unwrap_or(Value::Null); + let media = jarr(&rel, "media").first().cloned().unwrap_or(Value::Null); + let tr = jarr(&media, "track").first().cloned().unwrap_or(Value::Null); + let size = if cover_size >= 1000 { 1200 } else { 500 }; + let rel_credit = jarr(&rel, "artist-credit"); + let album_artist = (if rel_credit.is_empty() { credit } else { rel_credit }).iter().map(|x| js(x, "name")).collect::<Vec<_>>().join(", "); + let mut tags: Vec<&Value> = jarr(r, "tags").iter().collect(); + tags.sort_by_key(|t| -ji(t, "count").unwrap_or(0)); + let mut c = Candidate { + provider: "musicbrainz".into(), + title: js(r, "title"), + artists: names, + album: js(&rel, "title"), + album_artist, + track_number: to_int(&js(&tr, "number")), + track_total: ji(&media, "track-count"), + disc_number: ji(&media, "position"), + year: parse_year(&{ + let d = js(&rel, "date"); + if d.is_empty() { js(r, "first-release-date") } else { d } + }), + isrc: jarr(r, "isrcs").first().and_then(|v| v.as_str()).unwrap_or("").to_string(), + cover_url: if js(&rel, "id").is_empty() { String::new() } else { format!("https://coverartarchive.org/release/{}/front-{size}", js(&rel, "id")) }, + duration: ji(r, "length").filter(|l| *l > 0).map(|l| l as f64 / 1000.0), + id: js(r, "id"), + url: format!("https://musicbrainz.org/recording/{}", js(r, "id")), + genre: tags.first().map(|t| title_case(&js(t, "name"))).unwrap_or_default(), + ..Default::default() + }; + c.score = score(track, &title, &artists, &c); + out.push(c); + } + Ok(sort(out)) +} + +fn title_case(s: &str) -> String { + s.split(' ').map(|w| { + let mut cs = w.chars(); + match cs.next() { + Some(f) => f.to_uppercase().collect::<String>() + &cs.as_str().to_lowercase(), + None => String::new(), + } + }).collect::<Vec<_>>().join(" ") +} + +pub fn search_one(name: &str, track: &Track, cover_size: i64) -> Result<Vec<Candidate>, String> { + match name { + "deezer" => search_deezer(track, cover_size), + "itunes" => search_itunes(track, cover_size), + "musicbrainz" => search_musicbrainz(track, cover_size), + _ => Ok(vec![]), + } +} + +/// Every enabled provider's candidates, best first. +pub fn search_all(track: &Track, providers: &[String], cover_size: i64, log: Log) -> BTreeMap<String, Vec<Candidate>> { + let mut results = BTreeMap::new(); + std::thread::scope(|s| { + let handles: Vec<_> = providers.iter().map(|p| (p.clone(), s.spawn(move || search_one(p, track, cover_size)))).collect(); + for (name, h) in handles { + match h.join().unwrap_or_else(|_| Err("panicked".into())) { + Ok(c) => { + results.insert(name, c); + } + Err(e) => { + log("warning", &format!("{} lookup failed: {e}", provider_name(&name))); + results.insert(name, vec![]); + } + } + } + }); + results +} + +// ---- choosing values per field ------------------------------------------------- + +const ALBUM_FIELDS: &[&str] = &["album", "album_artist", "track_number", "disc_number", "year", "cover"]; + +fn auto_order(key: &str) -> &'static [&'static str] { + match key { + "genre" => &["itunes", "deezer", "musicbrainz"], + "isrc" => &["deezer", "musicbrainz", "itunes"], + "cover" => &["itunes", "deezer", "musicbrainz"], + _ => &["deezer", "itunes", "musicbrainz"], + } +} + +/// Providers by match quality; near-ties (within 0.05) keep the field's preferred order. +fn ranked(best: &BTreeMap<String, Candidate>, order: &[&str]) -> Vec<String> { + let present: Vec<&str> = order.iter().copied().filter(|p| best.contains_key(*p)).collect(); + if present.is_empty() { + return vec![]; + } + let top = present.iter().map(|p| best[*p].score).fold(f64::MIN, f64::max); + let (near, rest): (Vec<&str>, Vec<&str>) = present.into_iter().partition(|p| best[*p].score >= top - 0.05); + let mut rest = rest; + rest.sort_by(|a, b| best[*b].score.partial_cmp(&best[*a].score).unwrap_or(std::cmp::Ordering::Equal)); + near.into_iter().chain(rest).map(String::from).collect() +} + +fn candidate_str(c: &Candidate, key: &str) -> Option<String> { + let non = |s: &str| Some(s.to_string()).filter(|s| !s.is_empty()); + let num = |n: Option<i64>| n.map(|n| n.to_string()); + match key { + "cover" => non(&c.cover_url), + "album" => non(&c.album), + "album_artist" => non(&c.album_artist), + "year" => non(&c.year), + "genre" => non(&c.genre), + "isrc" => non(&c.isrc), + "title" => non(&c.title), + "track_number" => num(c.track_number), + "disc_number" => num(c.disc_number), + _ => None, + } +} + +fn apply(track: &mut Track, key: &str, cand: &Candidate) { + match key { + "artist" => track.artists = cand.artists.iter().filter(|a| !a.is_empty()).cloned().collect(), + "cover" => track.cover_url = cand.cover_url.clone(), + "track_number" => { + track.track_number = cand.track_number; + if cand.track_total.is_some() { + track.track_total = cand.track_total; + } + } + "title" => track.title = cand.title.clone(), + "album" => track.album = cand.album.clone(), + "album_artist" => track.album_artist = cand.album_artist.clone(), + "disc_number" => track.disc_number = cand.disc_number, + "year" => track.year = cand.year.clone(), + "genre" => track.genre = cand.genre.clone(), + "isrc" => track.isrc = cand.isrc.clone(), + _ => {} + } +} + +fn has_value(c: &Candidate, key: &str) -> bool { + if key == "artist" { !c.artists.is_empty() } else { candidate_str(c, key).is_some() } +} + +/// Fill the track's tags from the best matches, following the per-field settings. +pub fn enrich(track: &mut Track, snap: &Value, log: Log) -> BTreeMap<String, Vec<Candidate>> { + if !get_bool(snap, "metadata.enabled") { + track.enriched = true; + return BTreeMap::new(); + } + let mut providers: Vec<String> = lookup(snap, "metadata.providers").and_then(|v| v.as_object()).map(|o| o.iter().filter(|(_, v)| v.as_bool().unwrap_or(false)).map(|(k, _)| k.clone()).collect()).unwrap_or_default(); + let fields: Vec<(String, String)> = lookup(snap, "metadata.fields").and_then(|v| v.as_object()).map(|o| o.iter().map(|(k, v)| (k.clone(), v.as_str().unwrap_or("auto").to_string())).collect()).unwrap_or_default(); + // A field pinned to a provider needs that provider even when it is off for "auto". + for (_, src) in &fields { + if ["deezer", "itunes", "musicbrainz"].contains(&src.as_str()) && !providers.contains(src) { + providers.push(src.clone()); + } + } + let threshold = { let t = get_f64(snap, "metadata.match_threshold"); if t > 0.0 { t } else { 0.72 } }; + let cover_size = { let c = get_i64(snap, "metadata.cover_size"); if c > 0 { c } else { 1200 } }; + + let results = if providers.is_empty() { BTreeMap::new() } else { search_all(track, &providers, cover_size, log) }; + let mut best: BTreeMap<String, Candidate> = BTreeMap::new(); + for (name, cands) in &results { + if let Some(c) = cands.first().filter(|c| c.score >= threshold) { + best.insert(name.clone(), c.clone()); + } + } + if let Some(d) = best.remove("deezer") { + best.insert("deezer".into(), deezer_details(d, cover_size)); + } + for (name, c) in &best { + log("meta", &format!("{}: {} – {} [{}] (match {:.0}%)", provider_name(name), c.artist(), c.title, c.album, c.score * 100.0)); + } + if !providers.is_empty() && best.is_empty() { + log("warning", "No confident metadata match; keeping the source's tags"); + } + + // When the source already names the album, only trust candidates from that album for album fields. + let same_album = |track: &Track, c: &Candidate| !(track.authoritative && !track.album.is_empty()) || similarity(&track.album, &c.album) >= 0.6; + let album_cands: Vec<&str> = ["deezer", "itunes", "musicbrainz"].into_iter().filter(|n| best.get(*n).map(|c| same_album(track, c)).unwrap_or(false)).collect(); + let album_source = album_cands.iter().max_by(|a, b| best[**a].score.partial_cmp(&best[**b].score).unwrap_or(std::cmp::Ordering::Equal)).map(|s| s.to_string()); + let mut skip: Vec<String> = track.skip_fields.clone(); + for (key, src) in &fields { + if track.overrides.contains_key(key) { + continue; + } + if src == "off" { + if !skip.contains(key) { + skip.push(key.clone()); + } + continue; + } + skip.retain(|k| k != key); + if src == "source" { + continue; + } + let order: Vec<String> = if ["deezer", "itunes", "musicbrainz"].contains(&src.as_str()) { + vec![src.clone()] + } else if ALBUM_FIELDS.contains(&key.as_str()) && album_source.is_some() { + let a = album_source.clone().unwrap(); + let mut o = vec![a.clone()]; + o.extend(ranked(&best, auto_order(key)).into_iter().filter(|p| *p != a)); + o + } else { + ranked(&best, auto_order(key)) + }; + let source_has = match key.as_str() { + "cover" => !track.cover_url.is_empty(), + "artist" => !track.artists.is_empty(), + "title" => !track.title.is_empty(), + "album" => !track.album.is_empty(), + "album_artist" => !track.album_artist.is_empty(), + "year" => !track.year.is_empty(), + _ => false, + }; + if src == "auto" && source_has && (key == "title" || key == "artist" || (track.authoritative && ["album", "album_artist", "year"].contains(&key.as_str()))) { + continue; // what the user picked names the song; Spotify and friends also know their albums + } + let mut usable: Vec<&Candidate> = order.iter().filter_map(|n| best.get(n)).filter(|c| !ALBUM_FIELDS.contains(&key.as_str()) || same_album(track, c)).collect(); + if key == "isrc" { + usable.retain(|c| c.score >= 0.9); // an ISRC pins one exact recording + } + if key == "year" && src == "auto" { + if let Some(top) = usable.first().map(|c| c.score) { + let years: Vec<&String> = usable.iter().filter(|c| !c.year.is_empty() && c.score >= top - 0.05).map(|c| &c.year).collect(); + if let Some(y) = years.into_iter().min() { + track.year = y.clone(); + } + } + continue; + } + if let Some(c) = usable.into_iter().find(|c| has_value(c, key)) { + let c = c.clone(); + apply(track, key, &c); + } + } + skip.sort(); + track.skip_fields = skip; + track.enriched = true; + results +} + +/// The tag editor's 'use this match' button: take every field from one candidate. +pub fn apply_candidate(track: &mut Track, c: &Candidate) { + for key in ["title", "artist", "album", "album_artist", "track_number", "disc_number", "year", "genre", "isrc", "cover"] { + if has_value(c, key) { + apply(track, key, c); + } + } +} diff --git a/src/core/mod.rs b/src/core/mod.rs new file mode 100644 index 0000000..fec5c5b --- /dev/null +++ b/src/core/mod.rs @@ -0,0 +1,25 @@ +//! Everything that isn't UI: link resolving, matching, tags, lyrics, downloading. + +pub mod covers; +pub mod downloader; +pub mod http; +pub mod library; +pub mod lyrics; +pub mod matcher; +pub mod metadata; +pub mod models; +pub mod paths; +pub mod resolvers; +pub mod settings; +pub mod spotify; +pub mod tagger; +pub mod template; +pub mod textutil; +pub mod ytdlp; +pub mod ytmusic; + +/// Log callback: (kind, text). Kinds: info, warning, error, success, yt, meta, match, progress, debug. +pub type Log<'a> = &'a (dyn Fn(&str, &str) + Sync); +pub type Res<T> = Result<T, String>; + +pub fn no_log(_: &str, _: &str) {} diff --git a/src/core/models.rs b/src/core/models.rs new file mode 100644 index 0000000..d7b96c3 --- /dev/null +++ b/src/core/models.rs @@ -0,0 +1,188 @@ +//! The data that moves between the resolver, the downloader and the UI. + +use std::collections::HashMap; +use std::sync::atomic::{AtomicU64, Ordering}; + +static IDS: AtomicU64 = AtomicU64::new(1); +pub fn next_id() -> u64 { + IDS.fetch_add(1, Ordering::Relaxed) +} + +/// Fields a user can edit by hand; they win over anything looked up. +pub const EDITABLE_FIELDS: &[&str] = &["title", "artist", "album", "album_artist", "track_number", "track_total", "disc_number", "year", "genre", "isrc", "comment"]; + +#[derive(Clone, Debug, Default)] +pub struct Track { + pub title: String, + pub artists: Vec<String>, + pub album: String, + pub album_artist: String, + pub track_number: Option<i64>, + pub track_total: Option<i64>, + pub disc_number: Option<i64>, + pub year: String, + pub genre: String, + pub isrc: String, + pub comment: String, + pub duration: Option<f64>, + pub cover_url: String, + + pub service: String, + pub page_url: String, + /// Something yt-dlp can download; empty means "find a match". + pub download_url: String, + pub source_id: String, + pub playlist: String, + pub playlist_index: Option<i64>, + /// Fields from a flat playlist listing are guesses; the full extraction may replace them. + pub weak: bool, + /// Authoritative sources keep their title/artist. + pub authoritative: bool, + + // what used to be the `extra` dict + pub folder: Vec<String>, + pub match_cover: String, + pub thumbnail: String, + pub skip_fields: Vec<String>, + pub uploader: String, + pub official: bool, + pub isrc_hit: bool, + pub score: f64, + pub info_ready: bool, + + pub enriched: bool, + pub overrides: HashMap<String, String>, + pub cover_override: Option<Vec<u8>>, + pub lyrics_override: Option<String>, + pub matched: Option<MatchInfo>, + pub uid: u64, +} + +#[derive(Clone, Debug, Default)] +pub struct MatchInfo { + pub service: String, + pub title: String, + pub artist: String, + pub url: String, + pub score: f64, +} + +impl Track { + pub fn new() -> Track { + Track { uid: next_id(), ..Default::default() } + } + pub fn artist(&self) -> String { + self.artists.iter().filter(|a| !a.is_empty()).cloned().collect::<Vec<_>>().join(", ") + } + pub fn display_artist(&self) -> String { + self.overrides.get("artist").filter(|s| !s.is_empty()).cloned().unwrap_or_else(|| self.artist()) + } + pub fn display_title(&self) -> String { + self.overrides.get("title").filter(|s| !s.is_empty()).cloned().or_else(|| Some(self.title.clone()).filter(|s| !s.is_empty())).unwrap_or_else(|| "Unknown title".into()) + } + /// A field's final value as text: the hand edit when there is one. + pub fn value(&self, key: &str) -> String { + if let Some(v) = self.overrides.get(key).filter(|v| !v.is_empty()) { + return v.clone(); + } + let num = |n: Option<i64>| n.map(|n| n.to_string()).unwrap_or_default(); + match key { + "title" => self.title.clone(), + "artist" => self.artist(), + "album" => self.album.clone(), + "album_artist" => self.album_artist.clone(), + "track_number" => num(self.track_number), + "track_total" => num(self.track_total), + "disc_number" => num(self.disc_number), + "year" => self.year.clone(), + "genre" => self.genre.clone(), + "isrc" => self.isrc.clone(), + "comment" => self.comment.clone(), + _ => String::new(), + } + } +} + +#[derive(Clone, Debug, Default)] +pub struct ResolveResult { + /// "track" | "collection" | "search" + pub kind: String, + pub title: String, + pub subtitle: String, + pub cover_url: String, + pub service: String, + pub url: String, + pub tracks: Vec<Track>, + pub note: String, + pub artist: bool, + pub mode: String, +} + +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +pub enum JobState { + Queued, + Resolving, + Matching, + Downloading, + Converting, + Metadata, + Lyrics, + Tagging, + Done, + Skipped, + Failed, + Cancelled, +} + +impl JobState { + pub fn label(self) -> &'static str { + match self { + JobState::Queued => "Queued", + JobState::Resolving => "Getting info", + JobState::Matching => "Finding a match", + JobState::Downloading => "Downloading", + JobState::Converting => "Converting", + JobState::Metadata => "Looking up tags", + JobState::Lyrics => "Fetching lyrics", + JobState::Tagging => "Writing tags", + JobState::Done => "Done", + JobState::Skipped => "Already downloaded", + JobState::Failed => "Failed", + JobState::Cancelled => "Cancelled", + } + } + pub fn finished(self) -> bool { + matches!(self, JobState::Done | JobState::Skipped | JobState::Failed | JobState::Cancelled) + } + pub fn active(self) -> bool { + !self.finished() && self != JobState::Queued + } +} + +#[derive(Clone, Debug)] +pub struct DownloadOptions { + pub output_dir: String, + pub template: String, + pub format: String, + pub bitrate: String, + pub sample_rate: String, + pub bit_depth: String, + /// off | plain | synced + pub lyrics: String, + pub save_lrc: bool, + pub collection_folder: bool, +} + +#[derive(Clone, Debug)] +pub struct Job { + pub uid: u64, + pub track: Track, + pub options: DownloadOptions, + pub state: JobState, + pub progress: f32, + pub speed: Option<f64>, + pub eta: Option<f64>, + pub status: String, + pub error: String, + pub output_path: String, +} diff --git a/src/core/paths.rs b/src/core/paths.rs new file mode 100644 index 0000000..0bec36f --- /dev/null +++ b/src/core/paths.rs @@ -0,0 +1,77 @@ +//! Where Audiphi keeps things. Same folders as the Python version, so settings carry over. + +use crate::APP_ID; +use std::path::{Path, PathBuf}; + +pub fn config_dir() -> PathBuf { + let p = dirs::config_dir().unwrap_or_else(|| PathBuf::from(".")).join(APP_ID); + let _ = std::fs::create_dir_all(&p); + p +} + +pub fn cache_dir() -> PathBuf { + let p = dirs::cache_dir().unwrap_or_else(|| PathBuf::from(".")).join(APP_ID); + let _ = std::fs::create_dir_all(&p); + p +} + +pub fn music_dir() -> PathBuf { + dirs::audio_dir().unwrap_or_else(|| dirs::home_dir().unwrap_or_default().join("Music")) +} + +pub fn which(name: &str) -> Option<PathBuf> { + let path = std::env::var_os("PATH")?; + std::env::split_paths(&path).map(|d| d.join(name)).find(|p| p.is_file()) +} + +pub fn find_ffmpeg(configured: &str) -> Option<String> { + if !configured.is_empty() { + let mut p = PathBuf::from(shellexpand(configured)); + if p.is_dir() { + p = p.join("ffmpeg"); + } + if p.is_file() { + return Some(p.to_string_lossy().into_owned()); + } + } + if let Some(p) = which("ffmpeg") { + return Some(p.to_string_lossy().into_owned()); + } + let local = std::env::current_exe().ok()?.parent()?.join("ffmpeg"); + local.is_file().then(|| local.to_string_lossy().into_owned()) +} + +pub fn find_ytdlp() -> Option<String> { + if let Ok(exe) = std::env::current_exe() { + if let Some(p) = exe.parent().map(|d| d.join("yt-dlp")).filter(|p| p.is_file()) { + return Some(p.to_string_lossy().into_owned()); + } + } + which("yt-dlp").map(|p| p.to_string_lossy().into_owned()) +} + +pub fn js_runtimes() -> Vec<&'static str> { + ["deno", "node", "bun"].into_iter().filter(|n| which(n).is_some()).collect() +} + +pub fn shellexpand(p: &str) -> String { + if let Some(rest) = p.strip_prefix("~/") { + return dirs::home_dir().unwrap_or_default().join(rest).to_string_lossy().into_owned(); + } + if p == "~" { + return dirs::home_dir().unwrap_or_default().to_string_lossy().into_owned(); + } + p.to_string() +} + +pub fn caelestia_scheme() -> Option<PathBuf> { + let state = std::env::var_os("XDG_STATE_HOME").filter(|v| !v.is_empty()).map(PathBuf::from).unwrap_or_else(|| dirs::home_dir().unwrap_or_default().join(".local/state")); + let p = state.join("caelestia").join("scheme.json"); + p.is_file().then_some(p) +} + +pub const AUDIO_EXTENSIONS: &[&str] = &["mp3", "m4a", "flac", "opus", "ogg", "oga", "wav", "aiff", "aif", "aac", "webm", "alac", "wma"]; + +pub fn is_audio(p: &Path) -> bool { + p.extension().map(|e| AUDIO_EXTENSIONS.contains(&e.to_string_lossy().to_lowercase().as_str())).unwrap_or(false) +} diff --git a/src/core/resolvers.rs b/src/core/resolvers.rs new file mode 100644 index 0000000..8a034a7 --- /dev/null +++ b/src/core/resolvers.rs @@ -0,0 +1,832 @@ +//! Turning whatever the user pasted into tracks. +//! +//! Order of attempts: +//! 1. Services yt-dlp can't download from (Spotify, Deezer, Apple Music) are read through their free +//! public endpoints, then matched on YouTube Music later. +//! 2. Anything yt-dlp has a real extractor for (YouTube, SoundCloud, Bandcamp, Mixcloud, ... ~1800 sites) +//! is downloaded directly. +//! 3. Any other page is read for schema.org music data or OpenGraph tags, and its tracks are matched on +//! YouTube Music. That covers Tidal, Amazon Music, Qobuz, Napster, Pandora links and so on. +//! 4. Text that isn't a link is a search. + +use super::http::{self, RateLimiter}; +use super::matcher; +use super::metadata::{deezer_cover, itunes_cover, itunes_lookup, jarr, ji, js}; +use super::models::{ResolveResult, Track}; +use super::textutil::*; +use super::{spotify, ytdlp, ytmusic, Log, Res}; +use regex::Regex; +use serde_json::Value; +use std::collections::HashSet; +use std::sync::LazyLock; + +macro_rules! re { + ($pat:expr) => {{ + static R: LazyLock<Regex> = LazyLock::new(|| Regex::new($pat).unwrap()); + &*R + }}; +} + +pub fn service_name(key: &str) -> String { + match key { + "spotify" => "Spotify", + "deezer" => "Deezer", + "apple" => "Apple Music", + "youtube" => "YouTube", + "ytmusic" => "YouTube Music", + "soundcloud" => "SoundCloud", + "bandcamp" => "Bandcamp", + "tidal" => "Tidal", + "amazon" => "Amazon Music", + "mixcloud" => "Mixcloud", + "audiomack" => "Audiomack", + "search" => "Search", + "web" => "Web page", + "qobuz" => "Qobuz", + "vimeo" => "Vimeo", + "" => "Unknown", + o => return o.replace('_', " "), + } + .to_string() +} + +pub fn looks_like_url(text: &str) -> bool { + let t = text.trim(); + re!(r"(?i)^(https?://|www\.)\S+$").is_match(t) || re!(r"^[\w-]+(\.[\w-]+)+/\S*$").is_match(t) +} + +fn host_of(url: &str) -> String { + let rest = url.split("://").nth(1).unwrap_or(url); + let host = rest.split(['/', '?', '#']).next().unwrap_or("").to_lowercase(); + host.strip_prefix("www.").unwrap_or(&host).to_string() +} + +pub fn resolve(text: &str, snap: &Value, log: Log, mode: &str) -> Res<ResolveResult> { + let mut text = text.trim().to_string(); + if text.is_empty() { + return Err("Paste a link or type something to search for.".into()); + } + if let Some(rest) = text.strip_prefix("spotify:") { + let mut p = rest.split(':'); + let (kind, sid) = (p.next().unwrap_or(""), p.next().unwrap_or("")); + text = format!("https://open.spotify.com/{kind}/{sid}"); + } + if !looks_like_url(&text) { + return search(&text, snap, log); + } + let mut url = if re!(r"(?i)^https?://").is_match(&text) { text.clone() } else { format!("https://{text}") }; + let mut host = host_of(&url); + let cover_size = super::settings::get_i64(snap, "metadata.cover_size").max(300); + + if host == "spotify.link" || host == "spotify.app.link" || host.ends_with("deezer.page.link") || host == "link.deezer.com" { + url = http::final_url(&url)?; + host = host_of(&url); + } + if host.ends_with("spotify.com") { + return spotify::resolve(snap, &url, mode, cover_size, log); + } + if host.ends_with("deezer.com") { + return resolve_deezer(&url, log, cover_size, mode); + } + if ["music.apple.com", "itunes.apple.com", "geo.music.apple.com"].contains(&host.as_str()) { + if let Some(r) = resolve_apple(&url, log, cover_size, mode)? { + return Ok(r); + } + } + if host == "music.youtube.com" { + match resolve_ytmusic(&url, log, mode) { + Ok(Some(r)) => return Ok(r), + Ok(None) => {} + Err(e) => log("warning", &format!("YouTube Music page: {e}; asking yt-dlp instead")), + } + } + const PAGE_ONLY: &[&str] = &["tidal.com", "amazon.", "qobuz.com", "napster.com", "pandora.com", "anghami.com", "jiosaavn.com", "boomplay.com", "play.google.com"]; + if !PAGE_ONLY.iter().any(|h| host.contains(h)) { + match resolve_ytdlp(snap, &url, log) { + Ok(r) => return Ok(r), + Err(e) if e.contains("Unsupported URL") || e.contains("No suitable extractor") => {} + Err(e) => return Err(e), + } + } + resolve_page(&url, log) +} + +// ---- search -------------------------------------------------------------------- + +pub fn search(query: &str, snap: &Value, log: Log) -> Res<ResolveResult> { + log("info", &format!("Searching YouTube Music for “{query}”")); + let mut tracks = vec![]; + match ytmusic::search_songs(query, 12) { + Ok(t) => tracks = t, + Err(e) => log("warning", &format!("YouTube Music search failed: {e}")), + } + if tracks.is_empty() { + tracks = matcher::search_ytdlp(snap, query, "ytsearch", 10, log).unwrap_or_default(); + } + if tracks.is_empty() { + return Err(format!("Nothing found for “{query}”.")); + } + // YouTube Music sometimes ranks medleys or covers first; put the closest name on top. + let closeness = |t: &Track| { + let s = similarity(query, &format!("{} {}", t.artist(), t.title)).max(similarity(query, &format!("{} {}", t.title, t.artist()))); + s - 0.5 * version_penalty(query, &t.title) + }; + let best = (0..tracks.len()).max_by(|a, b| closeness(&tracks[*a]).partial_cmp(&closeness(&tracks[*b])).unwrap_or(std::cmp::Ordering::Equal)).unwrap_or(0); + let top = tracks.remove(best); + tracks.insert(0, top); + Ok(ResolveResult { kind: "search".into(), title: format!("Results for “{query}”"), service: "search".into(), subtitle: "Search · Top songs on YouTube Music".into(), cover_url: tracks[0].cover_url.clone(), tracks, ..Default::default() }) +} + +// ---- artists: shared ----------------------------------------------------------- + +pub const ARTIST_MODES: &[(&str, &str)] = &[("top", "Top songs"), ("discography", "Discography")]; + +/// Deluxe/explicit/remastered duplicates of one album collapse to the same key. +pub fn album_key(name: &str) -> String { + normalize(&re!(r"(?i)\s*[\(\[][^\)\]]*(deluxe|explicit|clean|remaster|edition|version|expanded|anniversary)[^\)\]]*[\)\]]").replace_all(name, "")) +} + +pub fn artist_result(name: &str, mut tracks: Vec<Track>, mode: &str, service: &str, url: &str, cover: &str, note: &str) -> Res<ResolveResult> { + if tracks.is_empty() { + return Err(format!("Couldn't list any songs for {name}.")); + } + let subtitle; + if mode == "discography" { + // Soundtracks and splits list other artists' songs too; keep this artist's own. + let key = normalize(name); + let own: Vec<Track> = tracks.iter().filter(|t| t.artists.iter().any(|a| similarity(a, name) >= 0.8 || normalize(a).contains(&key))).cloned().collect(); + if !own.is_empty() { + tracks = own; + } + let albums = tracks.iter().map(|t| t.album.clone()).collect::<HashSet<_>>().len(); + subtitle = format!("Discography · {albums} release{}", if albums != 1 { "s" } else { "" }); + for t in tracks.iter_mut() { + t.folder = vec![if t.album_artist.is_empty() { name.to_string() } else { t.album_artist.clone() }, if t.album.is_empty() { "Singles".into() } else { t.album.clone() }]; + } + } else { + subtitle = "Top songs".into(); + for (i, t) in tracks.iter_mut().enumerate() { + t.playlist = format!("{name} – Top songs"); + t.playlist_index = Some(i as i64 + 1); + } + } + Ok(ResolveResult { kind: "collection".into(), title: name.into(), subtitle: format!("{subtitle} · {name}"), cover_url: cover.into(), service: service.into(), url: url.into(), tracks, note: note.into(), artist: true, mode: mode.into() }) +} + +// ---- Deezer -------------------------------------------------------------------- + +static DEEZER_LIMIT: RateLimiter = RateLimiter::new(120); // Deezer allows 50 requests per 5 seconds + +fn deezer_get(path: &str, params: &[(&str, String)]) -> Res<Value> { + DEEZER_LIMIT.wait(); + let url = if path.starts_with("http") { path.to_string() } else { format!("https://api.deezer.com/{path}") }; + let data = http::get_json(&url, if path.starts_with("http") { &[] } else { params }, false, &[])?; + if let Some(e) = data.get("error").filter(|e| e.is_object()) { + let m = js(e, "message"); + return Err(if m.is_empty() { "Deezer error".into() } else { m }); + } + Ok(data) +} + +fn deezer_pages(path: &str, params: &[(&str, String)], limit: usize) -> Res<Vec<Value>> { + let mut data = deezer_get(path, params)?; + let mut items: Vec<Value> = jarr(&data, "data").to_vec(); + while !js(&data, "next").is_empty() && items.len() < limit { + data = deezer_get(&js(&data, "next"), &[])?; + items.extend(jarr(&data, "data").iter().cloned()); + } + Ok(items) +} + +fn deezer_track(d: &Value, cover_size: i64) -> Track { + let album = d.get("album").cloned().unwrap_or(Value::Null); + let mut t = Track::new(); + t.title = js(d, "title"); + t.artists = vec![js(d.get("artist").unwrap_or(&Value::Null), "name")]; + t.album = js(&album, "title"); + t.duration = d.get("duration").and_then(|x| x.as_f64()); + t.isrc = js(d, "isrc"); + t.cover_url = deezer_cover(&js(&album, "cover_xl"), cover_size); + t.service = "deezer".into(); + t.page_url = js(d, "link"); + t.source_id = js(d, "id"); + t.authoritative = true; + t +} + +fn deezer_album_tracks(album: &Value, cover_size: i64) -> Res<Vec<Track>> { + let tr = album.get("tracks").cloned().unwrap_or(Value::Null); + let mut items: Vec<Value> = jarr(&tr, "data").to_vec(); + let mut next = js(&tr, "next"); + while !next.is_empty() { + let page = deezer_get(&next, &[])?; + items.extend(jarr(&page, "data").iter().cloned()); + next = js(&page, "next"); + } + let genre = album.get("genres").map(|g| jarr(g, "data")).and_then(|g| g.first()).map(|g| js(g, "name")).unwrap_or_default(); + let total = items.len() as i64; + Ok(items + .iter() + .enumerate() + .map(|(i, item)| { + let mut item = item.clone(); + item["album"] = serde_json::json!({"title": js(album, "title"), "cover_xl": js(album, "cover_xl")}); + let mut t = deezer_track(&item, cover_size); + t.album_artist = js(album.get("artist").unwrap_or(&Value::Null), "name"); + t.track_number = Some(i as i64 + 1); + t.track_total = Some(total); + t.year = parse_year(&js(album, "release_date")); + t.genre = genre.clone(); + t + }) + .collect()) +} + +pub fn deezer_artist_by_name(name: &str) -> Res<Option<Value>> { + let data = deezer_get("search/artist", &[("q", name.into()), ("limit", "5".into())])?; + Ok(jarr(&data, "data").iter().find(|a| similarity(&js(a, "name"), name) >= 0.85).cloned()) +} + +pub fn resolve_deezer_artist(artist: &Value, log: Log, cover_size: i64, mode: &str, url: &str) -> Res<ResolveResult> { + let aid = js(artist, "id"); + let name = js(artist, "name"); + let cover = js(artist, "picture_xl"); + let tracks: Vec<Track>; + if mode == "discography" { + let mut albums = vec![]; + let mut seen = HashSet::new(); + for a in deezer_pages(&format!("artist/{aid}/albums"), &[("limit", "100".into())], 5000)? { + if !["album", "single", "ep"].contains(&js(&a, "record_type").as_str()) { + continue; // skip compilations they only appear on + } + if seen.insert(album_key(&js(&a, "title"))) { + albums.push(a); + } + } + log("info", &format!("{name}: {} albums, EPs and singles", albums.len())); + let chunks: Vec<Vec<Track>> = std::thread::scope(|s| { + let hs: Vec<_> = albums + .chunks(albums.len().div_ceil(4).max(1)) + .map(|chunk| { + s.spawn(move || { + chunk.iter().map(|a| match deezer_get(&format!("album/{}", js(a, "id")), &[]).and_then(|al| deezer_album_tracks(&al, cover_size)) { + Ok(t) => t, + Err(e) => { + log("warning", &format!("Skipped {}: {e}", js(a, "title"))); + vec![] + } + }).collect::<Vec<_>>() + }) + }) + .collect(); + hs.into_iter().flat_map(|h| h.join().unwrap_or_default()).collect() + }); + tracks = chunks.into_iter().flatten().collect(); + } else { + tracks = deezer_pages(&format!("artist/{aid}/top"), &[("limit", "100".into())], 100)?.iter().map(|d| deezer_track(d, cover_size)).collect(); + } + artist_result(&name, tracks, mode, "deezer", url, &cover, "") +} + +pub fn resolve_deezer(url: &str, log: Log, cover_size: i64, mode: &str) -> Res<ResolveResult> { + let m = re!(r"/(track|album|playlist|artist)/(\d+)").captures(url).ok_or("That Deezer link doesn't point at a track, album, playlist or artist.")?; + let (kind, did) = (m[1].to_string(), m[2].to_string()); + log("info", &format!("Reading Deezer {kind} {did}")); + if kind == "track" { + let d = deezer_get(&format!("track/{did}"), &[])?; + let mut t = deezer_track(&d, cover_size); + t.track_number = ji(&d, "track_position"); + t.disc_number = ji(&d, "disk_number"); + t.year = parse_year(&js(&d, "release_date")); + return Ok(ResolveResult { kind: "track".into(), title: t.title.clone(), subtitle: t.artist(), cover_url: t.cover_url.clone(), service: "deezer".into(), url: url.into(), tracks: vec![t], ..Default::default() }); + } + if kind == "artist" { + return resolve_deezer_artist(&deezer_get(&format!("artist/{did}"), &[])?, log, cover_size, mode, url); + } + let d = deezer_get(&format!("{kind}/{did}"), &[])?; + let name = js(&d, "title"); + let tracks = if kind == "album" { + let mut tr = deezer_album_tracks(&d, cover_size)?; + for (i, t) in tr.iter_mut().enumerate() { + t.playlist = name.clone(); + t.playlist_index = Some(i as i64 + 1); + } + tr + } else { + let items = deezer_pages(&format!("playlist/{did}/tracks"), &[("limit", "100".into())], 5000)?; + log("info", &format!("{} tracks in “{name}”", items.len())); + items.iter().enumerate().map(|(i, item)| { + let mut t = deezer_track(item, cover_size); + t.playlist = name.clone(); + t.playlist_index = Some(i as i64 + 1); + t + }).collect() + }; + let owner = js(d.get("artist").or_else(|| d.get("creator")).unwrap_or(&Value::Null), "name"); + let cover = deezer_cover(&Some(js(&d, "cover_xl")).filter(|s| !s.is_empty()).unwrap_or_else(|| js(&d, "picture_xl")), cover_size); + let label = if kind == "album" { "Album" } else { "Playlist" }; + Ok(ResolveResult { kind: "collection".into(), title: name, subtitle: format!("{label} · {owner}"), cover_url: cover, service: "deezer".into(), url: url.into(), tracks, ..Default::default() }) +} + +// ---- Apple Music --------------------------------------------------------------- + +fn itunes_track(r: &Value, cover_size: i64) -> Track { + let mut t = Track::new(); + t.title = js(r, "trackName"); + t.artists = vec![js(r, "artistName")]; + t.album = js(r, "collectionName"); + t.album_artist = Some(js(r, "collectionArtistName")).filter(|s| !s.is_empty()).unwrap_or_else(|| js(r, "artistName")); + t.track_number = ji(r, "trackNumber"); + t.track_total = ji(r, "trackCount"); + t.disc_number = ji(r, "discNumber"); + t.year = parse_year(&js(r, "releaseDate")); + t.genre = js(r, "primaryGenreName"); + t.duration = ji(r, "trackTimeMillis").filter(|d| *d > 0).map(|d| d as f64 / 1000.0); + t.cover_url = itunes_cover(&js(r, "artworkUrl100"), cover_size); + t.service = "apple".into(); + t.page_url = js(r, "trackViewUrl"); + t.source_id = js(r, "trackId"); + t.authoritative = true; + t +} + +fn itunes_batch(ids: &[String], country: &str, entity: Option<&str>) -> Res<Vec<Value>> { + let mut out = vec![]; + for chunk in ids.chunks(100) { + let mut p = vec![("id", chunk.join(",")), ("country", country.to_string()), ("limit", "200".into())]; + if let Some(e) = entity { + p.push(("entity", e.to_string())); + } + out.extend(jarr(&http::get_json("https://itunes.apple.com/lookup", &p, false, &[])?, "results").iter().cloned()); + } + Ok(out) +} + +/// Song entries from an Apple Music page's embedded data (playlists list all their songs here). +fn apple_page_tracks(body: &str) -> Vec<Value> { + let Some(m) = re!(r#"(?s)<script type="application/json" id="serialized-server-data">(.*?)</script>"#).captures(body) else { return vec![] }; + let Ok(data) = serde_json::from_str::<Value>(&m[1]) else { return vec![] }; + fn walk(o: &Value, found: &mut Vec<Value>) { + match o { + Value::Object(m) => { + if m.contains_key("title") && m.contains_key("subtitleLinks") && m.contains_key("duration") { + found.push(o.clone()); + return; + } + m.values().for_each(|v| walk(v, found)); + } + Value::Array(a) => a.iter().for_each(|v| walk(v, found)), + _ => {} + } + } + let mut found = vec![]; + walk(&data, &mut found); + found +} + +fn query_param(url: &str, key: &str) -> Option<String> { + let q = url.split_once('?')?.1.split('#').next()?; + q.split('&').find_map(|kv| kv.split_once('=').filter(|(k, _)| *k == key).map(|(_, v)| v.to_string())) +} + +pub fn resolve_apple(url: &str, log: Log, cover_size: i64, mode: &str) -> Res<Option<ResolveResult>> { + let path = url.split("://").nth(1).unwrap_or(url).split_once('/').map(|x| x.1).unwrap_or("").split(['?', '#']).next().unwrap_or(""); + let parts: Vec<&str> = path.split('/').filter(|p| !p.is_empty()).collect(); + let last_digits = parts.last().map(|p| p.chars().all(|c| c.is_ascii_digit()) && !p.is_empty()).unwrap_or(false); + let country = parts.first().filter(|p| p.len() == 2).copied().unwrap_or("us"); + let mut track_id = query_param(url, "i"); + if track_id.is_none() && parts.contains(&"song") && last_digits { + track_id = parts.last().map(|s| s.to_string()); + } + if let Some(id) = track_id { + log("info", &format!("Looking up Apple Music song {id}")); + let results = itunes_lookup(&id, country, None)?; + if let Some(r) = results.first() { + let mut t = itunes_track(r, cover_size); + t.page_url = url.into(); + return Ok(Some(ResolveResult { kind: "track".into(), title: t.title.clone(), subtitle: t.artist(), cover_url: t.cover_url.clone(), service: "apple".into(), url: url.into(), tracks: vec![t], ..Default::default() })); + } + } + let wrapper = |r: &Value| js(r, "wrapperType"); + if parts.contains(&"album") && last_digits { + let id = parts.last().unwrap().to_string(); + log("info", &format!("Looking up Apple Music album {id}")); + let results = itunes_batch(&[id], country, Some("song"))?; + let album = results.iter().find(|r| wrapper(r) == "collection"); + let mut songs: Vec<&Value> = results.iter().filter(|r| wrapper(r) == "track").collect(); + songs.sort_by_key(|r| (ji(r, "discNumber").unwrap_or(1), ji(r, "trackNumber").unwrap_or(0))); + if let (Some(album), false) = (album, songs.is_empty()) { + let name = js(album, "collectionName"); + let tracks = songs.iter().enumerate().map(|(i, r)| { + let mut t = itunes_track(r, cover_size); + t.playlist = name.clone(); + t.playlist_index = Some(i as i64 + 1); + t + }).collect(); + return Ok(Some(ResolveResult { kind: "collection".into(), title: name, subtitle: format!("Album · {}", js(album, "artistName")), cover_url: itunes_cover(&js(album, "artworkUrl100"), cover_size), service: "apple".into(), url: url.into(), tracks, ..Default::default() })); + } + } + if parts.contains(&"artist") && last_digits { + let aid = parts.last().unwrap().to_string(); + log("info", &format!("Looking up Apple Music artist {aid}")); + let name; + let tracks: Vec<Track>; + if mode == "discography" { + let results = itunes_batch(&[aid.clone()], country, Some("album"))?; + name = results.iter().find(|r| wrapper(r) == "artist").map(|r| js(r, "artistName")).unwrap_or_default(); + let mut albums = vec![]; + let mut seen = HashSet::new(); + for r in &results { + if wrapper(r) == "collection" && js(r, "artistId") == aid { + let key = album_key(&re!(r"\s*-\s*(Single|EP)$").replace(&js(r, "collectionName"), "")); + if seen.insert(key) { + albums.push(js(r, "collectionId")); + } + } + } + let mut songs: Vec<Value> = itunes_batch(&albums, country, Some("song"))?.into_iter().filter(|r| wrapper(r) == "track").collect(); + songs.sort_by_key(|r| (albums.iter().position(|a| *a == js(r, "collectionId")).unwrap_or(0), ji(r, "discNumber").unwrap_or(1), ji(r, "trackNumber").unwrap_or(0))); + tracks = songs.iter().map(|r| itunes_track(r, cover_size)).collect(); + } else { + let results = itunes_batch(&[aid.clone()], country, Some("song"))?; + name = results.iter().find(|r| wrapper(r) == "artist").map(|r| js(r, "artistName")).unwrap_or_default(); + let own: Vec<&Value> = results.iter().filter(|r| wrapper(r) == "track" && js(r, "artistId") == aid).collect(); + let pool: Vec<&Value> = if own.is_empty() { results.iter().collect() } else { own }; + let mut seen = HashSet::new(); + let mut out = vec![]; + for r in pool { + if wrapper(r) != "track" { + continue; + } + let key = normalize(&re!(r"\s*\([^)]*\)").replace_all(&js(r, "trackName"), "")); + if out.len() < 50 && seen.insert(key) { + out.push(itunes_track(r, cover_size)); // the same hit appears on several releases + } + } + tracks = out; + } + let cover = tracks.first().map(|t| t.cover_url.clone()).unwrap_or_default(); + return artist_result(&name, tracks, mode, "apple", url, &cover, "").map(Some); + } + if parts.contains(&"playlist") { + log("info", "Reading the Apple Music playlist page"); + let (final_url, body) = http::get_text(url)?; + let entries = apple_page_tracks(&body); + if entries.is_empty() { + return Ok(None); + } + let ids: Vec<String> = entries.iter().map(|e| e.pointer("/contentDescriptor/identifiers/storeAdamID").map(|v| match v { Value::String(s) => s.clone(), o => o.to_string() }).unwrap_or_default()).collect(); + let lookup: std::collections::HashMap<String, Value> = itunes_batch(&ids.iter().filter(|i| !i.is_empty()).cloned().collect::<Vec<_>>(), country, None)?.into_iter().filter(|r| wrapper(r) == "track").map(|r| (js(&r, "trackId"), r)).collect(); + let name = html_unescape(&meta(&body, "og:title")); + let name = re!(r"\s+(?:on|-)\s+Apple Music$").replace(if name.is_empty() { "Apple Music playlist" } else { &name }, "").into_owned(); + let tracks = entries.iter().zip(&ids).enumerate().map(|(i, (e, sid))| { + let mut t = if let Some(r) = lookup.get(sid) { + itunes_track(r, cover_size) + } else { + let art = e.pointer("/artwork/dictionary/url").and_then(|u| u.as_str()).unwrap_or("").replace("{w}x{h}bb.{f}", &format!("{cover_size}x{cover_size}bb.jpg")); + let mut t = Track::new(); + t.title = js(e, "title"); + t.artists = jarr(e, "subtitleLinks").iter().map(|x| js(x, "title")).collect(); + t.album = jarr(e, "tertiaryLinks").first().map(|x| js(x, "title")).unwrap_or_default(); + t.duration = ji(e, "duration").filter(|d| *d > 0).map(|d| d as f64 / 1000.0); + t.cover_url = art; + t.service = "apple".into(); + t.page_url = final_url.clone(); + t.source_id = sid.clone(); + t.authoritative = true; + t + }; + t.playlist = name.clone(); + t.playlist_index = Some(i as i64 + 1); + t + }).collect(); + return Ok(Some(ResolveResult { kind: "collection".into(), title: name, subtitle: "Playlist · Apple Music".into(), cover_url: meta(&body, "og:image"), service: "apple".into(), url: final_url, tracks, ..Default::default() })); + } + Ok(None) // anything else falls through to the generic page reader +} + +// ---- YouTube Music (artists and albums) ----------------------------------------- + +pub fn resolve_ytmusic(url: &str, log: Log, mode: &str) -> Res<Option<ResolveResult>> { + let path = url.split("://").nth(1).unwrap_or(url).split_once('/').map(|x| x.1).unwrap_or("").split(['?', '#']).next().unwrap_or(""); + let path = format!("/{path}"); + if let Some(m) = re!(r"/browse/(MPREb_[\w-]+)").captures(&path) { + let album = ytmusic::get_album(&m[1])?; + return Ok(Some(ResolveResult { + kind: "collection".into(), title: album.title.clone(), subtitle: format!("Album · {}", album.artists.join(", ")), cover_url: album.cover.clone(), + service: "ytmusic".into(), url: url.into(), tracks: album.tracks.into_iter().enumerate().map(|(i, mut t)| { t.playlist = album.title.clone(); t.playlist_index = Some(i as i64 + 1); t }).collect(), ..Default::default() + })); + } + let Some(m) = re!(r"/(?:channel|browse)/(UC[\w-]{20,})").captures(&path) else { return Ok(None) }; + let artist = ytmusic::get_artist(&m[1], mode == "discography")?; + log("info", &format!("Reading {} on YouTube Music", artist.name)); + let tracks: Vec<Track>; + if mode == "discography" { + let releases = artist.releases; + if releases.is_empty() { + return Ok(None); + } + log("info", &format!("{}: {} albums and singles", artist.name, releases.len())); + let chunks: Vec<Vec<Track>> = std::thread::scope(|s| { + let hs: Vec<_> = releases.chunks(releases.len().div_ceil(6).max(1)).map(|chunk| s.spawn(move || { + chunk.iter().map(|r| match ytmusic::get_album(&r.browse_id) { + Ok(a) => a.tracks, + Err(e) => { log("warning", &format!("Skipped {}: {e}", r.title)); vec![] } + }).collect::<Vec<_>>() + })).collect(); + hs.into_iter().flat_map(|h| h.join().unwrap_or_default()).collect() + }); + tracks = chunks.into_iter().flatten().collect(); + } else { + let mut songs = artist.songs; + if let Some(b) = &artist.songs_browse { + if let Ok(all) = ytmusic::get_playlist_tracks(b) { + if !all.is_empty() { + songs = all; + } + } + } + for s in songs.iter_mut() { + if s.artists.is_empty() { + s.artists = vec![artist.name.clone()]; + } + } + tracks = songs; + } + if tracks.is_empty() { + return Ok(None); + } + artist_result(&artist.name, tracks, mode, "ytmusic", url, &artist.cover, "").map(Some) +} + +// ---- yt-dlp sites -------------------------------------------------------------- + +fn service_from_extractor(key: &str, url: &str) -> String { + let key = key.to_lowercase(); + if url.contains("music.youtube.com") { + return "ytmusic".into(); + } + for n in ["youtube", "soundcloud", "bandcamp", "mixcloud", "audiomack", "vimeo"] { + if key.starts_with(n) { + return n.into(); + } + } + if key.is_empty() { "web".into() } else { key } +} + +/// A full yt-dlp info dict -> Track. +pub fn track_from_info(info: &Value, url: &str) -> Track { + let uploader = [js(info, "channel"), js(info, "uploader"), js(info, "creator")].into_iter().find(|s| !s.is_empty()).unwrap_or_default(); + let mut artists: Vec<String> = jarr(info, "artists").iter().filter_map(|a| a.as_str().map(String::from)).collect(); + if artists.is_empty() && !js(info, "artist").is_empty() { + artists = vec![js(info, "artist")]; + } + artists = artists.join(",").split(',').map(|a| a.trim().to_string()).filter(|a| !a.is_empty()).collect(); + let mut title = js(info, "track"); + if title.is_empty() { + let (guess, t) = split_artist_title(&js(info, "title"), &uploader); + title = t; + if artists.is_empty() && !guess.is_empty() { + artists = vec![guess]; + } + } + if artists.is_empty() && !uploader.is_empty() { + artists = vec![clean_artist(&uploader)]; + } + let mut album_artists: Vec<String> = jarr(info, "album_artists").iter().filter_map(|a| a.as_str().map(String::from)).collect(); + if album_artists.is_empty() && !js(info, "album_artist").is_empty() { + album_artists = vec![js(info, "album_artist")]; + } + let genre = jarr(info, "genres").first().and_then(|g| g.as_str().map(String::from)).unwrap_or_else(|| js(info, "genre")); + let url = if url.is_empty() { Some(js(info, "webpage_url")).filter(|s| !s.is_empty()).unwrap_or_else(|| js(info, "original_url")) } else { url.to_string() }; + let year = if ji(info, "release_year").is_some() { js(info, "release_year") } else { parse_year(&Some(js(info, "release_date")).filter(|s| !s.is_empty()).unwrap_or_else(|| js(info, "upload_date"))) }; + let mut t = Track::new(); + t.title = clean_title(&title); + t.authoritative = !js(info, "track").is_empty() && (!jarr(info, "artists").is_empty() || !js(info, "artist").is_empty()); + t.artists = artists; + t.album = js(info, "album"); + t.album_artist = album_artists.join(", "); + t.track_number = ji(info, "track_number"); + t.disc_number = ji(info, "disc_number"); + t.year = year; + t.genre = genre; + t.duration = info.get("duration").and_then(|d| d.as_f64()); + t.cover_url = js(info, "thumbnail"); + t.service = service_from_extractor(&js(info, "extractor_key"), &url); + t.page_url = url.clone(); + t.download_url = url; + t.source_id = js(info, "id"); + t +} + +pub fn resolve_ytdlp(snap: &Value, url: &str, log: Log) -> Res<ResolveResult> { + log("info", &format!("Asking yt-dlp about {url}")); + let info = ytdlp::extract(snap, url, true, &["--use-extractors", "default,-generic", "--no-warnings"], log)?; + let is_playlist = matches!(js(&info, "_type").as_str(), "playlist" | "multi_video") || info.get("entries").is_some(); + if is_playlist { + let name = Some(js(&info, "title")).filter(|s| !s.is_empty()).unwrap_or_else(|| "Playlist".into()); + let uploader = Some(js(&info, "channel")).filter(|s| !s.is_empty()).unwrap_or_else(|| js(&info, "uploader")); + let service = service_from_extractor(&js(&info, "extractor_key"), url); + let mut tracks = vec![]; + for (i, e) in jarr(&info, "entries").iter().enumerate() { + if !e.is_object() { + continue; + } + let mut e_url = Some(js(e, "url")).filter(|s| !s.is_empty()).unwrap_or_else(|| js(e, "webpage_url")); + if e_url.is_empty() { + continue; + } + if !e_url.starts_with("http") && js(e, "ie_key") == "Youtube" { + e_url = format!("https://www.youtube.com/watch?v={e_url}"); + } + let e_up = Some(js(e, "channel")).filter(|s| !s.is_empty()).unwrap_or_else(|| js(e, "uploader")); + let (artist, title) = split_artist_title(&js(e, "title"), &e_up); + let mut t = Track::new(); + t.title = title; + t.artists = if artist.is_empty() { vec![] } else { vec![artist] }; + t.duration = e.get("duration").and_then(|d| d.as_f64()); + t.cover_url = jarr(e, "thumbnails").last().map(|x| js(x, "url")).filter(|s| !s.is_empty()).unwrap_or_else(|| js(e, "thumbnail")); + t.service = service.clone(); + t.page_url = e_url.clone(); + t.download_url = e_url; + t.source_id = js(e, "id"); + t.playlist = name.clone(); + t.playlist_index = Some(i as i64 + 1); + t.weak = true; + tracks.push(t); + } + if tracks.is_empty() { + return Err("That playlist is empty or private.".into()); + } + let cover = jarr(&info, "thumbnails").last().map(|x| js(x, "url")).filter(|s| !s.is_empty()).unwrap_or_else(|| tracks[0].cover_url.clone()); + return Ok(ResolveResult { kind: "collection".into(), title: name, subtitle: if uploader.is_empty() { "Playlist".into() } else { format!("Playlist · {uploader}") }, cover_url: cover, service: tracks[0].service.clone(), url: url.into(), tracks, ..Default::default() }); + } + let mut t = track_from_info(&info, url); + t.info_ready = true; + Ok(ResolveResult { kind: "track".into(), title: t.title.clone(), subtitle: t.artist(), cover_url: t.cover_url.clone(), service: t.service.clone(), url: url.into(), tracks: vec![t], ..Default::default() }) +} + +// ---- any other page ------------------------------------------------------------ + +pub fn html_unescape(s: &str) -> String { + s.replace("&", "&").replace("<", "<").replace(">", ">").replace(""", "\"").replace("'", "'").replace("'", "'").replace("'", "'").replace(" ", " ") +} + +fn jsonld_objects(body: &str) -> Vec<Value> { + let mut out = vec![]; + for m in re!(r#"(?is)<script[^>]+type="application/ld\+json"[^>]*>(.*?)</script>"#).captures_iter(body) { + let Ok(data) = serde_json::from_str::<Value>(html_unescape(m[1].trim()).as_str()) else { continue }; + let mut stack: Vec<Value> = if data.is_array() { data.as_array().unwrap().clone() } else { vec![data] }; + while !stack.is_empty() { + let obj = stack.remove(0); + match obj { + Value::Object(ref m) => { + if let Some(Value::Array(g)) = m.get("@graph") { + stack.extend(g.clone()); + } + out.push(obj); + } + Value::Array(a) => stack.extend(a), + _ => {} + } + } + } + out +} + +fn names(v: &Value) -> Vec<String> { + match v { + Value::Array(a) => a.iter().flat_map(names).collect(), + Value::Object(_) => Some(js(v, "name")).filter(|s| !s.is_empty()).into_iter().collect(), + Value::String(s) if !s.is_empty() => vec![s.clone()], + _ => vec![], + } +} + +fn jsonld_track(obj: &Value) -> Track { + let album = obj.get("inAlbum").cloned().unwrap_or(Value::Null); + let image = match obj.get("image") { + Some(Value::Array(a)) => a.first().cloned().unwrap_or(Value::Null), + Some(o) => o.clone(), + None => Value::Null, + }; + let image = match &image { + Value::Object(_) => js(&image, "url"), + Value::String(s) => s.clone(), + _ => String::new(), + }; + let mut t = Track::new(); + t.title = html_unescape(&js(obj, "name")); + t.artists = names(obj.get("byArtist").unwrap_or(&Value::Null)).iter().map(|n| html_unescape(n)).collect(); + t.album = if album.is_object() { html_unescape(&js(&album, "name")) } else { String::new() }; + t.duration = parse_iso_duration(&js(obj, "duration")); + t.isrc = js(obj, "isrcCode"); + t.cover_url = image; + t.page_url = js(obj, "url"); + t.authoritative = true; + t +} + +pub fn meta(body: &str, prop: &str) -> String { + let p = regex::escape(prop); + let a = Regex::new(&format!(r#"(?i)<meta[^>]+(?:property|name)="{p}"[^>]+content="([^"]*)""#)).unwrap(); + let b = Regex::new(&format!(r#"(?i)<meta[^>]+content="([^"]*)"[^>]+(?:property|name)="{p}""#)).unwrap(); + a.captures(body).or_else(|| b.captures(body)).map(|c| html_unescape(&c[1]).trim().to_string()).unwrap_or_default() +} + +/// 'Song by Artist on TIDAL' / 'Artist - Song | Site' -> (artist, title) +fn guess_from_title(text: &str) -> (String, String) { + let t = re!(r"(?i)\s*(?:[|\-–—·]\s*)?(?:on\s+)?(?:Listen\s+(?:on|to)\s+)?(?:TIDAL|Amazon Music(?: Unlimited)?|Apple Music|Spotify|Deezer|Qobuz|Napster|Pandora|YouTube Music|SoundCloud|Audiomack|Anghami|JioSaavn|Boomplay)\s*$").replace(text, "").trim().to_string(); + let t = re!(r"(?i)^(?:Listen to|Play|Stream)\s+").replace(&t, "").into_owned(); + let t = re!(r"(?i)\s*[-–]\s*(?:song|single|track)\s+(?:and\s+lyrics\s+)?by\s+").replace(&t, " by ").into_owned(); + if let Some(m) = re!(r"^(.+?)\s+by\s+(.+)$").captures(&t) { + return (m[2].trim().to_string(), m[1].trim().to_string()); + } + split_artist_title(&t, "") +} + +pub fn resolve_page(url: &str, log: Log) -> Res<ResolveResult> { + log("info", &format!("Reading {} for music info", host_of(url))); + let (final_url, body) = http::get_text(url).map_err(|e| format!("Couldn't open that page: {e}"))?; + let host = host_of(&final_url); + let service = ["tidal", "amazon", "qobuz", "apple", "napster", "pandora", "audiomack"].iter().find(|k| host.contains(*k)).map(|s| s.to_string()).unwrap_or_else(|| "web".into()); + + for obj in jsonld_objects(&body) { + let kind = match obj.get("@type") { + Some(Value::Array(a)) => a.first().and_then(|x| x.as_str()).unwrap_or("").to_string(), + Some(Value::String(s)) => s.clone(), + _ => String::new(), + }; + if kind == "MusicAlbum" || kind == "MusicPlaylist" { + let raw: Vec<Value> = match obj.get("track") { + Some(Value::Array(a)) => a.clone(), + Some(o @ Value::Object(_)) => o.get("itemListElement").and_then(|x| x.as_array()).cloned().unwrap_or_else(|| vec![o.clone()]), + _ => vec![], + }; + let items: Vec<Value> = raw.iter().filter_map(|x| x.as_object().map(|_| x.get("item").cloned().unwrap_or_else(|| x.clone()))).filter(|i| i.is_object() && !js(i, "name").is_empty()).collect(); + if !items.is_empty() { + let name = html_unescape(&js(&obj, "name")); + let album_artist = names(obj.get("byArtist").unwrap_or(&Value::Null)).join(", "); + let tracks = items.iter().enumerate().map(|(i, item)| { + let mut t = jsonld_track(item); + t.service = service.clone(); + t.playlist = name.clone(); + t.playlist_index = Some(i as i64 + 1); + if kind == "MusicAlbum" { + if t.album.is_empty() { + t.album = name.clone(); + } + t.album_artist = album_artist.clone(); + t.track_number = Some(i as i64 + 1); + } + if t.artists.is_empty() && !album_artist.is_empty() { + t.artists = vec![album_artist.clone()]; + } + if t.page_url.is_empty() { + t.page_url = final_url.clone(); + } + t + }).collect(); + let label = if kind == "MusicAlbum" { "Album" } else { "Playlist" }; + return Ok(ResolveResult { kind: "collection".into(), title: name, subtitle: format!("{label} · {album_artist}").trim_end_matches([' ', '·']).to_string(), cover_url: meta(&body, "og:image"), service, url: final_url, tracks, ..Default::default() }); + } + } + if kind == "MusicRecording" && !js(&obj, "name").is_empty() { + let mut t = jsonld_track(&obj); + t.service = service.clone(); + t.page_url = final_url.clone(); + if t.cover_url.is_empty() { + t.cover_url = meta(&body, "og:image"); + } + return Ok(ResolveResult { kind: "track".into(), title: t.title.clone(), subtitle: t.artist(), cover_url: t.cover_url.clone(), service, url: final_url, tracks: vec![t], ..Default::default() }); + } + } + + let mut title = meta(&body, "og:title"); + if title.is_empty() { + title = meta(&body, "twitter:title"); + } + if title.is_empty() { + title = re!(r"(?is)<title[^>]*>(.*?)").captures(&body).map(|m| html_unescape(&m[1]).trim().to_string()).unwrap_or_default(); + } + if title.is_empty() { + return Err("Couldn't find any song on that page.".into()); + } + let (mut artist, song) = guess_from_title(&title); + if artist.is_empty() { + let desc = meta(&body, "og:description"); + if let Some(m) = re!(r"^(?:Song|Single|Track)\s*[·•]\s*([^·•]+)").captures(&desc) { + artist = m[1].trim().to_string(); + } + } + let dur = meta(&body, "music:duration"); + let mut t = Track::new(); + t.title = song; + t.artists = if artist.is_empty() { vec![] } else { vec![artist] }; + t.cover_url = meta(&body, "og:image"); + t.service = service.clone(); + t.page_url = final_url.clone(); + t.duration = dur.parse::().ok(); + log("info", &format!("Page says: {} – {}", if t.artist().is_empty() { "?".into() } else { t.artist() }, t.title)); + Ok(ResolveResult { kind: "track".into(), title: t.title.clone(), subtitle: t.artist(), cover_url: t.cover_url.clone(), service, url: final_url, tracks: vec![t], ..Default::default() }) +} diff --git a/src/core/settings.rs b/src/core/settings.rs new file mode 100644 index 0000000..e543287 --- /dev/null +++ b/src/core/settings.rs @@ -0,0 +1,190 @@ +//! Settings: one JSON file with dotted keys (the same file the Python version wrote). + +use super::paths; +use serde_json::{json, Value}; +use std::path::PathBuf; +use std::time::{Duration, Instant}; + +pub const FIELD_SOURCES: &[(&str, &str)] = &[("auto", "Best match"), ("source", "From the link"), ("deezer", "Deezer"), ("itunes", "iTunes"), ("musicbrainz", "MusicBrainz"), ("off", "Leave out")]; +pub const METADATA_FIELDS: &[(&str, &str)] = &[ + ("title", "Title"), + ("artist", "Artist"), + ("album", "Album"), + ("album_artist", "Album artist"), + ("track_number", "Track number"), + ("disc_number", "Disc number"), + ("year", "Year"), + ("genre", "Genre"), + ("isrc", "ISRC"), + ("cover", "Cover art"), +]; + +pub fn defaults() -> Value { + let mut fields = serde_json::Map::new(); + for (k, _) in METADATA_FIELDS { + fields.insert((*k).into(), json!("auto")); + } + json!({ + "download": { + "output_dir": "", "filename_template": "{artist} - {title}", "collection_folder": true, + "format": "mp3", "bitrate": "320", "sample_rate": "source", "bit_depth": "16", "concurrent": 3, + "existing": "rename", "search_source": "ytmusic", "cookies_browser": "none", "ffmpeg_path": "", + "write_source_comment": true, "artist_separator": ", " + }, + "metadata": { + "enabled": true, "providers": {"deezer": true, "itunes": true, "musicbrainz": false}, "fields": fields, + "match_threshold": 0.72, "embed_cover": true, "cover_size": 1200, "cover_square": true, "save_cover_file": false + }, + "lyrics": {"embed": "synced", "save_lrc": false, "fallback_plain": true}, + "spotify": {"client_id": "", "client_secret": ""}, + "player": {"visualizer": true, "visualizer_bars": 56, "wavy_progress": true, "volume": 80, "library_dir": "", "repeat": "off", "shuffle": false}, + "appearance": {"theme_source": "auto", "seed_color": "#7e6bc9", "mode": "system", "variant": "tonal_spot", "animations": true}, + "ui": {"show_terminal": false, "last_tab": 0} + }) +} + +fn merge(base: &Value, over: &Value) -> Value { + match (base, over) { + (Value::Object(b), Value::Object(o)) => { + let mut out = b.clone(); + for (k, v) in o { + let merged = match out.get(k) { + Some(bv) if bv.is_object() && v.is_object() => merge(bv, v), + _ => v.clone(), + }; + out.insert(k.clone(), merged); + } + Value::Object(out) + } + (_, o) => o.clone(), + } +} + +pub fn lookup<'a>(data: &'a Value, key: &str) -> Option<&'a Value> { + let mut node = data; + for part in key.split('.') { + node = node.as_object()?.get(part)?; + } + Some(node) +} + +pub fn get_str(data: &Value, key: &str) -> String { + match lookup(data, key) { + Some(Value::String(s)) => s.clone(), + Some(Value::Number(n)) => n.to_string(), + _ => String::new(), + } +} +pub fn get_bool(data: &Value, key: &str) -> bool { + lookup(data, key).and_then(|v| v.as_bool()).unwrap_or(false) +} +pub fn get_f64(data: &Value, key: &str) -> f64 { + lookup(data, key).and_then(|v| v.as_f64()).unwrap_or(0.0) +} +pub fn get_i64(data: &Value, key: &str) -> i64 { + lookup(data, key).and_then(|v| v.as_i64().or_else(|| v.as_f64().map(|f| f as i64))).unwrap_or(0) +} + +pub struct Settings { + pub data: Value, + file: PathBuf, + dirty_since: Option, + pub revision: u64, +} + +impl Settings { + pub fn load() -> Settings { + let file = paths::config_dir().join("settings.json"); + let mut data = defaults(); + if let Ok(txt) = std::fs::read_to_string(&file) { + if let Ok(v) = serde_json::from_str::(&txt) { + data = merge(&data, &v); + } + } + Settings { data, file, dirty_since: None, revision: 0 } + } + + pub fn get_str(&self, key: &str) -> String { + get_str(&self.data, key) + } + pub fn get_bool(&self, key: &str) -> bool { + get_bool(&self.data, key) + } + pub fn get_f64(&self, key: &str) -> f64 { + get_f64(&self.data, key) + } + pub fn get_i64(&self, key: &str) -> i64 { + get_i64(&self.data, key) + } + + pub fn set(&mut self, key: &str, value: Value) { + let parts: Vec<&str> = key.split('.').collect(); + let mut node = &mut self.data; + for p in &parts[..parts.len() - 1] { + if !node.get(*p).map(|v| v.is_object()).unwrap_or(false) { + node[*p] = json!({}); + } + node = node.get_mut(*p).unwrap(); + } + let last = parts[parts.len() - 1]; + if node.get(last) == Some(&value) { + return; + } + node[last] = value; + self.dirty_since = Some(Instant::now()); + self.revision += 1; + } + pub fn set_str(&mut self, key: &str, v: &str) { + self.set(key, json!(v)); + } + pub fn set_bool(&mut self, key: &str, v: bool) { + self.set(key, json!(v)); + } + + pub fn reset(&mut self, section: &str) { + if let Some(d) = defaults().get(section) { + self.data[section] = d.clone(); + self.dirty_since = Some(Instant::now()); + self.revision += 1; + } + } + + /// Coalesce bursts of changes (sliders, typing) into one write. + pub fn save_if_due(&mut self) { + if let Some(t) = self.dirty_since { + if t.elapsed() > Duration::from_millis(400) { + self.save(); + } + } + } + + pub fn save(&mut self) { + self.dirty_since = None; + let tmp = self.file.with_extension("tmp"); + if let Ok(txt) = serde_json::to_string_pretty(&self.data) { + if std::fs::write(&tmp, txt).is_ok() { + let _ = std::fs::rename(&tmp, &self.file); + } + } + } + + pub fn output_dir(&self) -> String { + let d = self.get_str("download.output_dir"); + if d.is_empty() { + paths::music_dir().to_string_lossy().into_owned() + } else { + d + } + } + pub fn library_dir(&self) -> String { + let d = self.get_str("player.library_dir"); + if d.is_empty() { + self.output_dir() + } else { + d + } + } + pub fn snapshot(&self) -> Value { + self.data.clone() + } +} diff --git a/src/core/spotify.rs b/src/core/spotify.rs new file mode 100644 index 0000000..955fe72 --- /dev/null +++ b/src/core/spotify.rs @@ -0,0 +1,369 @@ +//! Spotify through the Web API (client credentials) with a graceful fallback to the public embed. +//! +//! Spotify's February 2026 changes (https://developer.spotify.com/documentation/web-api/tutorials/february-2026-migration-guide) +//! renamed `/playlists/{id}/tracks` to `/playlists/{id}/items`, removed artist top tracks and the batch +//! `/albums?ids=` lookup, and only return playlist items for playlists the app's owner can edit. The old code +//! called the removed endpoints and surfaced the resulting 403/404 as an error even with valid keys. Now every +//! API failure that isn't "your keys are wrong" falls back to the embed page, and wrong keys are reported as a +//! note on the result instead of a failure. + +use super::http::{self, HttpError}; +use super::metadata::{jarr, ji, js}; +use super::models::{ResolveResult, Track}; +use super::resolvers::{artist_result, resolve_deezer_artist, album_key, deezer_artist_by_name, resolve_ytdlp}; +use super::settings::get_str; +use super::textutil::parse_year; +use super::{Log, Res}; +use regex::Regex; +use serde_json::Value; +use std::collections::HashMap; +use std::sync::{LazyLock, Mutex}; +use std::time::{Duration, Instant}; + +const TOKEN_URL: &str = "https://accounts.spotify.com/api/token"; +const API: &str = "https://api.spotify.com/v1"; + +static TOKENS: LazyLock>> = LazyLock::new(|| Mutex::new(HashMap::new())); + +/// Why the API couldn't answer. +#[derive(Debug)] +pub enum ApiError { + /// Wrong client ID/secret. + BadKeys, + /// 403/404: the API can't show this (hidden playlist, removed endpoint, app owner without Premium...). + Unavailable(String), + Other(String), +} + +pub struct Api { + id: String, + secret: String, +} + +fn clean_key(s: &str) -> String { + s.chars().filter(|c| !c.is_whitespace() && *c != '"' && *c != '\'').collect() +} + +impl Api { + pub fn from_settings(snap: &Value) -> Option { + let (id, secret) = (clean_key(&get_str(snap, "spotify.client_id")), clean_key(&get_str(snap, "spotify.client_secret"))); + (!id.is_empty() && !secret.is_empty()).then_some(Api { id, secret }) + } + + pub fn new(id: &str, secret: &str) -> Api { + Api { id: clean_key(id), secret: clean_key(secret) } + } + + fn token(&self, force: bool) -> Result { + if !force { + if let Some((t, exp)) = TOKENS.lock().unwrap().get(&self.id) { + if Instant::now() + Duration::from_secs(60) < *exp { + return Ok(t.clone()); + } + } + } + let auth = format!("Basic {}", http::b64(&format!("{}:{}", self.id, self.secret))); + let r = http::post_form(TOKEN_URL, &[("grant_type", "client_credentials")], &[("Authorization", auth.as_str()), ("Accept", "application/json")]).map_err(|e| ApiError::Other(e.to_string()))?; + if r.status == 400 || r.status == 401 { + return Err(ApiError::BadKeys); + } + if !r.ok() { + return Err(ApiError::Other(format!("Spotify's login server answered {}", r.status))); + } + let data = r.json().map_err(|e| ApiError::Other(e.to_string()))?; + let token = js(&data, "access_token"); + if token.is_empty() { + return Err(ApiError::BadKeys); + } + let ttl = ji(&data, "expires_in").unwrap_or(3600) as u64; + TOKENS.lock().unwrap().insert(self.id.clone(), (token.clone(), Instant::now() + Duration::from_secs(ttl))); + Ok(token) + } + + pub fn get(&self, path: &str, params: &[(&str, String)]) -> Result { + let url = if path.starts_with("http") { path.to_string() } else { format!("{API}/{path}") }; + let url = if path.starts_with("http") { url } else { http::with_params(&url, params) }; + let mut refreshed = false; + for attempt in 0..4 { + let token = self.token(refreshed).map_err(|e| e)?; + let bearer = format!("Bearer {token}"); + let r = http::get(&url, &[("Authorization", bearer.as_str()), ("Accept", "application/json")]).map_err(|HttpError { msg, .. }| ApiError::Other(msg))?; + match r.status { + 200..=299 => return r.json().map_err(|e| ApiError::Other(e.to_string())), + 401 if !refreshed => { + refreshed = true; + continue; + } + 429 => { + let wait = r.header("retry-after").and_then(|s| s.parse::().ok()).unwrap_or(2).min(10); + if attempt == 3 { + return Err(ApiError::Other("Spotify is rate-limiting requests; try again in a minute.".into())); + } + std::thread::sleep(Duration::from_secs(wait)); + } + 401 => return Err(ApiError::BadKeys), + 403 | 404 => { + let msg = serde_json::from_slice::(&r.body).ok().and_then(|v| v.get("error").map(|e| js(e, "message"))).unwrap_or_default(); + return Err(ApiError::Unavailable(format!("{} {}", r.status, msg).trim().to_string())); + } + s => return Err(ApiError::Other(format!("Spotify answered {s}"))), + } + } + Err(ApiError::Other("Spotify didn't answer".into())) + } + + /// Items of a paged endpoint, following `next`. + pub fn pages(&self, path: &str, params: &[(&str, String)], limit: usize) -> Result, ApiError> { + let mut data = self.get(path, params)?; + let mut out: Vec = vec![]; + loop { + out.extend(jarr(&data, "items").iter().cloned()); + let next = js(&data, "next"); + if next.is_empty() || out.len() >= limit { + return Ok(out); + } + data = self.get(&next, &[])?; + } + } + + /// Checks the keys by asking for a token; returns a human message. + pub fn test(&self) -> String { + match self.token(true) { + Ok(_) => "Keys accepted.".into(), + Err(ApiError::BadKeys) => "Spotify rejected that Client ID/secret. Copy them again from the dashboard (Settings of your app).".into(), + Err(ApiError::Other(e)) | Err(ApiError::Unavailable(e)) => format!("Couldn't reach Spotify: {e}"), + } + } +} + +fn api_track(t: &Value, album: Option<&Value>) -> Track { + let null = Value::Null; + let album = album.or_else(|| t.get("album")).unwrap_or(&null); + let images = jarr(album, "images"); + let mut tr = Track::new(); + tr.title = js(t, "name"); + tr.artists = jarr(t, "artists").iter().map(|a| js(a, "name")).collect(); + tr.album = js(album, "name"); + tr.album_artist = jarr(album, "artists").first().map(|a| js(a, "name")).unwrap_or_default(); + tr.track_number = ji(t, "track_number"); + tr.disc_number = ji(t, "disc_number"); + tr.track_total = ji(album, "total_tracks"); + tr.year = parse_year(&js(album, "release_date")); + tr.isrc = t.get("external_ids").map(|e| js(e, "isrc")).unwrap_or_default(); + tr.duration = ji(t, "duration_ms").filter(|d| *d > 0).map(|d| d as f64 / 1000.0); + tr.cover_url = images.first().map(|i| js(i, "url")).unwrap_or_default(); + tr.service = "spotify".into(); + tr.page_url = t.get("external_urls").map(|e| js(e, "spotify")).unwrap_or_default(); + tr.source_id = js(t, "id"); + tr.authoritative = true; + tr +} + +fn via_api(api: &Api, kind: &str, sid: &str, url: &str, mode: &str, log: Log) -> Result { + match kind { + "track" => { + let mut t = api_track(&api.get(&format!("tracks/{sid}"), &[])?, None); + t.page_url = url.into(); + Ok(ResolveResult { kind: "track".into(), title: t.title.clone(), subtitle: t.artist(), cover_url: t.cover_url.clone(), service: "spotify".into(), url: url.into(), tracks: vec![t], ..Default::default() }) + } + "album" => { + let album = api.get(&format!("albums/{sid}"), &[])?; + let mut items: Vec = album.get("tracks").map(|t| jarr(t, "items").to_vec()).unwrap_or_default(); + if let Some(next) = album.get("tracks").map(|t| js(t, "next")).filter(|n| !n.is_empty()) { + items.extend(api.pages(&next, &[], 5000)?); + } + let name = js(&album, "name"); + let tracks: Vec = items.iter().enumerate().map(|(i, t)| { + let mut tr = api_track(t, Some(&album)); + tr.playlist = name.clone(); + tr.playlist_index = Some(i as i64 + 1); + tr + }).collect(); + let owner = jarr(&album, "artists").iter().map(|a| js(a, "name")).collect::>().join(", "); + Ok(ResolveResult { kind: "collection".into(), title: name, subtitle: format!("Album · {owner}"), cover_url: tracks.first().map(|t| t.cover_url.clone()).unwrap_or_default(), service: "spotify".into(), url: url.into(), tracks, ..Default::default() }) + } + "playlist" => { + let pl = api.get(&format!("playlists/{sid}"), &[("fields", "name,owner(display_name),images".into())])?; + // /items is the current endpoint; /tracks still answers for apps that predate the rename + let items = match api.pages(&format!("playlists/{sid}/items"), &[("limit", "50".into()), ("additional_types", "track".into())], 5000) { + Ok(i) => i, + Err(ApiError::Unavailable(_)) => api.pages(&format!("playlists/{sid}/tracks"), &[("limit", "100".into()), ("additional_types", "track".into())], 5000)?, + Err(e) => return Err(e), + }; + log("info", &format!("Read {} tracks through the Spotify API", items.len())); + let name = js(&pl, "name"); + let mut tracks = vec![]; + for item in &items { + let t = item.get("item").or_else(|| item.get("track")).filter(|t| t.is_object()); + if let Some(t) = t.filter(|t| !js(t, "id").is_empty() && { let ty = js(t, "type"); ty.is_empty() || ty == "track" }) { + let mut tr = api_track(t, None); + tr.playlist = name.clone(); + tr.playlist_index = Some(tracks.len() as i64 + 1); + tracks.push(tr); + } + } + if tracks.is_empty() { + return Err(ApiError::Unavailable("playlist items are hidden from this app".into())); + } + let images = jarr(&pl, "images"); + Ok(ResolveResult { + kind: "collection".into(), title: name, + subtitle: format!("Playlist · {}", pl.get("owner").map(|o| js(o, "display_name")).unwrap_or_default()), + cover_url: images.first().map(|i| js(i, "url")).unwrap_or_default(), service: "spotify".into(), url: url.into(), tracks, ..Default::default() + }) + } + "artist" => { + let artist = api.get(&format!("artists/{sid}"), &[])?; + let name = js(&artist, "name"); + let cover = jarr(&artist, "images").first().map(|i| js(i, "url")).unwrap_or_default(); + if mode != "discography" { + // artist top tracks were removed from the API; the embed still lists them + return Err(ApiError::Unavailable("top tracks are no longer in the API".into())); + } + let mut ids = vec![]; + let mut seen = std::collections::HashSet::new(); + for a in api.pages(&format!("artists/{sid}/albums"), &[("include_groups", "album,single".into()), ("limit", "50".into())], 2000)? { + if seen.insert((album_key(&js(&a, "name")), ji(&a, "total_tracks"))) { + ids.push(js(&a, "id")); + } + } + log("info", &format!("{name}: {} albums and singles", ids.len())); + let albums: Vec> = std::thread::scope(|s| { + let hs: Vec<_> = ids.chunks(4).map(|chunk| s.spawn(move || chunk.iter().map(|id| api.get(&format!("albums/{id}"), &[])).collect::>())).collect(); + hs.into_iter().flat_map(|h| h.join().unwrap_or_default()).collect() + }); + let mut tracks = vec![]; + for album in albums { + let album = album?; + let mut items: Vec = album.get("tracks").map(|t| jarr(t, "items").to_vec()).unwrap_or_default(); + if let Some(next) = album.get("tracks").map(|t| js(t, "next")).filter(|n| !n.is_empty()) { + items.extend(api.pages(&next, &[], 5000)?); + } + tracks.extend(items.iter().map(|t| api_track(t, Some(&album)))); + } + artist_result(&name, tracks, mode, "spotify", url, &cover, "").map_err(ApiError::Other) + } + _ => Err(ApiError::Other("That Spotify link isn't a track, album, playlist or artist.".into())), + } +} + +// ---- the public embed ---------------------------------------------------------- + +fn entity(kind: &str, sid: &str) -> Res { + static R: LazyLock = LazyLock::new(|| Regex::new(r#"(?s)"#).unwrap()); + let (_, body) = http::get_text(&format!("https://open.spotify.com/embed/{kind}/{sid}"))?; + let m = R.captures(&body).ok_or("Spotify didn't return the track list (the embed page changed?).")?; + let data: Value = serde_json::from_str(&m[1]).map_err(|e| format!("Spotify's page wasn't readable: {e}"))?; + data.pointer("/props/pageProps/state/data/entity").cloned().filter(|e| e.is_object()).ok_or_else(|| "This Spotify link is private or no longer available.".to_string()) +} + +fn embed_cover(e: &Value) -> String { + let mut images: Vec = e.get("visualIdentity").map(|v| jarr(v, "image").to_vec()).unwrap_or_default(); + images.extend(e.get("coverArt").map(|v| jarr(v, "sources").to_vec()).unwrap_or_default()); + let best = images.iter().max_by_key(|i| ji(i, "maxWidth").or(ji(i, "width")).unwrap_or(0)); + // 300 px -> 640 px variant of the same image + best.map(|i| js(i, "url").replace("ab67616d00001e02", "ab67616d0000b273")).unwrap_or_default() +} + +fn embed_artists(text: &str) -> Vec { + text.replace('\u{a0}', " ").split(',').map(|a| a.trim().to_string()).filter(|a| !a.is_empty()).collect() +} + +fn via_embed(snap: &Value, kind: &str, sid: &str, url: &str, mode: &str, cover_size: i64, log: Log) -> Res { + log("info", &format!("Reading Spotify {kind} {sid}")); + let e = entity(kind, sid)?; + let cover = embed_cover(&e); + let name = Some(js(&e, "name")).filter(|s| !s.is_empty()).unwrap_or_else(|| js(&e, "title")); + let year = parse_year(&e.get("releaseDate").map(|r| js(r, "isoString")).unwrap_or_default()); + if kind == "track" { + let mut t = Track::new(); + t.title = name; + t.artists = jarr(&e, "artists").iter().map(|a| js(a, "name")).collect(); + t.duration = ji(&e, "duration").filter(|d| *d > 0).map(|d| d as f64 / 1000.0); + t.year = year; + t.cover_url = cover.clone(); + t.service = "spotify".into(); + t.page_url = url.into(); + t.source_id = sid.into(); + t.authoritative = true; + return Ok(ResolveResult { kind: "track".into(), title: t.title.clone(), subtitle: t.artist(), cover_url: cover, service: "spotify".into(), url: url.into(), tracks: vec![t], ..Default::default() }); + } + if kind == "artist" && mode == "discography" { + // The embed only knows the top 10; Deezer lists whole discographies without a key. + log("info", &format!("Getting {name}'s discography from Deezer")); + let dz = deezer_artist_by_name(&name)?.ok_or_else(|| format!("Couldn't find {name} on Deezer for the discography. Add Spotify API keys in Settings to read it from Spotify instead."))?; + let mut r = resolve_deezer_artist(&dz, log, cover_size, mode, url)?; + r.note = "Discography listed from Deezer (Spotify's API doesn't share it with this app).".into(); + return Ok(r); + } + let owner = js(&e, "subtitle"); + let list = jarr(&e, "trackList"); + let total = list.len() as i64; + let mut tracks = vec![]; + for (i, item) in list.iter().enumerate() { + let id = js(item, "uri").rsplit(':').next().unwrap_or("").to_string(); + let mut t = Track::new(); + t.title = js(item, "title"); + t.artists = embed_artists(&js(item, "subtitle")); + t.duration = ji(item, "duration").filter(|d| *d > 0).map(|d| d as f64 / 1000.0); + t.service = "spotify".into(); + t.page_url = format!("https://open.spotify.com/track/{id}"); + t.source_id = id; + t.playlist = name.clone(); + t.playlist_index = Some(i as i64 + 1); + t.authoritative = true; + if kind == "album" { + t.album = name.clone(); + t.album_artist = owner.clone(); + t.track_number = Some(i as i64 + 1); + t.cover_url = cover.clone(); + t.year = year.clone(); + t.track_total = Some(total); + } + tracks.push(t); + } + if kind == "artist" { + return artist_result(&name, tracks, "top", "spotify", url, &cover, ""); + } + if tracks.is_empty() { + return Err("Spotify's page listed no songs for that link.".into()); + } + let note = if kind == "playlist" && tracks.len() >= 100 { + "Without API keys Spotify only shows the first 100 songs of a playlist. Add free Spotify API keys in Settings › Spotify (the app owner needs Premium and the playlist must be one they own or collaborate on).".to_string() + } else { + String::new() + }; + let label = if kind == "album" { "Album" } else { "Playlist" }; + Ok(ResolveResult { kind: "collection".into(), title: name, subtitle: if owner.is_empty() { label.into() } else { format!("{label} · {owner}") }, cover_url: cover, service: "spotify".into(), url: url.into(), tracks, note, ..Default::default() }) +} + +pub fn resolve(snap: &Value, url: &str, mode: &str, cover_size: i64, log: Log) -> Res { + static R: LazyLock = LazyLock::new(|| Regex::new(r"/(track|album|playlist|artist|episode|show)/([A-Za-z0-9]+)").unwrap()); + let m = R.captures(url).ok_or("That Spotify link doesn't point at a track, album, playlist or artist.")?; + let (kind, sid) = (m[1].to_string(), m[2].to_string()); + if kind == "episode" || kind == "show" { + return resolve_ytdlp(snap, url, log); // yt-dlp handles Spotify podcasts itself + } + let mut key_note = String::new(); + if let Some(api) = Api::from_settings(snap) { + log("info", &format!("Reading Spotify {kind} {sid} through the Web API")); + match via_api(&api, &kind, &sid, url, mode, log) { + Ok(r) => return Ok(r), + Err(ApiError::BadKeys) => { + key_note = "Spotify rejected the Client ID/secret in Settings › Spotify, so the public page was used instead.".into(); + log("warning", &key_note); + } + Err(ApiError::Unavailable(why)) => { + log("warning", &format!("The Spotify API can't show this one ({why}); using the public page instead")); + } + Err(ApiError::Other(e)) => { + log("warning", &format!("Spotify API problem ({e}); using the public page instead")); + } + } + } + let mut r = via_embed(snap, &kind, &sid, url, mode, cover_size, log)?; + if !key_note.is_empty() { + r.note = if r.note.is_empty() { key_note } else { format!("{key_note} {}", r.note) }; + } + Ok(r) +} diff --git a/src/core/tagger.rs b/src/core/tagger.rs new file mode 100644 index 0000000..9f2c37b --- /dev/null +++ b/src/core/tagger.rs @@ -0,0 +1,152 @@ +//! Reading and writing tags, cover art and lyrics (lofty), for every format we produce. + +use super::lyrics::{is_synced, lrc_to_plain}; +use super::textutil::to_int; +use lofty::config::WriteOptions; +use lofty::file::{AudioFile, TaggedFile, TaggedFileExt}; +use lofty::picture::{MimeType, Picture, PictureType}; +use lofty::prelude::*; +use lofty::tag::items::Timestamp; +use lofty::tag::{ItemKey, Tag}; +use std::collections::HashSet; + +#[derive(Clone, Debug, Default)] +pub struct Tags { + pub title: String, + pub artist: String, + pub album: String, + pub album_artist: String, + pub track_number: Option, + pub track_total: Option, + pub disc_number: Option, + pub year: String, + pub genre: String, + pub isrc: String, + pub comment: String, + /// plain text or LRC + pub lyrics: String, + pub cover: Option>, + pub duration: Option, + pub bitrate: Option, + pub sample_rate: Option, + pub codec: String, + /// Fields the user turned off: leave them out. + pub skip: HashSet, +} + +fn primary_or_new(f: &mut TaggedFile) -> &mut Tag { + if f.primary_tag().is_none() && f.first_tag().is_none() { + let t = Tag::new(f.primary_tag_type()); + f.insert_tag(t); + } + if f.primary_tag().is_some() { + f.primary_tag_mut().unwrap() + } else { + f.first_tag_mut().unwrap() + } +} + +fn put(tag: &mut Tag, key: ItemKey, val: &str) { + tag.remove_key(key.clone()); + if !val.trim().is_empty() { + tag.insert_text(key, val.trim().to_string()); + } +} + +fn year_of(s: &str) -> Option { + super::textutil::parse_year(s).parse().ok() +} + +/// Replace every tag field we manage. Skipped fields are removed. +pub fn write(path: &str, t: &Tags, lyrics_mode: &str) -> Result<(), String> { + let mut f = lofty::read_from_path(path).map_err(|e| e.to_string())?; + { + let tag = primary_or_new(&mut f); + let sk = |k: &str| t.skip.contains(k); + let s = |k: &str, v: &str| if sk(k) { String::new() } else { v.to_string() }; + let title = s("title", &t.title); + let artist = s("artist", &t.artist); + let album = s("album", &t.album); + let genre = s("genre", &t.genre); + if title.trim().is_empty() { tag.remove_title() } else { tag.set_title(title.trim().into()) } + if artist.trim().is_empty() { tag.remove_artist() } else { tag.set_artist(artist.trim().into()) } + if album.trim().is_empty() { tag.remove_album() } else { tag.set_album(album.trim().into()) } + if genre.trim().is_empty() { tag.remove_genre() } else { tag.set_genre(genre.trim().into()) } + if t.comment.trim().is_empty() { tag.remove_comment() } else { tag.set_comment(t.comment.trim().into()) } + put(tag, ItemKey::AlbumArtist, &s("album_artist", &t.album_artist)); + put(tag, ItemKey::Isrc, &s("isrc", &t.isrc)); + match t.track_number.filter(|_| !sk("track_number")) { + Some(n) => tag.set_track(n as u32), + None => tag.remove_track(), + } + match t.track_total.filter(|_| !sk("track_number")) { + Some(n) => tag.set_track_total(n as u32), + None => tag.remove_track_total(), + } + match t.disc_number.filter(|_| !sk("disc_number")) { + Some(n) => tag.set_disk(n as u32), + None => tag.remove_disk(), + } + match year_of(&t.year).filter(|_| !sk("year")) { + Some(y) => tag.set_date(Timestamp { year: y, ..Default::default() }), + None => tag.remove_date(), + } + tag.remove_key(ItemKey::UnsyncLyrics); + tag.remove_key(ItemKey::Lyrics); + let mut lyr = if lyrics_mode == "off" { String::new() } else { t.lyrics.clone() }; + if lyrics_mode == "plain" && is_synced(&lyr) { + lyr = lrc_to_plain(&lyr); + } + if !lyr.trim().is_empty() { + tag.insert_text(ItemKey::UnsyncLyrics, lyr); + } + tag.remove_picture_type(PictureType::CoverFront); + if let Some(c) = t.cover.as_ref().filter(|_| !sk("cover")) { + let mime = if c.starts_with(&[0x89, b'P', b'N', b'G']) { MimeType::Png } else { MimeType::Jpeg }; + tag.push_picture(Picture::unchecked(c.clone()).pic_type(PictureType::CoverFront).mime_type(mime).build()); + } + } + f.save_to_path(path, WriteOptions::default()).map_err(|e| e.to_string()) +} + +pub fn read(path: &str, with_cover: bool) -> Tags { + let mut t = Tags::default(); + let Ok(f) = lofty::read_from_path(path) else { return t }; + let p = f.properties(); + t.duration = Some(p.duration().as_secs_f64()).filter(|d| *d > 0.0); + t.bitrate = p.audio_bitrate().or(p.overall_bitrate()); + t.sample_rate = p.sample_rate(); + t.codec = format!("{:?}", f.file_type()).to_uppercase(); + let Some(tag) = f.primary_tag().or_else(|| f.first_tag()) else { return t }; + let g = |o: Option>| o.map(|c| c.trim().to_string()).unwrap_or_default(); + t.title = g(tag.title()); + t.artist = g(tag.artist()); + t.album = g(tag.album()); + t.genre = g(tag.genre()); + t.comment = g(tag.comment()); + t.album_artist = tag.get_string(ItemKey::AlbumArtist).unwrap_or("").trim().to_string(); + t.isrc = tag.get_string(ItemKey::Isrc).unwrap_or("").trim().to_string(); + t.track_number = tag.track().map(|n| n as i64); + t.track_total = tag.track_total().map(|n| n as i64); + t.disc_number = tag.disk().map(|n| n as i64); + t.year = tag.date().map(|d| d.year.to_string()).unwrap_or_default(); + for key in [ItemKey::UnsyncLyrics, ItemKey::Lyrics] { + if let Some(l) = tag.get_string(key).filter(|l| !l.trim().is_empty()) { + t.lyrics = l.to_string(); + break; + } + } + if t.lyrics.is_empty() { + let side = std::path::Path::new(path).with_extension("lrc"); + if let Ok(s) = std::fs::read_to_string(side) { + t.lyrics = s; + } + } + if with_cover { + let pics = tag.pictures(); + let pic = pics.iter().find(|p| p.pic_type() == PictureType::CoverFront).or_else(|| pics.first()); + t.cover = pic.map(|p| p.data().to_vec()); + } + let _ = to_int; + t +} diff --git a/src/core/template.rs b/src/core/template.rs new file mode 100644 index 0000000..ab09b70 --- /dev/null +++ b/src/core/template.rs @@ -0,0 +1,262 @@ +//! File name templates: '{artist}/{album}/{track:02} - {title}'. +//! +//! - Any token can have a fallback: {album|Singles} +//! - Number tokens take a format spec: {track:02} +//! - '/' makes folders; empty folders are dropped +//! - yt-dlp style %(title)s is accepted and translated + +use super::models::Track; +use super::textutil::{safe_component, to_int}; +use regex::Regex; +use std::collections::HashMap; +use std::sync::LazyLock; + +/// (token, description, example): the help panel under the file name box shows these. +pub const TOKENS: &[(&str, &str, &str)] = &[ + ("title", "Track title", "Boulevard of Broken Dreams"), + ("artist", "All artists", "Green Day"), + ("first_artist", "Only the main artist", "Green Day"), + ("album", "Album name", "American Idiot"), + ("album_artist", "Album artist", "Green Day"), + ("track", "Track number (try {track:02})", "4"), + ("track_total", "Tracks on the album", "13"), + ("disc", "Disc number", "1"), + ("year", "Release year", "2004"), + ("genre", "Genre", "Alternative"), + ("playlist", "Playlist or album you pasted", "Rock Classics"), + ("playlist_index", "Position in that playlist (try {playlist_index:03})", "7"), + ("service", "Where the link came from", "spotify"), + ("id", "The source's ID for the track", "FPrHuDvXEBw"), + ("isrc", "ISRC code", "USRE10401426"), + ("format", "File format", "mp3"), + ("bitrate", "Bitrate or quality", "320k"), + ("duration", "Length (m-ss)", "4-21"), +]; + +#[derive(Clone, Debug)] +pub enum Val { + S(String), + I(Option), +} + +impl Val { + fn empty(&self) -> bool { + match self { + Val::S(s) => s.is_empty(), + Val::I(i) => i.is_none(), + } + } +} + +pub fn sample_track() -> Track { + let mut t = Track::new(); + t.title = "Boulevard of Broken Dreams".into(); + t.artists = vec!["Green Day".into()]; + t.album = "American Idiot".into(); + t.album_artist = "Green Day".into(); + t.track_number = Some(4); + t.track_total = Some(13); + t.disc_number = Some(1); + t.year = "2004".into(); + t.genre = "Alternative".into(); + t.isrc = "USRE10401426".into(); + t.duration = Some(261.0); + t.service = "youtube".into(); + t.source_id = "FPrHuDvXEBw".into(); + t.playlist = "Rock Classics".into(); + t.playlist_index = Some(7); + t +} + +pub fn track_values(t: &Track, fmt: &str, bitrate: &str, sep: &str) -> HashMap { + let artist_list: Vec = match t.overrides.get("artist").filter(|s| !s.is_empty()) { + Some(a) => a.split(sep).map(|s| s.to_string()).collect(), + None => t.artists.clone(), + }; + let artist = if t.overrides.get("artist").map(|s| !s.is_empty()).unwrap_or(false) { t.value("artist") } else { t.artists.join(sep) }; + let first = artist_list.first().cloned().unwrap_or_default(); + let int = |k: &str| Val::I(to_int(&t.value(k))); + let s = |x: String| Val::S(x); + let mut m = HashMap::new(); + m.insert("title".into(), s(t.value("title"))); + m.insert("artist".into(), s(artist)); + m.insert("first_artist".into(), s(first.clone())); + m.insert("album".into(), s(t.value("album"))); + let aa = t.value("album_artist"); + m.insert("album_artist".into(), s(if aa.is_empty() { first } else { aa })); + m.insert("track".into(), int("track_number")); + m.insert("track_total".into(), int("track_total")); + m.insert("disc".into(), int("disc_number")); + m.insert("year".into(), s(t.value("year"))); + m.insert("genre".into(), s(t.value("genre"))); + m.insert("playlist".into(), s(t.playlist.clone())); + m.insert("playlist_index".into(), Val::I(t.playlist_index)); + m.insert("service".into(), s(t.service.clone())); + m.insert("id".into(), s(t.source_id.clone())); + m.insert("isrc".into(), s(t.value("isrc"))); + m.insert("format".into(), s(fmt.into())); + m.insert("bitrate".into(), s(bitrate.into())); + m.insert("duration".into(), s(t.duration.filter(|d| *d > 0.0).map(|d| format!("{}-{:02}", (d / 60.0) as i64, (d % 60.0) as i64)).unwrap_or_default())); + m +} + +static YTDLP: LazyLock = LazyLock::new(|| Regex::new(r"%\((\w+)\)(?:0?(\d+))?[sd]").unwrap()); + +pub fn translate_ytdlp(t: &str) -> String { + YTDLP + .replace_all(t, |c: ®ex::Captures| { + let name = match &c[1] { + "track_number" => "track", + "uploader" | "creator" => "artist", + "disc_number" => "disc", + "release_year" => "year", + "ext" => "format", + o => o, + }; + match c.get(2) { + Some(w) => format!("{{{name}:0{}}}", w.as_str()), + None => format!("{{{name}}}"), + } + }) + .into_owned() +} + +/// Apply a Python-ish format spec ('02', '>5', '^7') to a value. +fn apply_spec(v: &Val, spec: &str) -> String { + let text = match v { + Val::S(s) => s.clone(), + Val::I(Some(i)) => i.to_string(), + Val::I(None) => return String::new(), + }; + if spec.is_empty() { + return text; + } + let chars: Vec = spec.chars().collect(); + let (mut fill, mut align, mut i) = (' ', None, 0); + if chars.len() >= 2 && "<>^".contains(chars[1]) { + fill = chars[0]; + align = Some(chars[1]); + i = 2; + } else if !chars.is_empty() && "<>^".contains(chars[0]) { + align = Some(chars[0]); + i = 1; + } + if i < chars.len() && chars[i] == '0' && align.is_none() { + fill = '0'; + align = Some('>'); + i += 1; + } + let width: usize = chars[i..].iter().take_while(|c| c.is_ascii_digit()).collect::().parse().unwrap_or(0); + let len = text.chars().count(); + if len >= width { + return text; + } + let pad = width - len; + let numeric = matches!(v, Val::I(_)); + let (l, r) = match align.unwrap_or(if numeric { '>' } else { '<' }) { + '>' => (pad, 0), + '^' => (pad / 2, pad - pad / 2), + _ => (0, pad), + }; + format!("{}{}{}", fill.to_string().repeat(l), text, fill.to_string().repeat(r)) +} + +fn format_template(t: &str, values: &HashMap) -> Option { + let chars: Vec = t.chars().collect(); + let mut out = String::new(); + let mut i = 0; + while i < chars.len() { + match chars[i] { + '{' if chars.get(i + 1) == Some(&'{') => { + out.push('{'); + i += 2; + } + '}' if chars.get(i + 1) == Some(&'}') => { + out.push('}'); + i += 2; + } + '}' => return None, + '{' => { + let end = chars[i + 1..].iter().position(|c| *c == '}')? + i + 1; + let inner: String = chars[i + 1..end].iter().collect(); + let (head, spec) = match inner.split_once(':') { + Some((h, s)) => (h.to_string(), s.to_string()), + None => (inner.clone(), String::new()), + }; + let (head, conv) = match head.split_once('!') { + Some((h, c)) => (h.to_string(), c.to_string()), + None => (head, String::new()), + }; + let (name, fallback) = head.split_once('|').map(|(a, b)| (a.trim().to_string(), b.to_string())).unwrap_or((head.trim().to_string(), String::new())); + let val = values.get(&name).cloned().unwrap_or(Val::S(String::new())); + let val = if val.empty() { Val::S(fallback) } else { val }; + let mut s = if val.empty() { String::new() } else { apply_spec(&val, &spec) }; + match conv.as_str() { + "u" => s = s.to_uppercase(), + "l" => s = s.to_lowercase(), + _ => {} + } + out.push_str(&s); + i = end + 1; + } + c => { + out.push(c); + i += 1; + } + } + } + Some(out) +} + +fn tidy(part: &str) -> String { + static EMPTY: LazyLock = LazyLock::new(|| Regex::new(r"\(\s*\)|\[\s*\]").unwrap()); + static DASHES: LazyLock = LazyLock::new(|| Regex::new(r"(\s*[-–·|_]\s*){2,}").unwrap()); + static LEAD: LazyLock = LazyLock::new(|| Regex::new(r"^[\s\-–·|_.]+|[\s\-–·|_]+$").unwrap()); + let p = EMPTY.replace_all(part, ""); + let p = DASHES.replace_all(&p, " - "); + LEAD.replace_all(&p, "").into_owned() +} + +/// The relative path (without extension) a template gives for these values. +pub fn render(template: &str, values: &HashMap) -> String { + let tpl = translate_ytdlp(template.trim()); + let tpl = if tpl.is_empty() { "{artist} - {title}".to_string() } else { tpl }; + let text = format_template(&tpl, values).unwrap_or(tpl); + let mut parts: Vec = text.split(['/', '\\']).map(|p| safe_component(&tidy(p))).filter(|p| !p.is_empty() && p != "." && p != "..").collect(); + if parts.is_empty() { + let title = match values.get("title") { + Some(Val::S(s)) if !s.is_empty() => s.clone(), + _ => "track".into(), + }; + parts.push(safe_component(&title)); + } + parts.join("/") +} + +/// An error message, or None when the template is fine. +pub fn validate(template: &str) -> Option { + let t = translate_ytdlp(template); + let mut depth = 0; + let mut cur = String::new(); + for c in t.chars() { + match c { + '{' => { + depth += 1; + cur.clear(); + } + '}' => { + if depth == 0 { + return Some("Unbalanced braces".into()); + } + depth -= 1; + let name = cur.split([':', '!']).next().unwrap_or("").split('|').next().unwrap_or("").trim().to_string(); + if !name.is_empty() && !TOKENS.iter().any(|t| t.0 == name) { + return Some(format!("Unknown token {{{name}}}")); + } + } + c if depth > 0 => cur.push(c), + _ => {} + } + } + (depth != 0).then(|| "Unbalanced braces".to_string()) +} diff --git a/src/core/textutil.rs b/src/core/textutil.rs new file mode 100644 index 0000000..e3f1d87 --- /dev/null +++ b/src/core/textutil.rs @@ -0,0 +1,327 @@ +//! Cleaning up titles, comparing names, and making safe file names. + +use regex::Regex; +use std::sync::LazyLock; +use unicode_normalization::UnicodeNormalization; + +macro_rules! re { + ($name:ident, $pat:expr) => { + static $name: LazyLock = LazyLock::new(|| Regex::new($pat).unwrap()); + }; +} + +re!(NOISE, r"(?i)\s*[\(\[\{【]\s*(?:official\s*)?(?:music\s*)?(?:hd\s*|hq\s*|4k\s*)?(?:video|audio|lyrics?|lyric\s*video|visuali[sz]er|mv|m/v|clip|videoclip|explicit|clean|official|full\s*album|audio\s*only|color\s*coded\s*lyrics|en\s*español|subtitulado|\d{3,4}p|remaster(?:ed)?(?:\s*\d{4})?|\d{4}\s*remaster(?:ed)?|4k\s*upgrade|hd\s*upgrade)[^\)\]\}】]*[\)\]\}】]"); +re!(TRAILING, r"(?i)\s*[-|–—]\s*(?:official\s+)?(?:music\s+)?(?:video|audio|lyrics?)\s*$"); +re!(FEAT, r"(?i)\s*[\(\[]?\s*(?:feat\.?|ft\.?|featuring|with)\s+([^\)\]]+)[\)\]]?"); +re!(SPACES, r"\s{2,}"); +re!(TOPIC, r"\s*-\s*Topic$"); +re!(NONWORD, r"[^\w\s]"); +re!(PAREN, r"[\(\[]([^\)\]]*)[\)\]]"); +re!(DASH_SUFFIX, r"\s[-–—]\s(.+)$"); +re!(BENIGN, r"(?i)^(?:(?:\d{4}\s*)?(?:digital(?:ly)?\s*)?re\s*master(?:ed)?(?:\s*\d{4})?(?:\s*version)?|\d{4}|mono|stereo|explicit|clean|single(?:\s*version)?|album\s*version|original(?:\s*(?:version|mix))?|radio\s*edit|from\s.*|deluxe.*|bonus\s*track|remastered\s*version|(?:feat|ft|featuring|with)\b.*)$"); +re!(ALBUM_VERSION, r"(?i)\b(?:lullab(?:y|ies)|renditions?|tribute|karaoke|instrumentals?|covers|piano\s+(?:versions?|covers?)|string\s+quartet|8[- ]bit|music\s+box|made\s+famous|in\s+the\s+style\s+of|originally\s+performed|cast\s+recording|original\s+cast|broadway|the\s+musical)\b"); + +/// Words that mark a different recording; matching penalises them unless the target has them too. +pub const VERSION_WORDS: &[&str] = &[ + "live", "remix", "karaoke", "instrumental", "cover", "acoustic", "sped up", "speed up", "slowed", "nightcore", "8d", "reverb", "lullaby", + "piano version", "tribute", "mashup", "extended", "edit", "demo", "a cappella", "acapella", "8-bit", "orchestral", +]; + +pub fn collapse_spaces(s: &str) -> String { + SPACES.replace_all(s, " ").into_owned() +} + +/// 'Artist - Song (Official Video) [4K]' -> 'Artist - Song'. +pub fn clean_title(title: &str) -> String { + if title.is_empty() { + return String::new(); + } + let mut out = title.to_string(); + for _ in 0..3 { + let new = NOISE.replace_all(&out, "").into_owned(); + if new == out { + break; + } + out = new; + } + out = TRAILING.replace(&out, "").into_owned(); + out = out.replace(['“', '”'], "\""); + let out = collapse_spaces(&out); + let out = out.trim().trim_matches(|c| matches!(c, ' ' | '-' | '|' | '·')).to_string(); + if out.is_empty() { + title.trim().to_string() + } else { + out + } +} + +/// 'Green Day - Topic' -> 'Green Day', 'GreenDayVEVO' -> 'GreenDay'. +pub fn clean_artist(name: &str) -> String { + if name.is_empty() { + return String::new(); + } + let mut n = TOPIC.replace(name, "").into_owned(); + if n.ends_with("VEVO") && n.len() > 4 { + let head = &n[..n.len() - 4]; + if head.chars().last().map(|c| c.is_ascii_lowercase()).unwrap_or(false) { + n = head.to_string(); + } + } + n.trim().to_string() +} + +/// Videos are usually titled 'Artist - Song'. Returns (artist, title). +pub fn split_artist_title(title: &str, fallback_artist: &str) -> (String, String) { + let t = clean_title(title); + for sep in [" - ", " – ", " — ", " ~ ", " | "] { + if let Some((l, r)) = t.split_once(sep) { + if !l.trim().is_empty() && !r.trim().is_empty() { + return (l.trim().to_string(), r.trim().trim_matches('"').to_string()); + } + } + } + (clean_artist(fallback_artist), t.trim_matches('"').to_string()) +} + +pub fn strip_feat(title: &str) -> String { + FEAT.replace_all(title, "").trim().to_string() +} + +pub fn normalize(text: &str) -> String { + let t: String = text.nfkd().filter(|c| !('\u{300}'..='\u{36f}').contains(c)).collect::().to_lowercase(); + let t = t.replace('&', " and "); + let t = NONWORD.replace_all(&t, " "); + collapse_spaces(&t).trim().to_string() +} + +/// Python's difflib.SequenceMatcher.ratio() for short strings. +pub fn seq_ratio(a: &str, b: &str) -> f64 { + let a: Vec = a.chars().collect(); + let b: Vec = b.chars().collect(); + if a.is_empty() && b.is_empty() { + return 1.0; + } + fn matches(a: &[char], b: &[char]) -> usize { + if a.is_empty() || b.is_empty() { + return 0; + } + // longest common substring (earliest in a, then b) + let (mut best, mut bi, mut bj) = (0usize, 0usize, 0usize); + let mut prev = vec![0usize; b.len() + 1]; + for i in 1..=a.len() { + let mut cur = vec![0usize; b.len() + 1]; + for j in 1..=b.len() { + if a[i - 1] == b[j - 1] { + cur[j] = prev[j - 1] + 1; + if cur[j] > best { + best = cur[j]; + bi = i - best; + bj = j - best; + } + } + } + prev = cur; + } + if best == 0 { + return 0; + } + best + matches(&a[..bi], &b[..bj]) + matches(&a[bi + best..], &b[bj + best..]) + } + 2.0 * matches(&a, &b) as f64 / (a.len() + b.len()) as f64 +} + +pub fn similarity(a: &str, b: &str) -> f64 { + let (a, b) = (normalize(a), normalize(b)); + if a.is_empty() || b.is_empty() { + return 0.0; + } + if a == b { + return 1.0; + } + let mut ratio = seq_ratio(&a, &b); + if a.contains(&b) || b.contains(&a) { + ratio = ratio.max(0.86); + } + let wa: std::collections::HashSet<&str> = a.split(' ').collect(); + let wb: std::collections::HashSet<&str> = b.split(' ').collect(); + let inter = wa.intersection(&wb).count() as f64; + let union = wa.union(&wb).count() as f64; + ratio.max(inter / union) +} + +pub fn artist_similarity(wanted: &[String], found: &[String]) -> f64 { + let w: Vec<&String> = wanted.iter().filter(|s| !s.is_empty()).collect(); + let f: Vec<&String> = found.iter().filter(|s| !s.is_empty()).collect(); + if w.is_empty() || f.is_empty() { + return 0.5; + } + let mut best: f64 = 0.0; + for x in &w { + for y in &f { + best = best.max(similarity(x, y)); + } + } + let joined = similarity(&w.iter().map(|s| s.as_str()).collect::>().join(" "), &f.iter().map(|s| s.as_str()).collect::>().join(" ")); + best.max(joined) +} + +fn has_word(hay: &str, word: &str) -> bool { + Regex::new(&format!(r"\b{}\b", regex::escape(word))).map(|r| r.is_match(hay)).unwrap_or(false) +} + +pub fn version_penalty(target: &str, candidate: &str) -> f64 { + let (t, c) = (normalize(target), normalize(candidate)); + let mut p = 0.0; + for w in VERSION_WORDS { + if has_word(&c, w) && !has_word(&t, w) { + p += 0.25; + } + } + f64::min(p, 0.6) +} + +/// 1 for the same length, falling to 0 at 20 s apart; 0.6 when either is unknown. +pub fn duration_score(wanted: Option, found: Option) -> f64 { + match (wanted, found) { + (Some(w), Some(f)) if w > 0.0 && f > 0.0 => { + let d = (w - f).abs(); + if d <= 2.0 { + 1.0 + } else { + (1.0 - (d - 2.0) / 18.0).max(0.0) + } + } + _ => 0.6, + } +} + +fn qualifiers(title: &str) -> std::collections::HashSet { + let title = clean_title(title); + let mut quals: std::collections::HashSet = PAREN.captures_iter(&title).map(|c| c[1].to_string()).filter(|q| !q.trim().is_empty()).map(|q| normalize(&q)).collect(); + let stripped = PAREN.replace_all(&title, "").into_owned(); + if let Some(m) = DASH_SUFFIX.captures(&stripped) { + quals.insert(normalize(&m[1])); + } + quals.into_iter().filter(|q| !q.is_empty() && !BENIGN.is_match(q)).collect() +} + +pub fn qualifier_penalty(target: &str, candidate: &str) -> f64 { + let (tq, cq) = (qualifiers(target), qualifiers(candidate)); + let differing = cq.difference(&tq).count() + tq.difference(&cq).count(); + f64::min(0.6, 0.35 * differing as f64) +} + +fn core_title(title: &str) -> String { + let t = strip_feat(&clean_title(title)); + let no_paren = PAREN.replace_all(&t, "").into_owned(); + let core = DASH_SUFFIX.replace(&no_paren, "").trim().to_string(); + if core.is_empty() { + t + } else { + core + } +} + +pub fn match_score(title: &str, artists: &[String], duration: Option, cand_title: &str, cand_artists: &[String], cand_duration: Option) -> f64 { + let t = similarity(&core_title(title), &core_title(cand_title)); + let a = artist_similarity(artists, cand_artists); + let d = duration_score(duration, cand_duration); + let mut score = 0.45 * t + 0.35 * a + 0.2 * d; + if a < 0.5 && !artists.is_empty() && !cand_artists.is_empty() { + score *= 0.6; // a different artist is almost never the song we want + } + let penalty = version_penalty(title, cand_title).max(qualifier_penalty(title, cand_title)); + (score - penalty).max(0.0) +} + +/// A 'Lullaby Renditions of ...' album is a cover even when the song title matches. +pub fn album_penalty(wanted_album: &str, cand_album: &str) -> f64 { + if !cand_album.is_empty() && ALBUM_VERSION.is_match(cand_album) && !ALBUM_VERSION.is_match(wanted_album) { + 0.3 + } else { + 0.0 + } +} + +// ---- file names ---------------------------------------------------------------- + +fn bad_char(c: char) -> char { + match c { + '/' => '∕', + '\\' => '⧵', + ':' => '꞉', + '*' => '∗', + '?' => '?', + '"' => '”', + '<' => '‹', + '>' => '›', + '|' => 'ǀ', + c => c, + } +} + +/// One path segment that works on Linux and Windows alike. +pub fn safe_component(name: &str) -> String { + let n: String = name.chars().filter(|c| *c >= ' ').map(bad_char).collect(); + let mut n = n.trim().trim_end_matches(['.', ' ']).to_string(); + let stem = n.split('.').next().unwrap_or("").to_uppercase(); + let reserved = ["CON", "PRN", "AUX", "NUL"].contains(&stem.as_str()) + || ((stem.starts_with("COM") || stem.starts_with("LPT")) && stem.len() == 4 && stem.chars().last().map(|c| ('1'..='9').contains(&c)).unwrap_or(false)); + if reserved { + n = format!("_{n}"); + } + if n.len() > 200 { + let mut end = 200; + while !n.is_char_boundary(end) { + end -= 1; + } + n = n[..end].trim_end_matches(['.', ' ']).to_string(); + } + n +} + +pub fn format_duration(seconds: Option) -> String { + let Some(s) = seconds.filter(|s| *s >= 0.0) else { return "–:––".into() }; + let s = s.round() as i64; + let (h, rem) = (s / 3600, s % 3600); + let (m, s) = (rem / 60, rem % 60); + if h > 0 { + format!("{h}:{m:02}:{s:02}") + } else { + format!("{m}:{s:02}") + } +} + +pub fn format_size(num: f64) -> String { + if num <= 0.0 { + return String::new(); + } + let mut n = num; + for unit in ["B", "KB", "MB", "GB"] { + if n < 1024.0 { + return if unit == "B" { format!("{} B", n as i64) } else { format!("{n:.1} {unit}") }; + } + n /= 1024.0; + } + format!("{n:.1} TB") +} + +re!(YEAR, r"(1[89]\d\d|20\d\d)"); +pub fn parse_year(v: &str) -> String { + YEAR.captures(v).map(|c| c[1].to_string()).unwrap_or_default() +} + +re!(ISO_DUR, r"^P(?:T)?(?:(\d+)H)?(?:(\d+)M)?(?:(\d+(?:\.\d+)?)S)?"); +/// 'PT3M35S' -> 215.0 (schema.org durations). +pub fn parse_iso_duration(v: &str) -> Option { + let c = ISO_DUR.captures(v)?; + if c.get(1).is_none() && c.get(2).is_none() && c.get(3).is_none() { + return None; + } + let g = |i: usize| c.get(i).and_then(|m| m.as_str().parse::().ok()).unwrap_or(0.0); + Some(g(1) * 3600.0 + g(2) * 60.0 + g(3)) +} + +pub fn to_int(s: &str) -> Option { + s.split('/').next().and_then(|x| x.trim().parse().ok()) +} diff --git a/src/core/ytdlp.rs b/src/core/ytdlp.rs new file mode 100644 index 0000000..68e6841 --- /dev/null +++ b/src/core/ytdlp.rs @@ -0,0 +1,122 @@ +//! Running the yt-dlp command line: JSON extraction, searches and downloads. + +use super::paths; +use super::settings::{get_str, lookup}; +use super::{Log, Res}; +use serde_json::Value; +use std::io::{BufRead, BufReader}; +use std::process::{Command, Stdio}; +use std::sync::atomic::{AtomicBool, Ordering}; +use std::sync::{Arc, Mutex}; + +pub fn binary() -> Res { + paths::find_ytdlp().ok_or_else(|| "yt-dlp wasn't found. Install it (e.g. “sudo pacman -S yt-dlp”) and make sure it is on your PATH.".to_string()) +} + +pub fn version() -> Option { + let out = Command::new(paths::find_ytdlp()?).arg("--version").output().ok()?; + Some(String::from_utf8_lossy(&out.stdout).trim().to_string()) +} + +/// Options every yt-dlp call shares. +pub fn base_args(snap: &Value) -> Vec { + let mut a: Vec = ["--ignore-config", "--no-colors", "--socket-timeout", "20", "--retries", "5", "--fragment-retries", "5", "--no-playlist"].iter().map(|s| s.to_string()).collect(); + let rt = paths::js_runtimes(); + for r in if rt.is_empty() { vec!["deno"] } else { rt } { + a.push("--js-runtimes".into()); + a.push(r.into()); + } + if let Some(ff) = paths::find_ffmpeg(&get_str(snap, "download.ffmpeg_path")) { + a.push("--ffmpeg-location".into()); + a.push(ff); + } + let browser = lookup(snap, "download.cookies_browser").and_then(|v| v.as_str()).unwrap_or("none"); + if !browser.is_empty() && browser != "none" { + a.push("--cookies-from-browser".into()); + a.push(browser.into()); + } + a +} + +pub struct Outcome { + pub ok: bool, + pub cancelled: bool, + /// ERROR lines (without the prefix) + pub errors: Vec, +} + +/// Run yt-dlp, feeding each stdout line to `on_line` and stderr to the log. +pub fn run(args: &[String], cancel: Option<&Arc>, log: Log, mut on_line: impl FnMut(&str)) -> Res { + let mut cmd = Command::new(binary()?); + cmd.args(args).stdin(Stdio::null()).stdout(Stdio::piped()).stderr(Stdio::piped()); + let mut child = cmd.spawn().map_err(|e| format!("couldn't start yt-dlp: {e}"))?; + let stdout = child.stdout.take().unwrap(); + let stderr = child.stderr.take().unwrap(); + let child = Arc::new(Mutex::new(child)); + let done = Arc::new(AtomicBool::new(false)); + let was_cancelled = Arc::new(AtomicBool::new(false)); + let errors = Mutex::new(Vec::::new()); + std::thread::scope(|s| { + if let Some(c) = cancel { + let (child, done, c, wc) = (child.clone(), done.clone(), c.clone(), was_cancelled.clone()); + s.spawn(move || { + while !done.load(Ordering::Relaxed) { + if c.load(Ordering::Relaxed) { + wc.store(true, Ordering::Relaxed); + let _ = child.lock().unwrap().kill(); + break; + } + std::thread::sleep(std::time::Duration::from_millis(100)); + } + }); + } + s.spawn(|| { + for line in BufReader::new(stderr).lines().map_while(Result::ok) { + if let Some(e) = line.strip_prefix("ERROR: ") { + errors.lock().unwrap().push(e.to_string()); + log("error", e); + } else if let Some(w) = line.strip_prefix("WARNING: ") { + log("warning", w); + } else if let Some(e) = line.strip_prefix("yt-dlp: error: ") { + errors.lock().unwrap().push(e.to_string()); + log("error", e); + } else if !line.starts_with("[debug]") { + log("yt", &line); + } + } + }); + for line in BufReader::new(stdout).lines().map_while(Result::ok) { + on_line(&line); + } + let status = child.lock().unwrap().wait(); + done.store(true, Ordering::Relaxed); + status + }) + .map(|status| Outcome { ok: status.success(), cancelled: was_cancelled.load(Ordering::Relaxed), errors: errors.into_inner().unwrap() }) + .map_err(|e| e.to_string()) +} + +pub fn error_text(o: &Outcome) -> String { + o.errors.last().cloned().unwrap_or_else(|| "yt-dlp failed".into()) +} + +/// `yt-dlp -J` (or --flat-playlist -J) on a URL or search expression. +pub fn extract(snap: &Value, target: &str, flat: bool, extra: &[&str], log: Log) -> Res { + let mut args = base_args(snap); + args.push("-J".into()); + args.push("--no-warnings".into()); + if flat { + args.push("--flat-playlist".into()); + // playlists are wanted here; override the --no-playlist default + args.push("--yes-playlist".into()); + } + args.extend(extra.iter().map(|s| s.to_string())); + args.push("--".into()); + args.push(target.into()); + let mut json = String::new(); + let out = run(&args, None, log, |l| json.push_str(l))?; + if !out.ok || json.trim().is_empty() { + return Err(error_text(&out)); + } + serde_json::from_str(&json).map_err(|e| format!("yt-dlp output wasn't JSON: {e}")) +} diff --git a/src/core/ytmusic.rs b/src/core/ytmusic.rs new file mode 100644 index 0000000..d44d99c --- /dev/null +++ b/src/core/ytmusic.rs @@ -0,0 +1,327 @@ +//! A small YouTube Music (innertube) client: search, albums and artists. No API key or login. + +use super::http; +use super::metadata::{js, jarr}; +use super::models::Track; +use super::textutil::to_int; +use super::Res; +use serde_json::{json, Value}; + +const BASE: &str = "https://music.youtube.com/youtubei/v1"; + +fn context() -> Value { + json!({"client": {"clientName": "WEB_REMIX", "clientVersion": "1.20250101.01.00", "hl": "en", "gl": "US"}, "user": {}}) +} + +fn call(endpoint: &str, mut body: Value) -> Res { + body["context"] = context(); + let url = format!("{BASE}/{endpoint}?prettyPrint=false"); + let headers = [ + ("User-Agent", http::BROWSER_UA), + ("Origin", "https://music.youtube.com"), + ("Referer", "https://music.youtube.com/"), + ("Cookie", "SOCS=CAI"), + ("X-Goog-Api-Format-Version", "1"), + ]; + Ok(http::post_json(&url, &body, &headers)?) +} + +pub fn search_params(filter: &str) -> &'static str { + match filter { + "songs" => "EgWKAQIIAWoMEA4QChADEAQQCRAF", + "videos" => "EgWKAQIQAWoMEA4QChADEAQQCRAF", + "albums" => "EgWKAQIYAWoMEA4QChADEAQQCRAF", + "artists" => "EgWKAQIgAWoMEA4QChADEAQQCRAF", + _ => "", + } +} + +/// Every object under `key` anywhere in the tree. +pub fn find_all<'a>(v: &'a Value, key: &str, out: &mut Vec<&'a Value>) { + match v { + Value::Object(m) => { + for (k, x) in m { + if k == key { + out.push(x); + } else { + find_all(x, key, out); + } + } + } + Value::Array(a) => a.iter().for_each(|x| find_all(x, key, out)), + _ => {} + } +} + +fn first_str(v: &Value, key: &str) -> Option { + let mut out = vec![]; + find_all(v, key, &mut out); + out.into_iter().find_map(|x| x.as_str().map(String::from)) +} + +fn runs(v: &Value) -> &[Value] { + jarr(v.get("text").unwrap_or(&Value::Null), "runs") +} + +fn flex_runs(item: &Value, col: usize) -> Vec { + item.get("flexColumns") + .and_then(|c| c.as_array()) + .and_then(|c| c.get(col)) + .and_then(|c| c.get("musicResponsiveListItemFlexColumnRenderer")) + .map(|c| runs(c).to_vec()) + .unwrap_or_default() +} + +fn thumbnails(v: &Value) -> String { + let mut out = vec![]; + find_all(v, "thumbnails", &mut out); + let best = out.iter().filter_map(|t| t.as_array()).flatten().last().cloned().unwrap_or(Value::Null); + big_thumb(&js(&best, "url"), 1200) +} + +pub fn big_thumb(url: &str, size: u32) -> String { + if url.contains("googleusercontent") || url.contains("ggpht") { + if let Some((base, _)) = url.split_once('=') { + return format!("{base}=w{size}-h{size}-l90-rj"); + } + } + url.to_string() +} + +fn parse_duration(s: &str) -> Option { + let parts: Vec<&str> = s.split(':').collect(); + if parts.len() < 2 || parts.len() > 3 || !parts.iter().all(|p| p.chars().all(|c| c.is_ascii_digit()) && !p.is_empty()) { + return None; + } + Some(parts.iter().fold(0.0, |acc, p| acc * 60.0 + p.parse::().unwrap_or(0.0))) +} + +fn nav_browse(r: &Value) -> Option { + first_str(r, "browseId") +} + +/// A song row from search results, an album page or an artist's song list. +fn song_from_item(item: &Value, album_name: &str) -> Option { + let video_id = item + .get("playlistItemData") + .map(|p| js(p, "videoId")) + .filter(|s| !s.is_empty()) + .or_else(|| { + let mut found = vec![]; + find_all(item, "watchEndpoint", &mut found); + found.iter().map(|w| js(w, "videoId")).find(|s| !s.is_empty()) + })?; + let title_runs = flex_runs(item, 0); + let title = title_runs.iter().map(|r| js(r, "text")).collect::(); + if title.is_empty() { + return None; + } + let mut artists = vec![]; + let mut album = album_name.to_string(); + let mut duration = None; + let mut year = String::new(); + for col in 1..4 { + for r in flex_runs(item, col) { + let text = js(&r, "text"); + let id = nav_browse(&r).unwrap_or_default(); + if id.starts_with("UC") && !artists.contains(&text) { + artists.push(text); + } else if id.starts_with("MPRE") { + album = text; + } else if let Some(d) = parse_duration(&text) { + duration = Some(d); + } else if text.len() == 4 && text.chars().all(|c| c.is_ascii_digit()) { + year = text; + } + } + } + if duration.is_none() { + // album pages keep the length in fixedColumns + let mut fixed = vec![]; + find_all(item.get("fixedColumns").unwrap_or(&Value::Null), "text", &mut fixed); + for t in fixed { + let s = t.get("runs").and_then(|r| r.as_array()).and_then(|r| r.first()).map(|r| js(r, "text")).or_else(|| t.as_str().map(String::from)).unwrap_or_default(); + if let Some(d) = parse_duration(&s) { + duration = Some(d); + } + } + } + let url = format!("https://music.youtube.com/watch?v={video_id}"); + let mut t = Track::new(); + t.title = title; + t.artists = artists; + t.album = album; + t.duration = duration; + t.cover_url = thumbnails(item); + t.service = "ytmusic".into(); + t.download_url = url.clone(); + t.page_url = url; + t.source_id = video_id; + t.year = year; + t.authoritative = true; + Some(t) +} + +pub fn search_songs(query: &str, limit: usize) -> Res> { + let data = call("search", json!({"query": query, "params": search_params("songs")}))?; + let mut items = vec![]; + find_all(&data, "musicResponsiveListItemRenderer", &mut items); + Ok(items.into_iter().filter_map(|i| song_from_item(i, "")).take(limit).collect()) +} + +pub struct Album { + pub title: String, + pub artists: Vec, + pub year: String, + pub cover: String, + pub tracks: Vec, +} + +pub fn get_album(browse_id: &str) -> Res { + let data = call("browse", json!({"browseId": browse_id}))?; + let mut headers = vec![]; + for k in ["musicResponsiveHeaderRenderer", "musicDetailHeaderRenderer", "musicImmersiveHeaderRenderer"] { + find_all(&data, k, &mut headers); + } + let header = headers.first().copied().cloned().unwrap_or(Value::Null); + let title = header.get("title").map(|t| runs(&json!({"text": t.clone()})).iter().map(|r| js(r, "text")).collect::()).unwrap_or_default(); + // subtitle runs: "Album • Artist • 2020" + let mut artists = vec![]; + let mut year = String::new(); + let mut sub = vec![]; + for k in ["straplineTextOne", "subtitle"] { + if let Some(s) = header.get(k) { + sub.extend(jarr(s, "runs").iter().cloned()); + } + } + for r in &sub { + let t = js(r, "text"); + if nav_browse(r).map(|b| b.starts_with("UC")).unwrap_or(false) { + artists.push(t); + } else if t.len() == 4 && t.chars().all(|c| c.is_ascii_digit()) { + year = t; + } + } + let cover = thumbnails(&header); + let mut items = vec![]; + find_all(&data, "musicResponsiveListItemRenderer", &mut items); + let mut tracks: Vec = items.into_iter().filter_map(|i| { + let mut t = song_from_item(i, &title)?; + let mut idx = vec![]; + find_all(i, "index", &mut idx); + t.track_number = idx.first().and_then(|x| x.get("runs")).and_then(|r| r.as_array()).and_then(|r| r.first()).and_then(|r| to_int(&js(r, "text"))); + Some(t) + }).collect(); + if title.is_empty() && tracks.is_empty() { + return Err("YouTube Music returned nothing for that album".into()); + } + let total = tracks.len() as i64; + for (i, t) in tracks.iter_mut().enumerate() { + t.album = title.clone(); + t.album_artist = artists.join(", "); + t.track_number = t.track_number.or(Some(i as i64 + 1)); + t.track_total = Some(total); + t.year = year.clone(); + t.cover_url = cover.clone(); + if t.artists.is_empty() { + t.artists = artists.clone(); + } + } + Ok(Album { title, artists, year, cover, tracks }) +} + +pub struct Release { + pub browse_id: String, + pub title: String, +} + +pub struct Artist { + pub name: String, + pub cover: String, + pub songs: Vec, + /// browseId of the "all songs" playlist, when the page has one + pub songs_browse: Option, + pub releases: Vec, +} + +fn two_row_releases(v: &Value) -> Vec { + let mut items = vec![]; + find_all(v, "musicTwoRowItemRenderer", &mut items); + items + .into_iter() + .filter_map(|i| { + let id = nav_browse(i)?; + if !id.starts_with("MPRE") { + return None; + } + let title = i.get("title").map(|t| jarr(t, "runs").iter().map(|r| js(r, "text")).collect::()).unwrap_or_default(); + Some(Release { browse_id: id, title }) + }) + .collect() +} + +pub fn get_artist(browse_id: &str, full_discography: bool) -> Res { + let data = call("browse", json!({"browseId": browse_id}))?; + let mut headers = vec![]; + for k in ["musicImmersiveHeaderRenderer", "musicVisualHeaderRenderer", "musicHeaderRenderer"] { + find_all(&data, k, &mut headers); + } + let header = headers.first().copied().cloned().unwrap_or(Value::Null); + let name = header.get("title").map(|t| jarr(t, "runs").iter().map(|r| js(r, "text")).collect::()).unwrap_or_default(); + if name.is_empty() { + return Err("Couldn't read that artist page".into()); + } + let cover = thumbnails(&header); + let mut songs = vec![]; + let mut songs_browse = None; + let mut releases: Vec = vec![]; + let mut shelves = vec![]; + find_all(&data, "musicShelfRenderer", &mut shelves); + for sh in shelves { + let mut items = vec![]; + find_all(sh, "musicResponsiveListItemRenderer", &mut items); + songs.extend(items.into_iter().filter_map(|i| song_from_item(i, ""))); + if let Some(h) = sh.get("title").and_then(|t| t.get("runs")).and_then(|r| r.as_array()).and_then(|r| r.first()) { + songs_browse = nav_browse(h).filter(|b| b.starts_with("VL")); + } + } + let mut carousels = vec![]; + find_all(&data, "musicCarouselShelfRenderer", &mut carousels); + for car in carousels { + let title = first_str(car.get("header").unwrap_or(&Value::Null), "text").unwrap_or_default().to_lowercase(); + if !(title.contains("album") || title.contains("single") || title.contains("ep")) { + continue; + } + let mut found = two_row_releases(car); + if full_discography { + // the "more" button opens the complete grid + let mut btn = vec![]; + find_all(car.get("header").unwrap_or(&Value::Null), "moreContentButton", &mut btn); + if let Some(be) = btn.first().and_then(|b| { let mut x = vec![]; find_all(b, "browseEndpoint", &mut x); x.first().copied().cloned() }) { + if let Ok(grid) = call("browse", json!({"browseId": js(&be, "browseId"), "params": js(&be, "params")})) { + let more = two_row_releases(&grid); + if more.len() > found.len() { + found = more; + } + } + } + } + releases.extend(found); + } + let mut seen = std::collections::HashSet::new(); + releases.retain(|r| seen.insert(r.browse_id.clone())); + for s in songs.iter_mut() { + if s.artists.is_empty() { + s.artists = vec![name.clone()]; + } + } + Ok(Artist { name, cover, songs, songs_browse, releases }) +} + +/// All tracks of a playlist-style browse id (an artist's "all songs"). +pub fn get_playlist_tracks(browse_id: &str) -> Res> { + let data = call("browse", json!({"browseId": browse_id}))?; + let mut items = vec![]; + find_all(&data, "musicResponsiveListItemRenderer", &mut items); + Ok(items.into_iter().filter_map(|i| song_from_item(i, "")).collect()) +} diff --git a/src/icondata.rs b/src/icondata.rs new file mode 100644 index 0000000..5824b54 --- /dev/null +++ b/src/icondata.rs @@ -0,0 +1,188 @@ +//! Material Symbols Rounded (Apache 2.0) path data, viewBox 0 -960 960 960. Generated by tools/gen_icons.py. + +pub const ICONS: &[(&str, &str)] = &[ + ("add", "M450-450H230q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h220v-220q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v220h220q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H510v220q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63-8.5-8.62-8.5-21.37v-220Z"), + ("album", "M480 -204Q555 -204 607.5 -256.5Q660 -309 660 -384Q660 -459 607.5 -511.5Q555 -564 480 -564Q405 -564 352.5 -511.5Q300 -459 300 -384Q300 -309 352.5 -256.5Q405 -204 480 -204ZM480 -344Q463 -344 451.5 -355.5Q440 -367 440 -384Q440 -401 451.5 -412.5Q463 -424 480 -424Q497 -424 508.5 -412.5Q520 -401 520 -384Q520 -367 508.5 -355.5Q497 -344 480 -344ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16ZM480 -64Q614 -64 707 -157Q800 -250 800 -384Q800 -518 707 -611Q614 -704 480 -704Q346 -704 253 -611Q160 -518 160 -384Q160 -250 253 -157Q346 -64 480 -64ZM480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Z"), + ("album_fill", "M480 -204Q555 -204 607.5 -256.5Q660 -309 660 -384Q660 -459 607.5 -511.5Q555 -564 480 -564Q405 -564 352.5 -511.5Q300 -459 300 -384Q300 -309 352.5 -256.5Q405 -204 480 -204ZM480 -344Q463 -344 451.5 -355.5Q440 -367 440 -384Q440 -401 451.5 -412.5Q463 -424 480 -424Q497 -424 508.5 -412.5Q520 -401 520 -384Q520 -367 508.5 -355.5Q497 -344 480 -344ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16Z"), + ("android", "M40 -144Q49 -251 105.5 -341Q162 -431 256 -484L182 -612Q176 -621 179 -631Q182 -641 192 -646Q200 -651 210 -648Q220 -645 226 -636L300 -508Q386 -544 480 -544Q574 -544 660 -508L734 -636Q740 -645 750 -648Q760 -651 768 -646Q778 -641 781 -631Q784 -621 778 -612L704 -484Q798 -431 854.5 -341Q911 -251 920 -144ZM280 -254Q301 -254 315.5 -268.5Q330 -283 330 -304Q330 -325 315.5 -339.5Q301 -354 280 -354Q259 -354 244.5 -339.5Q230 -325 230 -304Q230 -283 244.5 -268.5Q259 -254 280 -254ZM680 -254Q701 -254 715.5 -268.5Q730 -283 730 -304Q730 -325 715.5 -339.5Q701 -354 680 -354Q659 -354 644.5 -339.5Q630 -325 630 -304Q630 -283 644.5 -268.5Q659 -254 680 -254Z"), + ("arrow_back", "m274-450 227 227q9 9 9 21t-9 21q-9 9-21 9t-21-9L181-459q-5-5-7-10t-2-11q0-6 2-11t7-10l278-278q9-9 21-9t21 9q9 9 9 21t-9 21L274-510h496q13 0 21.5 8.5T800-480q0 13-8.5 21.5T770-450H274Z"), + ("arrow_forward", "M647 -344H200Q183 -344 171.5 -355.5Q160 -367 160 -384Q160 -401 171.5 -412.5Q183 -424 200 -424H647L451 -620Q439 -632 439.5 -648Q440 -664 452 -676Q464 -687 480 -687.5Q496 -688 508 -676L772 -412Q778 -406 780.5 -399Q783 -392 783 -384Q783 -376 780.5 -369Q778 -362 772 -356L508 -92Q497 -81 480.5 -81Q464 -81 452 -92Q440 -104 440 -120.5Q440 -137 452 -149Z"), + ("art_track", "M100-200q-24 0-42-18t-18-42v-440q0-24 18-42t42-18h440q24 0 42 18t18 42v440q0 24-18 42t-42 18H100Zm0-60h440v-440H100v440Zm196-120-48-66q-5-6-12-6t-12 6l-50 65q-6 8-1.32 16t13.32 8h265q8.5 0 12.75-8t-.75-16l-70-93q-5-6-12-6t-12 6l-73 94Zm412.5 171.37Q700-217.25 700-230v-500q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v500q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63Zm160 0Q860-217.25 860-230v-500q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v500q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63ZM100-260v-440 440Z"), + ("artist", "M700 -64Q658 -64 629 -93Q600 -122 600 -164Q600 -206 629 -235Q658 -264 700 -264Q708 -264 718 -262.5Q728 -261 740 -256V-424Q740 -441 751.5 -452.5Q763 -464 780 -464H840Q857 -464 868.5 -452.5Q880 -441 880 -424Q880 -407 868.5 -395.5Q857 -384 840 -384H800V-164Q800 -122 771 -93Q742 -64 700 -64ZM160 -64Q143 -64 131.5 -75.5Q120 -87 120 -104V-176Q120 -211 137.5 -239Q155 -267 184 -282Q246 -313 310 -328.5Q374 -344 440 -344Q463 -344 487 -342.5Q511 -341 534 -336Q555 -332 563 -318Q571 -304 569 -289Q567 -274 555 -263Q543 -252 524 -256Q503 -260 482.5 -262Q462 -264 440 -264Q383 -264 328 -250Q273 -236 220 -210Q211 -205 205.5 -196Q200 -187 200 -176V-144H493Q513 -144 523 -131.5Q533 -119 533 -104Q533 -89 523 -76.5Q513 -64 493 -64ZM440 -384Q374 -384 327 -431Q280 -478 280 -544Q280 -610 327 -657Q374 -704 440 -704Q506 -704 553 -657Q600 -610 600 -544Q600 -478 553 -431Q506 -384 440 -384ZM440 -464Q473 -464 496.5 -487.5Q520 -511 520 -544Q520 -577 496.5 -600.5Q473 -624 440 -624Q407 -624 383.5 -600.5Q360 -577 360 -544Q360 -511 383.5 -487.5Q407 -464 440 -464ZM440 -544Q440 -544 440 -544Q440 -544 440 -544Q440 -544 440 -544Q440 -544 440 -544Q440 -544 440 -544Q440 -544 440 -544Q440 -544 440 -544Q440 -544 440 -544ZM440 -144Q440 -144 440 -144Q440 -144 440 -144Q440 -144 440 -144Q440 -144 440 -144Q440 -144 440 -144Q440 -144 440 -144Q440 -144 440 -144Q440 -144 440 -144Z"), + ("artist_fill", "M700 -64Q658 -64 629 -93Q600 -122 600 -164Q600 -206 629 -235Q658 -264 700 -264Q708 -264 718 -262.5Q728 -261 740 -256V-424Q740 -441 751.5 -452.5Q763 -464 780 -464H840Q857 -464 868.5 -452.5Q880 -441 880 -424Q880 -407 868.5 -395.5Q857 -384 840 -384H800V-164Q800 -122 771 -93Q742 -64 700 -64ZM440 -384Q374 -384 327 -431Q280 -478 280 -544Q280 -610 327 -657Q374 -704 440 -704Q506 -704 553 -657Q600 -610 600 -544Q600 -478 553 -431Q506 -384 440 -384ZM160 -64Q143 -64 131.5 -75.5Q120 -87 120 -104V-176Q120 -211 137.5 -239Q155 -267 184 -282Q246 -313 310 -328.5Q374 -344 440 -344Q468 -344 495.5 -341Q523 -338 551 -332Q568 -328 572.5 -311Q577 -294 563 -280Q542 -255 531.5 -225.5Q521 -196 521 -164Q521 -151 522.5 -138.5Q524 -126 528 -113Q533 -95 523.5 -79.5Q514 -64 497 -64Z"), + ("auto_awesome", "M550-590q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h100v-160q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v160h100q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H550Zm108.5 461.37Q650-137.25 650-150v-350q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v350q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63Zm-400 0Q250-137.25 250-150v-150H150q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h260q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H310v150q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63Zm0-300Q250-437.25 250-450v-360q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v360q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63Z"), + ("badge", "M240 -144H480V-162Q480 -179 470.5 -193.5Q461 -208 444 -216Q424 -225 403.5 -229.5Q383 -234 360 -234Q337 -234 316.5 -229.5Q296 -225 276 -216Q259 -208 249.5 -193.5Q240 -179 240 -162ZM590 -204H690Q703 -204 711.5 -212.5Q720 -221 720 -234Q720 -247 711.5 -255.5Q703 -264 690 -264H590Q577 -264 568.5 -255.5Q560 -247 560 -234Q560 -221 568.5 -212.5Q577 -204 590 -204ZM360 -264Q385 -264 402.5 -281.5Q420 -299 420 -324Q420 -349 402.5 -366.5Q385 -384 360 -384Q335 -384 317.5 -366.5Q300 -349 300 -324Q300 -299 317.5 -281.5Q335 -264 360 -264ZM590 -324H690Q703 -324 711.5 -332.5Q720 -341 720 -354Q720 -367 711.5 -375.5Q703 -384 690 -384H590Q577 -384 568.5 -375.5Q560 -367 560 -354Q560 -341 568.5 -332.5Q577 -324 590 -324ZM160 16Q127 16 103.5 -7.5Q80 -31 80 -64V-504Q80 -537 103.5 -560.5Q127 -584 160 -584H360V-704Q360 -737 383.5 -760.5Q407 -784 440 -784H520Q553 -784 576.5 -760.5Q600 -737 600 -704V-584H800Q833 -584 856.5 -560.5Q880 -537 880 -504V-64Q880 -31 856.5 -7.5Q833 16 800 16ZM160 -64H800Q800 -64 800 -64Q800 -64 800 -64V-504Q800 -504 800 -504Q800 -504 800 -504H600Q600 -471 576.5 -447.5Q553 -424 520 -424H440Q407 -424 383.5 -447.5Q360 -471 360 -504H160Q160 -504 160 -504Q160 -504 160 -504V-64Q160 -64 160 -64Q160 -64 160 -64ZM440 -504H520V-704H440ZM480 -284Q480 -284 480 -284Q480 -284 480 -284Q480 -284 480 -284Q480 -284 480 -284Q480 -284 480 -284Q480 -284 480 -284Q480 -284 480 -284Q480 -284 480 -284Q480 -284 480 -284Q480 -284 480 -284Q480 -284 480 -284Q480 -284 480 -284Z"), + ("badge_fill", "M240 -144H480V-162Q480 -179 470.5 -193.5Q461 -208 444 -216Q424 -225 403.5 -229.5Q383 -234 360 -234Q337 -234 316.5 -229.5Q296 -225 276 -216Q259 -208 249.5 -193.5Q240 -179 240 -162ZM590 -204H690Q703 -204 711.5 -212.5Q720 -221 720 -234Q720 -247 711.5 -255.5Q703 -264 690 -264H590Q577 -264 568.5 -255.5Q560 -247 560 -234Q560 -221 568.5 -212.5Q577 -204 590 -204ZM360 -264Q385 -264 402.5 -281.5Q420 -299 420 -324Q420 -349 402.5 -366.5Q385 -384 360 -384Q335 -384 317.5 -366.5Q300 -349 300 -324Q300 -299 317.5 -281.5Q335 -264 360 -264ZM590 -324H690Q703 -324 711.5 -332.5Q720 -341 720 -354Q720 -367 711.5 -375.5Q703 -384 690 -384H590Q577 -384 568.5 -375.5Q560 -367 560 -354Q560 -341 568.5 -332.5Q577 -324 590 -324ZM160 16Q127 16 103.5 -7.5Q80 -31 80 -64V-504Q80 -537 103.5 -560.5Q127 -584 160 -584H360V-704Q360 -737 383.5 -760.5Q407 -784 440 -784H520Q553 -784 576.5 -760.5Q600 -737 600 -704V-584H800Q833 -584 856.5 -560.5Q880 -537 880 -504V-64Q880 -31 856.5 -7.5Q833 16 800 16ZM440 -504H520V-704H440Z"), + ("battery_saver", "M640 -104H560Q543 -104 531.5 -115.5Q520 -127 520 -144Q520 -161 531.5 -172.5Q543 -184 560 -184H640V-264Q640 -281 651.5 -292.5Q663 -304 680 -304Q697 -304 708.5 -292.5Q720 -281 720 -264V-184H800Q817 -184 828.5 -172.5Q840 -161 840 -144Q840 -127 828.5 -115.5Q817 -104 800 -104H720V-24Q720 -7 708.5 4.5Q697 16 680 16Q663 16 651.5 4.5Q640 -7 640 -24ZM360 -64Q360 -64 360 -64Q360 -64 360 -64Q360 -64 360 -64Q360 -64 360 -64ZM320 16Q303 16 291.5 4.5Q280 -7 280 -24V-664Q280 -681 291.5 -692.5Q303 -704 320 -704H400V-744Q400 -761 411.5 -772.5Q423 -784 440 -784H520Q537 -784 548.5 -772.5Q560 -761 560 -744V-704H640Q657 -704 668.5 -692.5Q680 -681 680 -664V-424Q680 -407 668.5 -395.5Q657 -384 640 -384Q623 -384 611.5 -395.5Q600 -407 600 -424V-624H360V-64H461Q478 -64 489.5 -52.5Q501 -41 501 -24Q501 -7 489.5 4.5Q478 16 461 16Z"), + ("battery_saver_fill", "M640 -104H560Q543 -104 531.5 -115.5Q520 -127 520 -144Q520 -161 531.5 -172.5Q543 -184 560 -184H640V-264Q640 -281 651.5 -292.5Q663 -304 680 -304Q697 -304 708.5 -292.5Q720 -281 720 -264V-184H800Q817 -184 828.5 -172.5Q840 -161 840 -144Q840 -127 828.5 -115.5Q817 -104 800 -104H720V-24Q720 -7 708.5 4.5Q697 16 680 16Q663 16 651.5 4.5Q640 -7 640 -24ZM320 16Q303 16 291.5 4.5Q280 -7 280 -24V-664Q280 -681 291.5 -692.5Q303 -704 320 -704H400V-744Q400 -761 411.5 -772.5Q423 -784 440 -784H520Q537 -784 548.5 -772.5Q560 -761 560 -744V-704H640Q657 -704 668.5 -692.5Q680 -681 680 -664V-411Q680 -400 672 -391.5Q664 -383 653 -382Q611 -377 575 -359.5Q539 -342 511 -314Q479 -282 459.5 -238.5Q440 -195 440 -144Q440 -114 447 -86Q454 -58 468 -32Q476 -15 468 0.5Q460 16 443 16Z"), + ("block", "M480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16ZM480 -64Q534 -64 584 -81.5Q634 -99 676 -132L228 -580Q195 -538 177.5 -488Q160 -438 160 -384Q160 -250 253 -157Q346 -64 480 -64ZM732 -188Q765 -230 782.5 -280Q800 -330 800 -384Q800 -518 707 -611Q614 -704 480 -704Q426 -704 376 -686.5Q326 -669 284 -636Z"), + ("bookmark", "M480 -144 312 -72Q272 -55 236 -78.5Q200 -102 200 -145V-664Q200 -697 223.5 -720.5Q247 -744 280 -744H680Q713 -744 736.5 -720.5Q760 -697 760 -664V-145Q760 -102 724 -78.5Q688 -55 648 -72ZM480 -232 680 -146Q680 -146 680 -146Q680 -146 680 -146V-664Q680 -664 680 -664Q680 -664 680 -664H280Q280 -664 280 -664Q280 -664 280 -664V-146Q280 -146 280 -146Q280 -146 280 -146ZM480 -664H280Q280 -664 280 -664Q280 -664 280 -664Q280 -664 280 -664Q280 -664 280 -664H680Q680 -664 680 -664Q680 -664 680 -664Q680 -664 680 -664Q680 -664 680 -664Z"), + ("bookmark_fill", "M480 -144 312 -72Q272 -55 236 -78.5Q200 -102 200 -145V-664Q200 -697 223.5 -720.5Q247 -744 280 -744H680Q713 -744 736.5 -720.5Q760 -697 760 -664V-145Q760 -102 724 -78.5Q688 -55 648 -72Z"), + ("cancel", "M480 -328 596 -212Q607 -201 624 -201Q641 -201 652 -212Q663 -223 663 -240Q663 -257 652 -268L536 -384L652 -500Q663 -511 663 -528Q663 -545 652 -556Q641 -567 624 -567Q607 -567 596 -556L480 -440L364 -556Q353 -567 336 -567Q319 -567 308 -556Q297 -545 297 -528Q297 -511 308 -500L424 -384L308 -268Q297 -257 297 -240Q297 -223 308 -212Q319 -201 336 -201Q353 -201 364 -212ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16ZM480 -64Q614 -64 707 -157Q800 -250 800 -384Q800 -518 707 -611Q614 -704 480 -704Q346 -704 253 -611Q160 -518 160 -384Q160 -250 253 -157Q346 -64 480 -64ZM480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Z"), + ("cancel_fill", "M480 -328 596 -212Q607 -201 624 -201Q641 -201 652 -212Q663 -223 663 -240Q663 -257 652 -268L536 -384L652 -500Q663 -511 663 -528Q663 -545 652 -556Q641 -567 624 -567Q607 -567 596 -556L480 -440L364 -556Q353 -567 336 -567Q319 -567 308 -556Q297 -545 297 -528Q297 -511 308 -500L424 -384L308 -268Q297 -257 297 -240Q297 -223 308 -212Q319 -201 336 -201Q353 -201 364 -212ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16Z"), + ("check", "M382 -258 721 -597Q733 -609 749 -609Q765 -609 777 -597Q789 -585 789 -568.5Q789 -552 777 -540L410 -172Q398 -160 382 -160Q366 -160 354 -172L182 -344Q170 -356 170.5 -372.5Q171 -389 183 -401Q195 -413 211.5 -413Q228 -413 240 -401Z"), + ("check_circle", "M424 -312 338 -398Q327 -409 310 -409Q293 -409 282 -398Q271 -387 271 -370Q271 -353 282 -342L396 -228Q408 -216 424 -216Q440 -216 452 -228L678 -454Q689 -465 689 -482Q689 -499 678 -510Q667 -521 650 -521Q633 -521 622 -510ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16ZM480 -64Q614 -64 707 -157Q800 -250 800 -384Q800 -518 707 -611Q614 -704 480 -704Q346 -704 253 -611Q160 -518 160 -384Q160 -250 253 -157Q346 -64 480 -64ZM480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Z"), + ("check_circle_fill", "M424 -312 338 -398Q327 -409 310 -409Q293 -409 282 -398Q271 -387 271 -370Q271 -353 282 -342L396 -228Q408 -216 424 -216Q440 -216 452 -228L678 -454Q689 -465 689 -482Q689 -499 678 -510Q667 -521 650 -521Q633 -521 622 -510ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16Z"), + ("chevron_left", "m406-481 177 177q9 9 8.5 21t-9.5 21q-9 9-21.5 9t-21.5-9L341-460q-5-5-7-10t-2-11q0-6 2-11t7-10l199-199q9-9 21.5-9t21.5 9q9 9 9 21.5t-9 21.5L406-481Z"), + ("chevron_right", "M530-481 353-658q-9-9-8.5-21t9.5-21q9-9 21.5-9t21.5 9l198 198q5 5 7 10t2 11q0 6-2 11t-7 10L396-261q-9 9-21 8.5t-21-9.5q-9-9-9-21.5t9-21.5l176-176Z"), + ("clear_all", "M160 -184Q143 -184 131.5 -195.5Q120 -207 120 -224Q120 -241 131.5 -252.5Q143 -264 160 -264H640Q657 -264 668.5 -252.5Q680 -241 680 -224Q680 -207 668.5 -195.5Q657 -184 640 -184ZM240 -344Q223 -344 211.5 -355.5Q200 -367 200 -384Q200 -401 211.5 -412.5Q223 -424 240 -424H720Q737 -424 748.5 -412.5Q760 -401 760 -384Q760 -367 748.5 -355.5Q737 -344 720 -344ZM320 -504Q303 -504 291.5 -515.5Q280 -527 280 -544Q280 -561 291.5 -572.5Q303 -584 320 -584H800Q817 -584 828.5 -572.5Q840 -561 840 -544Q840 -527 828.5 -515.5Q817 -504 800 -504Z"), + ("close", "M480 -328 284 -132Q273 -121 256 -121Q239 -121 228 -132Q217 -143 217 -160Q217 -177 228 -188L424 -384L228 -580Q217 -591 217 -608Q217 -625 228 -636Q239 -647 256 -647Q273 -647 284 -636L480 -440L676 -636Q687 -647 704 -647Q721 -647 732 -636Q743 -625 743 -608Q743 -591 732 -580L536 -384L732 -188Q743 -177 743 -160Q743 -143 732 -132Q721 -121 704 -121Q687 -121 676 -132Z"), + ("close_fullscreen", "M420-378 143-101q-9 9-21 9t-21-9q-9-9-9-21t9-21l277-277H190q-13 0-21.5-8.5T160-450q0-13 8.5-21.5T190-480h260q13 0 21.5 8.5T480-450v260q0 13-8.5 21.5T450-160q-13 0-21.5-8.5T420-190v-188Zm162-162h188q13 0 21.5 8.5T800-510q0 13-8.5 21.5T770-480H510q-13 0-21.5-8.5T480-510v-260q0-13 8.5-21.5T510-800q13 0 21.5 8.5T540-770v188l277-277q9-9 21-9t21 9q9 9 9 21t-9 21L582-540Z"), + ("cloud_download", "M451-448v-289q-86 11-135 75.5T267-522h-19q-61 0-104.5 43T100-371q0 65 45 108t106 43h500q45 0 77-32t32-77q0-45-32-77t-77-32h-63v-84q0-68-33-117.5T570-718v-65q81 29 129.5 101T748-522v24q72-2 122 46t50 123q0 69-50 119t-119 50H251q-88 0-149.5-61.5T40-371q0-79 50.5-137.5T217-579q15-84 82-148.5T451-792q24 0 42 13.5t18 36.5v294l62-62q9-9 21-9t21 9q9 9 9 21.5t-9 21.5L502-353q-9 9-21 9t-21-9L346-467q-9-9-8.5-21.5T347-510q9-9 21.5-9t21.5 9l61 62Zm29-59Z"), + ("colorize", "M120 -64V-181Q120 -197 126 -211.5Q132 -226 143 -237L478 -572L420 -628L478 -684L554 -608L678 -732Q683 -737 690.5 -740Q698 -743 706 -743Q714 -743 721 -740Q728 -737 734 -732L828 -638Q833 -632 836 -625Q839 -618 839 -610Q839 -602 836 -594.5Q833 -587 828 -582L705 -459L781 -381L724 -324L668 -382L333 -47Q322 -36 307.5 -30Q293 -24 277 -24H160Q143 -24 131.5 -35.5Q120 -47 120 -64ZM200 -104H278L610 -438L534 -514L200 -182ZM647 -514 743 -610 706 -647 610 -551ZM647 -514 610 -551 647 -514Z"), + ("colorize_fill", "M120 -64V-181Q120 -197 126 -211.5Q132 -226 143 -237L478 -572L420 -628L478 -684L554 -608L678 -732Q683 -737 690.5 -740Q698 -743 706 -743Q714 -743 721 -740Q728 -737 734 -732L828 -638Q833 -632 836 -625Q839 -618 839 -610Q839 -602 836 -594.5Q833 -587 828 -582L705 -459L781 -381L724 -324L668 -382L333 -47Q322 -36 307.5 -30Q293 -24 277 -24H160Q143 -24 131.5 -35.5Q120 -47 120 -64ZM200 -104H278L610 -438L534 -514L200 -182Z"), + ("colors", "M346 -44 100 -290Q90 -300 85 -312Q80 -324 80 -337Q80 -350 85 -362Q90 -374 100 -384L330 -613L255 -688Q242 -701 241.5 -719Q241 -737 254 -751Q267 -765 286 -765Q305 -765 319 -751L686 -384Q696 -374 700.5 -362Q705 -350 705 -337Q705 -324 700.5 -312Q696 -300 686 -290L440 -44Q430 -34 418 -29Q406 -24 393 -24Q380 -24 368 -29Q356 -34 346 -44ZM393 -550 179 -336Q179 -336 179 -336Q179 -336 179 -336H607Q607 -336 607 -336Q607 -336 607 -336ZM792 -24Q756 -24 731 -49.5Q706 -75 706 -112Q706 -139 719.5 -163Q733 -187 750 -210L769 -234Q778 -245 792.5 -245.5Q807 -246 816 -235L836 -210Q852 -187 866 -163Q880 -139 880 -112Q880 -75 854 -49.5Q828 -24 792 -24Z"), + ("comment", "M280 -304H680Q697 -304 708.5 -315.5Q720 -327 720 -344Q720 -361 708.5 -372.5Q697 -384 680 -384H280Q263 -384 251.5 -372.5Q240 -361 240 -344Q240 -327 251.5 -315.5Q263 -304 280 -304ZM280 -424H680Q697 -424 708.5 -435.5Q720 -447 720 -464Q720 -481 708.5 -492.5Q697 -504 680 -504H280Q263 -504 251.5 -492.5Q240 -481 240 -464Q240 -447 251.5 -435.5Q263 -424 280 -424ZM280 -544H680Q697 -544 708.5 -555.5Q720 -567 720 -584Q720 -601 708.5 -612.5Q697 -624 680 -624H280Q263 -624 251.5 -612.5Q240 -601 240 -584Q240 -567 251.5 -555.5Q263 -544 280 -544ZM160 -144Q127 -144 103.5 -167.5Q80 -191 80 -224V-704Q80 -737 103.5 -760.5Q127 -784 160 -784H800Q833 -784 856.5 -760.5Q880 -737 880 -704V-81Q880 -54 855.5 -43.5Q831 -33 812 -52L720 -144ZM754 -224 800 -179V-704Q800 -704 800 -704Q800 -704 800 -704H160Q160 -704 160 -704Q160 -704 160 -704V-224Q160 -224 160 -224Q160 -224 160 -224ZM160 -224Q160 -224 160 -224Q160 -224 160 -224V-704Q160 -704 160 -704Q160 -704 160 -704Q160 -704 160 -704Q160 -704 160 -704V-224Z"), + ("comment_fill", "M280 -304H680Q697 -304 708.5 -315.5Q720 -327 720 -344Q720 -361 708.5 -372.5Q697 -384 680 -384H280Q263 -384 251.5 -372.5Q240 -361 240 -344Q240 -327 251.5 -315.5Q263 -304 280 -304ZM280 -424H680Q697 -424 708.5 -435.5Q720 -447 720 -464Q720 -481 708.5 -492.5Q697 -504 680 -504H280Q263 -504 251.5 -492.5Q240 -481 240 -464Q240 -447 251.5 -435.5Q263 -424 280 -424ZM280 -544H680Q697 -544 708.5 -555.5Q720 -567 720 -584Q720 -601 708.5 -612.5Q697 -624 680 -624H280Q263 -624 251.5 -612.5Q240 -601 240 -584Q240 -567 251.5 -555.5Q263 -544 280 -544ZM160 -144Q127 -144 103.5 -167.5Q80 -191 80 -224V-704Q80 -737 103.5 -760.5Q127 -784 160 -784H800Q833 -784 856.5 -760.5Q880 -737 880 -704V-81Q880 -54 855.5 -43.5Q831 -33 812 -52L720 -144Z"), + ("content_copy", "M360 -144Q327 -144 303.5 -167.5Q280 -191 280 -224V-704Q280 -737 303.5 -760.5Q327 -784 360 -784H720Q753 -784 776.5 -760.5Q800 -737 800 -704V-224Q800 -191 776.5 -167.5Q753 -144 720 -144ZM360 -224H720Q720 -224 720 -224Q720 -224 720 -224V-704Q720 -704 720 -704Q720 -704 720 -704H360Q360 -704 360 -704Q360 -704 360 -704V-224Q360 -224 360 -224Q360 -224 360 -224ZM200 16Q167 16 143.5 -7.5Q120 -31 120 -64V-584Q120 -601 131.5 -612.5Q143 -624 160 -624Q177 -624 188.5 -612.5Q200 -601 200 -584V-64Q200 -64 200 -64Q200 -64 200 -64H600Q617 -64 628.5 -52.5Q640 -41 640 -24Q640 -7 628.5 4.5Q617 16 600 16ZM360 -224Q360 -224 360 -224Q360 -224 360 -224V-704Q360 -704 360 -704Q360 -704 360 -704Q360 -704 360 -704Q360 -704 360 -704V-224Q360 -224 360 -224Q360 -224 360 -224Z"), + ("content_copy_fill", "M360 -144Q327 -144 303.5 -167.5Q280 -191 280 -224V-704Q280 -737 303.5 -760.5Q327 -784 360 -784H720Q753 -784 776.5 -760.5Q800 -737 800 -704V-224Q800 -191 776.5 -167.5Q753 -144 720 -144ZM200 16Q167 16 143.5 -7.5Q120 -31 120 -64V-584Q120 -601 131.5 -612.5Q143 -624 160 -624Q177 -624 188.5 -612.5Q200 -601 200 -584V-64Q200 -64 200 -64Q200 -64 200 -64H600Q617 -64 628.5 -52.5Q640 -41 640 -24Q640 -7 628.5 4.5Q617 16 600 16Z"), + ("content_paste", "M200 -24Q167 -24 143.5 -47.5Q120 -71 120 -104V-664Q120 -697 143.5 -720.5Q167 -744 200 -744H367Q378 -779 410 -801.5Q442 -824 480 -824Q520 -824 551.5 -801.5Q583 -779 594 -744H760Q793 -744 816.5 -720.5Q840 -697 840 -664V-104Q840 -71 816.5 -47.5Q793 -24 760 -24ZM200 -104H760Q760 -104 760 -104Q760 -104 760 -104V-664Q760 -664 760 -664Q760 -664 760 -664H680V-584Q680 -567 668.5 -555.5Q657 -544 640 -544H320Q303 -544 291.5 -555.5Q280 -567 280 -584V-664H200Q200 -664 200 -664Q200 -664 200 -664V-104Q200 -104 200 -104Q200 -104 200 -104ZM480 -664Q497 -664 508.5 -675.5Q520 -687 520 -704Q520 -721 508.5 -732.5Q497 -744 480 -744Q463 -744 451.5 -732.5Q440 -721 440 -704Q440 -687 451.5 -675.5Q463 -664 480 -664Z"), + ("dark", "M480-120q-150 0-255-105T120-480q0-135 79.5-229T408-830q20-5 34-1t22 15q8 10 7.5 25t-8.5 35q-9 23-14 47t-5 49q0 90 63 153t153 63q25 0 48.5-4.5T754-461q22-8 38-7t26 9q10 8 13 23t-2 36q-27 121-121 200.5T480-120Zm0-60q109 0 190-67.5T771-406q-25 11-53.5 16.5T660-384q-115 0-195.5-80.5T384-660q0-24 5-51.5t18-62.5q-98 27-162.5 109.5T180-480q0 125 87.5 212.5T480-180Zm-4-297Z"), + ("delete", "M261-120q-24.75 0-42.37-17.63Q201-155.25 201-180v-570h-11q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h158q0-13 8.63-21.5 8.62-8.5 21.37-8.5h204q12.75 0 21.38 8.62Q612-822.75 612-810h158q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5h-11v570q0 24.75-17.62 42.37Q723.75-120 699-120H261Zm438-630H261v570h438v-570ZM418.5-274.63q8.5-8.62 8.5-21.37v-339q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82 0-21.32 8.62-8.5 8.63-8.5 21.38v339q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63 12.82 0 21.32-8.63Zm166 0q8.5-8.62 8.5-21.37v-339q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82 0-21.32 8.62-8.5 8.63-8.5 21.38v339q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63 12.82 0 21.32-8.63ZM261-750v570-570Z"), + ("description", "M360 -144H600Q617 -144 628.5 -155.5Q640 -167 640 -184Q640 -201 628.5 -212.5Q617 -224 600 -224H360Q343 -224 331.5 -212.5Q320 -201 320 -184Q320 -167 331.5 -155.5Q343 -144 360 -144ZM360 -304H600Q617 -304 628.5 -315.5Q640 -327 640 -344Q640 -361 628.5 -372.5Q617 -384 600 -384H360Q343 -384 331.5 -372.5Q320 -361 320 -344Q320 -327 331.5 -315.5Q343 -304 360 -304ZM240 16Q207 16 183.5 -7.5Q160 -31 160 -64V-704Q160 -737 183.5 -760.5Q207 -784 240 -784H527Q543 -784 557.5 -778Q572 -772 583 -761L777 -567Q788 -556 794 -541.5Q800 -527 800 -511V-64Q800 -31 776.5 -7.5Q753 16 720 16ZM520 -544V-704H240Q240 -704 240 -704Q240 -704 240 -704V-64Q240 -64 240 -64Q240 -64 240 -64H720Q720 -64 720 -64Q720 -64 720 -64V-504H560Q543 -504 531.5 -515.5Q520 -527 520 -544ZM240 -704V-544Q240 -527 240 -515.5Q240 -504 240 -504V-704V-544Q240 -527 240 -515.5Q240 -504 240 -504V-64Q240 -64 240 -64Q240 -64 240 -64Q240 -64 240 -64Q240 -64 240 -64V-704Q240 -704 240 -704Q240 -704 240 -704Z"), + ("description_fill", "M360 -144H600Q617 -144 628.5 -155.5Q640 -167 640 -184Q640 -201 628.5 -212.5Q617 -224 600 -224H360Q343 -224 331.5 -212.5Q320 -201 320 -184Q320 -167 331.5 -155.5Q343 -144 360 -144ZM360 -304H600Q617 -304 628.5 -315.5Q640 -327 640 -344Q640 -361 628.5 -372.5Q617 -384 600 -384H360Q343 -384 331.5 -372.5Q320 -361 320 -344Q320 -327 331.5 -315.5Q343 -304 360 -304ZM240 16Q207 16 183.5 -7.5Q160 -31 160 -64V-704Q160 -737 183.5 -760.5Q207 -784 240 -784H527Q543 -784 557.5 -778Q572 -772 583 -761L777 -567Q788 -556 794 -541.5Q800 -527 800 -511V-64Q800 -31 776.5 -7.5Q753 16 720 16ZM520 -544Q520 -527 531.5 -515.5Q543 -504 560 -504H720L520 -704Z"), + ("deselect", "M763 12 567 -184H360Q327 -184 303.5 -207.5Q280 -231 280 -264V-471L84 -667Q73 -678 73 -694.5Q73 -711 84 -723Q96 -735 112.5 -735Q129 -735 141 -723L820 -44Q832 -32 831.5 -16Q831 0 819 12Q807 23 791 23.5Q775 24 763 12ZM487 -264 360 -391V-264Q360 -264 360 -264Q360 -264 360 -264ZM680 -297 600 -377V-504Q600 -504 600 -504Q600 -504 600 -504H473L393 -584H600Q633 -584 656.5 -560.5Q680 -537 680 -504ZM320 -664Q303 -664 291.5 -675.5Q280 -687 280 -704Q280 -721 291.5 -732.5Q303 -744 320 -744Q337 -744 348.5 -732.5Q360 -721 360 -704Q360 -687 348.5 -675.5Q337 -664 320 -664ZM480 -664Q463 -664 451.5 -675.5Q440 -687 440 -704Q440 -721 451.5 -732.5Q463 -744 480 -744Q497 -744 508.5 -732.5Q520 -721 520 -704Q520 -687 508.5 -675.5Q497 -664 480 -664ZM640 -664Q623 -664 611.5 -675.5Q600 -687 600 -704Q600 -721 611.5 -732.5Q623 -744 640 -744Q657 -744 668.5 -732.5Q680 -721 680 -704Q680 -687 668.5 -675.5Q657 -664 640 -664ZM800 -664Q783 -664 771.5 -675.5Q760 -687 760 -704Q760 -721 771.5 -732.5Q783 -744 800 -744Q817 -744 828.5 -732.5Q840 -721 840 -704Q840 -687 828.5 -675.5Q817 -664 800 -664ZM160 -504Q143 -504 131.5 -515.5Q120 -527 120 -544Q120 -561 131.5 -572.5Q143 -584 160 -584Q177 -584 188.5 -572.5Q200 -561 200 -544Q200 -527 188.5 -515.5Q177 -504 160 -504ZM800 -504Q783 -504 771.5 -515.5Q760 -527 760 -544Q760 -561 771.5 -572.5Q783 -584 800 -584Q817 -584 828.5 -572.5Q840 -561 840 -544Q840 -527 828.5 -515.5Q817 -504 800 -504ZM160 -344Q143 -344 131.5 -355.5Q120 -367 120 -384Q120 -401 131.5 -412.5Q143 -424 160 -424Q177 -424 188.5 -412.5Q200 -401 200 -384Q200 -367 188.5 -355.5Q177 -344 160 -344ZM800 -344Q783 -344 771.5 -355.5Q760 -367 760 -384Q760 -401 771.5 -412.5Q783 -424 800 -424Q817 -424 828.5 -412.5Q840 -401 840 -384Q840 -367 828.5 -355.5Q817 -344 800 -344ZM160 -184Q143 -184 131.5 -195.5Q120 -207 120 -224Q120 -241 131.5 -252.5Q143 -264 160 -264Q177 -264 188.5 -252.5Q200 -241 200 -224Q200 -207 188.5 -195.5Q177 -184 160 -184ZM800 -184Q783 -184 771.5 -195.5Q760 -207 760 -224Q760 -241 771.5 -252.5Q783 -264 800 -264Q817 -264 828.5 -252.5Q840 -241 840 -224Q840 -207 828.5 -195.5Q817 -184 800 -184ZM160 -24Q143 -24 131.5 -35.5Q120 -47 120 -64Q120 -81 131.5 -92.5Q143 -104 160 -104Q177 -104 188.5 -92.5Q200 -81 200 -64Q200 -47 188.5 -35.5Q177 -24 160 -24ZM320 -24Q303 -24 291.5 -35.5Q280 -47 280 -64Q280 -81 291.5 -92.5Q303 -104 320 -104Q337 -104 348.5 -92.5Q360 -81 360 -64Q360 -47 348.5 -35.5Q337 -24 320 -24ZM480 -24Q463 -24 451.5 -35.5Q440 -47 440 -64Q440 -81 451.5 -92.5Q463 -104 480 -104Q497 -104 508.5 -92.5Q520 -81 520 -64Q520 -47 508.5 -35.5Q497 -24 480 -24ZM640 -24Q623 -24 611.5 -35.5Q600 -47 600 -64Q600 -81 611.5 -92.5Q623 -104 640 -104Q657 -104 668.5 -92.5Q680 -81 680 -64Q680 -47 668.5 -35.5Q657 -24 640 -24Z"), + ("dictionary", "M228 -361H332L351 -308Q353 -302 358 -298.5Q363 -295 370 -295Q381 -295 387.5 -304Q394 -313 390 -323L308 -539Q306 -545 300.5 -549Q295 -553 288 -553H272Q265 -553 259.5 -549Q254 -545 252 -539L170 -323Q166 -313 172.5 -304Q179 -295 190 -295Q197 -295 202.5 -298.5Q208 -302 210 -309ZM241 -398 279 -505H281L319 -398ZM260 -224Q307 -224 351.5 -213.5Q396 -203 440 -182V-576Q399 -600 353 -612Q307 -624 260 -624Q224 -624 188.5 -617Q153 -610 120 -596Q120 -596 120 -596Q120 -596 120 -596V-200Q120 -200 120 -200Q120 -200 120 -200Q155 -212 189.5 -218Q224 -224 260 -224ZM520 -182Q564 -203 608.5 -213.5Q653 -224 700 -224Q736 -224 770.5 -218Q805 -212 840 -200Q840 -200 840 -200Q840 -200 840 -200V-596Q840 -596 840 -596Q840 -596 840 -596Q807 -610 771.5 -617Q736 -624 700 -624Q653 -624 607 -612Q561 -600 520 -576ZM280 -403Q280 -403 280 -403Q280 -403 280 -403Q280 -403 280 -403Q280 -403 280 -403Q280 -403 280 -403Q280 -403 280 -403Q280 -403 280 -403Q280 -403 280 -403Q280 -403 280 -403Q280 -403 280 -403Q280 -403 280 -403Q280 -403 280 -403ZM480 -85Q466 -85 453.5 -88.5Q441 -92 430 -98Q391 -121 348 -132.5Q305 -144 260 -144Q218 -144 177.5 -133Q137 -122 100 -102Q79 -91 59.5 -103Q40 -115 40 -138V-620Q40 -631 45.5 -641Q51 -651 62 -656Q108 -680 158 -692Q208 -704 260 -704Q318 -704 373.5 -689Q429 -674 480 -644Q531 -674 586.5 -689Q642 -704 700 -704Q752 -704 802 -692Q852 -680 898 -656Q909 -651 914.5 -641Q920 -631 920 -620V-138Q920 -115 900.5 -103Q881 -91 860 -102Q823 -122 782.5 -133Q742 -144 700 -144Q655 -144 612 -132.5Q569 -121 530 -98Q519 -92 506.5 -88.5Q494 -85 480 -85ZM560 -513Q560 -522 566.5 -531.5Q573 -541 581 -544Q610 -554 639 -559Q668 -564 700 -564Q720 -564 739.5 -561.5Q759 -559 778 -555Q787 -553 793.5 -545Q800 -537 800 -527Q800 -510 789 -502Q778 -494 761 -498Q747 -501 731.5 -502.5Q716 -504 700 -504Q674 -504 649 -499Q624 -494 601 -486Q583 -479 571.5 -487Q560 -495 560 -513ZM560 -293Q560 -302 566.5 -311.5Q573 -321 581 -324Q610 -334 639 -339Q668 -344 700 -344Q720 -344 739.5 -341.5Q759 -339 778 -335Q787 -333 793.5 -325Q800 -317 800 -307Q800 -290 789 -282Q778 -274 761 -278Q747 -281 731.5 -282.5Q716 -284 700 -284Q674 -284 649 -279.5Q624 -275 601 -267Q583 -260 571.5 -267.5Q560 -275 560 -293ZM560 -403Q560 -412 566.5 -421.5Q573 -431 581 -434Q610 -444 639 -449Q668 -454 700 -454Q720 -454 739.5 -451.5Q759 -449 778 -445Q787 -443 793.5 -435Q800 -427 800 -417Q800 -400 789 -392Q778 -384 761 -388Q747 -391 731.5 -392.5Q716 -394 700 -394Q674 -394 649 -389Q624 -384 601 -376Q583 -369 571.5 -377Q560 -385 560 -403Z"), + ("dictionary_fill", "M241 -398 279 -505H281L319 -398ZM520 -182Q564 -203 608.5 -213.5Q653 -224 700 -224Q736 -224 770.5 -218Q805 -212 840 -200Q840 -200 840 -200Q840 -200 840 -200V-596Q840 -596 840 -596Q840 -596 840 -596Q807 -610 771.5 -617Q736 -624 700 -624Q653 -624 607 -612Q561 -600 520 -576ZM228 -361H332L351 -308Q353 -302 358 -298.5Q363 -295 370 -295Q381 -295 387.5 -304Q394 -313 390 -323L308 -539Q306 -545 300.5 -549Q295 -553 288 -553H272Q265 -553 259.5 -549Q254 -545 252 -539L170 -323Q166 -313 172.5 -304Q179 -295 190 -295Q197 -295 202.5 -298.5Q208 -302 210 -309ZM480 -85Q466 -85 453.5 -88.5Q441 -92 430 -98Q391 -121 348 -132.5Q305 -144 260 -144Q218 -144 177.5 -133Q137 -122 100 -102Q79 -91 59.5 -103Q40 -115 40 -138V-620Q40 -631 45.5 -641Q51 -651 62 -656Q108 -680 158 -692Q208 -704 260 -704Q318 -704 373.5 -689Q429 -674 480 -644Q531 -674 586.5 -689Q642 -704 700 -704Q752 -704 802 -692Q852 -680 898 -656Q909 -651 914.5 -641Q920 -631 920 -620V-138Q920 -115 900.5 -103Q881 -91 860 -102Q823 -122 782.5 -133Q742 -144 700 -144Q655 -144 612 -132.5Q569 -121 530 -98Q519 -92 506.5 -88.5Q494 -85 480 -85ZM560 -513Q560 -522 566.5 -531.5Q573 -541 581 -544Q610 -554 639 -559Q668 -564 700 -564Q720 -564 739.5 -561.5Q759 -559 778 -555Q787 -553 793.5 -545Q800 -537 800 -527Q800 -510 789 -502Q778 -494 761 -498Q747 -501 731.5 -502.5Q716 -504 700 -504Q674 -504 649 -499Q624 -494 601 -486Q583 -479 571.5 -487Q560 -495 560 -513ZM560 -293Q560 -302 566.5 -311.5Q573 -321 581 -324Q610 -334 639 -339Q668 -344 700 -344Q720 -344 739.5 -341.5Q759 -339 778 -335Q787 -333 793.5 -325Q800 -317 800 -307Q800 -290 789 -282Q778 -274 761 -278Q747 -281 731.5 -282.5Q716 -284 700 -284Q674 -284 649 -279.5Q624 -275 601 -267Q583 -260 571.5 -267.5Q560 -275 560 -293ZM560 -403Q560 -412 566.5 -421.5Q573 -431 581 -434Q610 -444 639 -449Q668 -454 700 -454Q720 -454 739.5 -451.5Q759 -449 778 -445Q787 -443 793.5 -435Q800 -427 800 -417Q800 -400 789 -392Q778 -384 761 -388Q747 -391 731.5 -392.5Q716 -394 700 -394Q674 -394 649 -389Q624 -384 601 -376Q583 -369 571.5 -377Q560 -385 560 -403Z"), + ("done_all", "M70 -342Q58 -354 58.5 -370Q59 -386 71 -398Q83 -409 99 -409.5Q115 -410 127 -398L269 -256Q276 -249 283 -242Q290 -235 297 -228Q309 -216 308.5 -200Q308 -184 296 -172Q284 -161 268 -160.5Q252 -160 240 -172ZM494 -257 834 -597Q846 -609 862 -608.5Q878 -608 890 -596Q901 -584 901.5 -568Q902 -552 890 -540L522 -172Q510 -160 494 -160Q478 -160 466 -172L296 -342Q285 -353 285 -369.5Q285 -386 296 -398Q308 -410 324.5 -410Q341 -410 353 -398ZM663 -539 522 -398Q511 -387 494.5 -387Q478 -387 466 -398Q454 -410 454 -426.5Q454 -443 466 -455L607 -596Q618 -607 634.5 -607Q651 -607 663 -596Q675 -584 675 -567.5Q675 -551 663 -539Z"), + ("download", "M480 -241Q472 -241 465 -243.5Q458 -246 452 -252L308 -396Q296 -408 296.5 -424Q297 -440 308 -452Q320 -464 336.5 -464.5Q353 -465 365 -453L440 -378V-664Q440 -681 451.5 -692.5Q463 -704 480 -704Q497 -704 508.5 -692.5Q520 -681 520 -664V-378L595 -453Q607 -465 623.5 -464.5Q640 -464 652 -452Q663 -440 663.5 -424Q664 -408 652 -396L508 -252Q502 -246 495 -243.5Q488 -241 480 -241ZM240 -64Q207 -64 183.5 -87.5Q160 -111 160 -144V-224Q160 -241 171.5 -252.5Q183 -264 200 -264Q217 -264 228.5 -252.5Q240 -241 240 -224V-144Q240 -144 240 -144Q240 -144 240 -144H720Q720 -144 720 -144Q720 -144 720 -144V-224Q720 -241 731.5 -252.5Q743 -264 760 -264Q777 -264 788.5 -252.5Q800 -241 800 -224V-144Q800 -111 776.5 -87.5Q753 -64 720 -64Z"), + ("download_done", "M382 -338 720 -676Q732 -688 748.5 -688Q765 -688 777 -676Q789 -664 789 -647.5Q789 -631 777 -619L410 -252Q398 -240 382 -240Q366 -240 354 -252L183 -423Q171 -435 171.5 -451.5Q172 -468 184 -480Q196 -492 212.5 -492Q229 -492 241 -480ZM240 -64Q223 -64 211.5 -75.5Q200 -87 200 -104Q200 -121 211.5 -132.5Q223 -144 240 -144H720Q737 -144 748.5 -132.5Q760 -121 760 -104Q760 -87 748.5 -75.5Q737 -64 720 -64Z"), + ("download_for_offline", "M320 -184H640Q657 -184 668.5 -195.5Q680 -207 680 -224Q680 -241 668.5 -252.5Q657 -264 640 -264H320Q303 -264 291.5 -252.5Q280 -241 280 -224Q280 -207 291.5 -195.5Q303 -184 320 -184ZM440 -458 404 -493Q393 -504 376.5 -504Q360 -504 348 -492Q337 -481 337 -464Q337 -447 348 -436L452 -332Q464 -320 480 -320Q496 -320 508 -332L612 -436Q623 -447 623.5 -463.5Q624 -480 612 -492Q601 -503 584.5 -503.5Q568 -504 556 -493L520 -458V-584Q520 -601 508.5 -612.5Q497 -624 480 -624Q463 -624 451.5 -612.5Q440 -601 440 -584ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16ZM480 -64Q614 -64 707 -157Q800 -250 800 -384Q800 -518 707 -611Q614 -704 480 -704Q346 -704 253 -611Q160 -518 160 -384Q160 -250 253 -157Q346 -64 480 -64ZM480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Z"), + ("download_for_offline_fill", "M320 -184H640Q657 -184 668.5 -195.5Q680 -207 680 -224Q680 -241 668.5 -252.5Q657 -264 640 -264H320Q303 -264 291.5 -252.5Q280 -241 280 -224Q280 -207 291.5 -195.5Q303 -184 320 -184ZM440 -458 404 -493Q393 -504 376.5 -504Q360 -504 348 -492Q337 -481 337 -464Q337 -447 348 -436L452 -332Q464 -320 480 -320Q496 -320 508 -332L612 -436Q623 -447 623.5 -463.5Q624 -480 612 -492Q601 -503 584.5 -503.5Q568 -504 556 -493L520 -458V-584Q520 -601 508.5 -612.5Q497 -624 480 -624Q463 -624 451.5 -612.5Q440 -601 440 -584ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16Z"), + ("downloading", "M392 6Q255 -25 167.5 -134Q80 -243 80 -384Q80 -525 167.5 -634Q255 -743 392 -774Q411 -779 425.5 -767Q440 -755 440 -735Q440 -721 432 -710Q424 -699 410 -696Q300 -671 230 -584Q160 -497 160 -384Q160 -271 230 -184Q300 -97 410 -72Q424 -69 432 -58Q440 -47 440 -33Q440 -13 425.5 -1Q411 11 392 6ZM568 6Q549 11 534.5 -1Q520 -13 520 -33Q520 -47 528 -58Q536 -69 550 -72Q577 -78 602.5 -88.5Q628 -99 651 -114Q662 -122 675.5 -120Q689 -118 699 -108Q713 -94 711 -75.5Q709 -57 693 -46Q664 -28 632.5 -15Q601 -2 568 6ZM756 -164Q746 -174 744 -187.5Q742 -201 750 -212Q765 -235 775.5 -261Q786 -287 792 -314Q795 -328 806 -335.5Q817 -343 831 -343Q851 -343 863 -328.5Q875 -314 870 -295Q862 -262 849 -230.5Q836 -199 818 -170Q807 -154 788.5 -152Q770 -150 756 -164ZM831 -424Q817 -424 806 -432Q795 -440 792 -454Q786 -481 775.5 -506.5Q765 -532 750 -555Q742 -567 744 -580.5Q746 -594 756 -604Q770 -618 788.5 -616Q807 -614 818 -597Q836 -568 849 -536.5Q862 -505 870 -472Q875 -453 863 -438.5Q851 -424 831 -424ZM651 -654Q628 -669 602.5 -679.5Q577 -690 550 -696Q536 -699 528 -710Q520 -721 520 -735Q520 -755 534.5 -767Q549 -779 568 -774Q601 -766 632.5 -753Q664 -740 693 -722Q710 -711 712 -692.5Q714 -674 700 -660Q690 -650 676.5 -648Q663 -646 651 -654ZM519 -339 593 -413Q605 -425 622 -425Q639 -425 651 -413Q663 -401 662.5 -384Q662 -367 650 -355L507 -212Q496 -201 479 -201Q462 -201 451 -212L306 -358Q294 -370 294.5 -386.5Q295 -403 307 -415Q319 -427 335.5 -427Q352 -427 364 -415L439 -339V-544Q439 -561 450.5 -572.5Q462 -584 479 -584Q496 -584 507.5 -572.5Q519 -561 519 -544Z"), + ("drag_indicator", "M349.91-160q-28.91 0-49.41-20.59-20.5-20.59-20.5-49.5t20.59-49.41q20.59-20.5 49.5-20.5t49.41 20.59q20.5 20.59 20.5 49.5t-20.59 49.41q-20.59 20.5-49.5 20.5Zm260 0q-28.91 0-49.41-20.59-20.5-20.59-20.5-49.5t20.59-49.41q20.59-20.5 49.5-20.5t49.41 20.59q20.5 20.59 20.5 49.5t-20.59 49.41q-20.59 20.5-49.5 20.5Zm-260-250q-28.91 0-49.41-20.59-20.5-20.59-20.5-49.5t20.59-49.41q20.59-20.5 49.5-20.5t49.41 20.59q20.5 20.59 20.5 49.5t-20.59 49.41q-20.59 20.5-49.5 20.5Zm260 0q-28.91 0-49.41-20.59-20.5-20.59-20.5-49.5t20.59-49.41q20.59-20.5 49.5-20.5t49.41 20.59q20.5 20.59 20.5 49.5t-20.59 49.41q-20.59 20.5-49.5 20.5Zm-260-250q-28.91 0-49.41-20.59-20.5-20.59-20.5-49.5t20.59-49.41q20.59-20.5 49.5-20.5t49.41 20.59q20.5 20.59 20.5 49.5t-20.59 49.41q-20.59 20.5-49.5 20.5Zm260 0q-28.91 0-49.41-20.59-20.5-20.59-20.5-49.5t20.59-49.41q20.59-20.5 49.5-20.5t49.41 20.59q20.5 20.59 20.5 49.5t-20.59 49.41q-20.59 20.5-49.5 20.5Z"), + ("edit", "M200 -104H257L648 -495L591 -552L200 -161ZM160 -24Q143 -24 131.5 -35.5Q120 -47 120 -64V-161Q120 -177 126 -191.5Q132 -206 143 -217L648 -721Q660 -732 674.5 -738Q689 -744 705 -744Q721 -744 736 -738Q751 -732 762 -720L817 -664Q829 -653 834.5 -638Q840 -623 840 -608Q840 -592 834.5 -577.5Q829 -563 817 -551L313 -47Q302 -36 287.5 -30Q273 -24 257 -24ZM760 -608 704 -664ZM619 -523 591 -552 648 -495Z"), + ("edit_fill", "M160 -24Q143 -24 131.5 -35.5Q120 -47 120 -64V-161Q120 -177 126 -191.5Q132 -206 143 -217L648 -721Q660 -732 674.5 -738Q689 -744 705 -744Q721 -744 736 -738Q751 -732 762 -720L817 -664Q829 -653 834.5 -638Q840 -623 840 -608Q840 -592 834.5 -577.5Q829 -563 817 -551L313 -47Q302 -36 287.5 -30Q273 -24 257 -24ZM704 -552 760 -608 704 -664 648 -608Z"), + ("edit_note", "M200 -304Q183 -304 171.5 -315.5Q160 -327 160 -344Q160 -361 171.5 -372.5Q183 -384 200 -384H400Q417 -384 428.5 -372.5Q440 -361 440 -344Q440 -327 428.5 -315.5Q417 -304 400 -304ZM200 -464Q183 -464 171.5 -475.5Q160 -487 160 -504Q160 -521 171.5 -532.5Q183 -544 200 -544H560Q577 -544 588.5 -532.5Q600 -521 600 -504Q600 -487 588.5 -475.5Q577 -464 560 -464ZM200 -624Q183 -624 171.5 -635.5Q160 -647 160 -664Q160 -681 171.5 -692.5Q183 -704 200 -704H560Q577 -704 588.5 -692.5Q600 -681 600 -664Q600 -647 588.5 -635.5Q577 -624 560 -624ZM520 -104V-170Q520 -178 523 -185.5Q526 -193 532 -199L741 -407Q750 -416 761 -420Q772 -424 783 -424Q795 -424 806 -419.5Q817 -415 826 -406L863 -369Q871 -360 875.5 -349Q880 -338 880 -327Q880 -316 876 -304.5Q872 -293 863 -284L655 -76Q649 -70 641.5 -67Q634 -64 626 -64H560Q543 -64 531.5 -75.5Q520 -87 520 -104ZM820 -327 783 -364ZM580 -124H618L739 -246L721 -265L702 -283L580 -162ZM721 -265 702 -283 739 -246Z"), + ("edit_note_fill", "M200 -304Q183 -304 171.5 -315.5Q160 -327 160 -344Q160 -361 171.5 -372.5Q183 -384 200 -384H400Q417 -384 428.5 -372.5Q440 -361 440 -344Q440 -327 428.5 -315.5Q417 -304 400 -304ZM200 -464Q183 -464 171.5 -475.5Q160 -487 160 -504Q160 -521 171.5 -532.5Q183 -544 200 -544H560Q577 -544 588.5 -532.5Q600 -521 600 -504Q600 -487 588.5 -475.5Q577 -464 560 -464ZM200 -624Q183 -624 171.5 -635.5Q160 -647 160 -664Q160 -681 171.5 -692.5Q183 -704 200 -704H560Q577 -704 588.5 -692.5Q600 -681 600 -664Q600 -647 588.5 -635.5Q577 -624 560 -624ZM520 -104V-170Q520 -178 523 -185.5Q526 -193 532 -199L741 -407Q750 -416 761 -420Q772 -424 783 -424Q795 -424 806 -419.5Q817 -415 826 -406L863 -369Q871 -360 875.5 -349Q880 -338 880 -327Q880 -316 876 -304.5Q872 -293 863 -284L655 -76Q649 -70 641.5 -67Q634 -64 626 -64H560Q543 -64 531.5 -75.5Q520 -87 520 -104ZM783 -288 820 -327 783 -364 745 -326ZM580 -124H618L739 -246L721 -265L702 -283L580 -162ZM580 -124V-162L702 -283L739 -246L618 -124Z"), + ("eject", "M230-260h500q13 0 21.5 8.5T760-230q0 13-8.5 21.5T730-200H230q-13 0-21.5-8.5T200-230q0-13 8.5-21.5T230-260Zm10-139 215-323q5-7 11-10.5t14-3.5q8 0 14 3.5t11 10.5l215 323q10 15 1.5 31T695-352H265q-18 0-26.5-16t1.5-31Zm241-13Zm-162 0h322L480-650 319-412Z"), + ("equalizer", "M180.5-180.56Q160-201.13 160-230v-180q0-28.88 20.59-49.44t49.5-20.56q28.91 0 49.41 20.56Q300-438.88 300-410v180q0 28.87-20.59 49.44Q258.82-160 229.91-160t-49.41-20.56ZM479.91-160q-28.91 0-49.41-20.56Q410-201.13 410-230v-500q0-28.88 20.59-49.44t49.5-20.56q28.91 0 49.41 20.56Q550-758.88 550-730v500q0 28.87-20.59 49.44Q508.82-160 479.91-160Zm200.59-20.56Q660-201.13 660-230v-300q0-28.88 20.59-49.44t49.5-20.56q28.91 0 49.41 20.56Q800-558.88 800-530v300q0 28.87-20.59 49.44Q758.82-160 729.91-160t-49.41-20.56Z"), + ("error", "M480 -184Q497 -184 508.5 -195.5Q520 -207 520 -224Q520 -241 508.5 -252.5Q497 -264 480 -264Q463 -264 451.5 -252.5Q440 -241 440 -224Q440 -207 451.5 -195.5Q463 -184 480 -184ZM480 -344Q497 -344 508.5 -355.5Q520 -367 520 -384V-544Q520 -561 508.5 -572.5Q497 -584 480 -584Q463 -584 451.5 -572.5Q440 -561 440 -544V-384Q440 -367 451.5 -355.5Q463 -344 480 -344ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16ZM480 -64Q614 -64 707 -157Q800 -250 800 -384Q800 -518 707 -611Q614 -704 480 -704Q346 -704 253 -611Q160 -518 160 -384Q160 -250 253 -157Q346 -64 480 -64ZM480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Z"), + ("error_fill", "M480 -184Q497 -184 508.5 -195.5Q520 -207 520 -224Q520 -241 508.5 -252.5Q497 -264 480 -264Q463 -264 451.5 -252.5Q440 -241 440 -224Q440 -207 451.5 -195.5Q463 -184 480 -184ZM480 -344Q497 -344 508.5 -355.5Q520 -367 520 -384V-544Q520 -561 508.5 -572.5Q497 -584 480 -584Q463 -584 451.5 -572.5Q440 -561 440 -544V-384Q440 -367 451.5 -355.5Q463 -344 480 -344ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16Z"), + ("expand_less", "M480 -433 324 -277Q313 -266 296 -266Q279 -266 268 -277Q257 -288 257 -305Q257 -322 268 -333L452 -517Q458 -523 465 -525.5Q472 -528 480 -528Q488 -528 495 -525.5Q502 -523 508 -517L692 -333Q703 -322 703 -305Q703 -288 692 -277Q681 -266 664 -266Q647 -266 636 -277Z"), + ("expand_more", "M480 -266Q472 -266 465 -268.5Q458 -271 452 -277L268 -461Q257 -472 257 -489Q257 -506 268 -517Q279 -528 296 -528Q313 -528 324 -517L480 -361L636 -517Q647 -528 664 -528Q681 -528 692 -517Q703 -506 703 -489Q703 -472 692 -461L508 -277Q502 -271 495 -268.5Q488 -266 480 -266Z"), + ("favorite", "M458.19-144Q447-148 439-156l-53-49Q262-320 171-424.5T80-643q0-90.15 60.5-150.58Q201-854 290-854q51 0 101 24.5t89 80.5q44-56 91-80.5t99-24.5q89 0 149.5 60.42Q880-733.15 880-643q0 114-91 218.5T574-205l-53 49q-8.25 8.38-19.12 12.19Q491-140 480.19-140q-10.8 0-22-4ZM454-683q-27-49-71-80t-93-31q-66 0-108 42.5t-42 108.93q0 57.57 38.88 121.22 38.88 63.66 93 123.5Q326-338 384-286.5q58 51.5 96 86.5 38-34 96-86t112-112.5q54-60.5 93-124.19T820-643q0-66-42.5-108.5T670-794q-50 0-93.5 30.5T504-683q-5 8-11 11.5t-14 3.5q-8 0-14.5-3.5T454-683Zm26 186Z"), + ("favorite_fill", "M458-144q-11-4-19-12l-53-49Q262-320 171-424.5T80-643q0-90 60.5-150.5T290-854q51 0 101 24.5t89 80.5q44-56 91-80.5t99-24.5q89 0 149.5 60.5T880-643q0 114-91 218.5T574-205l-53 49q-8 8-19 12t-22 4q-11 0-22-4Z"), + ("fiber_manual_record", "M478-478ZM281.5-281.5Q200-363 200-480t81.5-198.5Q363-760 480-760t198.5 81.5Q760-597 760-480t-81.5 198.5Q597-200 480-200t-198.5-81.5ZM636-324q64-64 64-156t-64-156q-64-64-156-64t-156 64q-64 64-64 156t64 156q64 64 156 64t156-64Z"), + ("file_open", "M220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h315q12.44 0 23.72 5T578-862l204 204q8 8 13 19.28 5 11.28 5 23.72v215q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63-8.5-8.62-8.5-21.37v-200H550q-12.75 0-21.37-8.63Q520-617.25 520-630v-190H220v680h380q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32Q612.75-80 600-80H220Zm530-127v95q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63Q690-99.25 690-112v-168q0-12.75 8.63-21.38Q707.25-310 720-310h168q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5h-96l107 107q9 9 9 21.16t-8.61 21Q890-92 877.53-92q-12.46 0-21.53-9L750-207Zm-530 67v-680 680Z"), + ("filter_list", "M430-240q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h100q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H430ZM270-450q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h420q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H270ZM150-660q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Z"), + ("fingerprint", "M481-779q108 0 203.5 46T843-601q3 5 2.5 8t-3.5 6q-3 3-7.5 3t-8.5-5q-59-82-150.5-126T481-759q-103 0-193 44.5T138-589q-4 5-7.5 6t-7.5-1q-4-2-4-6.5t2-8.5q62-86 157-133t203-47Zm0 96q136 0 233.5 90T812-371q0 46-34 78t-82 32q-49 0-84-32t-35-78q0-39-28.5-65T481-462q-39 0-68 26t-29 65q0 104 63 173.5T604-100q6 2 7.5 5t.5 7q-1 5-4 7t-8 0q-103-26-169.5-103T364-371q0-47 34.5-79t82.5-32q48 0 82.5 32t34.5 79q0 38 29.5 64t68.5 26q38 0 66.5-26t28.5-64q0-123-91.5-206T481-660q-127 0-218.5 83T171-371q0 24 5.5 62.5T200-221q2 5 0 7.5t-5 4.5q-4 2-8.5 1t-6.5-6q-13-38-20.5-77.5T152-371q0-129 98-220.5T481-683Zm0-197q65 0 127.5 16T728-819q5 2 5.5 6t-1.5 7q-2 3-5.5 5t-8.5 0q-55-27-115-42.5T481-859q-62 0-121 14.5T247-801q-5 2-7.5.5T235-805q-2-2-2-6t3-6q57-31 119.5-47T481-880Zm0 298q92 0 158.5 61T706-371q0 5-2.5 7.5T696-361q-5 0-8-2.5t-3-7.5q0-81-60.5-136T481-562q-83 0-142.5 55T279-371q0 85 29.5 145T396-106q4 4 3.5 7.5T396-92q-2 2-6.5 3.5T381-92q-58-60-90.5-126T258-371q0-89 65.5-150T481-582Zm-1 200q5 0 7.5 3t2.5 8q0 81 59.5 133.5T687-185q8 0 19-1t24-3q5-1 8 1.5t4 5.5q1 4-.5 7t-6.5 4q-18 5-31.5 5.5t-16.5.5q-88 0-152.5-58.5T470-371q0-5 2.5-8t7.5-3Z"), + ("folder", "M160 -64Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704H367Q383 -704 397.5 -698Q412 -692 423 -681L480 -624H800Q833 -624 856.5 -600.5Q880 -577 880 -544V-144Q880 -111 856.5 -87.5Q833 -64 800 -64ZM160 -144H800Q800 -144 800 -144Q800 -144 800 -144V-544Q800 -544 800 -544Q800 -544 800 -544H447L367 -624Q367 -624 367 -624Q367 -624 367 -624H160Q160 -624 160 -624Q160 -624 160 -624V-144Q160 -144 160 -144Q160 -144 160 -144ZM160 -144Q160 -144 160 -144Q160 -144 160 -144V-624Q160 -624 160 -624Q160 -624 160 -624Q160 -624 160 -624Q160 -624 160 -624V-544Q160 -544 160 -544Q160 -544 160 -544V-144Q160 -144 160 -144Q160 -144 160 -144Z"), + ("folder_fill", "M160 -64Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704H367Q383 -704 397.5 -698Q412 -692 423 -681L480 -624H800Q833 -624 856.5 -600.5Q880 -577 880 -544V-144Q880 -111 856.5 -87.5Q833 -64 800 -64Z"), + ("folder_open", "M160 -64Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704H367Q383 -704 397.5 -698Q412 -692 423 -681L480 -624H840Q857 -624 868.5 -612.5Q880 -601 880 -584Q880 -567 868.5 -555.5Q857 -544 840 -544H447L367 -624H160Q160 -624 160 -624Q160 -624 160 -624V-144Q160 -144 160 -144Q160 -144 160 -144L239 -407Q247 -433 268.5 -448.5Q290 -464 316 -464H832Q873 -464 896.5 -431.5Q920 -399 909 -361L837 -121Q829 -95 807.5 -79.5Q786 -64 760 -64ZM244 -144H760Q760 -144 760 -144Q760 -144 760 -144L832 -384Q832 -384 832 -384Q832 -384 832 -384H316Q316 -384 316 -384Q316 -384 316 -384ZM160 -406V-624Q160 -624 160 -624Q160 -624 160 -624V-544Q160 -544 160 -505Q160 -466 160 -406ZM244 -144 316 -384Q316 -384 316 -384Q316 -384 316 -384Q316 -384 316 -384Q316 -384 316 -384L244 -144Q244 -144 244 -144Q244 -144 244 -144Z"), + ("folder_open_fill", "M160 -64Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704H367Q383 -704 397.5 -698Q412 -692 423 -681L480 -624H840Q857 -624 868.5 -612.5Q880 -601 880 -584Q880 -567 868.5 -555.5Q857 -544 840 -544H314Q252 -544 206 -505Q160 -466 160 -406V-144Q160 -144 160 -144Q160 -144 160 -144L239 -407Q247 -433 268.5 -448.5Q290 -464 316 -464H832Q873 -464 896.5 -431.5Q920 -399 909 -361L837 -121Q829 -95 807.5 -79.5Q786 -64 760 -64Z"), + ("genres", "M400 -144Q450 -144 485 -179Q520 -214 520 -264V-544H600Q617 -544 628.5 -555.5Q640 -567 640 -584Q640 -601 628.5 -612.5Q617 -624 600 -624H500Q483 -624 471.5 -612.5Q460 -601 460 -584V-368Q446 -376 431 -380Q416 -384 400 -384Q350 -384 315 -349Q280 -314 280 -264Q280 -214 315 -179Q350 -144 400 -144ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16ZM480 -64Q614 -64 707 -157Q800 -250 800 -384Q800 -518 707 -611Q614 -704 480 -704Q346 -704 253 -611Q160 -518 160 -384Q160 -250 253 -157Q346 -64 480 -64ZM480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Z"), + ("genres_fill", "M400 -144Q450 -144 485 -179Q520 -214 520 -264V-544H600Q617 -544 628.5 -555.5Q640 -567 640 -584Q640 -601 628.5 -612.5Q617 -624 600 -624H500Q483 -624 471.5 -612.5Q460 -601 460 -584V-368Q446 -376 431 -380Q416 -384 400 -384Q350 -384 315 -349Q280 -314 280 -264Q280 -214 315 -179Q350 -144 400 -144ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16Z"), + ("graphic_eq", "M280 -184V-584Q280 -601 291.5 -612.5Q303 -624 320 -624Q337 -624 348.5 -612.5Q360 -601 360 -584V-184Q360 -167 348.5 -155.5Q337 -144 320 -144Q303 -144 291.5 -155.5Q280 -167 280 -184ZM440 -24V-744Q440 -761 451.5 -772.5Q463 -784 480 -784Q497 -784 508.5 -772.5Q520 -761 520 -744V-24Q520 -7 508.5 4.5Q497 16 480 16Q463 16 451.5 4.5Q440 -7 440 -24ZM120 -344V-424Q120 -441 131.5 -452.5Q143 -464 160 -464Q177 -464 188.5 -452.5Q200 -441 200 -424V-344Q200 -327 188.5 -315.5Q177 -304 160 -304Q143 -304 131.5 -315.5Q120 -327 120 -344ZM600 -184V-584Q600 -601 611.5 -612.5Q623 -624 640 -624Q657 -624 668.5 -612.5Q680 -601 680 -584V-184Q680 -167 668.5 -155.5Q657 -144 640 -144Q623 -144 611.5 -155.5Q600 -167 600 -184ZM760 -344V-424Q760 -441 771.5 -452.5Q783 -464 800 -464Q817 -464 828.5 -452.5Q840 -441 840 -424V-344Q840 -327 828.5 -315.5Q817 -304 800 -304Q783 -304 771.5 -315.5Q760 -327 760 -344Z"), + ("help", "M478 -144Q499 -144 513.5 -158.5Q528 -173 528 -194Q528 -215 513.5 -229.5Q499 -244 478 -244Q457 -244 442.5 -229.5Q428 -215 428 -194Q428 -173 442.5 -158.5Q457 -144 478 -144ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16ZM480 -64Q614 -64 707 -157Q800 -250 800 -384Q800 -518 707 -611Q614 -704 480 -704Q346 -704 253 -611Q160 -518 160 -384Q160 -250 253 -157Q346 -64 480 -64ZM480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384ZM484 -556Q509 -556 527.5 -540Q546 -524 546 -500Q546 -478 532.5 -461Q519 -444 502 -429Q479 -409 461.5 -385Q444 -361 444 -331Q444 -317 454.5 -307.5Q465 -298 479 -298Q494 -298 504.5 -308Q515 -318 518 -333Q522 -354 536 -370.5Q550 -387 566 -402Q589 -424 605.5 -450Q622 -476 622 -508Q622 -559 580.5 -591.5Q539 -624 484 -624Q446 -624 411.5 -608Q377 -592 359 -559Q352 -547 354.5 -533.5Q357 -520 368 -513Q382 -505 397 -508Q412 -511 422 -525Q433 -540 449.5 -548Q466 -556 484 -556Z"), + ("help_fill", "M478 -144Q499 -144 513.5 -158.5Q528 -173 528 -194Q528 -215 513.5 -229.5Q499 -244 478 -244Q457 -244 442.5 -229.5Q428 -215 428 -194Q428 -173 442.5 -158.5Q457 -144 478 -144ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16ZM484 -556Q509 -556 527.5 -540Q546 -524 546 -500Q546 -478 532.5 -461Q519 -444 502 -429Q479 -409 461.5 -385Q444 -361 444 -331Q444 -317 454.5 -307.5Q465 -298 479 -298Q494 -298 504.5 -308Q515 -318 518 -333Q522 -354 536 -370.5Q550 -387 566 -402Q589 -424 605.5 -450Q622 -476 622 -508Q622 -559 580.5 -591.5Q539 -624 484 -624Q446 -624 411.5 -608Q377 -592 359 -559Q352 -547 354.5 -533.5Q357 -520 368 -513Q382 -505 397 -508Q412 -511 422 -525Q433 -540 449.5 -548Q466 -556 484 -556Z"), + ("hide_image", "M840 -664V-224Q840 -204 827.5 -194Q815 -184 800 -184Q785 -184 772.5 -194.5Q760 -205 760 -225V-664Q760 -664 760 -664Q760 -664 760 -664H320Q300 -664 290 -676.5Q280 -689 280 -704Q280 -719 290 -731.5Q300 -744 320 -744H760Q793 -744 816.5 -720.5Q840 -697 840 -664ZM200 -24Q167 -24 143.5 -47.5Q120 -71 120 -104V-632L84 -668Q73 -679 73 -696Q73 -713 84 -724Q95 -735 112 -735Q129 -735 140 -724L820 -44Q831 -33 831 -16Q831 1 820 12Q809 23 792 23Q775 23 764 12L728 -24ZM567 -184H280Q268 -184 262 -195Q256 -206 264 -216L344 -323Q350 -331 360 -331Q370 -331 376 -323L450 -224L483 -268L200 -551V-104Q200 -104 200 -104Q200 -104 200 -104H647ZM537 -441Q537 -441 537 -441Q537 -441 537 -441ZM424 -328Q424 -328 424 -328Q424 -328 424 -328Z"), + ("hide_image_fill", "M840 -664V-235Q840 -221 833 -212Q826 -203 815 -198Q804 -193 793 -194.5Q782 -196 772 -206L302 -676Q292 -686 290.5 -697Q289 -708 294 -719Q299 -730 308 -737Q317 -744 331 -744H760Q793 -744 816.5 -720.5Q840 -697 840 -664ZM200 -24Q167 -24 143.5 -47.5Q120 -71 120 -104V-632L84 -668Q73 -679 73 -696Q73 -713 84 -724Q95 -735 112 -735Q129 -735 140 -724L820 -44Q831 -33 831 -16Q831 1 820 12Q809 23 792 23Q775 23 764 12L728 -24ZM567 -184 483 -268 450 -224 376 -323Q370 -331 360 -331Q350 -331 344 -323L264 -216Q256 -206 262 -195Q268 -184 280 -184Z"), + ("high_quality", "M590 -264V-234Q590 -221 598.5 -212.5Q607 -204 620 -204Q633 -204 641.5 -212.5Q650 -221 650 -234V-264H680Q697 -264 708.5 -275.5Q720 -287 720 -304V-464Q720 -481 708.5 -492.5Q697 -504 680 -504H560Q543 -504 531.5 -492.5Q520 -481 520 -464V-304Q520 -287 531.5 -275.5Q543 -264 560 -264ZM300 -344H380V-294Q380 -281 388.5 -272.5Q397 -264 410 -264Q423 -264 431.5 -272.5Q440 -281 440 -294V-474Q440 -487 431.5 -495.5Q423 -504 410 -504Q397 -504 388.5 -495.5Q380 -487 380 -474V-404H300V-474Q300 -487 291.5 -495.5Q283 -504 270 -504Q257 -504 248.5 -495.5Q240 -487 240 -474V-294Q240 -281 248.5 -272.5Q257 -264 270 -264Q283 -264 291.5 -272.5Q300 -281 300 -294ZM580 -324Q580 -324 580 -324Q580 -324 580 -324V-444Q580 -444 580 -444Q580 -444 580 -444H660Q660 -444 660 -444Q660 -444 660 -444V-324Q660 -324 660 -324Q660 -324 660 -324ZM160 -64Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704H800Q833 -704 856.5 -680.5Q880 -657 880 -624V-144Q880 -111 856.5 -87.5Q833 -64 800 -64ZM160 -144H800Q800 -144 800 -144Q800 -144 800 -144V-624Q800 -624 800 -624Q800 -624 800 -624H160Q160 -624 160 -624Q160 -624 160 -624V-144Q160 -144 160 -144Q160 -144 160 -144ZM160 -144Q160 -144 160 -144Q160 -144 160 -144V-624Q160 -624 160 -624Q160 -624 160 -624Q160 -624 160 -624Q160 -624 160 -624V-144Q160 -144 160 -144Q160 -144 160 -144Z"), + ("high_quality_fill", "M590 -264V-234Q590 -221 598.5 -212.5Q607 -204 620 -204Q633 -204 641.5 -212.5Q650 -221 650 -234V-264H680Q697 -264 708.5 -275.5Q720 -287 720 -304V-464Q720 -481 708.5 -492.5Q697 -504 680 -504H560Q543 -504 531.5 -492.5Q520 -481 520 -464V-304Q520 -287 531.5 -275.5Q543 -264 560 -264ZM300 -344H380V-294Q380 -281 388.5 -272.5Q397 -264 410 -264Q423 -264 431.5 -272.5Q440 -281 440 -294V-474Q440 -487 431.5 -495.5Q423 -504 410 -504Q397 -504 388.5 -495.5Q380 -487 380 -474V-404H300V-474Q300 -487 291.5 -495.5Q283 -504 270 -504Q257 -504 248.5 -495.5Q240 -487 240 -474V-294Q240 -281 248.5 -272.5Q257 -264 270 -264Q283 -264 291.5 -272.5Q300 -281 300 -294ZM580 -324Q580 -324 580 -324Q580 -324 580 -324V-444Q580 -444 580 -444Q580 -444 580 -444H660Q660 -444 660 -444Q660 -444 660 -444V-324Q660 -324 660 -324Q660 -324 660 -324ZM160 -64Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704H800Q833 -704 856.5 -680.5Q880 -657 880 -624V-144Q880 -111 856.5 -87.5Q833 -64 800 -64Z"), + ("history", "M477-120q-142 0-243.5-95.5T121-451q-1-12 7.5-21t21.5-9q12 0 20.5 8.5T181-451q11 115 95 193t201 78q127 0 215-89t88-216q0-124-89-209.5T477-780q-68 0-127.5 31T246-667h75q13 0 21.5 8.5T351-637q0 13-8.5 21.5T321-607H172q-13 0-21.5-8.5T142-637v-148q0-13 8.5-21.5T172-815q13 0 21.5 8.5T202-785v76q52-61 123.5-96T477-840q75 0 141 28t115.5 76.5Q783-687 811.5-622T840-482q0 75-28.5 141t-78 115Q684-177 618-148.5T477-120Zm34-374 115 113q9 9 9 21.5t-9 21.5q-9 9-21 9t-21-9L460-460q-5-5-7-10.5t-2-11.5v-171q0-13 8.5-21.5T481-683q13 0 21.5 8.5T511-653v159Z"), + ("http", "M40 -294V-474Q40 -487 48.5 -495.5Q57 -504 70 -504Q83 -504 91.5 -495.5Q100 -487 100 -474V-424H180V-474Q180 -487 188.5 -495.5Q197 -504 210 -504Q223 -504 231.5 -495.5Q240 -487 240 -474V-294Q240 -281 231.5 -272.5Q223 -264 210 -264Q197 -264 188.5 -272.5Q180 -281 180 -294V-364H100V-294Q100 -281 91.5 -272.5Q83 -264 70 -264Q57 -264 48.5 -272.5Q40 -281 40 -294ZM340 -294V-444H310Q297 -444 288.5 -452.5Q280 -461 280 -474Q280 -487 288.5 -495.5Q297 -504 310 -504H430Q443 -504 451.5 -495.5Q460 -487 460 -474Q460 -461 451.5 -452.5Q443 -444 430 -444H400V-294Q400 -281 391.5 -272.5Q383 -264 370 -264Q357 -264 348.5 -272.5Q340 -281 340 -294ZM560 -294V-444H530Q517 -444 508.5 -452.5Q500 -461 500 -474Q500 -487 508.5 -495.5Q517 -504 530 -504H650Q663 -504 671.5 -495.5Q680 -487 680 -474Q680 -461 671.5 -452.5Q663 -444 650 -444H620V-294Q620 -281 611.5 -272.5Q603 -264 590 -264Q577 -264 568.5 -272.5Q560 -281 560 -294ZM720 -294V-474Q720 -487 728.5 -495.5Q737 -504 750 -504H860Q884 -504 902 -486Q920 -468 920 -444V-404Q920 -380 902 -362Q884 -344 860 -344H780V-294Q780 -281 771.5 -272.5Q763 -264 750 -264Q737 -264 728.5 -272.5Q720 -281 720 -294ZM780 -404H860Q860 -404 860 -404Q860 -404 860 -404V-444Q860 -444 860 -444Q860 -444 860 -444H780Z"), + ("image", "M200 -24Q167 -24 143.5 -47.5Q120 -71 120 -104V-664Q120 -697 143.5 -720.5Q167 -744 200 -744H760Q793 -744 816.5 -720.5Q840 -697 840 -664V-104Q840 -71 816.5 -47.5Q793 -24 760 -24ZM200 -104H760Q760 -104 760 -104Q760 -104 760 -104V-664Q760 -664 760 -664Q760 -664 760 -664H200Q200 -664 200 -664Q200 -664 200 -664V-104Q200 -104 200 -104Q200 -104 200 -104ZM200 -104Q200 -104 200 -104Q200 -104 200 -104V-664Q200 -664 200 -664Q200 -664 200 -664Q200 -664 200 -664Q200 -664 200 -664V-104Q200 -104 200 -104Q200 -104 200 -104ZM280 -184H680Q692 -184 698 -195Q704 -206 696 -216L586 -363Q580 -371 570 -371Q560 -371 554 -363L450 -224L376 -323Q370 -331 360 -331Q350 -331 344 -323L264 -216Q256 -206 262 -195Q268 -184 280 -184Z"), + ("image_fill", "M200 -24Q167 -24 143.5 -47.5Q120 -71 120 -104V-664Q120 -697 143.5 -720.5Q167 -744 200 -744H760Q793 -744 816.5 -720.5Q840 -697 840 -664V-104Q840 -71 816.5 -47.5Q793 -24 760 -24ZM280 -184H680Q692 -184 698 -195Q704 -206 696 -216L586 -363Q580 -371 570 -371Q560 -371 554 -363L450 -224L376 -323Q370 -331 360 -331Q350 -331 344 -323L264 -216Q256 -206 262 -195Q268 -184 280 -184Z"), + ("info", "M480 -184Q497 -184 508.5 -195.5Q520 -207 520 -224V-384Q520 -401 508.5 -412.5Q497 -424 480 -424Q463 -424 451.5 -412.5Q440 -401 440 -384V-224Q440 -207 451.5 -195.5Q463 -184 480 -184ZM480 -504Q497 -504 508.5 -515.5Q520 -527 520 -544Q520 -561 508.5 -572.5Q497 -584 480 -584Q463 -584 451.5 -572.5Q440 -561 440 -544Q440 -527 451.5 -515.5Q463 -504 480 -504ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16ZM480 -64Q614 -64 707 -157Q800 -250 800 -384Q800 -518 707 -611Q614 -704 480 -704Q346 -704 253 -611Q160 -518 160 -384Q160 -250 253 -157Q346 -64 480 -64ZM480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Z"), + ("info_fill", "M480 -184Q497 -184 508.5 -195.5Q520 -207 520 -224V-384Q520 -401 508.5 -412.5Q497 -424 480 -424Q463 -424 451.5 -412.5Q440 -401 440 -384V-224Q440 -207 451.5 -195.5Q463 -184 480 -184ZM480 -504Q497 -504 508.5 -515.5Q520 -527 520 -544Q520 -561 508.5 -572.5Q497 -584 480 -584Q463 -584 451.5 -572.5Q440 -561 440 -544Q440 -527 451.5 -515.5Q463 -504 480 -504ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16Z"), + ("key", "M280 -304Q247 -304 223.5 -327.5Q200 -351 200 -384Q200 -417 223.5 -440.5Q247 -464 280 -464Q313 -464 336.5 -440.5Q360 -417 360 -384Q360 -351 336.5 -327.5Q313 -304 280 -304ZM280 -144Q180 -144 110 -214Q40 -284 40 -384Q40 -484 110 -554Q180 -624 280 -624Q347 -624 401.5 -591Q456 -558 488 -504H823Q831 -504 838.5 -501Q846 -498 852 -492L932 -412Q938 -406 940.5 -399Q943 -392 943 -384Q943 -376 940.5 -369Q938 -362 932 -356L805 -229Q800 -224 793 -221Q786 -218 779 -217Q772 -216 765 -218Q758 -220 752 -225L700 -264L643 -221Q638 -217 632 -215Q626 -213 620 -213Q614 -213 607.5 -215Q601 -217 596 -221L535 -264H488Q456 -210 401.5 -177Q347 -144 280 -144ZM280 -224Q336 -224 378.5 -258Q421 -292 435 -344H560L618 -303Q618 -303 618 -302.5Q618 -302 618 -303Q618 -303 618 -303Q618 -303 618 -303L700 -364L771 -309Q771 -309 771 -309Q771 -309 771 -309Q771 -309 771 -309Q771 -309 771 -309L846 -384Q845 -384 845.5 -384Q846 -384 846 -384Q846 -384 846 -384Q846 -384 846 -384L806 -424Q806 -425 806 -424.5Q806 -424 806 -424H435Q421 -476 378.5 -510Q336 -544 280 -544Q214 -544 167 -497Q120 -450 120 -384Q120 -318 167 -271Q214 -224 280 -224Z"), + ("key_fill", "M280 -264Q230 -264 195 -299Q160 -334 160 -384Q160 -434 195 -469Q230 -504 280 -504Q330 -504 365 -469Q400 -434 400 -384Q400 -334 365 -299Q330 -264 280 -264ZM280 -144Q357 -144 419 -188Q481 -232 506 -304H520L572 -252Q578 -246 585 -243.5Q592 -241 600 -241Q608 -241 615 -243.5Q622 -246 628 -252L680 -304L750 -249Q756 -244 763.5 -241.5Q771 -239 779 -240Q787 -241 793.5 -244.5Q800 -248 805 -254L895 -357Q900 -363 902.5 -370Q905 -377 905 -385Q905 -393 902 -399.5Q899 -406 894 -411L853 -452Q847 -458 839.5 -461Q832 -464 824 -464H506Q482 -532 421.5 -578Q361 -624 280 -624Q180 -624 110 -554Q40 -484 40 -384Q40 -284 110 -214Q180 -144 280 -144Z"), + ("label", "M140-160q-24.75 0-42.37-17.63Q80-195.25 80-220v-520q0-24.75 17.63-42.38Q115.25-800 140-800h471q14.25 0 27 6.37 12.75 6.38 21 17.63l195 260q12 15.68 12 35.84Q866-460 854-444L660-184q-8.25 11.25-21 17.62-12.75 6.38-27 6.38H140Zm0-60h471l195-260-195-260H140v520Zm333-260Z"), + ("lan", "M120 -64V-184Q120 -217 143.5 -240.5Q167 -264 200 -264H240V-344Q240 -377 263.5 -400.5Q287 -424 320 -424H440V-504H400Q367 -504 343.5 -527.5Q320 -551 320 -584V-704Q320 -737 343.5 -760.5Q367 -784 400 -784H560Q593 -784 616.5 -760.5Q640 -737 640 -704V-584Q640 -551 616.5 -527.5Q593 -504 560 -504H520V-424H640Q673 -424 696.5 -400.5Q720 -377 720 -344V-264H760Q793 -264 816.5 -240.5Q840 -217 840 -184V-64Q840 -31 816.5 -7.5Q793 16 760 16H600Q567 16 543.5 -7.5Q520 -31 520 -64V-184Q520 -217 543.5 -240.5Q567 -264 600 -264H640V-344Q640 -344 640 -344Q640 -344 640 -344H320Q320 -344 320 -344Q320 -344 320 -344V-264H360Q393 -264 416.5 -240.5Q440 -217 440 -184V-64Q440 -31 416.5 -7.5Q393 16 360 16H200Q167 16 143.5 -7.5Q120 -31 120 -64ZM400 -584H560V-704H400ZM200 -64H360V-184H200ZM600 -64H760V-184H600ZM480 -584ZM360 -184ZM600 -184Z"), + ("lan_fill", "M120 -64V-184Q120 -217 143.5 -240.5Q167 -264 200 -264H240V-344Q240 -377 263.5 -400.5Q287 -424 320 -424H440V-504H400Q367 -504 343.5 -527.5Q320 -551 320 -584V-704Q320 -737 343.5 -760.5Q367 -784 400 -784H560Q593 -784 616.5 -760.5Q640 -737 640 -704V-584Q640 -551 616.5 -527.5Q593 -504 560 -504H520V-424H640Q673 -424 696.5 -400.5Q720 -377 720 -344V-264H760Q793 -264 816.5 -240.5Q840 -217 840 -184V-64Q840 -31 816.5 -7.5Q793 16 760 16H600Q567 16 543.5 -7.5Q520 -31 520 -64V-184Q520 -217 543.5 -240.5Q567 -264 600 -264H640V-344Q640 -344 640 -344Q640 -344 640 -344H320Q320 -344 320 -344Q320 -344 320 -344V-264H360Q393 -264 416.5 -240.5Q440 -217 440 -184V-64Q440 -31 416.5 -7.5Q393 16 360 16H200Q167 16 143.5 -7.5Q120 -31 120 -64Z"), + ("library_add", "M561.5-386.63q8.5-8.62 8.5-21.37v-102h102q12.75 0 21.38-8.68 8.62-8.67 8.62-21.5 0-12.82-8.62-21.32-8.63-8.5-21.38-8.5H570v-102q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82 0-21.32 8.62-8.5 8.63-8.5 21.38v102H408q-12.75 0-21.37 8.68-8.63 8.67-8.63 21.5 0 12.82 8.63 21.32 8.62 8.5 21.37 8.5h102v102q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63 12.82 0 21.32-8.63ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-590q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v590h590q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32Q742.75-80 730-80H140Zm120-740v560-560Z"), + ("library_music", "M500 -264Q542 -264 571 -293Q600 -322 600 -364V-584H680Q697 -584 708.5 -595.5Q720 -607 720 -624Q720 -641 708.5 -652.5Q697 -664 680 -664H600Q583 -664 571.5 -652.5Q560 -641 560 -624V-444Q547 -454 532 -459Q517 -464 500 -464Q458 -464 429 -435Q400 -406 400 -364Q400 -322 429 -293Q458 -264 500 -264ZM320 -144Q287 -144 263.5 -167.5Q240 -191 240 -224V-704Q240 -737 263.5 -760.5Q287 -784 320 -784H800Q833 -784 856.5 -760.5Q880 -737 880 -704V-224Q880 -191 856.5 -167.5Q833 -144 800 -144ZM320 -224H800Q800 -224 800 -224Q800 -224 800 -224V-704Q800 -704 800 -704Q800 -704 800 -704H320Q320 -704 320 -704Q320 -704 320 -704V-224Q320 -224 320 -224Q320 -224 320 -224ZM160 16Q127 16 103.5 -7.5Q80 -31 80 -64V-584Q80 -601 91.5 -612.5Q103 -624 120 -624Q137 -624 148.5 -612.5Q160 -601 160 -584V-64Q160 -64 160 -64Q160 -64 160 -64H680Q697 -64 708.5 -52.5Q720 -41 720 -24Q720 -7 708.5 4.5Q697 16 680 16ZM320 -704Q320 -704 320 -704Q320 -704 320 -704V-224Q320 -224 320 -224Q320 -224 320 -224Q320 -224 320 -224Q320 -224 320 -224V-704Q320 -704 320 -704Q320 -704 320 -704Z"), + ("library_music_fill", "M500 -264Q542 -264 571 -293Q600 -322 600 -364V-584H680Q697 -584 708.5 -595.5Q720 -607 720 -624Q720 -641 708.5 -652.5Q697 -664 680 -664H600Q583 -664 571.5 -652.5Q560 -641 560 -624V-444Q547 -454 532 -459Q517 -464 500 -464Q458 -464 429 -435Q400 -406 400 -364Q400 -322 429 -293Q458 -264 500 -264ZM320 -144Q287 -144 263.5 -167.5Q240 -191 240 -224V-704Q240 -737 263.5 -760.5Q287 -784 320 -784H800Q833 -784 856.5 -760.5Q880 -737 880 -704V-224Q880 -191 856.5 -167.5Q833 -144 800 -144ZM160 16Q127 16 103.5 -7.5Q80 -31 80 -64V-584Q80 -601 91.5 -612.5Q103 -624 120 -624Q137 -624 148.5 -612.5Q160 -601 160 -584V-64Q160 -64 160 -64Q160 -64 160 -64H680Q697 -64 708.5 -52.5Q720 -41 720 -24Q720 -7 708.5 4.5Q697 16 680 16Z"), + ("light", "M480 -24Q414 -24 367 -71Q320 -118 320 -184H200Q167 -184 143.5 -207.5Q120 -231 120 -264Q120 -404 212 -505.5Q304 -607 440 -622V-704Q440 -721 451.5 -732.5Q463 -744 480 -744Q497 -744 508.5 -732.5Q520 -721 520 -704V-622Q656 -607 748 -505.5Q840 -404 840 -264Q840 -231 816.5 -207.5Q793 -184 760 -184H640Q640 -118 593 -71Q546 -24 480 -24ZM200 -264H760Q760 -380 678 -462Q596 -544 480 -544Q364 -544 282 -462Q200 -380 200 -264ZM480 -104Q513 -104 536.5 -127.5Q560 -151 560 -184H400Q400 -151 423.5 -127.5Q447 -104 480 -104ZM480 -184Q480 -184 480 -184Q480 -184 480 -184Q480 -184 480 -184Q480 -184 480 -184Z"), + ("light_fill", "M480 -24Q414 -24 367 -71Q320 -118 320 -184H200Q167 -184 143.5 -207.5Q120 -231 120 -264Q120 -404 212 -505.5Q304 -607 440 -622V-704Q440 -721 451.5 -732.5Q463 -744 480 -744Q497 -744 508.5 -732.5Q520 -721 520 -704V-622Q656 -607 748 -505.5Q840 -404 840 -264Q840 -231 816.5 -207.5Q793 -184 760 -184H640Q640 -118 593 -71Q546 -24 480 -24ZM200 -264H760Q760 -380 678 -462Q596 -544 480 -544Q364 -544 282 -462Q200 -380 200 -264Z"), + ("link", "M280 -184Q197 -184 138.5 -242.5Q80 -301 80 -384Q80 -467 138.5 -525.5Q197 -584 280 -584H400Q417 -584 428.5 -572.5Q440 -561 440 -544Q440 -527 428.5 -515.5Q417 -504 400 -504H280Q230 -504 195 -469Q160 -434 160 -384Q160 -334 195 -299Q230 -264 280 -264H400Q417 -264 428.5 -252.5Q440 -241 440 -224Q440 -207 428.5 -195.5Q417 -184 400 -184ZM360 -344Q343 -344 331.5 -355.5Q320 -367 320 -384Q320 -401 331.5 -412.5Q343 -424 360 -424H600Q617 -424 628.5 -412.5Q640 -401 640 -384Q640 -367 628.5 -355.5Q617 -344 600 -344ZM560 -184Q543 -184 531.5 -195.5Q520 -207 520 -224Q520 -241 531.5 -252.5Q543 -264 560 -264H680Q730 -264 765 -299Q800 -334 800 -384Q800 -434 765 -469Q730 -504 680 -504H560Q543 -504 531.5 -515.5Q520 -527 520 -544Q520 -561 531.5 -572.5Q543 -584 560 -584H680Q763 -584 821.5 -525.5Q880 -467 880 -384Q880 -301 821.5 -242.5Q763 -184 680 -184Z"), + ("lists", "M399-160q-36 0-61-25.58t-25-61.5Q313-283 338-308t61-25h395q36 0 61 25t25 60.92q0 35.92-25 61.5T794-160H399Zm1-233q-35.89 0-61.44-25.58Q313-444.16 313-480.08t25.56-61.42Q364.11-567 400-567h393q35.89 0 61.44 25.58Q880-515.84 880-479.92t-25.56 61.42Q828.89-393 793-393H400Zm-1-234q-36 0-61-25.58t-25-61.5Q313-750 338-775t61-25h395q36 0 61 25t25 60.92q0 35.92-25 61.5T794-627H399Zm-293.42-25.58Q80-678.16 80-714.08T105.58-775q25.58-25 61.5-25T228-775q25 25 25 60.92t-25 61.5Q203-627 167.08-627t-61.5-25.58ZM166.92-393q-35.92 0-61.42-25.58T80-480.08q0-35.92 25.58-61.42t61.5-25.5q35.92 0 61.42 25.58t25.5 61.5q0 35.92-25.58 61.42t-61.5 25.5Zm.16 233q-35.92 0-61.5-25.58T80-247.08Q80-283 105.58-308t61.5-25Q203-333 228-308t25 60.92q0 35.92-25 61.5T167.08-160Z"), + ("lock_open", "M240 16Q207 16 183.5 -7.5Q160 -31 160 -64V-464Q160 -497 183.5 -520.5Q207 -544 240 -544H600V-624Q600 -674 565 -709Q530 -744 480 -744Q438 -744 406.5 -718.5Q375 -693 364 -655Q360 -641 347.5 -632.5Q335 -624 320 -624Q303 -624 291.5 -635Q280 -646 283 -661Q297 -730 352 -777Q407 -824 480 -824Q563 -824 621.5 -765.5Q680 -707 680 -624V-544H720Q753 -544 776.5 -520.5Q800 -497 800 -464V-64Q800 -31 776.5 -7.5Q753 16 720 16ZM240 -64H720Q720 -64 720 -64Q720 -64 720 -64V-464Q720 -464 720 -464Q720 -464 720 -464H240Q240 -464 240 -464Q240 -464 240 -464V-64Q240 -64 240 -64Q240 -64 240 -64ZM480 -184Q513 -184 536.5 -207.5Q560 -231 560 -264Q560 -297 536.5 -320.5Q513 -344 480 -344Q447 -344 423.5 -320.5Q400 -297 400 -264Q400 -231 423.5 -207.5Q447 -184 480 -184ZM240 -64Q240 -64 240 -64Q240 -64 240 -64V-464Q240 -464 240 -464Q240 -464 240 -464Q240 -464 240 -464Q240 -464 240 -464V-64Q240 -64 240 -64Q240 -64 240 -64Z"), + ("lock_open_fill", "M240 16Q207 16 183.5 -7.5Q160 -31 160 -64V-464Q160 -497 183.5 -520.5Q207 -544 240 -544H600V-624Q600 -674 565 -709Q530 -744 480 -744Q438 -744 406.5 -718.5Q375 -693 364 -655Q360 -641 347.5 -632.5Q335 -624 320 -624Q303 -624 291.5 -635Q280 -646 283 -661Q294 -729 349.5 -776.5Q405 -824 480 -824Q563 -824 621.5 -765.5Q680 -707 680 -624V-544H720Q753 -544 776.5 -520.5Q800 -497 800 -464V-64Q800 -31 776.5 -7.5Q753 16 720 16ZM480 -184Q513 -184 536.5 -207.5Q560 -231 560 -264Q560 -297 536.5 -320.5Q513 -344 480 -344Q447 -344 423.5 -320.5Q400 -297 400 -264Q400 -231 423.5 -207.5Q447 -184 480 -184Z"), + ("lyrics", "M280 -304H360Q377 -304 388.5 -315.5Q400 -327 400 -344Q400 -361 388.5 -372.5Q377 -384 360 -384H280Q263 -384 251.5 -372.5Q240 -361 240 -344Q240 -327 251.5 -315.5Q263 -304 280 -304ZM760 -384Q710 -384 675 -419Q640 -454 640 -504Q640 -554 675 -589Q710 -624 760 -624Q771 -624 781 -622Q791 -620 800 -617V-784Q800 -801 811.5 -812.5Q823 -824 840 -824H920Q937 -824 948.5 -812.5Q960 -801 960 -784Q960 -767 948.5 -755.5Q937 -744 920 -744H880V-504Q880 -454 845 -419Q810 -384 760 -384ZM280 -424H480Q497 -424 508.5 -435.5Q520 -447 520 -464Q520 -481 508.5 -492.5Q497 -504 480 -504H280Q263 -504 251.5 -492.5Q240 -481 240 -464Q240 -447 251.5 -435.5Q263 -424 280 -424ZM280 -544H480Q497 -544 508.5 -555.5Q520 -567 520 -584Q520 -601 508.5 -612.5Q497 -624 480 -624H280Q263 -624 251.5 -612.5Q240 -601 240 -584Q240 -567 251.5 -555.5Q263 -544 280 -544ZM600 -144H240L148 -52Q142 -46 135 -43Q128 -40 120 -40Q104 -40 92 -51.5Q80 -63 80 -81V-704Q80 -737 103.5 -760.5Q127 -784 160 -784H600Q633 -784 656.5 -760.5Q680 -737 680 -704V-687Q656 -676 636 -660Q616 -644 600 -624V-704Q600 -704 600 -704Q600 -704 600 -704H160Q160 -704 160 -704Q160 -704 160 -704V-177L207 -224H600Q600 -224 600 -224Q600 -224 600 -224V-384Q616 -364 636 -348Q656 -332 680 -321V-224Q680 -191 656.5 -167.5Q633 -144 600 -144ZM160 -224V-704Q160 -704 160 -704Q160 -704 160 -704Q160 -704 160 -704Q160 -704 160 -704V-624Q160 -599 160 -568.5Q160 -538 160 -504Q160 -470 160 -439.5Q160 -409 160 -384V-224Q160 -224 160 -224Q160 -224 160 -224Z"), + ("lyrics_fill", "M280 -304H360Q377 -304 388.5 -315.5Q400 -327 400 -344Q400 -361 388.5 -372.5Q377 -384 360 -384H280Q263 -384 251.5 -372.5Q240 -361 240 -344Q240 -327 251.5 -315.5Q263 -304 280 -304ZM760 -384Q710 -384 675 -419Q640 -454 640 -504Q640 -554 675 -589Q710 -624 760 -624Q771 -624 781 -622Q791 -620 800 -617V-784Q800 -801 811.5 -812.5Q823 -824 840 -824H920Q937 -824 948.5 -812.5Q960 -801 960 -784Q960 -767 948.5 -755.5Q937 -744 920 -744H880V-504Q880 -454 845 -419Q810 -384 760 -384ZM280 -424H480Q497 -424 508.5 -435.5Q520 -447 520 -464Q520 -481 508.5 -492.5Q497 -504 480 -504H280Q263 -504 251.5 -492.5Q240 -481 240 -464Q240 -447 251.5 -435.5Q263 -424 280 -424ZM280 -544H480Q497 -544 508.5 -555.5Q520 -567 520 -584Q520 -601 508.5 -612.5Q497 -624 480 -624H280Q263 -624 251.5 -612.5Q240 -601 240 -584Q240 -567 251.5 -555.5Q263 -544 280 -544ZM240 -144 148 -52Q142 -46 135 -43Q128 -40 120 -40Q104 -40 92 -51.5Q80 -63 80 -81V-704Q80 -737 103.5 -760.5Q127 -784 160 -784H600Q631 -784 654.5 -765Q678 -746 678 -716Q678 -702 671.5 -691Q665 -680 654 -673Q610 -646 585 -601Q560 -556 560 -504Q560 -450 586.5 -404Q613 -358 660 -331Q682 -318 695 -296.5Q708 -275 708 -249Q708 -204 676.5 -174Q645 -144 600 -144Z"), + ("menu", "M150-240q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-210q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-210q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Z"), + ("mic", "M408-453.92q-29-30.91-29-75.08v-251q0-41.67 29.44-70.83Q437.88-880 479.94-880t71.56 29.17Q581-821.67 581-780v251q0 44.17-29 75.08Q523-423 480-423t-72-30.92ZM480-651Zm-30 501v-106q-96-11-166.5-77.5T202-498q-2-12.85 6.59-21.93 8.6-9.07 21.5-9.07 12.91 0 21.41 9t10.5 22q12 81 74.71 132.5Q399.42-314 479.65-314q81.35 0 143.85-51.5T698-498q2-13 10.68-22 8.67-9 21.5-9 12.82 0 21.32 9.07 8.5 9.08 6.5 21.93-11 97-81 164t-167 78v106q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63-8.5-8.62-8.5-21.37Zm59.5-346.5Q521-510 521-529v-251q0-17-11.79-28.5T480-820q-17.42 0-29.21 11.5T439-780v251q0 19 11.5 32.5T480-483q18 0 29.5-13.5Z"), + ("mop", "M440 -424H520V-704Q520 -721 508.5 -732.5Q497 -744 480 -744Q463 -744 451.5 -732.5Q440 -721 440 -704ZM200 -264H760V-344Q760 -344 760 -344Q760 -344 760 -344H200Q200 -344 200 -344Q200 -344 200 -344ZM142 -24H240V-104Q240 -121 251.5 -132.5Q263 -144 280 -144Q297 -144 308.5 -132.5Q320 -121 320 -104V-24H440V-104Q440 -121 451.5 -132.5Q463 -144 480 -144Q497 -144 508.5 -132.5Q520 -121 520 -104V-24H640V-104Q640 -121 651.5 -132.5Q663 -144 680 -144Q697 -144 708.5 -132.5Q720 -121 720 -104V-24H818Q818 -24 818 -24Q818 -24 818 -24L778 -184H182L142 -24Q142 -24 142 -24Q142 -24 142 -24ZM818 56H142Q103 56 79 25Q55 -6 65 -44L120 -264V-344Q120 -377 143.5 -400.5Q167 -424 200 -424H360V-704Q360 -754 395 -789Q430 -824 480 -824Q530 -824 565 -789Q600 -754 600 -704V-424H760Q793 -424 816.5 -400.5Q840 -377 840 -344V-264L895 -44Q908 -6 883.5 25Q859 56 818 56ZM760 -344H200Q200 -344 200 -344Q200 -344 200 -344H760Q760 -344 760 -344Q760 -344 760 -344ZM520 -424H440Q440 -424 451.5 -424Q463 -424 480 -424Q497 -424 508.5 -424Q520 -424 520 -424Z"), + ("mop_fill", "M142 -24H240V-104Q240 -121 251.5 -132.5Q263 -144 280 -144Q297 -144 308.5 -132.5Q320 -121 320 -104V-24H440V-104Q440 -121 451.5 -132.5Q463 -144 480 -144Q497 -144 508.5 -132.5Q520 -121 520 -104V-24H640V-104Q640 -121 651.5 -132.5Q663 -144 680 -144Q697 -144 708.5 -132.5Q720 -121 720 -104V-24H818Q818 -24 818 -24Q818 -24 818 -24L778 -184H182L142 -24Q142 -24 142 -24Q142 -24 142 -24ZM818 56H142Q103 56 79 25Q55 -6 65 -44L120 -264V-344Q120 -377 143.5 -400.5Q167 -424 200 -424H360V-704Q360 -754 395 -789Q430 -824 480 -824Q530 -824 565 -789Q600 -754 600 -704V-424H760Q793 -424 816.5 -400.5Q840 -377 840 -344V-264L895 -44Q908 -6 883.5 25Q859 56 818 56Z"), + ("more_vert", "M479.86-160Q460-160 446-174.14t-14-34Q432-228 446.14-242t34-14Q500-256 514-241.86t14 34Q528-188 513.86-174t-34 14Zm0-272Q460-432 446-446.14t-14-34Q432-500 446.14-514t34-14Q500-528 514-513.86t14 34Q528-460 513.86-446t-34 14Zm0-272Q460-704 446-718.14t-14-34Q432-772 446.14-786t34-14Q500-800 514-785.86t14 34Q528-732 513.86-718t-34 14Z"), + ("movie", "M160 -704 225 -574Q232 -560 245 -552Q258 -544 273 -544Q303 -544 319 -569.5Q335 -595 321 -622L280 -704H360L425 -574Q432 -560 445 -552Q458 -544 473 -544Q503 -544 519 -569.5Q535 -595 521 -622L480 -704H560L625 -574Q632 -560 645 -552Q658 -544 673 -544Q703 -544 719 -569.5Q735 -595 721 -622L680 -704H800Q833 -704 856.5 -680.5Q880 -657 880 -624V-144Q880 -111 856.5 -87.5Q833 -64 800 -64H160Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704ZM160 -464V-144Q160 -144 160 -144Q160 -144 160 -144H800Q800 -144 800 -144Q800 -144 800 -144V-464ZM160 -464V-144Q160 -144 160 -144Q160 -144 160 -144Q160 -144 160 -144Q160 -144 160 -144Z"), + ("movie_fill", "M160 -704 225 -574Q232 -560 245 -552Q258 -544 273 -544Q303 -544 319 -569.5Q335 -595 321 -622L280 -704H360L425 -574Q432 -560 445 -552Q458 -544 473 -544Q503 -544 519 -569.5Q535 -595 521 -622L480 -704H560L625 -574Q632 -560 645 -552Q658 -544 673 -544Q703 -544 719 -569.5Q735 -595 721 -622L680 -704H800Q833 -704 856.5 -680.5Q880 -657 880 -624V-144Q880 -111 856.5 -87.5Q833 -64 800 -64H160Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704Z"), + ("music_note", "M400 -24Q334 -24 287 -71Q240 -118 240 -184Q240 -250 287 -297Q334 -344 400 -344Q423 -344 442.5 -338.5Q462 -333 480 -322V-704Q480 -721 491.5 -732.5Q503 -744 520 -744H680Q697 -744 708.5 -732.5Q720 -721 720 -704V-624Q720 -607 708.5 -595.5Q697 -584 680 -584H560V-184Q560 -118 513 -71Q466 -24 400 -24Z"), + ("my_location", "M450-72v-45q-137-14-228-105T117-450H72q-13 0-21.5-8.5T42-480q0-13 8.5-21.5T72-510h45q14-137 105-228t228-105v-45q0-13 8.5-21.5T480-918q13 0 21.5 8.5T510-888v45q137 14 228 105t105 228h45q13 0 21.5 8.5T918-480q0 13-8.5 21.5T888-450h-45q-14 137-105 228T510-117v45q0 13-8.5 21.5T480-42q-13 0-21.5-8.5T450-72Zm244.5-193.5Q784-355 784-480t-89.5-214.5Q605-784 480-784t-214.5 89.5Q176-605 176-480t89.5 214.5Q355-176 480-176t214.5-89.5Zm-321-108Q330-417 330-480t43.5-106.5Q417-630 480-630t106.5 43.5Q630-543 630-480t-43.5 106.5Q543-330 480-330t-106.5-43.5ZM544-416q26-26 26-64t-26-64q-26-26-64-26t-64 26q-26 26-26 64t26 64q26 26 64 26t64-26Zm-64-64Z"), + ("opacity", "M480 -24Q347 -24 253.5 -116Q160 -208 160 -340Q160 -405 185 -461.5Q210 -518 254 -562L438 -743Q447 -751 458 -755.5Q469 -760 480 -760Q491 -760 502 -755.5Q513 -751 522 -743L706 -562Q750 -518 775 -461.5Q800 -405 800 -340Q800 -208 706.5 -116Q613 -24 480 -24ZM242 -304H716Q728 -376 702.5 -427Q677 -478 650 -504L480 -672L310 -504Q283 -478 257 -427Q231 -376 242 -304Z"), + ("open_in_full", "M150-120q-12.75 0-21.37-8.63Q120-137.25 120-150v-240q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v168l558-558H570q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h240q12.75 0 21.38 8.62Q840-822.75 840-810v240q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63-8.5-8.62-8.5-21.37v-168L222-180h168q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Z"), + ("open_in_new", "M200 -24Q167 -24 143.5 -47.5Q120 -71 120 -104V-664Q120 -697 143.5 -720.5Q167 -744 200 -744H440Q457 -744 468.5 -732.5Q480 -721 480 -704Q480 -687 468.5 -675.5Q457 -664 440 -664H200Q200 -664 200 -664Q200 -664 200 -664V-104Q200 -104 200 -104Q200 -104 200 -104H760Q760 -104 760 -104Q760 -104 760 -104V-344Q760 -361 771.5 -372.5Q783 -384 800 -384Q817 -384 828.5 -372.5Q840 -361 840 -344V-104Q840 -71 816.5 -47.5Q793 -24 760 -24ZM760 -608 416 -264Q405 -253 388 -253Q371 -253 360 -264Q349 -275 349 -292Q349 -309 360 -320L704 -664H600Q583 -664 571.5 -675.5Q560 -687 560 -704Q560 -721 571.5 -732.5Q583 -744 600 -744H800Q817 -744 828.5 -732.5Q840 -721 840 -704V-504Q840 -487 828.5 -475.5Q817 -464 800 -464Q783 -464 771.5 -475.5Q760 -487 760 -504Z"), + ("package", "M400 -474 453 -500Q466 -506 480 -506Q494 -506 507 -500L560 -474V-664H400ZM320 -184Q303 -184 291.5 -195.5Q280 -207 280 -224Q280 -241 291.5 -252.5Q303 -264 320 -264H440Q457 -264 468.5 -252.5Q480 -241 480 -224Q480 -207 468.5 -195.5Q457 -184 440 -184ZM200 -24Q167 -24 143.5 -47.5Q120 -71 120 -104V-664Q120 -697 143.5 -720.5Q167 -744 200 -744H760Q793 -744 816.5 -720.5Q840 -697 840 -664V-104Q840 -71 816.5 -47.5Q793 -24 760 -24ZM200 -664Q200 -664 200 -664Q200 -664 200 -664V-104Q200 -104 200 -104Q200 -104 200 -104Q200 -104 200 -104Q200 -104 200 -104V-664Q200 -664 200 -664Q200 -664 200 -664ZM200 -104H760Q760 -104 760 -104Q760 -104 760 -104V-664Q760 -664 760 -664Q760 -664 760 -664H640V-409Q640 -386 621 -374.5Q602 -363 582 -373L480 -424L378 -373Q358 -363 339 -374.5Q320 -386 320 -409V-664H200Q200 -664 200 -664Q200 -664 200 -664V-104Q200 -104 200 -104Q200 -104 200 -104Z"), + ("package_fill", "M200 -24Q167 -24 143.5 -47.5Q120 -71 120 -104V-664Q120 -697 143.5 -720.5Q167 -744 200 -744H760Q793 -744 816.5 -720.5Q840 -697 840 -664V-104Q840 -71 816.5 -47.5Q793 -24 760 -24ZM378 -373 480 -424 582 -373Q602 -363 621 -374.5Q640 -386 640 -409V-664H320V-409Q320 -386 339 -374.5Q358 -363 378 -373ZM320 -184H440Q457 -184 468.5 -195.5Q480 -207 480 -224Q480 -241 468.5 -252.5Q457 -264 440 -264H320Q303 -264 291.5 -252.5Q280 -241 280 -224Q280 -207 291.5 -195.5Q303 -184 320 -184Z"), + ("palette", "M480 16Q398 16 325 -15.5Q252 -47 197.5 -101.5Q143 -156 111.5 -229Q80 -302 80 -384Q80 -467 112.5 -540Q145 -613 200.5 -667Q256 -721 330 -752.5Q404 -784 488 -784Q568 -784 639 -756.5Q710 -729 763.5 -680.5Q817 -632 848.5 -565.5Q880 -499 880 -422Q880 -307 810 -245.5Q740 -184 640 -184H566Q557 -184 553.5 -179Q550 -174 550 -168Q550 -156 565 -133.5Q580 -111 580 -82Q580 -32 552.5 -8Q525 16 480 16ZM480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384ZM260 -344Q286 -344 303 -361Q320 -378 320 -404Q320 -430 303 -447Q286 -464 260 -464Q234 -464 217 -447Q200 -430 200 -404Q200 -378 217 -361Q234 -344 260 -344ZM380 -504Q406 -504 423 -521Q440 -538 440 -564Q440 -590 423 -607Q406 -624 380 -624Q354 -624 337 -607Q320 -590 320 -564Q320 -538 337 -521Q354 -504 380 -504ZM580 -504Q606 -504 623 -521Q640 -538 640 -564Q640 -590 623 -607Q606 -624 580 -624Q554 -624 537 -607Q520 -590 520 -564Q520 -538 537 -521Q554 -504 580 -504ZM700 -344Q726 -344 743 -361Q760 -378 760 -404Q760 -430 743 -447Q726 -464 700 -464Q674 -464 657 -447Q640 -430 640 -404Q640 -378 657 -361Q674 -344 700 -344ZM480 -64Q489 -64 494.5 -69Q500 -74 500 -82Q500 -96 485 -115Q470 -134 470 -172Q470 -214 499 -239Q528 -264 570 -264H640Q706 -264 753 -302.5Q800 -341 800 -422Q800 -543 707.5 -623.5Q615 -704 488 -704Q352 -704 256 -611Q160 -518 160 -384Q160 -251 253.5 -157.5Q347 -64 480 -64Z"), + ("palette_fill", "M480 16Q398 16 325 -15.5Q252 -47 197.5 -101.5Q143 -156 111.5 -229Q80 -302 80 -384Q80 -467 112.5 -540Q145 -613 200.5 -667Q256 -721 330 -752.5Q404 -784 488 -784Q568 -784 639 -756.5Q710 -729 763.5 -680.5Q817 -632 848.5 -565.5Q880 -499 880 -422Q880 -307 810 -245.5Q740 -184 640 -184H566Q557 -184 553.5 -179Q550 -174 550 -168Q550 -156 565 -133.5Q580 -111 580 -82Q580 -32 552.5 -8Q525 16 480 16ZM260 -344Q286 -344 303 -361Q320 -378 320 -404Q320 -430 303 -447Q286 -464 260 -464Q234 -464 217 -447Q200 -430 200 -404Q200 -378 217 -361Q234 -344 260 -344ZM380 -504Q406 -504 423 -521Q440 -538 440 -564Q440 -590 423 -607Q406 -624 380 -624Q354 -624 337 -607Q320 -590 320 -564Q320 -538 337 -521Q354 -504 380 -504ZM580 -504Q606 -504 623 -521Q640 -538 640 -564Q640 -590 623 -607Q606 -624 580 -624Q554 -624 537 -607Q520 -590 520 -564Q520 -538 537 -521Q554 -504 580 -504ZM700 -344Q726 -344 743 -361Q760 -378 760 -404Q760 -430 743 -447Q726 -464 700 -464Q674 -464 657 -447Q640 -430 640 -404Q640 -378 657 -361Q674 -344 700 -344Z"), + ("password", "M120 -184H840Q857 -184 868.5 -172.5Q880 -161 880 -144Q880 -127 868.5 -115.5Q857 -104 840 -104H120Q103 -104 91.5 -115.5Q80 -127 80 -144Q80 -161 91.5 -172.5Q103 -184 120 -184ZM160 -406 141 -372Q135 -361 123 -358Q111 -355 100 -361Q89 -367 86 -379Q83 -391 89 -402L108 -436H70Q57 -436 48.5 -444.5Q40 -453 40 -466Q40 -479 48.5 -487.5Q57 -496 70 -496H108L89 -528Q83 -539 86 -551Q89 -563 100 -569Q111 -575 123 -572Q135 -569 141 -558L160 -526L179 -558Q185 -569 197 -572Q209 -575 220 -569Q231 -563 234 -551Q237 -539 231 -528L212 -496H250Q263 -496 271.5 -487.5Q280 -479 280 -466Q280 -453 271.5 -444.5Q263 -436 250 -436H212L231 -402Q237 -391 234 -379Q231 -367 220 -361Q209 -355 197 -358Q185 -361 179 -372ZM480 -406 461 -372Q455 -361 443 -358Q431 -355 420 -361Q409 -367 406 -379Q403 -391 409 -402L428 -436H390Q377 -436 368.5 -444.5Q360 -453 360 -466Q360 -479 368.5 -487.5Q377 -496 390 -496H428L409 -528Q403 -539 406 -551Q409 -563 420 -569Q431 -575 443 -572Q455 -569 461 -558L480 -526L499 -558Q505 -569 517 -572Q529 -575 540 -569Q551 -563 554 -551Q557 -539 551 -528L532 -496H570Q583 -496 591.5 -487.5Q600 -479 600 -466Q600 -453 591.5 -444.5Q583 -436 570 -436H532L551 -402Q557 -391 554 -379Q551 -367 540 -361Q529 -355 517 -358Q505 -361 499 -372ZM800 -406 781 -372Q775 -361 763 -358Q751 -355 740 -361Q729 -367 726 -379Q723 -391 729 -402L748 -436H710Q697 -436 688.5 -444.5Q680 -453 680 -466Q680 -479 688.5 -487.5Q697 -496 710 -496H748L729 -528Q723 -539 726 -551Q729 -563 740 -569Q751 -575 763 -572Q775 -569 781 -558L800 -526L819 -558Q825 -569 837 -572Q849 -575 860 -569Q871 -563 874 -551Q877 -539 871 -528L852 -496H890Q903 -496 911.5 -487.5Q920 -479 920 -466Q920 -453 911.5 -444.5Q903 -436 890 -436H852L871 -402Q877 -391 874 -379Q871 -367 860 -361Q849 -355 837 -358Q825 -361 819 -372Z"), + ("pause", "M600 -104Q567 -104 543.5 -127.5Q520 -151 520 -184V-584Q520 -617 543.5 -640.5Q567 -664 600 -664H680Q713 -664 736.5 -640.5Q760 -617 760 -584V-184Q760 -151 736.5 -127.5Q713 -104 680 -104ZM280 -104Q247 -104 223.5 -127.5Q200 -151 200 -184V-584Q200 -617 223.5 -640.5Q247 -664 280 -664H360Q393 -664 416.5 -640.5Q440 -617 440 -584V-184Q440 -151 416.5 -127.5Q393 -104 360 -104ZM600 -184H680V-584H600ZM280 -184H360V-584H280ZM280 -584V-184ZM600 -584V-184Z"), + ("pause_fill", "M640 -104Q607 -104 583.5 -127.5Q560 -151 560 -184V-584Q560 -617 583.5 -640.5Q607 -664 640 -664Q673 -664 696.5 -640.5Q720 -617 720 -584V-184Q720 -151 696.5 -127.5Q673 -104 640 -104ZM320 -104Q287 -104 263.5 -127.5Q240 -151 240 -184V-584Q240 -617 263.5 -640.5Q287 -664 320 -664Q353 -664 376.5 -640.5Q400 -617 400 -584V-184Q400 -151 376.5 -127.5Q353 -104 320 -104Z"), + ("person", "M480 -384Q414 -384 367 -431Q320 -478 320 -544Q320 -610 367 -657Q414 -704 480 -704Q546 -704 593 -657Q640 -610 640 -544Q640 -478 593 -431Q546 -384 480 -384ZM160 -144V-176Q160 -210 177.5 -238.5Q195 -267 224 -282Q286 -313 350 -328.5Q414 -344 480 -344Q546 -344 610 -328.5Q674 -313 736 -282Q765 -267 782.5 -238.5Q800 -210 800 -176V-144Q800 -111 776.5 -87.5Q753 -64 720 -64H240Q207 -64 183.5 -87.5Q160 -111 160 -144ZM240 -144H720V-176Q720 -187 714.5 -196Q709 -205 700 -210Q646 -237 591 -250.5Q536 -264 480 -264Q424 -264 369 -250.5Q314 -237 260 -210Q251 -205 245.5 -196Q240 -187 240 -176ZM480 -464Q513 -464 536.5 -487.5Q560 -511 560 -544Q560 -577 536.5 -600.5Q513 -624 480 -624Q447 -624 423.5 -600.5Q400 -577 400 -544Q400 -511 423.5 -487.5Q447 -464 480 -464ZM480 -544Q480 -544 480 -544Q480 -544 480 -544Q480 -544 480 -544Q480 -544 480 -544Q480 -544 480 -544Q480 -544 480 -544Q480 -544 480 -544Q480 -544 480 -544ZM480 -144Q480 -144 480 -144Q480 -144 480 -144Q480 -144 480 -144Q480 -144 480 -144Q480 -144 480 -144Q480 -144 480 -144Q480 -144 480 -144Q480 -144 480 -144Z"), + ("person_fill", "M480 -384Q414 -384 367 -431Q320 -478 320 -544Q320 -610 367 -657Q414 -704 480 -704Q546 -704 593 -657Q640 -610 640 -544Q640 -478 593 -431Q546 -384 480 -384ZM160 -144V-176Q160 -210 177.5 -238.5Q195 -267 224 -282Q286 -313 350 -328.5Q414 -344 480 -344Q546 -344 610 -328.5Q674 -313 736 -282Q765 -267 782.5 -238.5Q800 -210 800 -176V-144Q800 -111 776.5 -87.5Q753 -64 720 -64H240Q207 -64 183.5 -87.5Q160 -111 160 -144Z"), + ("pip", "M120 -424Q103 -424 91.5 -435.5Q80 -447 80 -464Q80 -481 91.5 -492.5Q103 -504 120 -504H224L80 -647Q68 -659 68 -675.5Q68 -692 80 -704Q92 -716 108.5 -716Q125 -716 137 -704L280 -560V-664Q280 -681 291.5 -692.5Q303 -704 320 -704Q337 -704 348.5 -692.5Q360 -681 360 -664V-464Q360 -447 348.5 -435.5Q337 -424 320 -424ZM160 -64Q127 -64 103.5 -87.5Q80 -111 80 -144V-304Q80 -321 91.5 -332.5Q103 -344 120 -344Q137 -344 148.5 -332.5Q160 -321 160 -304V-144Q160 -144 160 -144Q160 -144 160 -144H440Q457 -144 468.5 -132.5Q480 -121 480 -104Q480 -87 468.5 -75.5Q457 -64 440 -64ZM840 -344Q823 -344 811.5 -355.5Q800 -367 800 -384V-624Q800 -624 800 -624Q800 -624 800 -624H480Q463 -624 451.5 -635.5Q440 -647 440 -664Q440 -681 451.5 -692.5Q463 -704 480 -704H800Q833 -704 856.5 -680.5Q880 -657 880 -624V-384Q880 -367 868.5 -355.5Q857 -344 840 -344ZM600 -64Q583 -64 571.5 -75.5Q560 -87 560 -104V-224Q560 -241 571.5 -252.5Q583 -264 600 -264H840Q857 -264 868.5 -252.5Q880 -241 880 -224V-104Q880 -87 868.5 -75.5Q857 -64 840 -64Z"), + ("play_arrow", "M320 -177V-591Q320 -608 332 -619.5Q344 -631 360 -631Q365 -631 370.5 -629.5Q376 -628 381 -625L707 -418Q716 -412 720.5 -403Q725 -394 725 -384Q725 -374 720.5 -365Q716 -356 707 -350L381 -143Q376 -140 370.5 -138.5Q365 -137 360 -137Q344 -137 332 -148.5Q320 -160 320 -177ZM400 -384ZM400 -250 610 -384 400 -518Z"), + ("play_arrow_fill", "M320 -177V-591Q320 -608 332 -619.5Q344 -631 360 -631Q365 -631 370.5 -629.5Q376 -628 381 -625L707 -418Q716 -412 720.5 -403Q725 -394 725 -384Q725 -374 720.5 -365Q716 -356 707 -350L381 -143Q376 -140 370.5 -138.5Q365 -137 360 -137Q344 -137 332 -148.5Q320 -160 320 -177Z"), + ("play_circle", "M426 -234 621 -359Q635 -368 635 -384Q635 -400 621 -409L426 -534Q411 -544 395.5 -535.5Q380 -527 380 -509V-259Q380 -241 395.5 -232.5Q411 -224 426 -234ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16ZM480 -64Q614 -64 707 -157Q800 -250 800 -384Q800 -518 707 -611Q614 -704 480 -704Q346 -704 253 -611Q160 -518 160 -384Q160 -250 253 -157Q346 -64 480 -64ZM480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Z"), + ("play_circle_fill", "M426 -234 621 -359Q635 -368 635 -384Q635 -400 621 -409L426 -534Q411 -544 395.5 -535.5Q380 -527 380 -509V-259Q380 -241 395.5 -232.5Q411 -224 426 -234ZM480 16Q397 16 324 -15.5Q251 -47 197 -101Q143 -155 111.5 -228Q80 -301 80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q563 -784 636 -752.5Q709 -721 763 -667Q817 -613 848.5 -540Q880 -467 880 -384Q880 -301 848.5 -228Q817 -155 763 -101Q709 -47 636 -15.5Q563 16 480 16Z"), + ("playlist_add", "M150-330q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h240q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h410q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h410q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm508.5 491.37Q650-177.25 650-190v-140H510q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h140v-140q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v140h140q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H710v140q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63Z"), + ("playlist_play", "M150-330q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h246q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h413q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-165q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h413q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm536 522q-4 3-8 3.5t-8-1.5q-4-2-6-5.6-2-3.6-2-8.4v-262q0-4.8 2-8.4 2-3.6 6-5.6 4-2 8-1.5t8 3.5l178 131q3.33 2 4.67 5 1.33 3 1.33 7t-1.33 7q-1.34 3-4.67 5L686-138Z"), + ("podcasts", "M450-110v-296q-22-9-36-29t-14-45q0-33 23.5-56.5T480-560q33 0 56.5 23.5T560-480q0 25-14 45t-36 29v296q0 13-8.5 21.5T480-80q-13 0-21.5-8.5T450-110ZM226-212q-9 9-22.5 9T182-213q-48-54-75-121.5T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 78-27 145.5T778-213q-8 10-21.5 10.5T734-211q-9-9-8-22t10-23q40-45 62-102t22-122q0-142-99-241t-241-99q-142 0-241 99t-99 241q0 65 22 122t62 102q9 10 10 22.5t-8 21.5Zm113-113q-9 9-22 9t-21-10q-26-32-41-70.5T240-480q0-100 70-170t170-70q100 0 170 70t70 170q0 45-15 83.5T664-326q-8 10-20.5 10.5T622-324q-9-9-9-22t8-23q18-23 28.5-51t10.5-60q0-75-52.5-127.5T480-660q-75 0-127.5 52.5T300-480q0 32 10.5 60t28.5 51q8 10 8.5 22.5T339-325Z"), + ("priority_high", "M480 -24Q447 -24 423.5 -47.5Q400 -71 400 -104Q400 -137 423.5 -160.5Q447 -184 480 -184Q513 -184 536.5 -160.5Q560 -137 560 -104Q560 -71 536.5 -47.5Q513 -24 480 -24ZM480 -264Q447 -264 423.5 -287.5Q400 -311 400 -344V-664Q400 -697 423.5 -720.5Q447 -744 480 -744Q513 -744 536.5 -720.5Q560 -697 560 -664V-344Q560 -311 536.5 -287.5Q513 -264 480 -264Z"), + ("queue_music", "M642.94-160q-47.94 0-81.44-33.56t-33.5-81.5q0-47.94 32.67-81.44Q593.33-390 640-390q15.97 0 30.48 3Q685-384 698-377v-308q0-14.88 10.35-24.94T734-720h111q14.88 0 24.94 10.29t10.06 25.5Q880-669 869.94-659T845-649h-87v375q0 47.5-33.56 80.75T642.94-160ZM150-320q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h246q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-170q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h413q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-170q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h413q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Z"), + ("queue_play_next", "M868-230 768-330q-10-9.96-10-22.98t9.97-23.02q9.96-10 23-10Q804-386 814-376l126 125q9 9 9 21t-9 21L814-83q-9.96 10-22.98 10T768-83.18q-10-10.19-10-23.5Q758-120 768-130l100-100ZM360-120q-12.75 0-21.37-8.63Q330-137.25 330-150v-50H140q-24 0-42-18t-18-42v-520q0-24 18-42t42-18h680q24 0 42 18t18 42v267q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63-8.5-8.62-8.5-21.37v-267H140v520h516q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5h-26v50q0 12.75-8.62 21.37Q612.75-120 600-120H360Zm89-379v100q0 12.75 8.68 21.37 8.67 8.63 21.5 8.63 12.82 0 21.32-8.63 8.5-8.62 8.5-21.37v-100h100q12.75 0 21.38-8.68 8.62-8.67 8.62-21.5 0-12.82-8.62-21.32-8.63-8.5-21.38-8.5H509v-100q0-12.75-8.68-21.38-8.67-8.62-21.5-8.62-12.82 0-21.32 8.62-8.5 8.63-8.5 21.38v100H349q-12.75 0-21.37 8.68-8.63 8.67-8.63 21.5 0 12.82 8.63 21.32 8.62 8.5 21.37 8.5h100ZM140-260v-520 520Z"), + ("radio", "M140-80q-24 0-42-18t-18-42v-511q0-22 15-38.5t35-24.5l471-190q10.59-5 20.79-.5Q632-900 636-889t-.18 21.12Q631.64-857.75 621-854L286-720h534q24 0 42 18t18 42v520q0 24-18 42t-42 18H140Zm0-60h680v-310H140v310Zm248-91.18q28-28.19 28-69Q416-341 387.82-369q-28.19-28-69-28Q278-397 250-368.82q-28 28.19-28 69Q222-259 250.18-231q28.19 28 69 28Q360-203 388-231.18ZM140-510h520v-30.18q0-12.82 8.68-21.32 8.67-8.5 21.5-8.5 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v30h100v-150H140v150Zm0 370v-310 310Z"), + ("redo", "M686-584H391q-70 0-120.5 46.5T220-422q0 69 50.5 115.5T391-260h280q13 0 21.5 8.5T701-230q0 13-8.5 21.5T671-200H392q-95 0-163.5-64T160-422q0-94 68.5-158T392-644h294l-93-93q-9-9-9-21t9-21q9-9 21-9t21 9l144 144q5 5 7 10t2 11q0 6-2 11t-7 10L635-449q-9 9-21 9t-21-9q-9-9-9-21t9-21l93-93Z"), + ("refresh", "M480 -64Q346 -64 253 -157Q160 -250 160 -384Q160 -518 253 -611Q346 -704 480 -704Q549 -704 612 -675.5Q675 -647 720 -594V-664Q720 -681 731.5 -692.5Q743 -704 760 -704Q777 -704 788.5 -692.5Q800 -681 800 -664V-464Q800 -447 788.5 -435.5Q777 -424 760 -424H560Q543 -424 531.5 -435.5Q520 -447 520 -464Q520 -481 531.5 -492.5Q543 -504 560 -504H688Q656 -560 600.5 -592Q545 -624 480 -624Q380 -624 310 -554Q240 -484 240 -384Q240 -284 310 -214Q380 -144 480 -144Q548 -144 604.5 -178.5Q661 -213 692 -271Q700 -285 714.5 -290.5Q729 -296 744 -291Q760 -286 767 -270Q774 -254 766 -240Q725 -160 649 -112Q573 -64 480 -64Z"), + ("remove", "M240 -344Q223 -344 211.5 -355.5Q200 -367 200 -384Q200 -401 211.5 -412.5Q223 -424 240 -424H720Q737 -424 748.5 -412.5Q760 -401 760 -384Q760 -367 748.5 -355.5Q737 -344 720 -344Z"), + ("repeat", "M274 -104 308 -70Q320 -58 319.5 -42Q319 -26 308 -14Q296 -2 279.5 -1.5Q263 -1 251 -13L148 -116Q142 -122 139.5 -129Q137 -136 137 -144Q137 -152 139.5 -159Q142 -166 148 -172L251 -275Q263 -287 279.5 -286.5Q296 -286 308 -274Q319 -262 319.5 -246Q320 -230 308 -218L274 -184H680Q680 -184 680 -184Q680 -184 680 -184V-304Q680 -321 691.5 -332.5Q703 -344 720 -344Q737 -344 748.5 -332.5Q760 -321 760 -304V-184Q760 -151 736.5 -127.5Q713 -104 680 -104ZM686 -584H280Q280 -584 280 -584Q280 -584 280 -584V-464Q280 -447 268.5 -435.5Q257 -424 240 -424Q223 -424 211.5 -435.5Q200 -447 200 -464V-584Q200 -617 223.5 -640.5Q247 -664 280 -664H686L652 -698Q640 -710 640.5 -726Q641 -742 652 -754Q664 -766 680.5 -766.5Q697 -767 709 -755L812 -652Q818 -646 820.5 -639Q823 -632 823 -624Q823 -616 820.5 -609Q818 -602 812 -596L709 -493Q697 -481 680.5 -481.5Q664 -482 652 -494Q641 -506 640.5 -522Q640 -538 652 -550Z"), + ("repeat_one", "M460 -444H430Q417 -444 408.5 -452.5Q400 -461 400 -474Q400 -487 408.5 -495.5Q417 -504 430 -504H480Q497 -504 508.5 -492.5Q520 -481 520 -464V-294Q520 -281 511.5 -272.5Q503 -264 490 -264Q477 -264 468.5 -272.5Q460 -281 460 -294ZM274 -104 308 -70Q320 -58 319.5 -42Q319 -26 308 -14Q296 -2 279.5 -1.5Q263 -1 251 -13L148 -116Q142 -122 139.5 -129Q137 -136 137 -144Q137 -152 139.5 -159Q142 -166 148 -172L251 -275Q263 -287 279.5 -286.5Q296 -286 308 -274Q319 -262 319.5 -246Q320 -230 308 -218L274 -184H680Q680 -184 680 -184Q680 -184 680 -184V-304Q680 -321 691.5 -332.5Q703 -344 720 -344Q737 -344 748.5 -332.5Q760 -321 760 -304V-184Q760 -151 736.5 -127.5Q713 -104 680 -104ZM686 -584H280Q280 -584 280 -584Q280 -584 280 -584V-464Q280 -447 268.5 -435.5Q257 -424 240 -424Q223 -424 211.5 -435.5Q200 -447 200 -464V-584Q200 -617 223.5 -640.5Q247 -664 280 -664H686L652 -698Q640 -710 640.5 -726Q641 -742 652 -754Q664 -766 680.5 -766.5Q697 -767 709 -755L812 -652Q818 -646 820.5 -639Q823 -632 823 -624Q823 -616 820.5 -609Q818 -602 812 -596L709 -493Q697 -481 680.5 -481.5Q664 -482 652 -494Q641 -506 640.5 -522Q640 -538 652 -550Z"), + ("restart_alt", "M393 -36Q290 -65 225 -149.5Q160 -234 160 -344Q160 -401 179 -452.5Q198 -504 233 -547Q244 -559 260 -559.5Q276 -560 289 -547Q300 -536 300.5 -520Q301 -504 290 -490Q266 -459 253 -422Q240 -385 240 -344Q240 -263 287.5 -199.5Q335 -136 410 -113Q423 -109 431.5 -98Q440 -87 440 -74Q440 -54 426 -42.5Q412 -31 393 -36ZM567 -36Q548 -31 534 -43Q520 -55 520 -75Q520 -87 528.5 -98Q537 -109 550 -113Q625 -137 672.5 -200Q720 -263 720 -344Q720 -444 650 -514Q580 -584 480 -584H477L493 -568Q504 -557 504 -540Q504 -523 493 -512Q482 -501 465 -501Q448 -501 437 -512L353 -596Q347 -602 344.5 -609Q342 -616 342 -624Q342 -632 344.5 -639Q347 -646 353 -652L437 -736Q448 -747 465 -747Q482 -747 493 -736Q504 -725 504 -708Q504 -691 493 -680L477 -664H480Q614 -664 707 -571Q800 -478 800 -344Q800 -235 735 -150Q670 -65 567 -36Z"), + ("save", "M180-120q-24 0-42-18t-18-42v-600q0-24 18-42t42-18h478q12.44 0 23.72 5T701-822l121 121q8 8 13 19.28 5 11.28 5 23.72v478q0 24-18 42t-42 18H180Zm600-536L656-780H180v600h600v-476ZM553.5-275.26q30.5-30.27 30.5-73.5 0-43.24-30.26-73.74-30.27-30.5-73.5-30.5-43.24 0-73.74 30.26-30.5 30.27-30.5 73.5 0 43.24 30.26 73.74 30.27 30.5 73.5 30.5 43.24 0 73.74-30.26ZM263-584h298q12.75 0 21.38-8.63Q591-601.25 591-614v-83q0-12.75-8.62-21.38Q573.75-727 561-727H263q-12.75 0-21.37 8.62Q233-709.75 233-697v83q0 12.75 8.63 21.37Q250.25-584 263-584Zm-83-72v476-600 124Z"), + ("score", "M200 -24Q167 -24 143.5 -47.5Q120 -71 120 -104V-664Q120 -697 143.5 -720.5Q167 -744 200 -744H760Q793 -744 816.5 -720.5Q840 -697 840 -664V-104Q840 -71 816.5 -47.5Q793 -24 760 -24ZM520 -204 760 -444V-664Q760 -664 760 -664Q760 -664 760 -664H200Q200 -664 200 -664Q200 -664 200 -664V-204L332 -336Q344 -348 360 -348Q376 -348 388 -336ZM510 -384Q497 -384 488.5 -392.5Q480 -401 480 -414V-594Q480 -607 488.5 -615.5Q497 -624 510 -624Q523 -624 531.5 -615.5Q540 -607 540 -594V-414Q540 -401 531.5 -392.5Q523 -384 510 -384ZM608 -504 659 -428Q668 -414 660 -399Q652 -384 635 -384Q628 -384 622 -387.5Q616 -391 612 -397L540 -504L612 -611Q616 -617 622 -620.5Q628 -624 635 -624Q652 -624 660.5 -609Q669 -594 659 -580ZM340 -444H410Q423 -444 431.5 -435.5Q440 -427 440 -414Q440 -401 431.5 -392.5Q423 -384 410 -384H310Q297 -384 288.5 -392.5Q280 -401 280 -414V-504Q280 -517 288.5 -525.5Q297 -534 310 -534H380V-564H310Q297 -564 288.5 -572.5Q280 -581 280 -594Q280 -607 288.5 -615.5Q297 -624 310 -624H410Q423 -624 431.5 -615.5Q440 -607 440 -594V-504Q440 -491 431.5 -482.5Q423 -474 410 -474H340ZM360 -264 200 -104Q200 -104 200 -104Q200 -104 200 -104H760Q760 -104 760 -104Q760 -104 760 -104V-344L548 -132Q536 -120 520 -120Q504 -120 492 -132ZM200 -104Q200 -104 200 -104Q200 -104 200 -104Q200 -104 200 -104Q200 -104 200 -104V-664Q200 -664 200 -664Q200 -664 200 -664Q200 -664 200 -664Q200 -664 200 -664Z"), + ("score_fill", "M200 -24Q167 -24 143.5 -47.5Q120 -71 120 -104V-664Q120 -697 143.5 -720.5Q167 -744 200 -744H760Q793 -744 816.5 -720.5Q840 -697 840 -664V-104Q840 -71 816.5 -47.5Q793 -24 760 -24ZM760 -344V-444L520 -204L388 -336Q376 -348 360 -348Q344 -348 332 -336L200 -204V-104L360 -264L492 -132Q504 -120 520 -120Q536 -120 548 -132ZM510 -384Q523 -384 531.5 -392.5Q540 -401 540 -414V-594Q540 -607 531.5 -615.5Q523 -624 510 -624Q497 -624 488.5 -615.5Q480 -607 480 -594V-414Q480 -401 488.5 -392.5Q497 -384 510 -384ZM608 -504 659 -580Q669 -594 660.5 -609Q652 -624 635 -624Q628 -624 622 -620.5Q616 -617 612 -611L540 -504L612 -397Q616 -391 622 -387.5Q628 -384 635 -384Q652 -384 660 -399Q668 -414 659 -428ZM340 -444V-474H410Q423 -474 431.5 -482.5Q440 -491 440 -504V-594Q440 -607 431.5 -615.5Q423 -624 410 -624H310Q297 -624 288.5 -615.5Q280 -607 280 -594Q280 -581 288.5 -572.5Q297 -564 310 -564H380V-534H310Q297 -534 288.5 -525.5Q280 -517 280 -504V-414Q280 -401 288.5 -392.5Q297 -384 310 -384H410Q423 -384 431.5 -392.5Q440 -401 440 -414Q440 -427 431.5 -435.5Q423 -444 410 -444Z"), + ("scrobble", "m450-478-62 62q-9 9-21.1 9-12.1 0-20.9-9-9-9-9-21.5t9-21.5l113-114q9-9 21-9t21 9l114 114q9 9 9 21t-9 21q-9 9-21.5 9t-21.5-9l-62-61v258h241q45 0 77-32t32-77q0-45-32-77t-77-32h-63v-84q0-89-60.5-153T478-739q-89 0-150 64t-61 153h-19q-62 0-105 43.5T100-371q0 62 43.93 106.5T250-220h110q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H250q-86 0-148-62T40-370q0-78 49.5-137.5T217-579q20-97 94-158.5T482-799q113 0 189.5 81.5T748-522v24q72-2 122 46.5T920-329q0 69-50 119t-119 50H510q-24 0-42-18t-18-42v-258Zm30 28Z"), + ("search", "M380 -224Q271 -224 195.5 -299.5Q120 -375 120 -484Q120 -593 195.5 -668.5Q271 -744 380 -744Q489 -744 564.5 -668.5Q640 -593 640 -484Q640 -440 626 -401Q612 -362 588 -332L812 -108Q823 -97 823 -80Q823 -63 812 -52Q801 -41 784 -41Q767 -41 756 -52L532 -276Q502 -252 463 -238Q424 -224 380 -224ZM380 -304Q455 -304 507.5 -356.5Q560 -409 560 -484Q560 -559 507.5 -611.5Q455 -664 380 -664Q305 -664 252.5 -611.5Q200 -559 200 -484Q200 -409 252.5 -356.5Q305 -304 380 -304Z"), + ("select_all", "M160 -664Q143 -664 131.5 -675.5Q120 -687 120 -704Q120 -721 131.5 -732.5Q143 -744 160 -744Q177 -744 188.5 -732.5Q200 -721 200 -704Q200 -687 188.5 -675.5Q177 -664 160 -664ZM320 -664Q303 -664 291.5 -675.5Q280 -687 280 -704Q280 -721 291.5 -732.5Q303 -744 320 -744Q337 -744 348.5 -732.5Q360 -721 360 -704Q360 -687 348.5 -675.5Q337 -664 320 -664ZM480 -664Q463 -664 451.5 -675.5Q440 -687 440 -704Q440 -721 451.5 -732.5Q463 -744 480 -744Q497 -744 508.5 -732.5Q520 -721 520 -704Q520 -687 508.5 -675.5Q497 -664 480 -664ZM640 -664Q623 -664 611.5 -675.5Q600 -687 600 -704Q600 -721 611.5 -732.5Q623 -744 640 -744Q657 -744 668.5 -732.5Q680 -721 680 -704Q680 -687 668.5 -675.5Q657 -664 640 -664ZM800 -664Q783 -664 771.5 -675.5Q760 -687 760 -704Q760 -721 771.5 -732.5Q783 -744 800 -744Q817 -744 828.5 -732.5Q840 -721 840 -704Q840 -687 828.5 -675.5Q817 -664 800 -664ZM160 -504Q143 -504 131.5 -515.5Q120 -527 120 -544Q120 -561 131.5 -572.5Q143 -584 160 -584Q177 -584 188.5 -572.5Q200 -561 200 -544Q200 -527 188.5 -515.5Q177 -504 160 -504ZM800 -504Q783 -504 771.5 -515.5Q760 -527 760 -544Q760 -561 771.5 -572.5Q783 -584 800 -584Q817 -584 828.5 -572.5Q840 -561 840 -544Q840 -527 828.5 -515.5Q817 -504 800 -504ZM160 -344Q143 -344 131.5 -355.5Q120 -367 120 -384Q120 -401 131.5 -412.5Q143 -424 160 -424Q177 -424 188.5 -412.5Q200 -401 200 -384Q200 -367 188.5 -355.5Q177 -344 160 -344ZM800 -344Q783 -344 771.5 -355.5Q760 -367 760 -384Q760 -401 771.5 -412.5Q783 -424 800 -424Q817 -424 828.5 -412.5Q840 -401 840 -384Q840 -367 828.5 -355.5Q817 -344 800 -344ZM160 -184Q143 -184 131.5 -195.5Q120 -207 120 -224Q120 -241 131.5 -252.5Q143 -264 160 -264Q177 -264 188.5 -252.5Q200 -241 200 -224Q200 -207 188.5 -195.5Q177 -184 160 -184ZM800 -184Q783 -184 771.5 -195.5Q760 -207 760 -224Q760 -241 771.5 -252.5Q783 -264 800 -264Q817 -264 828.5 -252.5Q840 -241 840 -224Q840 -207 828.5 -195.5Q817 -184 800 -184ZM160 -24Q143 -24 131.5 -35.5Q120 -47 120 -64Q120 -81 131.5 -92.5Q143 -104 160 -104Q177 -104 188.5 -92.5Q200 -81 200 -64Q200 -47 188.5 -35.5Q177 -24 160 -24ZM320 -24Q303 -24 291.5 -35.5Q280 -47 280 -64Q280 -81 291.5 -92.5Q303 -104 320 -104Q337 -104 348.5 -92.5Q360 -81 360 -64Q360 -47 348.5 -35.5Q337 -24 320 -24ZM480 -24Q463 -24 451.5 -35.5Q440 -47 440 -64Q440 -81 451.5 -92.5Q463 -104 480 -104Q497 -104 508.5 -92.5Q520 -81 520 -64Q520 -47 508.5 -35.5Q497 -24 480 -24ZM640 -24Q623 -24 611.5 -35.5Q600 -47 600 -64Q600 -81 611.5 -92.5Q623 -104 640 -104Q657 -104 668.5 -92.5Q680 -81 680 -64Q680 -47 668.5 -35.5Q657 -24 640 -24ZM800 -24Q783 -24 771.5 -35.5Q760 -47 760 -64Q760 -81 771.5 -92.5Q783 -104 800 -104Q817 -104 828.5 -92.5Q840 -81 840 -64Q840 -47 828.5 -35.5Q817 -24 800 -24ZM360 -184Q327 -184 303.5 -207.5Q280 -231 280 -264V-504Q280 -537 303.5 -560.5Q327 -584 360 -584H600Q633 -584 656.5 -560.5Q680 -537 680 -504V-264Q680 -231 656.5 -207.5Q633 -184 600 -184ZM360 -264H600Q600 -264 600 -264Q600 -264 600 -264V-504Q600 -504 600 -504Q600 -504 600 -504H360Q360 -504 360 -504Q360 -504 360 -504V-264Q360 -264 360 -264Q360 -264 360 -264Z"), + ("sell", "M856 -294 570 -8Q558 4 543 10Q528 16 513 16Q498 16 483 10Q468 4 456 -8L103 -361Q92 -372 86 -386.5Q80 -401 80 -417V-704Q80 -737 103.5 -760.5Q127 -784 160 -784H447Q463 -784 478 -777.5Q493 -771 504 -760L856 -407Q868 -395 873.5 -380Q879 -365 879 -350Q879 -335 873.5 -320.5Q868 -306 856 -294ZM513 -64 799 -350Q799 -350 799 -350Q799 -350 799 -350L446 -704H160Q160 -704 160 -704Q160 -704 160 -704V-418Q160 -418 160 -418Q160 -418 160 -418L513 -64Q513 -64 513 -64Q513 -64 513 -64ZM260 -544Q285 -544 302.5 -561.5Q320 -579 320 -604Q320 -629 302.5 -646.5Q285 -664 260 -664Q235 -664 217.5 -646.5Q200 -629 200 -604Q200 -579 217.5 -561.5Q235 -544 260 -544ZM480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Z"), + ("sell_fill", "M856 -294 570 -8Q558 4 543 10Q528 16 513 16Q498 16 483 10Q468 4 456 -8L103 -361Q92 -372 86 -386.5Q80 -401 80 -417V-704Q80 -737 103.5 -760.5Q127 -784 160 -784H447Q463 -784 478 -777.5Q493 -771 504 -760L856 -407Q868 -395 873.5 -380Q879 -365 879 -350Q879 -335 873.5 -320.5Q868 -306 856 -294ZM260 -544Q285 -544 302.5 -561.5Q320 -579 320 -604Q320 -629 302.5 -646.5Q285 -664 260 -664Q235 -664 217.5 -646.5Q200 -629 200 -604Q200 -579 217.5 -561.5Q235 -544 260 -544Z"), + ("settings", "M433 16Q406 16 386.5 -2Q367 -20 363 -46L354 -112Q341 -117 329.5 -124Q318 -131 307 -139L245 -113Q220 -102 195 -111Q170 -120 156 -143L109 -225Q95 -248 101 -274Q107 -300 128 -317L181 -357Q180 -364 180 -370.5Q180 -377 180 -384Q180 -391 180 -397.5Q180 -404 181 -411L128 -451Q107 -468 101 -494Q95 -520 109 -543L156 -625Q170 -648 195 -657Q220 -666 245 -655L307 -629Q318 -637 330 -644Q342 -651 354 -656L363 -722Q367 -748 386.5 -766Q406 -784 433 -784H527Q554 -784 573.5 -766Q593 -748 597 -722L606 -656Q619 -651 630.5 -644Q642 -637 653 -629L715 -655Q740 -666 765 -657Q790 -648 804 -625L851 -543Q865 -520 859 -494Q853 -468 832 -451L779 -411Q780 -404 780 -397.5Q780 -391 780 -384Q780 -377 780 -370.5Q780 -364 778 -357L831 -317Q852 -300 858 -274Q864 -248 850 -225L802 -143Q788 -120 763 -111Q738 -102 713 -113L653 -139Q642 -131 630 -124Q618 -117 606 -112L597 -46Q593 -20 573.5 -2Q554 16 527 16ZM440 -64H519L533 -170Q564 -178 590.5 -193.5Q617 -209 639 -231L738 -190L777 -258L691 -323Q696 -337 698 -352.5Q700 -368 700 -384Q700 -400 698 -415.5Q696 -431 691 -445L777 -510L738 -578L639 -536Q617 -559 590.5 -574.5Q564 -590 533 -598L520 -704H441L427 -598Q396 -590 369.5 -574.5Q343 -559 321 -537L222 -578L183 -510L269 -446Q264 -431 262 -416Q260 -401 260 -384Q260 -368 262 -353Q264 -338 269 -323L183 -258L222 -190L321 -232Q343 -209 369.5 -193.5Q396 -178 427 -170ZM482 -244Q540 -244 581 -285Q622 -326 622 -384Q622 -442 581 -483Q540 -524 482 -524Q423 -524 382.5 -483Q342 -442 342 -384Q342 -326 382.5 -285Q423 -244 482 -244ZM480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Q480 -384 480 -384Z"), + ("settings_fill", "M433 16Q406 16 386.5 -2Q367 -20 363 -46L354 -112Q341 -117 329.5 -124Q318 -131 307 -139L245 -113Q220 -102 195 -111Q170 -120 156 -143L109 -225Q95 -248 101 -274Q107 -300 128 -317L181 -357Q180 -364 180 -370.5Q180 -377 180 -384Q180 -391 180 -397.5Q180 -404 181 -411L128 -451Q107 -468 101 -494Q95 -520 109 -543L156 -625Q170 -648 195 -657Q220 -666 245 -655L307 -629Q318 -637 330 -644Q342 -651 354 -656L363 -722Q367 -748 386.5 -766Q406 -784 433 -784H527Q554 -784 573.5 -766Q593 -748 597 -722L606 -656Q619 -651 630.5 -644Q642 -637 653 -629L715 -655Q740 -666 765 -657Q790 -648 804 -625L851 -543Q865 -520 859 -494Q853 -468 832 -451L779 -411Q780 -404 780 -397.5Q780 -391 780 -384Q780 -377 780 -370.5Q780 -364 778 -357L831 -317Q852 -300 858 -274Q864 -248 850 -225L802 -143Q788 -120 763 -111Q738 -102 713 -113L653 -139Q642 -131 630 -124Q618 -117 606 -112L597 -46Q593 -20 573.5 -2Q554 16 527 16ZM482 -244Q540 -244 581 -285Q622 -326 622 -384Q622 -442 581 -483Q540 -524 482 -524Q423 -524 382.5 -483Q342 -442 342 -384Q342 -326 382.5 -285Q423 -244 482 -244Z"), + ("shadow", "M160 16Q127 16 103.5 -7.5Q80 -31 80 -64V-544Q80 -577 103.5 -600.5Q127 -624 160 -624H240V-704Q240 -737 263.5 -760.5Q287 -784 320 -784H800Q833 -784 856.5 -760.5Q880 -737 880 -704V-224Q880 -191 856.5 -167.5Q833 -144 800 -144H720V-64Q720 -31 696.5 -7.5Q673 16 640 16ZM320 -224H800Q800 -224 800 -224Q800 -224 800 -224V-704Q800 -704 800 -704Q800 -704 800 -704H320Q320 -704 320 -704Q320 -704 320 -704V-224Q320 -224 320 -224Q320 -224 320 -224Z"), + ("shuffle", "M600 -64Q583 -64 571.5 -75.5Q560 -87 560 -104Q560 -121 571.5 -132.5Q583 -144 600 -144H664L565 -243Q553 -255 553.5 -271.5Q554 -288 566 -300Q578 -312 594.5 -312Q611 -312 623 -300L720 -202V-264Q720 -281 731.5 -292.5Q743 -304 760 -304Q777 -304 788.5 -292.5Q800 -281 800 -264V-104Q800 -87 788.5 -75.5Q777 -64 760 -64ZM172 -76Q161 -87 161 -104Q161 -121 172 -132L664 -624H600Q583 -624 571.5 -635.5Q560 -647 560 -664Q560 -681 571.5 -692.5Q583 -704 600 -704H760Q777 -704 788.5 -692.5Q800 -681 800 -664V-504Q800 -487 788.5 -475.5Q777 -464 760 -464Q743 -464 731.5 -475.5Q720 -487 720 -504V-568L228 -76Q217 -65 200 -65Q183 -65 172 -76ZM171 -636Q160 -647 160 -664Q160 -681 171 -692Q182 -703 198.5 -703Q215 -703 227 -692L395 -525Q406 -514 406.5 -497.5Q407 -481 395 -469Q384 -458 367 -458Q350 -458 339 -469Z"), + ("skip_next", "M660 -184V-584Q660 -601 671.5 -612.5Q683 -624 700 -624Q717 -624 728.5 -612.5Q740 -601 740 -584V-184Q740 -167 728.5 -155.5Q717 -144 700 -144Q683 -144 671.5 -155.5Q660 -167 660 -184ZM220 -219V-549Q220 -567 232 -578Q244 -589 260 -589Q265 -589 271 -588Q277 -587 282 -583L530 -417Q539 -411 543.5 -402.5Q548 -394 548 -384Q548 -374 543.5 -365.5Q539 -357 530 -351L282 -185Q277 -181 271 -180Q265 -179 260 -179Q244 -179 232 -190Q220 -201 220 -219ZM300 -384ZM300 -294 436 -384 300 -474Z"), + ("skip_next_fill", "M660 -184V-584Q660 -601 671.5 -612.5Q683 -624 700 -624Q717 -624 728.5 -612.5Q740 -601 740 -584V-184Q740 -167 728.5 -155.5Q717 -144 700 -144Q683 -144 671.5 -155.5Q660 -167 660 -184ZM220 -219V-549Q220 -567 232 -578Q244 -589 260 -589Q265 -589 271 -588Q277 -587 282 -583L530 -417Q539 -411 543.5 -402.5Q548 -394 548 -384Q548 -374 543.5 -365.5Q539 -357 530 -351L282 -185Q277 -181 271 -180Q265 -179 260 -179Q244 -179 232 -190Q220 -201 220 -219Z"), + ("skip_previous", "M220 -184V-584Q220 -601 231.5 -612.5Q243 -624 260 -624Q277 -624 288.5 -612.5Q300 -601 300 -584V-184Q300 -167 288.5 -155.5Q277 -144 260 -144Q243 -144 231.5 -155.5Q220 -167 220 -184ZM678 -185 430 -351Q421 -357 416.5 -365.5Q412 -374 412 -384Q412 -394 416.5 -402.5Q421 -411 430 -417L678 -583Q683 -587 689 -588Q695 -589 700 -589Q716 -589 728 -578Q740 -567 740 -549V-219Q740 -201 728 -190Q716 -179 700 -179Q695 -179 689 -180Q683 -181 678 -185ZM660 -384ZM660 -294V-474L524 -384Z"), + ("skip_previous_fill", "M220 -184V-584Q220 -601 231.5 -612.5Q243 -624 260 -624Q277 -624 288.5 -612.5Q300 -601 300 -584V-184Q300 -167 288.5 -155.5Q277 -144 260 -144Q243 -144 231.5 -155.5Q220 -167 220 -184ZM678 -185 430 -351Q421 -357 416.5 -365.5Q412 -374 412 -384Q412 -394 416.5 -402.5Q421 -411 430 -417L678 -583Q683 -587 689 -588Q695 -589 700 -589Q716 -589 728 -578Q740 -567 740 -549V-219Q740 -201 728 -190Q716 -179 700 -179Q695 -179 689 -180Q683 -181 678 -185Z"), + ("sort", "M150-240q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h180q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-210q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h420q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm0-210q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h660q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Z"), + ("speed", "M418 -244Q442 -220 480 -220.5Q518 -221 536 -248L705 -501Q714 -515 702.5 -526.5Q691 -538 677 -529L424 -360Q397 -342 395.5 -305Q394 -268 418 -244ZM480 -704Q516 -704 551 -698Q586 -692 619 -679Q635 -673 653 -656.5Q671 -640 663 -625Q655 -610 627 -605Q599 -600 582 -606Q557 -615 531.5 -619.5Q506 -624 480 -624Q347 -624 253.5 -530.5Q160 -437 160 -304Q160 -262 171.5 -221Q183 -180 204 -144H756Q779 -182 789.5 -223Q800 -264 800 -308Q800 -334 795.5 -359Q791 -384 782 -408Q776 -425 780 -441Q784 -457 798 -468Q811 -478 826.5 -474Q842 -470 848 -456Q863 -421 871 -384.5Q879 -348 880 -310Q881 -253 867 -201Q853 -149 826 -102Q815 -84 796 -74Q777 -64 756 -64H204Q183 -64 164 -74Q145 -84 134 -102Q108 -147 94 -197.5Q80 -248 80 -304Q80 -387 111.5 -459.5Q143 -532 197.5 -586.5Q252 -641 325 -672.5Q398 -704 480 -704ZM487 -391Q487 -391 487 -391Q487 -391 487 -391Q487 -391 487 -391Q487 -391 487 -391Q487 -391 487 -391Q487 -391 487 -391Q487 -391 487 -391Q487 -391 487 -391Q487 -391 487 -391Q487 -391 487 -391Z"), + ("speed_fill", "M418 -244Q443 -219 481 -220.5Q519 -222 536 -248L705 -501Q714 -515 702.5 -526.5Q691 -538 677 -529L424 -360Q398 -342 395.5 -305.5Q393 -269 418 -244ZM204 -64Q182 -64 163.5 -73.5Q145 -83 134 -102Q108 -149 94 -199.5Q80 -250 80 -304Q80 -387 111.5 -460Q143 -533 197 -587Q251 -641 324 -672.5Q397 -704 480 -704Q562 -704 634 -673Q706 -642 760 -588.5Q814 -535 846 -463.5Q878 -392 879 -310Q880 -255 866.5 -202.5Q853 -150 825 -102Q814 -83 795.5 -73.5Q777 -64 755 -64Z"), + ("star", "m323-245 157-94 157 95-42-178 138-120-182-16-71-168-71 167-182 16 138 120-42 178Zm157-24L294-157q-8 5-17 4.5t-16-5.5q-7-5-10.5-13t-1.5-18l49-212-164-143q-8-7-9.5-15.5t.5-16.5q2-8 9-13.5t17-6.5l217-19 84-200q4-9 12-13.5t16-4.5q8 0 16 4.5t12 13.5l84 200 217 19q10 1 17 6.5t9 13.5q2 8 .5 16.5T826-544L662-401l49 212q2 10-1.5 18T699-158q-7 5-16 5.5t-17-4.5L480-269Zm0-206Z"), + ("star_fill", "M480-269 294-157q-8 5-17 4.5t-16-5.5q-7-5-10.5-13t-1.5-18l49-212-164-143q-8-7-9.5-15.5t.5-16.5q2-8 9-13.5t17-6.5l217-19 84-200q4-9 12-13.5t16-4.5q8 0 16 4.5t12 13.5l84 200 217 19q10 1 17 6.5t9 13.5q2 8 .5 16.5T826-544L662-401l49 212q2 10-1.5 18T699-158q-7 5-16 5.5t-17-4.5L480-269Z"), + ("stop_circle", "M360-330h240q12.75 0 21.38-8.63Q630-347.25 630-360v-240q0-12.75-8.62-21.38Q612.75-630 600-630H360q-12.75 0-21.37 8.62Q330-612.75 330-600v240q0 12.75 8.63 21.37Q347.25-330 360-330ZM480.27-80q-82.74 0-155.5-31.5Q252-143 197.5-197.5t-86-127.34Q80-397.68 80-480.5t31.5-155.66Q143-709 197.5-763t127.34-85.5Q397.68-880 480.5-880t155.66 31.5Q709-817 763-763t85.5 127Q880-563 880-480.27q0 82.74-31.5 155.5Q817-252 763-197.68q-54 54.31-127 86Q563-80 480.27-80Zm.23-60Q622-140 721-239.5t99-241Q820-622 721.19-721T480-820q-141 0-240.5 98.81T140-480q0 141 99.5 240.5t241 99.5Zm-.5-340Z"), + ("stop_fill", "M240-300v-360q0-24.75 17.63-42.38Q275.25-720 300-720h360q24.75 0 42.38 17.62Q720-684.75 720-660v360q0 24.75-17.62 42.37Q684.75-240 660-240H300q-24.75 0-42.37-17.63Q240-275.25 240-300Z"), + ("sync", "M220-477q0 63 23.5 109.5T307-287l30 21v-94q0-13 8.5-21.5T367-390q13 0 21.5 8.5T397-360v170q0 13-8.5 21.5T367-160H197q-13 0-21.5-8.5T167-190q0-13 8.5-21.5T197-220h100l-15-12q-64-51-93-111t-29-134q0-94 49.5-171.5T342-766q11-5 21 0t14 16q5 11 0 22.5T361-710q-64 34-102.5 96.5T220-477Zm520-6q0-48-23.5-97.5T655-668l-29-26v94q0 13-8.5 21.5T596-570q-13 0-21.5-8.5T566-600v-170q0-13 8.5-21.5T596-800h170q13 0 21.5 8.5T796-770q0 13-8.5 21.5T766-740H665l15 14q60 56 90 120t30 123q0 93-48 169.5T623-195q-11 6-22.5 1.5T584-210q-5-11 0-22.5t16-17.5q65-33 102.5-96T740-483Z"), + ("system_update_alt", "M160 -64Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704H320Q337 -704 348.5 -692.5Q360 -681 360 -664Q360 -647 348.5 -635.5Q337 -624 320 -624H160Q160 -624 160 -624Q160 -624 160 -624V-144Q160 -144 160 -144Q160 -144 160 -144H800Q800 -144 800 -144Q800 -144 800 -144V-624Q800 -624 800 -624Q800 -624 800 -624H640Q623 -624 611.5 -635.5Q600 -647 600 -664Q600 -681 611.5 -692.5Q623 -704 640 -704H800Q833 -704 856.5 -680.5Q880 -657 880 -624V-144Q880 -111 856.5 -87.5Q833 -64 800 -64ZM440 -400V-664Q440 -681 451.5 -692.5Q463 -704 480 -704Q497 -704 508.5 -692.5Q520 -681 520 -664V-400L596 -476Q607 -487 624 -487Q641 -487 652 -476Q663 -465 663 -448Q663 -431 652 -420L508 -276Q496 -264 480 -264Q464 -264 452 -276L308 -420Q297 -431 297 -448Q297 -465 308 -476Q319 -487 336 -487Q353 -487 364 -476Z"), + ("tab", "M160 -144H800Q800 -144 800 -144Q800 -144 800 -144V-464H560Q543 -464 531.5 -475.5Q520 -487 520 -504V-624H160Q160 -624 160 -624Q160 -624 160 -624V-144Q160 -144 160 -144Q160 -144 160 -144ZM160 -64Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704H800Q833 -704 856.5 -680.5Q880 -657 880 -624V-144Q880 -111 856.5 -87.5Q833 -64 800 -64ZM160 -144Q160 -144 160 -144Q160 -144 160 -144V-624Q160 -624 160 -624Q160 -624 160 -624Q160 -624 160 -624Q160 -624 160 -624V-144Q160 -144 160 -144Q160 -144 160 -144Z"), + ("tab_fill", "M160 -64Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704H800Q833 -704 856.5 -680.5Q880 -657 880 -624V-144Q880 -111 856.5 -87.5Q833 -64 800 -64ZM560 -464H800V-624Q800 -624 800 -624Q800 -624 800 -624H520V-504Q520 -487 531.5 -475.5Q543 -464 560 -464Z"), + ("terminal", "M160 -64Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704H800Q833 -704 856.5 -680.5Q880 -657 880 -624V-144Q880 -111 856.5 -87.5Q833 -64 800 -64ZM160 -144H800Q800 -144 800 -144Q800 -144 800 -144V-544H160V-144Q160 -144 160 -144Q160 -144 160 -144ZM347 -344 271 -420Q259 -432 259.5 -448Q260 -464 272 -476Q284 -487 300 -487.5Q316 -488 328 -476L432 -372Q444 -360 444 -344Q444 -328 432 -316L328 -212Q317 -201 300.5 -200.5Q284 -200 272 -212Q261 -223 261 -240Q261 -257 272 -268ZM520 -184Q503 -184 491.5 -195.5Q480 -207 480 -224Q480 -241 491.5 -252.5Q503 -264 520 -264H680Q697 -264 708.5 -252.5Q720 -241 720 -224Q720 -207 708.5 -195.5Q697 -184 680 -184Z"), + ("text_snippet", "M180-180h600v-375L555-780H180v600Zm0 60q-24.75 0-42.37-17.63Q120-155.25 120-180v-600q0-24.75 17.63-42.38Q155.25-840 180-840h375q12.44 0 23.72 5T598-822l224 224q8 8 13 19.28 5 11.28 5 23.72v375q0 24.75-17.62 42.37Q804.75-120 780-120H180Zm129-171h342q12.75 0 21.38-8.68 8.62-8.67 8.62-21.5 0-12.82-8.62-21.32-8.63-8.5-21.38-8.5H309q-12.75 0-21.37 8.68-8.63 8.67-8.63 21.5 0 12.82 8.63 21.32 8.62 8.5 21.37 8.5Zm0-159h342q12.75 0 21.38-8.68 8.62-8.67 8.62-21.5 0-12.82-8.62-21.32-8.63-8.5-21.38-8.5H309q-12.75 0-21.37 8.68-8.63 8.67-8.63 21.5 0 12.82 8.63 21.32 8.62 8.5 21.37 8.5Zm0-159h216q12.75 0 21.38-8.68 8.62-8.67 8.62-21.5 0-12.82-8.62-21.32-8.63-8.5-21.38-8.5H309q-12.75 0-21.37 8.68-8.63 8.67-8.63 21.5 0 12.82 8.63 21.32 8.62 8.5 21.37 8.5ZM180-180v-600 600Z"), + ("title", "M420 -584H260Q235 -584 217.5 -601.5Q200 -619 200 -644Q200 -669 217.5 -686.5Q235 -704 260 -704H700Q725 -704 742.5 -686.5Q760 -669 760 -644Q760 -619 742.5 -601.5Q725 -584 700 -584H540V-124Q540 -99 522.5 -81.5Q505 -64 480 -64Q455 -64 437.5 -81.5Q420 -99 420 -124Z"), + ("travel_explore", "M80 -384Q80 -467 111.5 -540Q143 -613 197 -667Q251 -721 324 -752.5Q397 -784 480 -784Q607 -784 706.5 -714Q806 -644 851 -533Q858 -516 851.5 -499Q845 -482 828 -476Q812 -471 797.5 -479Q783 -487 777 -503Q753 -563 708 -609Q663 -655 600 -680V-664Q600 -631 576.5 -607.5Q553 -584 520 -584H440V-504Q440 -487 428.5 -475.5Q417 -464 400 -464H320V-384H360Q377 -384 388.5 -372.5Q400 -361 400 -344V-264H360L168 -456Q165 -438 162.5 -420Q160 -402 160 -384Q160 -262 240.5 -171Q321 -80 443 -66Q459 -64 469.5 -52.5Q480 -41 480 -24Q480 -7 468.5 4.5Q457 16 441 14Q288 -1 184 -114Q80 -227 80 -384ZM816 -32 716 -132Q695 -120 671 -112Q647 -104 620 -104Q545 -104 492.5 -156.5Q440 -209 440 -284Q440 -359 492.5 -411.5Q545 -464 620 -464Q695 -464 747.5 -411.5Q800 -359 800 -284Q800 -257 792 -233Q784 -209 772 -188L872 -88Q883 -77 883 -60Q883 -43 872 -32Q861 -21 844 -21Q827 -21 816 -32ZM620 -184Q662 -184 691 -213Q720 -242 720 -284Q720 -326 691 -355Q662 -384 620 -384Q578 -384 549 -355Q520 -326 520 -284Q520 -242 549 -213Q578 -184 620 -184Z"), + ("trending_up", "M102-252q-9-9-9-21.5t9-21.5l228-227q16.93-17 41.97-17Q397-539 414-522l125 125 241-241h-97q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h167q12.75 0 21.38 8.62Q880-680.75 880-668v167q0 12-8.27 21t-20.5 9Q839-471 830-480t-9-21v-93L580-354q-16.93 17-41.97 17Q513-337 496-354L371-478 145-252q-9 9-21.5 9t-21.5-9Z"), + ("tune", "M435.5-128.63Q427-137.25 427-150v-165q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v53h323q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H487v52q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63ZM150-202q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h187q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Zm165.5-174.63Q307-385.25 307-398v-52H150q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h157v-54q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v166q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63ZM457-450q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h353q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H457Zm144.5-173.63Q593-632.25 593-645v-165q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v52h157q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H653v53q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63ZM150-698q-12.75 0-21.37-8.68-8.63-8.67-8.63-21.5 0-12.82 8.63-21.32 8.62-8.5 21.37-8.5h353q12.75 0 21.38 8.68 8.62 8.67 8.62 21.5 0 12.82-8.62 21.32-8.63 8.5-21.38 8.5H150Z"), + ("undo", "M289-200q-13 0-21.5-8.5T259-230q0-13 8.5-21.5T289-260h280q70 0 120.5-46.5T740-422q0-69-50.5-115.5T569-584H274l93 93q9 9 9 21t-9 21q-9 9-21 9t-21-9L181-593q-5-5-7-10t-2-11q0-6 2-11t7-10l144-144q9-9 21-9t21 9q9 9 9 21t-9 21l-93 93h294q95 0 163.5 64T800-422q0 94-68.5 158T568-200H289Z"), + ("upload", "M220-160q-24 0-42-18t-18-42v-113q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v113h520v-113q0-12.75 8.68-21.38 8.67-8.62 21.5-8.62 12.82 0 21.32 8.62 8.5 8.63 8.5 21.38v113q0 24-18 42t-42 18H220Zm230-524-99 99q-8.8 9-20.9 8.5-12.1-.5-21.49-9.5-8.61-9-8.61-21.5t9-21.5l150-150q5-5 10.13-7 5.14-2 11-2 5.87 0 10.87 2 5 2 10 7l151 151q9 9 9 21t-8.61 21q-9.39 9-21.89 9t-21.5-9l-99-98v341q0 12.75-8.68 21.37-8.67 8.63-21.5 8.63-12.82 0-21.32-8.63-8.5-8.62-8.5-21.37v-341Z"), + ("visibility", "M600.5-379.62q49.5-49.62 49.5-120.5T600.38-620.5Q550.76-670 479.88-670T359.5-620.38Q310-570.76 310-499.88t49.62 120.38q49.62 49.5 120.5 49.5t120.38-49.62Zm-200-41.12q-32.5-32.73-32.5-79.5 0-46.76 32.74-79.26 32.73-32.5 79.5-32.5 46.76 0 79.26 32.74 32.5 32.73 32.5 79.5 0 46.76-32.74 79.26-32.73 32.5-79.5 32.5-46.76 0-79.26-32.74ZM234.5-276Q124-352 57-470q-4-7.13-6-14.65-2-7.52-2-15.43 0-7.92 2-15.38 2-7.47 6-14.54 67-118 177.5-194T480-800q135 0 245.5 76T903-530q4 7.12 6 14.65 2 7.52 2 15.43 0 7.92-2 15.38-2 7.47-6 14.54-67 118-177.5 194T480-200q-135 0-245.5-76ZM480-500Zm222.5 174.5Q804-391 857-500q-53-109-154.33-174.5Q601.34-740 480.17-740T257.5-674.5Q156-609 102-500q54 109 155.33 174.5Q358.66-260 479.83-260t222.67-65.5Z"), + ("volume_down", "M360-360H230q-13 0-21.5-8.5T200-390v-180q0-13 8.5-21.5T230-600h130l149-149q14-14 32.5-6.5T560-728v496q0 20-18.5 27.5T509-211L360-360Zm380-120q0 52-26 94t-73 64q-8 4-14.5-1t-6.5-13v-289q0-8 6.5-13t14.5-1q47 22 73 65t26 94ZM500-648 387-540H260v120h127l113 109v-337ZM378-480Z"), + ("volume_off", "M681-188q-17 12-35.5 22T607-148q-12 5-24.5 0T565-165q-5-11 .5-22t17.5-16q15-5 28.5-12t26.5-17L473-397v165q0 20-18.5 27.5T422-211L273-360H143q-13 0-21.5-8.5T113-390v-180q0-13 8.5-21.5T143-600h126L70-799q-9-9-8.5-21.5T71-842q9-9 21.5-9t21.5 9l721 721q9 9 9 21.5T835-78q-9 9-22 9t-22-9L681-188Zm92-293q0-93-52.5-168.5T583-759q-12-5-17-16t0-22q5-12 17.5-16.5t25.5.5q101 41 162.5 130.5T833-481q0 38-7.5 75T802-334q-8 17-19.5 20.5T760-315q-11-5-16.5-14.5t.5-20.5q15-30 22-63t7-68ZM576-628q38 23 57.5 63.5T653-480v15q0 7-2 15-2 10-11 13t-17-5l-61-61q-5-5-7-10t-2-11v-91q0-9 7.5-13.5t15.5.5Zm-196-57q-5-5-5-11t5-11l42-42q14-14 32.5-6.5T473-728v100q0 10-9.5 13.5T447-618l-67-67Zm33 379v-150l-84-84H173v120h126l114 114Zm-42-192Z"), + ("volume_up", "M760 -385Q760 -468 716 -536.5Q672 -605 598 -639Q583 -646 576 -660.5Q569 -675 574 -690Q580 -706 595.5 -713Q611 -720 627 -713Q724 -670 782 -581.5Q840 -493 840 -385Q840 -277 782 -188.5Q724 -100 627 -57Q611 -50 595.5 -57Q580 -64 574 -80Q569 -95 576 -109.5Q583 -124 598 -131Q672 -165 716 -233.5Q760 -302 760 -385ZM280 -264H160Q143 -264 131.5 -275.5Q120 -287 120 -304V-464Q120 -481 131.5 -492.5Q143 -504 160 -504H280L412 -636Q431 -655 455.5 -644.5Q480 -634 480 -607V-161Q480 -134 455.5 -123.5Q431 -113 412 -132ZM660 -384Q660 -342 641 -304.5Q622 -267 591 -243Q581 -237 570.5 -242.5Q560 -248 560 -260V-510Q560 -522 570.5 -527.5Q581 -533 591 -527Q622 -502 641 -464Q660 -426 660 -384ZM400 -510 314 -424H200V-344H314L400 -258ZM300 -384Z"), + ("volume_up_fill", "M760 -385Q760 -468 716 -536.5Q672 -605 598 -639Q583 -646 576 -660.5Q569 -675 574 -690Q580 -706 595.5 -713Q611 -720 627 -713Q724 -670 782 -581.5Q840 -493 840 -385Q840 -277 782 -188.5Q724 -100 627 -57Q611 -50 595.5 -57Q580 -64 574 -80Q569 -95 576 -109.5Q583 -124 598 -131Q672 -165 716 -233.5Q760 -302 760 -385ZM280 -264H160Q143 -264 131.5 -275.5Q120 -287 120 -304V-464Q120 -481 131.5 -492.5Q143 -504 160 -504H280L412 -636Q431 -655 455.5 -644.5Q480 -634 480 -607V-161Q480 -134 455.5 -123.5Q431 -113 412 -132ZM660 -384Q660 -342 641 -304.5Q622 -267 591 -243Q581 -237 570.5 -242.5Q560 -248 560 -260V-510Q560 -522 570.5 -527.5Q581 -533 591 -527Q622 -502 641 -464Q660 -426 660 -384Z"), + ("warning", "M109 -24Q98 -24 89 -29.5Q80 -35 75 -44Q70 -53 69.5 -63.5Q69 -74 75 -84L445 -724Q451 -734 460.5 -739Q470 -744 480 -744Q490 -744 499.5 -739Q509 -734 515 -724L885 -84Q891 -74 890.5 -63.5Q890 -53 885 -44Q880 -35 871 -29.5Q862 -24 851 -24ZM178 -104H782L480 -624ZM480 -144Q497 -144 508.5 -155.5Q520 -167 520 -184Q520 -201 508.5 -212.5Q497 -224 480 -224Q463 -224 451.5 -212.5Q440 -201 440 -184Q440 -167 451.5 -155.5Q463 -144 480 -144ZM480 -264Q497 -264 508.5 -275.5Q520 -287 520 -304V-424Q520 -441 508.5 -452.5Q497 -464 480 -464Q463 -464 451.5 -452.5Q440 -441 440 -424V-304Q440 -287 451.5 -275.5Q463 -264 480 -264ZM480 -364Z"), + ("warning_fill", "M109 -24Q98 -24 89 -29.5Q80 -35 75 -44Q70 -53 69.5 -63.5Q69 -74 75 -84L445 -724Q451 -734 460.5 -739Q470 -744 480 -744Q490 -744 499.5 -739Q509 -734 515 -724L885 -84Q891 -74 890.5 -63.5Q890 -53 885 -44Q880 -35 871 -29.5Q862 -24 851 -24ZM480 -144Q497 -144 508.5 -155.5Q520 -167 520 -184Q520 -201 508.5 -212.5Q497 -224 480 -224Q463 -224 451.5 -212.5Q440 -201 440 -184Q440 -167 451.5 -155.5Q463 -144 480 -144ZM480 -264Q497 -264 508.5 -275.5Q520 -287 520 -304V-424Q520 -441 508.5 -452.5Q497 -464 480 -464Q463 -464 451.5 -452.5Q440 -441 440 -424V-304Q440 -287 451.5 -275.5Q463 -264 480 -264Z"), + ("web", "M160 -64Q127 -64 103.5 -87.5Q80 -111 80 -144V-624Q80 -657 103.5 -680.5Q127 -704 160 -704H800Q833 -704 856.5 -680.5Q880 -657 880 -624V-144Q880 -111 856.5 -87.5Q833 -64 800 -64ZM160 -144H580V-284H160V-144Q160 -144 160 -144Q160 -144 160 -144ZM660 -144H800Q800 -144 800 -144Q800 -144 800 -144V-504H660ZM160 -364H580V-504H160Z"), + ("width", "M273 -344 308 -307Q319 -296 319 -279.5Q319 -263 308 -252Q296 -240 279.5 -240Q263 -240 252 -252L148 -355Q142 -361 139 -368.5Q136 -376 136 -384Q136 -392 139 -399Q142 -406 148 -412L252 -516Q263 -527 279.5 -527Q296 -527 308 -516Q320 -504 320 -487.5Q320 -471 308 -459L273 -424H687L651 -460Q640 -471 640 -487.5Q640 -504 652 -516Q663 -527 679.5 -527Q696 -527 708 -516L811 -412Q817 -406 820 -399Q823 -392 823 -384Q823 -376 820 -368.5Q817 -361 811 -355L707 -251Q696 -240 679.5 -240Q663 -240 651 -252Q640 -263 640 -279.5Q640 -296 651 -307L687 -344Z"), +]; diff --git a/src/lib.rs b/src/lib.rs new file mode 100644 index 0000000..dad5065 --- /dev/null +++ b/src/lib.rs @@ -0,0 +1,11 @@ +#![allow(clippy::too_many_arguments, clippy::type_complexity)] +pub mod core; +pub mod icondata; +pub mod ui; +pub mod app; +pub mod player; + +pub const APP_NAME: &str = "Audiphi"; +pub const APP_ID: &str = "audiphi"; +pub const VERSION: &str = env!("CARGO_PKG_VERSION"); +pub const HOMEPAGE: &str = "https://archlinux.tail7c4f5e.ts.net/git/astar76/Audiphi"; diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..6990916 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,52 @@ +use audiphi::app::App; +use eframe::egui; + +fn app_icon() -> egui::IconData { + let svg = include_str!("../assets/audiphi.svg"); + let size = 256u32; + let mut pm = resvg::tiny_skia::Pixmap::new(size, size).unwrap(); + if let Ok(tree) = resvg::usvg::Tree::from_str(svg, &resvg::usvg::Options::default()) { + let s = size as f32 / tree.size().width().max(tree.size().height()); + resvg::render(&tree, resvg::tiny_skia::Transform::from_scale(s, s), &mut pm.as_mut()); + } + // tiny-skia is premultiplied; IconData wants straight alpha + let mut rgba = pm.take(); + for px in rgba.chunks_exact_mut(4) { + let a = px[3] as u32; + if a > 0 && a < 255 { + for c in &mut px[..3] { + *c = ((*c as u32 * 255 + a / 2) / a).min(255) as u8; + } + } + } + egui::IconData { rgba, width: size, height: size } +} + +fn main() -> eframe::Result { + let mut url = None; + for a in std::env::args().skip(1) { + match a.as_str() { + "--version" | "-V" => { + println!("{} {}", audiphi::APP_NAME, audiphi::VERSION); + return Ok(()); + } + "--help" | "-h" => { + println!("Usage: audiphi [LINK or SEARCH]\n\nFetches the link straight away."); + return Ok(()); + } + _ if !a.starts_with("--") => url = Some(a), + _ => {} + } + } + let viewport = egui::ViewportBuilder::default() + .with_title(audiphi::APP_NAME) + .with_app_id(audiphi::APP_ID) + .with_inner_size([1240.0, 860.0]) + .with_min_inner_size([900.0, 640.0]) + .with_icon(std::sync::Arc::new(app_icon())); + eframe::run_native( + audiphi::APP_NAME, + eframe::NativeOptions { viewport, multisampling: 4, ..Default::default() }, + Box::new(move |cc| Ok(Box::new(App::new(cc, url)))), + ) +} diff --git a/src/player.rs b/src/player.rs new file mode 100644 index 0000000..880a7e6 --- /dev/null +++ b/src/player.rs @@ -0,0 +1,327 @@ +//! The quick player: libmpv for sound, a library queue, lyrics and a spectrum for the visualizer. + +use crate::core::{library::LibraryItem, lyrics, settings::Settings, tagger}; +use libmpv2::Mpv; +use rustfft::{num_complex::Complex, FftPlanner}; +use std::io::Read; +use std::process::{Command, Stdio}; +use std::sync::{Arc, Mutex}; + +const SR: usize = 22050; +const FFT: usize = 2048; + +/// Mono PCM of the current song (decoded by ffmpeg in a thread) and the bars computed from it. +pub struct Spectrum { + samples: Arc>>, + pub bars: Vec, + peak_db: f32, + planner: FftPlanner, + window: Vec, +} + +impl Spectrum { + fn new() -> Spectrum { + let window = (0..FFT).map(|i| 0.5 - 0.5 * (std::f32::consts::TAU * i as f32 / (FFT - 1) as f32).cos()).collect(); + Spectrum { samples: Arc::new(Mutex::new(vec![])), bars: vec![], peak_db: 30.0, planner: FftPlanner::new(), window } + } + + fn load(&mut self, path: &str, ctx: &eframe::egui::Context) { + let store = Arc::new(Mutex::new(vec![])); + self.samples = store.clone(); + let (path, ctx) = (path.to_string(), ctx.clone()); + std::thread::spawn(move || { + let ffmpeg = crate::core::paths::find_ffmpeg("").unwrap_or_else(|| "ffmpeg".into()); + let Ok(mut child) = Command::new(ffmpeg).args(["-v", "error", "-nostdin", "-i", &path, "-vn", "-ac", "1", "-ar", &SR.to_string(), "-f", "f32le", "-"]).stdout(Stdio::piped()).stderr(Stdio::null()).spawn() else { return }; + let mut out = child.stdout.take().unwrap(); + let mut buf = vec![0u8; 1 << 16]; + let mut carry: Vec = vec![]; + let mut local: Vec = vec![]; + while let Ok(n) = out.read(&mut buf) { + if n == 0 { + break; + } + carry.extend_from_slice(&buf[..n]); + let usable = carry.len() / 4 * 4; + local.extend(carry[..usable].chunks_exact(4).map(|b| f32::from_le_bytes([b[0], b[1], b[2], b[3]]))); + carry.drain(..usable); + if local.len() > SR * 20 { + store.lock().unwrap().append(&mut local); + } + } + store.lock().unwrap().append(&mut local); + let _ = child.wait(); + ctx.request_repaint(); + }); + } + + /// Bars (0..1) for `n` log-spaced bands at playback position `pos`; `active` false lets them fall. + pub fn update(&mut self, pos: f64, n: usize, active: bool, dt: f32) { + if self.bars.len() != n { + self.bars = vec![0.0; n]; + } + let mut target = vec![0.0f32; n]; + let start = (pos * SR as f64) as usize; + let have = { + let s = self.samples.lock().unwrap(); + if active && s.len() > start + 16 { + let mut buf: Vec> = (0..FFT).map(|i| Complex::new(s.get(start + i).copied().unwrap_or(0.0) * self.window[i], 0.0)).collect(); + drop(s); + self.planner.plan_fft_forward(FFT).process(&mut buf); + let mag: Vec = buf[..FFT / 2].iter().map(|c| c.norm() / FFT as f32 * 4.0).collect(); + let (lo, hi) = (40.0f32, 12000.0f32); + let hz = |bin: usize| bin as f32 * SR as f32 / FFT as f32; + for (b, t) in target.iter_mut().enumerate() { + let f0 = lo * (hi / lo).powf(b as f32 / n as f32); + let f1 = lo * (hi / lo).powf((b + 1) as f32 / n as f32); + let (i0, i1) = (((f0 / hz(1)) as usize).max(1), ((f1 / hz(1)).ceil() as usize).max(2)); + let v = mag[i0.min(mag.len() - 1)..i1.min(mag.len())].iter().cloned().fold(0.0f32, f32::max); + *t = 20.0 * (v + 1e-7).log10(); + } + true + } else { + false + } + }; + if have { + let top = target.iter().cloned().fold(-120.0f32, f32::max); + self.peak_db = (self.peak_db - 8.0 * dt).max(top).max(-20.0); + for t in target.iter_mut() { + *t = ((*t - (self.peak_db - 45.0)) / 45.0).clamp(0.0, 1.0); + } + } + for (b, t) in self.bars.iter_mut().zip(target) { + let k = if t > *b { 1.0 - (-dt * 40.0).exp() } else { 1.0 - (-dt * 7.0).exp() }; + *b += (t - *b) * k; + } + } +} + +pub struct Player { + mpv: Option, + pub error: Option, + pub path: String, + pub tags: Option, + pub cover_key: String, + pub queue: Vec, + pub index: usize, + pub shuffle: bool, + pub repeat: String, + pub playing: bool, + pub pos: f64, + pub dur: f64, + pub volume: i64, + history: Vec, + pub lyrics: Vec<(i64, String)>, + pub lyrics_plain: String, + pub spectrum: Spectrum, + rng: u64, + pub track_changed: bool, + ctx: eframe::egui::Context, +} + +impl Player { + pub fn new(ctx: &eframe::egui::Context, s: &Settings) -> Player { + let mut error = None; + let mpv = match Mpv::with_initializer(|i| { + i.set_property("vid", "no")?; + i.set_property("ytdl", false)?; + i.set_property("input-default-bindings", false)?; + i.set_property("input-vo-keyboard", false)?; + i.set_property("idle", "yes")?; + i.set_property("keep-open", "yes")?; + i.set_property("audio-client-name", "audiphi")?; + i.set_property("audio-display", "no")?; + if std::env::var_os("AUDIPHI_SHOTS").is_some() { + i.set_property("ao", "null")?; + } + Ok(()) + }) { + Ok(m) => Some(m), + Err(e) => { + error = Some(format!("No audio engine could start ({e}). Install mpv (libmpv).")); + None + } + }; + let volume = s.get_i64("player.volume").clamp(0, 100); + if let Some(m) = &mpv { + let _ = m.set_property("volume", volume as f64); + } + Player { + mpv, error, path: String::new(), tags: None, cover_key: String::new(), queue: vec![], index: 0, + shuffle: s.get_bool("player.shuffle"), repeat: { let r = s.get_str("player.repeat"); if r.is_empty() { "off".into() } else { r } }, + playing: false, pos: 0.0, dur: 0.0, volume, history: vec![], lyrics: vec![], lyrics_plain: String::new(), + spectrum: Spectrum::new(), rng: 0x9E3779B97F4A7C15 ^ std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_nanos() as u64).unwrap_or(1), + track_changed: false, ctx: ctx.clone(), + } + } + + fn rand(&mut self, n: usize) -> usize { + self.rng ^= self.rng << 13; + self.rng ^= self.rng >> 7; + self.rng ^= self.rng << 17; + (self.rng % n.max(1) as u64) as usize + } + + pub fn set_queue(&mut self, items: &[LibraryItem]) { + let current = self.path.clone(); + self.queue = items.iter().map(|i| i.path.clone()).collect(); + self.index = self.queue.iter().position(|p| *p == current).unwrap_or(0); + } + + pub fn play_path(&mut self, path: &str) { + if let Some(i) = self.queue.iter().position(|p| p == path) { + self.history.push(self.index); + self.index = i; + } + self.load(path); + } + + fn load(&mut self, path: &str) { + let Some(m) = &self.mpv else { return }; + self.error = None; + if !std::path::Path::new(path).is_file() { + self.error = Some("That file isn't there anymore".into()); + return; + } + let _ = m.set_property("pause", false); + if let Err(e) = m.command("loadfile", &[path, "replace", "-1", ""]) { + self.error = Some(format!("Can't play {}: {e}", std::path::Path::new(path).file_name().unwrap_or_default().to_string_lossy())); + return; + } + self.path = path.to_string(); + self.cover_key = format!("file:{path}"); + self.playing = true; + self.pos = 0.0; + self.dur = 0.0; + let tags = tagger::read(path, false); + self.dur = tags.duration.unwrap_or(0.0); + self.set_lyrics_text(&tags.lyrics.clone()); + self.tags = Some(tags); + self.spectrum.load(path, &self.ctx); + self.track_changed = true; + } + + pub fn set_lyrics_text(&mut self, text: &str) { + if lyrics::is_synced(text) { + self.lyrics = lyrics::parse_lrc(text); + self.lyrics_plain = String::new(); + } else { + self.lyrics = vec![]; + self.lyrics_plain = text.to_string(); + } + } + + pub fn lyrics_mode(&self) -> &'static str { + if !self.lyrics.is_empty() { "synced" } else if !self.lyrics_plain.trim().is_empty() { "plain" } else { "none" } + } + + pub fn reload_tags(&mut self) { + if self.path.is_empty() { + return; + } + let tags = tagger::read(&self.path, false); + self.set_lyrics_text(&tags.lyrics.clone()); + self.tags = Some(tags); + self.track_changed = true; + } + + pub fn toggle(&mut self) { + let Some(m) = &self.mpv else { return }; + if self.path.is_empty() { + if let Some(p) = self.queue.get(self.index).cloned() { + self.load(&p); + } + return; + } + if self.mpv.as_ref().and_then(|m| m.get_property::("eof-reached").ok()).unwrap_or(false) { + let p = self.path.clone(); + self.load(&p); + return; + } + self.playing = !self.playing; + let _ = m.set_property("pause", !self.playing); + } + + pub fn seek(&mut self, sec: f64) { + if let Some(m) = &self.mpv { + let _ = m.command("seek", &[&format!("{:.3}", sec.max(0.0)), "absolute+exact"]); + self.pos = sec; + } + } + + pub fn next(&mut self, auto: bool) { + if self.queue.is_empty() { + return; + } + let nxt = if self.repeat == "one" && auto { + self.index + } else if self.shuffle && self.queue.len() > 1 { + loop { + let c = self.rand(self.queue.len()); + if c != self.index { + break c; + } + } + } else { + let n = self.index + 1; + if n >= self.queue.len() { + if auto && self.repeat == "off" { + self.playing = false; + return; + } + 0 + } else { + n + } + }; + self.history.push(self.index); + self.index = nxt; + let p = self.queue[nxt].clone(); + self.load(&p); + } + + pub fn previous(&mut self) { + if self.pos > 3.0 || self.queue.is_empty() { + self.seek(0.0); + return; + } + let prev = if self.shuffle { self.history.pop().unwrap_or(0) } else { (self.index + self.queue.len() - 1) % self.queue.len() }; + self.index = prev; + let p = self.queue[prev].clone(); + self.load(&p); + } + + pub fn set_volume(&mut self, v: i64) { + self.volume = v.clamp(0, 100); + if let Some(m) = &self.mpv { + let _ = m.set_property("volume", self.volume as f64); + } + } + + pub fn stop(&mut self) { + if let Some(m) = &self.mpv { + let _ = m.command("stop", &[]); + } + self.playing = false; + } + + /// Poll the engine; true when something moved on screen. + pub fn tick(&mut self) -> bool { + let Some(m) = &self.mpv else { return false }; + if self.path.is_empty() { + return false; + } + if let Ok(p) = m.get_property::("time-pos") { + self.pos = p; + } + if let Ok(d) = m.get_property::("duration") { + if d > 0.0 { + self.dur = d; + } + } + if self.playing && m.get_property::("eof-reached").unwrap_or(false) { + self.next(true); + } + self.playing + } +} diff --git a/src/ui/controls.rs b/src/ui/controls.rs new file mode 100644 index 0000000..1612d53 --- /dev/null +++ b/src/ui/controls.rs @@ -0,0 +1,351 @@ +//! Extra Material 3 controls on top of widgets.rs: buttons, chips, fields, the loading indicator, the cookie cover. + +use super::gfx::*; +use super::theme::{mix, with_alpha}; +use super::widgets::{combo, menu_frame}; +use eframe::egui::{self, Align2, Color32, Id, Pos2, Rect, Response, Sense, Shape, Stroke, StrokeKind, TextureId, Ui, Vec2}; + +#[derive(Clone, Copy, PartialEq, Eq)] +pub enum Kind { + Filled, + Tonal, + Text, + Outlined, + Danger, +} + +pub fn button(ui: &mut Ui, g: &mut Gfx, icon: Option<&str>, text: &str, kind: Kind) -> Response { + button_h(ui, g, icon, text, kind, 40.0) +} + +pub fn button_h(ui: &mut Ui, g: &mut Gfx, icon: Option<&str>, text: &str, kind: Kind, h: f32) -> Response { + let fnt = font_semi(if h >= 40.0 { 14.5 } else { 13.5 }); + let tw = ui.painter().layout_no_wrap(text.to_string(), fnt.clone(), Color32::WHITE).size().x; + let iw = if icon.is_some() { if text.is_empty() { 20.0 } else { 28.0 } } else { 0.0 }; + let pad = if text.is_empty() { 10.0 } else if kind == Kind::Text { 12.0 } else { 20.0 }; + let (rect, resp) = ui.allocate_exact_size(Vec2::new(tw + iw + pad * 2.0, h), Sense::click()); + let t = &g.theme; + let (bg, fg) = match kind { + Kind::Filled => (t.primary, t.on_primary), + Kind::Tonal => (t.secondary_container, t.on_secondary_container), + Kind::Text => (Color32::TRANSPARENT, t.primary), + Kind::Outlined => (Color32::TRANSPARENT, t.primary), + Kind::Danger => (t.error, t.on_error), + }; + let enabled = ui.is_enabled(); + let (bg, fg) = if enabled { (bg, fg) } else { (if bg.a() > 0 { with_alpha(t.on_surface, 0.12) } else { bg }, with_alpha(t.on_surface, 0.38)) }; + let hover = ui.ctx().animate_bool_with_time(resp.id.with("h"), resp.hovered() && enabled, 0.12); + let rad = h / 2.0; + let p = ui.painter(); + if bg.a() > 0 { + p.rect_filled(rect, cr(rad), bg); + } + if kind == Kind::Outlined { + p.rect_stroke(rect, cr(rad), Stroke::new(1.0, if enabled { t.outline } else { with_alpha(t.on_surface, 0.12) }), StrokeKind::Inside); + } + let state = hover * 0.08 + if resp.is_pointer_button_down_on() && enabled { 0.1 } else { 0.0 }; + if state > 0.0 { + p.rect_filled(rect, cr(rad), with_alpha(fg, state)); + } + let start = rect.center().x - (tw + iw) / 2.0; + if let Some(ic) = icon { + g.icon(ui.painter(), Rect::from_center_size(Pos2::new(start + 10.0, rect.center().y), Vec2::splat(20.0)), ic, fg); + } + if !text.is_empty() { + ui.painter().text(Pos2::new(start + iw, rect.center().y), Align2::LEFT_CENTER, text, fnt, fg); + } + if resp.hovered() && enabled { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + resp +} + +/// The big extended FAB (Download). +pub fn fab(ui: &mut Ui, g: &mut Gfx, icon: &str, text: &str) -> Response { + let fnt = font_semi(16.0); + let tw = ui.painter().layout_no_wrap(text.to_string(), fnt.clone(), Color32::WHITE).size().x; + let (rect, resp) = ui.allocate_exact_size(Vec2::new(tw + 84.0, 56.0), Sense::click()); + let t = &g.theme; + let enabled = ui.is_enabled(); + let (bg, fg) = if enabled { (t.primary_container, t.on_primary_container) } else { (with_alpha(t.on_surface, 0.12), with_alpha(t.on_surface, 0.38)) }; + let hover = ui.ctx().animate_bool_with_time(resp.id.with("h"), resp.hovered() && enabled, 0.12); + let p = ui.painter(); + p.rect_filled(rect.translate(Vec2::new(0.0, 2.0)), cr(18.0), with_alpha(Color32::BLACK, if enabled { 0.18 } else { 0.0 })); + p.rect_filled(rect, cr(18.0), bg); + p.rect_filled(rect, cr(18.0), with_alpha(fg, hover * 0.08 + if resp.is_pointer_button_down_on() && enabled { 0.1 } else { 0.0 })); + g.icon(ui.painter(), Rect::from_center_size(Pos2::new(rect.left() + 32.0, rect.center().y), Vec2::splat(24.0)), icon, fg); + ui.painter().text(Pos2::new(rect.left() + 54.0, rect.center().y), Align2::LEFT_CENTER, text, fnt, fg); + if resp.hovered() && enabled { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + resp +} + +/// A selectable filter chip. +pub fn chip(ui: &mut Ui, g: &mut Gfx, icon: Option<&str>, text: &str, selected: bool) -> Response { + let fnt = font(13.5); + let tw = ui.painter().layout_no_wrap(text.to_string(), fnt.clone(), Color32::WHITE).size().x; + let iw = if icon.is_some() { 24.0 } else { 0.0 }; + let (rect, resp) = ui.allocate_exact_size(Vec2::new(tw + iw + 28.0, 32.0), Sense::click()); + let t = &g.theme; + let (bg, fg) = if selected { (t.secondary_container, t.on_secondary_container) } else { (Color32::TRANSPARENT, t.on_surface_variant) }; + let hover = ui.ctx().animate_bool_with_time(resp.id.with("h"), resp.hovered(), 0.12); + let p = ui.painter(); + p.rect_filled(rect, cr(9.0), bg); + if !selected { + p.rect_stroke(rect, cr(9.0), Stroke::new(1.0, t.outline_variant), StrokeKind::Inside); + } + p.rect_filled(rect, cr(9.0), with_alpha(fg, hover * 0.08)); + let x0 = rect.left() + 14.0; + if let Some(ic) = icon { + g.icon(ui.painter(), Rect::from_center_size(Pos2::new(x0 + 8.0, rect.center().y), Vec2::splat(18.0)), ic, fg); + } + ui.painter().text(Pos2::new(x0 + iw, rect.center().y), Align2::LEFT_CENTER, text, fnt, fg); + if resp.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + resp +} + +/// A non-interactive tag with an optional coloured dot (service chips). +pub fn badge(ui: &mut Ui, g: &mut Gfx, dot: Option, icon: Option<&str>, text: &str) -> Response { + let fnt = font(13.0); + let tw = ui.painter().layout_no_wrap(text.to_string(), fnt.clone(), Color32::WHITE).size().x; + let lead = if dot.is_some() || icon.is_some() { 20.0 } else { 0.0 }; + let (rect, resp) = ui.allocate_exact_size(Vec2::new(tw + lead + 24.0, 28.0), Sense::hover()); + let t = &g.theme; + ui.painter().rect_filled(rect, cr(8.0), t.surface_container_high); + let mut x = rect.left() + 12.0; + if let Some(d) = dot { + ui.painter().circle_filled(Pos2::new(x + 4.0, rect.center().y), 4.0, d); + } + if let Some(ic) = icon { + g.icon(ui.painter(), Rect::from_center_size(Pos2::new(x + 8.0, rect.center().y), Vec2::splat(16.0)), ic, g.theme.on_surface_variant); + } + x += lead; + ui.painter().text(Pos2::new(x, rect.center().y), Align2::LEFT_CENTER, text, fnt, g.theme.on_surface_variant); + resp +} + +/// Caption above a control. +pub fn caption(ui: &mut Ui, g: &Gfx, text: &str) { + ui.label(egui::RichText::new(text).size(12.0).color(g.theme.on_surface_variant)); +} + +/// Filled text field with a caption above it. `trailing` icons (name, tooltip) are drawn inside on the right; returns (response, clicked trailing index). +pub fn field(ui: &mut Ui, g: &mut Gfx, label: &str, text: &mut String, width: f32, hint: &str, trailing: &[(&str, &str)]) -> (Response, Option) { + if !label.is_empty() { + caption(ui, g, label); + } + let h = 40.0; + let (rect, _) = ui.allocate_exact_size(Vec2::new(width, h), Sense::hover()); + let id = ui.id().with(("field", label, hint)); + let focused = ui.memory(|m| m.focused()).map(|f| f == id).unwrap_or(false); + let t = &g.theme; + ui.painter().rect_filled(rect, cr(10.0), t.surface_container_highest); + if focused { + ui.painter().rect_stroke(rect, cr(10.0), Stroke::new(2.0, t.primary), StrokeKind::Inside); + } + let right_pad = 8.0 + trailing.len() as f32 * 34.0; + let inner = Rect::from_min_max(Pos2::new(rect.left() + 12.0, rect.top() + 3.0), Pos2::new(rect.right() - right_pad, rect.bottom() - 3.0)); + let mut child = ui.new_child(egui::UiBuilder::new().max_rect(inner).layout(egui::Layout::left_to_right(egui::Align::Center))); + child.visuals_mut().widgets.inactive.bg_fill = Color32::TRANSPARENT; + child.visuals_mut().widgets.hovered.bg_fill = Color32::TRANSPARENT; + child.visuals_mut().widgets.active.bg_fill = Color32::TRANSPARENT; + child.visuals_mut().selection.bg_fill = g.theme.primary; + child.visuals_mut().selection.stroke = Stroke::new(1.0, g.theme.on_primary); + let resp = child.add( + egui::TextEdit::singleline(text) + .id(id) + .hint_text(egui::RichText::new(hint).color(with_alpha(g.theme.on_surface_variant, 0.7))) + .frame(egui::Frame::NONE) + .desired_width(inner.width()) + .margin(egui::Margin::symmetric(0, 8)) + .font(font(14.5)) + .text_color(g.theme.on_surface), + ); + let mut clicked = None; + for (i, (ic, tip)) in trailing.iter().enumerate() { + let r = Rect::from_center_size(Pos2::new(rect.right() - 22.0 - (trailing.len() - 1 - i) as f32 * 34.0, rect.center().y), Vec2::splat(30.0)); + let rr = ui.interact(r, id.with(("tr", i)), Sense::click()).on_hover_text(*tip); + if rr.hovered() { + ui.painter().circle_filled(r.center(), 15.0, with_alpha(g.theme.on_surface, 0.08)); + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + g.icon(ui.painter(), Rect::from_center_size(r.center(), Vec2::splat(20.0)), ic, g.theme.on_surface_variant); + if rr.clicked() { + clicked = Some(i); + } + } + (resp, clicked) +} + +/// Multi-line variant used for lyrics. +pub fn text_area(ui: &mut Ui, g: &Gfx, text: &mut String, width: f32, rows: usize) -> Response { + egui::Frame::NONE + .fill(g.theme.surface_container_highest) + .corner_radius(cr(10.0)) + .inner_margin(egui::Margin::symmetric(12, 8)) + .show(ui, |ui| { + ui.visuals_mut().selection.bg_fill = g.theme.primary; + ui.add(egui::TextEdit::multiline(text).frame(egui::Frame::NONE).desired_width(width - 24.0).desired_rows(rows).font(font(13.5))) + }) + .inner +} + +/// Labeled dropdown. Returns the newly chosen key. +pub fn dropdown(ui: &mut Ui, g: &mut Gfx, id: Id, label: &str, current: &str, items: &[(String, String)], width: f32) -> Option { + if !label.is_empty() { + caption(ui, g, label); + } + combo(ui, g, id, current, items, width) +} + +pub fn items(list: &[(&str, &str)]) -> Vec<(String, String)> { + list.iter().map(|(a, b)| (a.to_string(), b.to_string())).collect() +} + +/// A rounded-square icon badge (empty states). +pub fn icon_badge(ui: &mut Ui, g: &mut Gfx, icon: &str, size: f32, error: bool) { + let (rect, _) = ui.allocate_exact_size(Vec2::splat(size), Sense::hover()); + let t = &g.theme; + let (bg, fg) = if error { (t.error_container, t.on_error_container) } else { (t.primary_container, t.on_primary_container) }; + ui.painter().add(Shape::convex_polygon(cookie_points(rect.center(), size / 2.0 * 0.96, 0.0, 8, 0.05), bg, Stroke::NONE)); + g.icon(ui.painter(), Rect::from_center_size(rect.center(), Vec2::splat(size * 0.5)), icon, fg); +} + +/// A soft lobed outline: r(θ) = R·(1 + depth·cos(lobes·θ)). +pub fn cookie_points(c: Pos2, r: f32, rot: f32, lobes: u32, depth: f32) -> Vec { + let n = 96; + (0..n) + .map(|i| { + let th = i as f32 / n as f32 * std::f32::consts::TAU; + let rr = r * (1.0 + depth * (lobes as f32 * th).cos()); + let a = th + rot; + Pos2::new(c.x + rr * a.cos(), c.y + rr * a.sin()) + }) + .collect() +} + +/// A picture (or a placeholder) clipped to a rounded square. +pub fn cover(ui: &mut Ui, g: &mut Gfx, tex: Option<(TextureId, [u32; 2])>, size: f32, radius: f32) -> Response { + let (rect, resp) = ui.allocate_exact_size(Vec2::splat(size), Sense::click()); + paint_cover(ui, g, rect, tex, radius); + resp +} + +pub fn paint_cover(ui: &Ui, g: &mut Gfx, rect: Rect, tex: Option<(TextureId, [u32; 2])>, radius: f32) { + ui.painter().rect_filled(rect, cr(radius), g.theme.surface_container_highest); + match tex { + Some((id, [w, h])) => { + // cover-fit: crop the longer side + let (w, h) = (w.max(1) as f32, h.max(1) as f32); + let s = w.min(h); + let (uw, uh) = (s / w, s / h); + let uv = Rect::from_min_max(Pos2::new((1.0 - uw) / 2.0, (1.0 - uh) / 2.0), Pos2::new((1.0 + uw) / 2.0, (1.0 + uh) / 2.0)); + textured_rounded_uv(ui.painter(), rect, radius, id, uv); + } + None => { + let ic = rect.width() * 0.4; + let col = with_alpha(g.theme.on_surface_variant, 0.6); + g.icon(ui.painter(), Rect::from_center_size(rect.center(), Vec2::splat(ic)), "music_note", col); + } + } +} + +pub fn textured_rounded_uv(painter: &egui::Painter, rect: Rect, r: f32, tex: TextureId, uv: Rect) { + painter.add(rounded_mesh(rect, r, Some(tex), |p| (Color32::WHITE, Pos2::new(uv.left() + (p.x - rect.left()) / rect.width() * uv.width(), uv.top() + (p.y - rect.top()) / rect.height() * uv.height())))); +} + +/// Picture clipped to a (rotating) cookie outline; the art itself stays upright. +pub fn cookie_image(painter: &egui::Painter, center: Pos2, radius: f32, rot: f32, lobes: u32, depth: f32, tex: TextureId, tex_size: [u32; 2]) { + let pts = cookie_points(center, radius, rot, lobes, depth); + let rect = Rect::from_center_size(center, Vec2::splat(radius * 2.0)); + let (w, h) = (tex_size[0].max(1) as f32, tex_size[1].max(1) as f32); + let s = w.min(h); + let (uw, uh) = (s / w, s / h); + let uv = Rect::from_min_max(Pos2::new((1.0 - uw) / 2.0, (1.0 - uh) / 2.0), Pos2::new((1.0 + uw) / 2.0, (1.0 + uh) / 2.0)); + let mut mesh = egui::Mesh::with_texture(tex); + let to_uv = |p: Pos2| Pos2::new(uv.left() + (p.x - rect.left()) / rect.width() * uv.width(), uv.top() + (p.y - rect.top()) / rect.height() * uv.height()); + mesh.vertices.push(egui::epaint::Vertex { pos: center, uv: to_uv(center), color: Color32::WHITE }); + for p in &pts { + mesh.vertices.push(egui::epaint::Vertex { pos: *p, uv: to_uv(*p), color: Color32::WHITE }); + } + let n = pts.len() as u32; + for i in 0..n { + mesh.add_triangle(0, i + 1, ((i + 1) % n) + 1); + } + painter.add(Shape::mesh(mesh)); +} + +/// The loading indicator: a contained cookie whose lobes morph while it turns. +pub fn loading(ui: &mut Ui, g: &Gfx, size: f32) { + let (rect, _) = ui.allocate_exact_size(Vec2::splat(size), Sense::hover()); + let t = ui.input(|i| i.time) as f32; + let depth = 0.04 + 0.09 * (0.5 + 0.5 * (t * 2.4).sin()); + let lobes = 7 + ((t * 0.6) as u32 % 4); + let rot = t * 2.0; + let r = size / 2.0 * 0.62; + let bg = rect.center(); + ui.painter().circle_filled(bg, size / 2.0 * 0.98, g.theme.secondary_container); + ui.painter().add(Shape::convex_polygon(cookie_points(bg, r, rot, lobes, depth), g.theme.primary, Stroke::NONE)); + ui.ctx().request_repaint(); +} + +/// A circular indeterminate arc for small inline spinners. +pub fn spinner(ui: &mut Ui, g: &Gfx, size: f32) { + let (rect, _) = ui.allocate_exact_size(Vec2::splat(size), Sense::hover()); + let t = ui.input(|i| i.time) as f32; + let c = rect.center(); + let r = size / 2.0 - 2.0; + let start = t * 4.0; + let pts: Vec = (0..=24).map(|i| { + let a = start + i as f32 / 24.0 * 4.2; + Pos2::new(c.x + r * a.cos(), c.y + r * a.sin()) + }).collect(); + ui.painter().add(Shape::line(pts, Stroke::new(2.5, g.theme.primary))); + ui.ctx().request_repaint(); +} + +pub fn progress_bar(ui: &mut Ui, g: &Gfx, width: f32, value: f32, color: Option) { + let (rect, _) = ui.allocate_exact_size(Vec2::new(width, 8.0), Sense::hover()); + let t = &g.theme; + ui.painter().rect_filled(rect, cr(4.0), t.surface_container_highest); + let w = (rect.width() * value.clamp(0.0, 1.0)).max(if value > 0.0 { 8.0 } else { 0.0 }); + if w > 0.0 { + ui.painter().rect_filled(Rect::from_min_size(rect.min, Vec2::new(w, 8.0)), cr(4.0), color.unwrap_or(t.primary)); + } +} + +/// Indeterminate sliding bar. +pub fn progress_indeterminate(ui: &mut Ui, g: &Gfx, width: f32) { + let (rect, _) = ui.allocate_exact_size(Vec2::new(width, 8.0), Sense::hover()); + ui.painter().rect_filled(rect, cr(4.0), g.theme.surface_container_highest); + let t = (ui.input(|i| i.time) as f32 * 0.9) % 1.0; + let w = rect.width() * 0.3; + let x = rect.left() + (rect.width() + w) * t - w; + let bar = Rect::from_min_max(Pos2::new(x.max(rect.left()), rect.top()), Pos2::new((x + w).min(rect.right()), rect.bottom())); + if bar.width() > 0.0 { + ui.painter().rect_filled(bar, cr(4.0), g.theme.primary); + } + ui.ctx().request_repaint(); +} + +pub fn status_color(g: &Gfx, state: crate::core::models::JobState) -> (Color32, Color32) { + use crate::core::models::JobState::*; + let t = &g.theme; + match state { + Done | Skipped => (t.tertiary_container, t.on_tertiary_container), + Failed => (t.error_container, t.on_error_container), + Cancelled | Queued => (t.surface_container_high, t.on_surface_variant), + _ => (t.primary_container, t.on_primary_container), + } +} + +pub fn mix_c(a: Color32, b: Color32, t: f32) -> Color32 { + mix(a, b, t) +} + +pub fn menu_popup_frame(g: &Gfx) -> egui::Frame { + menu_frame(g) +} diff --git a/src/ui/fonts.rs b/src/ui/fonts.rs new file mode 100644 index 0000000..9ff941d --- /dev/null +++ b/src/ui/fonts.rs @@ -0,0 +1,34 @@ +//! Fonts: Rubik (bundled, SIL OFL) in a few weights for both body and display text. + +use eframe::egui::{self, FontData, FontDefinitions, FontFamily}; +use eframe::epaint::text::{FontTweak, VariationCoords}; +use std::sync::Arc; + +pub const SEMI: &str = "semi"; +pub const DISP_MED: &str = "disp_med"; +pub const DISP_SEMI: &str = "disp_semi"; +pub const DISP_BOLD: &str = "disp_bold"; + +static RUBIK: &[u8] = include_bytes!("../../assets/fonts/Rubik.ttf"); + +pub fn family(name: &str) -> FontFamily { + FontFamily::Name(Arc::from(name)) +} + +pub fn install(ctx: &egui::Context) { + let mut defs = FontDefinitions::default(); + let fallback: Vec = defs.families.get(&FontFamily::Proportional).cloned().unwrap_or_default(); + let mut add = |key: &str, fam: FontFamily, weight: f32| { + let tweak = FontTweak { coords: VariationCoords::new([(b"wght", weight)]), ..Default::default() }; + defs.font_data.insert(key.to_string(), Arc::new(FontData::from_static(RUBIK).tweak(tweak))); + let mut list = vec![key.to_string()]; + list.extend(fallback.iter().cloned()); + defs.families.insert(fam, list); + }; + add("body", FontFamily::Proportional, 400.0); + add("body_semi", family(SEMI), 600.0); + add("disp_med", family(DISP_MED), 500.0); + add("disp_semi", family(DISP_SEMI), 600.0); + add("disp_bold", family(DISP_BOLD), 700.0); + ctx.set_fonts(defs); +} diff --git a/src/ui/gfx.rs b/src/ui/gfx.rs new file mode 100644 index 0000000..3fbd168 --- /dev/null +++ b/src/ui/gfx.rs @@ -0,0 +1,113 @@ +//! Shared drawing context: theme + icon cache + text helpers. + +use super::fonts; +use super::icons::Icons; +use crate::ui::theme::Theme; +use eframe::egui::{self, Align2, Color32, CornerRadius, FontId, Painter, Pos2, Rect}; + +pub struct Gfx { + pub theme: Theme, + pub icons: Icons, + pub ctx: egui::Context, +} + +pub fn cr(r: f32) -> CornerRadius { + CornerRadius::same(r.round().clamp(0.0, 255.0) as u8) +} + +pub fn font(size: f32) -> FontId { + FontId::proportional(size) +} +pub fn font_semi(size: f32) -> FontId { + FontId::new(size, fonts::family(fonts::SEMI)) +} +pub fn disp(size: f32) -> FontId { + FontId::new(size, fonts::family(fonts::DISP_MED)) +} +pub fn disp_semi(size: f32) -> FontId { + FontId::new(size, fonts::family(fonts::DISP_SEMI)) +} +pub fn disp_bold(size: f32) -> FontId { + FontId::new(size, fonts::family(fonts::DISP_BOLD)) +} + +impl Gfx { + pub fn icon(&mut self, painter: &Painter, rect: Rect, name: &str, color: Color32) { + let ctx = self.ctx.clone(); + self.icons.paint(&ctx, painter, rect, name, color); + } + + pub fn icon_at(&mut self, painter: &Painter, center: Pos2, size: f32, name: &str, color: Color32) { + let ctx = self.ctx.clone(); + self.icons.paint_center(&ctx, painter, center, size, name, color); + } +} + +/// Truncate `text` with an ellipsis so it fits `max_w` in `font`. +pub fn elide(painter: &Painter, text: &str, font: &FontId, max_w: f32) -> String { + let w = |s: &str| painter.layout_no_wrap(s.to_string(), font.clone(), Color32::WHITE).size().x; + if w(text) <= max_w { + return text.to_string(); + } + let chars: Vec = text.chars().collect(); + let (mut lo, mut hi) = (0usize, chars.len()); + while lo < hi { + let mid = (lo + hi + 1) / 2; + let cand: String = chars[..mid].iter().collect::() + "…"; + if w(&cand) <= max_w { + lo = mid; + } else { + hi = mid - 1; + } + } + chars[..lo].iter().collect::() + "…" +} + +pub fn text_elided(painter: &Painter, pos: Pos2, align: Align2, text: &str, font: FontId, color: Color32, max_w: f32) -> Rect { + let t = elide(painter, text, &font, max_w); + painter.text(pos, align, t, font, color) +} + + +/// Points of a rounded rectangle outline (clockwise from the top-left corner's end), `seg` per corner. +pub fn rounded_points(rect: Rect, r: f32, seg: usize) -> Vec { + let r = r.min(rect.width() / 2.0).min(rect.height() / 2.0).max(0.0); + let mut pts = Vec::with_capacity(4 * (seg + 1)); + let corners = [ + (Pos2::new(rect.right() - r, rect.top() + r), -std::f32::consts::FRAC_PI_2), + (Pos2::new(rect.right() - r, rect.bottom() - r), 0.0), + (Pos2::new(rect.left() + r, rect.bottom() - r), std::f32::consts::FRAC_PI_2), + (Pos2::new(rect.left() + r, rect.top() + r), std::f32::consts::PI), + ]; + for (c, a0) in corners { + for i in 0..=seg { + let a = a0 + std::f32::consts::FRAC_PI_2 * i as f32 / seg as f32; + pts.push(c + egui::Vec2::angled(a) * r); + } + } + pts +} + +/// A rounded rectangle filled from a per-point colour/uv function (fan from the centre; convex only). +pub fn rounded_mesh(rect: Rect, r: f32, tex: Option, vert: impl Fn(Pos2) -> (Color32, Pos2)) -> egui::Shape { + let pts = rounded_points(rect, r, 8); + let mut mesh = match tex { + Some(t) => egui::Mesh::with_texture(t), + None => egui::Mesh::default(), + }; + let (cc, cuv) = vert(rect.center()); + mesh.vertices.push(egui::epaint::Vertex { pos: rect.center(), uv: cuv, color: cc }); + for p in &pts { + let (c, uv) = vert(*p); + mesh.vertices.push(egui::epaint::Vertex { pos: *p, uv, color: c }); + } + let n = pts.len() as u32; + for i in 0..n { + mesh.add_triangle(0, i + 1, ((i + 1) % n) + 1); + } + egui::Shape::mesh(mesh) +} + +pub fn textured_rounded(painter: &Painter, rect: Rect, r: f32, tex: egui::TextureId, tint: Color32) { + painter.add(rounded_mesh(rect, r, Some(tex), |p| (tint, Pos2::new((p.x - rect.left()) / rect.width(), (p.y - rect.top()) / rect.height())))); +} diff --git a/src/ui/icons.rs b/src/ui/icons.rs new file mode 100644 index 0000000..7e71f25 --- /dev/null +++ b/src/ui/icons.rs @@ -0,0 +1,52 @@ +//! Material Symbols icons rasterised from SVG path data and drawn tinted with theme colours. + +use crate::icondata::ICONS; +use eframe::egui::{self, Color32, Context, Painter, Rect, TextureHandle, TextureOptions}; +use std::collections::HashMap; + +#[derive(Default)] +pub struct Icons { + cache: HashMap<(&'static str, u32), TextureHandle>, +} + +fn path_for(name: &str) -> (&'static str, &'static str) { + ICONS + .iter() + .find(|(n, _)| *n == name) + .or_else(|| ICONS.iter().find(|(n, _)| *n == "music_note")) + .copied() + .unwrap() +} + +impl Icons { + fn texture(&mut self, ctx: &Context, name: &str, px: u32) -> egui::TextureId { + let (key, d) = path_for(name); + let h = self.cache.entry((key, px)).or_insert_with(|| { + let svg = format!( + r##""## + ); + let mut pm = resvg::tiny_skia::Pixmap::new(px, px).unwrap(); + if let Ok(tree) = resvg::usvg::Tree::from_str(&svg, &resvg::usvg::Options::default()) { + resvg::render(&tree, resvg::tiny_skia::Transform::identity(), &mut pm.as_mut()); + } + let img = egui::ColorImage::from_rgba_premultiplied([px as usize; 2], pm.data()); + ctx.load_texture(format!("icon-{key}-{px}"), img, TextureOptions::LINEAR) + }); + h.id() + } + + /// Paint an icon filling `rect`, tinted with `color` (alpha respected). + pub fn paint(&mut self, ctx: &Context, painter: &Painter, rect: Rect, name: &str, color: Color32) { + if color.a() == 0 { + return; + } + let ppp = ctx.pixels_per_point(); + let px = ((rect.width().max(rect.height()) * ppp).round() as u32).clamp(8, 512); + let id = self.texture(ctx, name, px); + painter.image(id, rect, Rect::from_min_max(egui::pos2(0.0, 0.0), egui::pos2(1.0, 1.0)), color); + } + + pub fn paint_center(&mut self, ctx: &Context, painter: &Painter, center: egui::Pos2, size: f32, name: &str, color: Color32) { + self.paint(ctx, painter, Rect::from_center_size(center, egui::vec2(size, size)), name, color); + } +} diff --git a/src/ui/images.rs b/src/ui/images.rs new file mode 100644 index 0000000..44c1643 --- /dev/null +++ b/src/ui/images.rs @@ -0,0 +1,111 @@ +//! Pictures from the network or from files, decoded off the UI thread and uploaded as textures. + +use crate::core::{http, tagger}; +use eframe::egui::{self, Color32, TextureHandle, TextureId, TextureOptions}; +use image::RgbaImage; +use std::collections::HashMap; +use std::sync::mpsc::{channel, Receiver, Sender}; +use std::sync::{Arc, Mutex}; + +pub enum Source { + Url(String), + Bytes(Vec), + /// the cover embedded in an audio file + File(String), +} + +enum Entry { + Loading, + Ready { tex: TextureHandle, accent: Option, size: [u32; 2] }, + Failed, +} + +pub struct Images { + ctx: egui::Context, + cache: HashMap, + jobs: Sender<(String, Source, u32)>, + done: Receiver<(String, Option)>, +} + +fn decode(src: Source, max: u32) -> Option { + let bytes = match src { + Source::Url(u) => http::get_bytes(&u).ok()?, + Source::Bytes(b) => b, + Source::File(p) => tagger::read(&p, true).cover?, + }; + let img = image::load_from_memory(&bytes).ok()?; + let img = if img.width().max(img.height()) > max { img.resize(max, max, image::imageops::FilterType::Triangle) } else { img }; + Some(img.to_rgba8()) +} + +impl Images { + pub fn new(ctx: &egui::Context) -> Images { + let (jobs, rx) = channel::<(String, Source, u32)>(); + let (dtx, done) = channel(); + let rx = Arc::new(Mutex::new(rx)); + for _ in 0..4 { + let (rx, dtx, ctx) = (rx.clone(), dtx.clone(), ctx.clone()); + std::thread::spawn(move || loop { + let job = rx.lock().unwrap().recv(); + let Ok((key, src, max)) = job else { break }; + let _ = dtx.send((key, decode(src, max))); + ctx.request_repaint(); + }); + } + Images { ctx: ctx.clone(), cache: HashMap::new(), jobs, done } + } + + /// Call once per frame: uploads whatever finished decoding. + pub fn pump(&mut self) { + while let Ok((key, img)) = self.done.try_recv() { + let entry = match img { + Some(img) => { + let size = [img.width(), img.height()]; + let accent = super::theme::dominant_color(&img); + let ci = egui::ColorImage::from_rgba_unmultiplied([size[0] as usize, size[1] as usize], img.as_raw()); + Entry::Ready { tex: self.ctx.load_texture(format!("img-{key}"), ci, TextureOptions::LINEAR), accent, size } + } + None => Entry::Failed, + }; + self.cache.insert(key, entry); + } + } + + pub fn request(&mut self, key: &str, src: impl FnOnce() -> Source, max: u32) { + if !self.cache.contains_key(key) { + self.cache.insert(key.to_string(), Entry::Loading); + let _ = self.jobs.send((key.to_string(), src(), max)); + } + } + + /// A picture by URL (starts loading it on first use). + pub fn url(&mut self, url: &str, max: u32) -> Option<(TextureId, [u32; 2])> { + if url.is_empty() { + return None; + } + self.request(url, || Source::Url(url.to_string()), max); + self.get(url) + } + + pub fn get(&self, key: &str) -> Option<(TextureId, [u32; 2])> { + match self.cache.get(key) { + Some(Entry::Ready { tex, size, .. }) => Some((tex.id(), *size)), + _ => None, + } + } + + pub fn accent(&self, key: &str) -> Option { + match self.cache.get(key) { + Some(Entry::Ready { accent, .. }) => *accent, + _ => None, + } + } + + pub fn forget(&mut self, key: &str) { + self.cache.remove(key); + } + + pub fn loading(&self) -> bool { + self.cache.values().any(|e| matches!(e, Entry::Loading)) + } +} diff --git a/src/ui/mod.rs b/src/ui/mod.rs new file mode 100644 index 0000000..725811e --- /dev/null +++ b/src/ui/mod.rs @@ -0,0 +1,8 @@ +pub mod controls; +pub mod fonts; +pub mod gfx; +pub mod icons; +pub mod images; +pub mod pages; +pub mod theme; +pub mod widgets; diff --git a/src/ui/pages/download.rs b/src/ui/pages/download.rs new file mode 100644 index 0000000..4c5e9d3 --- /dev/null +++ b/src/ui/pages/download.rs @@ -0,0 +1,636 @@ +//! Paste a link (or search), preview what it is, pick quality and naming, download. + +use super::column; +use crate::app::*; +use crate::core::downloader::*; +use crate::core::models::*; +use crate::core::resolvers::{self, service_name, ARTIST_MODES}; +use crate::core::settings::Settings; +use crate::core::template::{self, TOKENS}; +use crate::core::textutil::format_duration; +use crate::core::{metadata, paths}; +use crate::ui::controls::*; +use crate::ui::gfx::*; +use crate::ui::theme::with_alpha; +use crate::ui::widgets::*; +use eframe::egui::{self, Align2, Color32, Pos2, Rect, RichText, Sense, Ui, Vec2}; + +pub const SHOWCASE: &[&str] = &["ytmusic", "youtube", "spotify", "soundcloud", "apple", "deezer", "bandcamp", "tidal", "amazon", "mixcloud", "audiomack"]; +const NEEDS_MATCH: &[&str] = &["spotify", "apple", "deezer", "tidal", "amazon", "qobuz", "napster", "pandora", "web"]; + +pub fn service_color(s: &str) -> Option { + let h = match s { + "spotify" => "#1DB954", + "youtube" | "ytmusic" => "#FF3B30", + "soundcloud" => "#FF5500", + "apple" => "#FA243C", + "deezer" => "#A238FF", + "bandcamp" => "#1DA0C3", + "tidal" => "#33C2D4", + "amazon" => "#25D1DA", + "mixcloud" => "#5000FF", + "audiomack" => "#FFA200", + _ => return None, + }; + crate::ui::theme::hex(h) +} + +pub struct State { + pub query: String, + pub token: u64, + pub busy: bool, + pub title: String, + pub detail: String, + pub error: Option, + pub result: Option, + pub checked: Vec, + pub tokens_open: bool, + pub folder: String, + pub focus_query: bool, + folder_rev: u64, +} + +impl State { + pub fn new(s: &Settings) -> State { + State { query: String::new(), token: 0, busy: false, title: String::new(), detail: String::new(), error: None, result: None, checked: vec![], tokens_open: false, folder: s.output_dir(), focus_query: false, folder_rev: s.revision } + } +} + +pub fn fetch(app: &mut App, mode: &str) { + let query = app.dl.query.trim().to_string(); + if query.is_empty() { + app.dl.focus_query = true; + return; + } + let mode = if mode == "discography" { "discography" } else { "top" }.to_string(); + app.dl.token += 1; + let token = app.dl.token; + app.dl.busy = true; + app.dl.error = None; + app.dl.title = if mode == "discography" { "Collecting the whole discography…".into() } else if resolvers::looks_like_url(&query) { "Looking that up…".into() } else { "Searching…".into() }; + app.dl.detail.clear(); + app.log(0, "info", &format!("Fetching {query}")); + let snap = app.settings.snapshot(); + let (tx, ctx) = (app.tx.clone(), app.ctx.clone()); + std::thread::spawn(move || { + let log = |k: &str, t: &str| { + if matches!(k, "info" | "meta" | "yt") { + let _ = tx.send(Ev::FetchInfo(token, t.to_string())); + } + let _ = tx.send(Ev::Log(token, k.to_string(), t.to_string())); + ctx.request_repaint(); + }; + let mut r = resolvers::resolve(&query, &snap, &log, &mode); + if let Ok(res) = &mut r { + if res.kind == "track" && crate::core::settings::get_bool(&snap, "metadata.enabled") { + log("info", "Looking up tags on Deezer and iTunes…"); + metadata::enrich(&mut res.tracks[0], &snap, &log); + } + } + let _ = tx.send(Ev::Resolved(token, r)); + ctx.request_repaint(); + }); +} + +pub fn resolved(app: &mut App, token: u64, r: Result) { + if token != app.dl.token { + return; + } + app.dl.busy = false; + match r { + Ok(res) => { + app.log(0, "success", &format!("Found {}: {} ({} track{})", res.kind, res.title, res.tracks.len(), if res.tracks.len() != 1 { "s" } else { "" })); + app.dl.checked = match res.kind.as_str() { + "search" => (0..res.tracks.len()).map(|i| i == 0).collect(), + _ => vec![true; res.tracks.len()], + }; + app.dl.result = Some(res); + } + Err(m) => { + app.log(0, "error", &m); + app.dl.error = Some(m); + app.dl.result = None; + } + } +} + +fn options(app: &App) -> DownloadOptions { + let s = &app.settings; + DownloadOptions { + output_dir: if app.dl.folder.trim().is_empty() { s.output_dir() } else { app.dl.folder.trim().to_string() }, + template: s.get_str("download.filename_template"), + format: s.get_str("download.format"), + bitrate: s.get_str("download.bitrate"), + sample_rate: s.get_str("download.sample_rate"), + bit_depth: s.get_str("download.bit_depth"), + lyrics: s.get_str("lyrics.embed"), + save_lrc: s.get_bool("lyrics.save_lrc"), + collection_folder: s.get_bool("download.collection_folder") && app.dl.result.as_ref().map(|r| r.kind == "collection").unwrap_or(false), + } +} + +fn selected(app: &App) -> Vec { + match &app.dl.result { + None => vec![], + Some(r) if r.kind == "track" => r.tracks.clone(), + Some(r) => r.tracks.iter().zip(&app.dl.checked).filter(|(_, c)| **c).map(|(t, _)| t.clone()).collect(), + } +} + +fn start_download(app: &mut App) { + let tracks = selected(app); + if tracks.is_empty() { + return; + } + let folder = std::path::PathBuf::from(paths::shellexpand(if app.dl.folder.trim().is_empty() { "" } else { app.dl.folder.trim() })); + let folder = if folder.as_os_str().is_empty() { std::path::PathBuf::from(app.settings.output_dir()) } else { folder }; + if let Err(e) = std::fs::create_dir_all(&folder) { + app.dl.error = Some(format!("Can't use {}: {e}", folder.display())); + return; + } + app.settings.set_str("download.output_dir", &folder.to_string_lossy()); + let opts = options(app); + let snap = app.settings.snapshot(); + let n = app.manager.enqueue(&tracks, &opts, &snap); + app.toast_action(format!("Added {n} song{} to Downloads", if n != 1 { "s" } else { "" }), "View", TAB_QUEUE); +} + +fn summary(app: &App) -> String { + let s = &app.settings; + let fmt = s.get_str("download.format"); + let q = quality_label(&fmt, &s.get_str("download.bitrate"), &s.get_str("download.sample_rate"), &s.get_str("download.bit_depth")); + let name = match fmt.as_str() { + "vorbis" => "OGG".to_string(), + "best" => "Original".to_string(), + f => f.to_uppercase(), + }; + let quality = if fmt == "best" { "Original quality".to_string() } else { format!("{name} {q}") }; + let Some(r) = &app.dl.result else { return quality }; + let n = selected(app).len(); + let what = if r.kind == "track" { "1 song".to_string() } else { format!("{n} of {} selected", r.tracks.len()) }; + let folder = std::path::Path::new(&app.dl.folder).file_name().map(|f| f.to_string_lossy().into_owned()).unwrap_or_else(|| "/".into()); + format!("{what} · {quality} · {folder}") +} + +pub fn draw(app: &mut App, ui: &mut Ui) { + if app.dl.folder_rev != app.settings.revision { + // the folder may have been changed in Settings + } + let t = app.g.theme.clone(); + // sticky action bar + egui::Panel::bottom("dl-actions").frame(egui::Frame::NONE.fill(t.surface).inner_margin(egui::Margin { left: 32, right: 32, top: 10, bottom: 14 })).show_separator_line(false).show(ui, |ui| { + column(ui, 1040.0, |ui| { + ui.horizontal(|ui| { + let s = summary(app); + ui.label(RichText::new(s).color(t.on_surface_variant).size(14.0)); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + let can = !selected(app).is_empty() && !app.dl.busy; + ui.add_enabled_ui(can, |ui| { + if fab(ui, &mut app.g, "download", "Download").clicked() { + start_download(app); + } + }); + }); + }); + }); + }); + egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| { + ui.add_space(14.0); + column(ui, 1040.0, |ui| { + ui.spacing_mut().item_spacing.y = 14.0; + ui.label(RichText::new("Download music").font(disp_semi(30.0)).color(t.on_surface)); + ui.label(RichText::new("Paste a link to a song, album or playlist from any music service — or just type what you want to hear.").color(t.on_surface_variant)); + search_bar(app, ui); + ui.horizontal_wrapped(|ui| { + ui.spacing_mut().item_spacing = Vec2::new(6.0, 6.0); + for s in SHOWCASE { + badge(ui, &mut app.g, Some(service_color(s).unwrap_or(t.primary)), None, &service_name(s)); + } + badge(ui, &mut app.g, Some(t.primary), None, "+ 1,800 more sites").on_hover_text("Anything yt-dlp supports downloads directly. Other music pages (Tidal, Amazon Music, Qobuz…) are read for the song's name and matched on YouTube Music."); + }); + if app.dl.busy { + loading_card(app, ui); + } else if let Some(e) = app.dl.error.clone() { + error_card(app, ui, &e); + } else if app.dl.result.is_some() { + result_card(app, ui); + } else { + empty_card(app, ui); + } + options_card(app, ui); + ui.add_space(10.0); + }); + }); +} + +fn search_bar(app: &mut App, ui: &mut Ui) { + let w = ui.available_width(); + let is_url = resolvers::looks_like_url(&app.dl.query) || app.dl.query.trim().is_empty(); + ui.horizontal(|ui| { + let tr: Vec<(&str, &str)> = if app.dl.query.is_empty() { vec![("content_paste", "Paste from clipboard and fetch")] } else { vec![("close", "Clear"), ("content_paste", "Paste from clipboard and fetch")] }; + let (resp, clicked) = { + let g = &mut app.g; + field(ui, g, "", &mut app.dl.query, w - 130.0, "Paste a link, or search for a song…", &tr) + }; + if app.dl.focus_query { + resp.request_focus(); + app.dl.focus_query = false; + } + match clicked.map(|i| tr[i].0) { + Some("close") => { + app.dl.query.clear(); + resp.request_focus(); + } + Some("content_paste") => { + if let Ok(mut cb) = clipboard_text() { + cb = cb.trim().to_string(); + if !cb.is_empty() { + app.dl.query = cb; + fetch(app, "top"); + } + } + } + _ => {} + } + let enter = resp.lost_focus() && ui.input(|i| i.key_pressed(egui::Key::Enter)); + ui.add_enabled_ui(!app.dl.busy, |ui| { + let go = button(ui, &mut app.g, Some(if is_url { "arrow_forward" } else { "search" }), if is_url { "Fetch" } else { "Search" }, Kind::Filled).clicked(); + if go || enter { + fetch(app, "top"); + } + }); + }); +} + +fn clipboard_text() -> Result { + for (cmd, args) in [("wl-paste", vec!["-n"]), ("xclip", vec!["-selection", "clipboard", "-o"]), ("xsel", vec!["-b"])] { + if let Ok(o) = std::process::Command::new(cmd).args(&args).output() { + if o.status.success() { + return Ok(String::from_utf8_lossy(&o.stdout).into_owned()); + } + } + } + Err(()) +} + +fn card_frame(g: &Gfx, low: bool) -> egui::Frame { + egui::Frame::NONE.fill(if low { g.theme.surface_container_low } else { g.theme.surface_container }).corner_radius(cr(24.0)).inner_margin(egui::Margin::symmetric(24, 22)) +} + +fn empty_card(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + card_frame(&app.g, true).show(ui, |ui| { + ui.set_width(ui.available_width()); + ui.vertical_centered(|ui| { + ui.add_space(10.0); + icon_badge(ui, &mut app.g, "library_music", 72.0, false); + ui.add_space(6.0); + ui.label(RichText::new("Ready when you are").font(disp_semi(22.0)).color(t.on_surface)); + ui.label(RichText::new("Try a Spotify playlist, a YouTube Music album, a SoundCloud set — or type “artist - song”.").color(t.on_surface_variant)); + ui.label(RichText::new("You can also paste a link anywhere in this window with Ctrl+V.").color(t.on_surface_variant)); + ui.add_space(10.0); + }); + }); +} + +fn loading_card(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + let mut cancel = false; + card_frame(&app.g, true).show(ui, |ui| { + ui.set_width(ui.available_width()); + ui.vertical_centered(|ui| { + ui.add_space(10.0); + loading(ui, &app.g, 76.0); + ui.label(RichText::new(&app.dl.title).font(disp_semi(19.0)).color(t.on_surface)); + ui.label(RichText::new(&app.dl.detail).size(13.0).color(t.on_surface_variant)); + cancel = button(ui, &mut app.g, None, "Cancel", Kind::Text).clicked(); + ui.add_space(6.0); + }); + }); + if cancel { + app.dl.token += 1; + app.dl.busy = false; + } +} + +fn error_card(app: &mut App, ui: &mut Ui, msg: &str) { + let t = app.g.theme.clone(); + let mut retry = false; + card_frame(&app.g, true).show(ui, |ui| { + ui.set_width(ui.available_width()); + ui.vertical_centered(|ui| { + ui.add_space(10.0); + icon_badge(ui, &mut app.g, "error", 64.0, true); + ui.label(RichText::new("That didn't work").font(disp_semi(22.0)).color(t.on_surface)); + ui.label(RichText::new(msg).color(t.on_surface_variant)); + retry = button(ui, &mut app.g, Some("refresh"), "Try again", Kind::Tonal).clicked(); + ui.add_space(6.0); + }); + }); + if retry { + fetch(app, "top"); + } +} + +fn result_card(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + let r = app.dl.result.clone().unwrap(); + let mut refetch: Option<&str> = None; + let mut edit: Option> = None; + let mut select_all: Option = None; + card_frame(&app.g, false).show(ui, |ui| { + ui.set_width(ui.available_width()); + ui.horizontal_top(|ui| { + // cover + let cover_url = if r.kind == "track" { Some(r.tracks[0].cover_url.clone()).filter(|u| !u.is_empty()).unwrap_or_else(|| r.cover_url.clone()) } else if !r.cover_url.is_empty() { r.cover_url.clone() } else { r.tracks.first().map(|t| t.cover_url.clone()).unwrap_or_default() }; + let tex = if r.kind == "track" && r.tracks[0].cover_override.is_some() { + let key = format!("override:{}", r.tracks[0].uid); + app.images.request(&key, || crate::ui::images::Source::Bytes(r.tracks[0].cover_override.clone().unwrap()), 600); + app.images.get(&key) + } else { + app.images.url(&cover_url, 600) + }; + cover(ui, &mut app.g, tex, 148.0, 20.0); + ui.vertical(|ui| { + ui.set_width((ui.available_width() - 190.0).max(200.0)); + ui.spacing_mut().item_spacing.y = 6.0; + ui.horizontal(|ui| { + let svc = if r.service == "search" { "ytmusic".to_string() } else { r.service.clone() }; + badge(ui, &mut app.g, Some(service_color(&svc).unwrap_or(t.primary)), None, &if r.kind == "search" { "Search · YouTube Music".to_string() } else { service_name(&svc) }); + let kind = match r.kind.as_str() { + "track" => "Song".to_string(), + "search" => "Results".to_string(), + _ => r.subtitle.split(" · ").next().filter(|s| !s.is_empty()).unwrap_or("Collection").to_string(), + }; + badge(ui, &mut app.g, None, Some(if r.artist { "person" } else if r.kind == "collection" { "album" } else { "music_note" }), if r.artist { "Artist" } else { &kind }); + }); + let (title, sub, meta) = if r.kind == "track" { + let tr = &r.tracks[0]; + let meta: Vec = [tr.value("album"), tr.value("year"), tr.duration.map(|d| format_duration(Some(d))).unwrap_or_default()].into_iter().filter(|s| !s.is_empty()).collect(); + (tr.display_title(), if tr.display_artist().is_empty() { "Unknown artist".into() } else { tr.display_artist() }, meta.join(" · ")) + } else { + let owner = r.subtitle.split_once(" · ").map(|x| x.1.to_string()).unwrap_or_else(|| r.subtitle.clone()); + let total: f64 = r.tracks.iter().filter_map(|t| t.duration).sum(); + let mut meta = format!("{} tracks", r.tracks.len()); + if total > 0.0 { + meta += &format!(" · {}", format_duration(Some(total))); + } + if NEEDS_MATCH.contains(&r.service.as_str()) { + meta += &format!(" · matched on {} when downloading", service_name(&app.settings.get_str("download.search_source"))); + } + (r.title.clone(), owner, meta) + }; + ui.label(RichText::new(title).font(disp_semi(26.0)).color(t.on_surface)); + ui.label(RichText::new(sub).font(disp(17.0)).color(t.on_surface_variant)); + ui.label(RichText::new(meta).color(t.on_surface_variant).size(13.5)); + if !r.note.is_empty() { + ui.label(RichText::new(format!("ⓘ {}", r.note)).size(13.0).color(t.tertiary)); + } + }); + ui.with_layout(egui::Layout::top_down(egui::Align::Max), |ui| { + if r.kind == "track" { + if button(ui, &mut app.g, Some("edit"), "Edit tags", Kind::Tonal).clicked() { + edit = Some(None); + } + } else { + if r.artist { + ui.horizontal(|ui| { + for (key, text) in ARTIST_MODES { + if chip(ui, &mut app.g, None, text, r.mode == *key).clicked() && r.mode != *key { + refetch = Some(key); + } + } + }); + } + if button_h(ui, &mut app.g, Some("select_all"), "Select all", Kind::Tonal, 34.0).clicked() { + select_all = Some(true); + } + if button_h(ui, &mut app.g, Some("deselect"), "Select none", Kind::Text, 34.0).clicked() { + select_all = Some(false); + } + } + }); + }); + if r.kind == "track" { + let tr = &r.tracks[0]; + let mut rows: Vec<(String, String)> = vec![]; + for (key, name) in [("album_artist", "Album artist"), ("track_number", "Track"), ("disc_number", "Disc"), ("genre", "Genre"), ("isrc", "ISRC")] { + let v = tr.value(key); + if !v.is_empty() { + rows.push((name.into(), v)); + } + } + ui.add_space(4.0); + ui.horizontal_wrapped(|ui| { + for (k, v) in rows { + ui.label(RichText::new(k).size(13.0).color(t.on_surface_variant)); + ui.label(RichText::new(v).size(13.0).color(t.on_surface)); + ui.add_space(10.0); + } + if NEEDS_MATCH.contains(&tr.service.as_str()) || tr.download_url.is_empty() { + ui.label(RichText::new(format!("Audio comes from the best match on {}", service_name(&app.settings.get_str("download.search_source")))).size(13.0).color(t.tertiary)); + } + if !tr.overrides.is_empty() { + ui.label(RichText::new("✎ Edited by you").size(13.0).color(t.primary)); + } + }); + } else { + ui.add_space(6.0); + track_list(app, ui, &r, &mut edit); + } + }); + if let Some(a) = select_all { + app.dl.checked = vec![a; r.tracks.len()]; + } + if let Some(m) = refetch { + fetch(app, m); + } + if let Some(row) = edit { + app.editor = Some(crate::ui::pages::editor::Editor::for_track(app.dl.result.as_ref().unwrap(), row)); + } +} + +fn track_list(app: &mut App, ui: &mut Ui, r: &ResolveResult, edit: &mut Option>) { + let t = app.g.theme.clone(); + let rows = r.tracks.len(); + let h = ((rows as f32) * 60.0).min(460.0); + egui::ScrollArea::vertical().id_salt("tracklist").max_height(h).auto_shrink([false, true]).show_rows(ui, 60.0, rows, |ui, range| { + for i in range { + let tr = &r.tracks[i]; + let (rect, resp) = ui.allocate_exact_size(Vec2::new(ui.available_width(), 60.0), Sense::click()); + let inner = rect.shrink2(Vec2::new(4.0, 2.0)); + let hover = resp.hovered(); + let checked = app.dl.checked.get(i).copied().unwrap_or(true); + let p = ui.painter().clone(); + if hover { + p.rect_filled(inner, cr(14.0), with_alpha(t.on_surface, 0.06)); + } + let cb = Rect::from_center_size(Pos2::new(inner.left() + 24.0, inner.center().y), Vec2::splat(18.0)); + if checked { + p.rect_filled(cb, cr(4.0), t.primary); + app.g.icon(&p, cb.shrink(1.0), "check", t.on_primary); + } else { + p.rect_stroke(cb.shrink(1.0), cr(3.0), egui::Stroke::new(2.0, t.on_surface_variant), egui::StrokeKind::Inside); + } + let num = tr.playlist_index.unwrap_or(i as i64 + 1).to_string(); + p.text(Pos2::new(inner.left() + 70.0, inner.center().y), Align2::RIGHT_CENTER, num, font_semi(13.0), t.on_surface_variant); + let mut x = inner.left() + 84.0; + if !tr.cover_url.is_empty() { + let cr_ = Rect::from_min_size(Pos2::new(x, inner.center().y - 20.0), Vec2::splat(40.0)); + let tex = app.images.url(&tr.cover_url, 120); + paint_cover(ui, &mut app.g, cr_, tex, 8.0); + x += 52.0; + } + let right = inner.right() - if hover { 48.0 } else { 12.0 }; + p.text(Pos2::new(right, inner.center().y), Align2::RIGHT_CENTER, tr.duration.map(|d| format_duration(Some(d))).unwrap_or_default(), font(13.0), t.on_surface_variant); + let tw = right - 72.0 - x; + text_elided(&p, Pos2::new(x, inner.top() + 20.0), Align2::LEFT_CENTER, &tr.display_title(), font_semi(14.0), if checked { t.on_surface } else { t.on_surface_variant }, tw); + let mut sub = [tr.display_artist(), tr.value("album")].into_iter().filter(|s| !s.is_empty()).collect::>().join(" · "); + if !tr.overrides.is_empty() { + sub = format!("✎ {sub}"); + } + text_elided(&p, Pos2::new(x, inner.top() + 40.0), Align2::LEFT_CENTER, &sub, font(13.0), t.on_surface_variant, tw); + let er = Rect::from_center_size(Pos2::new(inner.right() - 28.0, inner.center().y), Vec2::splat(34.0)); + let mut on_edit = false; + if hover { + p.circle_filled(er.center(), 17.0, t.secondary_container); + app.g.icon(&p, Rect::from_center_size(er.center(), Vec2::splat(18.0)), "edit", t.on_secondary_container); + on_edit = ui.input(|i| i.pointer.hover_pos()).map(|pos| er.contains(pos)).unwrap_or(false); + } + if resp.clicked() { + if on_edit { + *edit = Some(Some(i)); + } else if let Some(c) = app.dl.checked.get_mut(i) { + *c = !*c; + } + } + if resp.double_clicked() { + *edit = Some(Some(i)); + } + if hover { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + } + }); +} + +fn options_card(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + card_frame(&app.g, false).show(ui, |ui| { + ui.set_width(ui.available_width()); + ui.spacing_mut().item_spacing.y = 14.0; + ui.label(RichText::new("Quality & output").font(disp_semi(19.0)).color(t.on_surface)); + quality_controls(app, ui, true); + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = 22.0; + for (text, key) in [("Save .lrc file", "lyrics.save_lrc"), ("Embed cover art", "metadata.embed_cover"), ("Album & playlist folders", "download.collection_folder")] { + let mut on = app.settings.get_bool(key); + ui.horizontal(|ui| { + if switch(ui, &app.g, &mut on) { + app.settings.set_bool(key, on); + } + ui.label(text); + }); + } + }); + template_field(app, ui); + let w = ui.available_width(); + let (_, clicked) = field(ui, &mut app.g, "Save to", &mut app.dl.folder, w, "", &[("folder_open", "Choose folder"), ("open_in_new", "Open folder")]); + match clicked { + Some(0) => { + if let Some(p) = rfd::FileDialog::new().set_directory(&app.dl.folder).set_title("Download folder").pick_folder() { + app.dl.folder = p.to_string_lossy().into_owned(); + app.settings.set_str("download.output_dir", &app.dl.folder.clone()); + } + } + Some(_) => { + let _ = std::process::Command::new("xdg-open").arg(&app.dl.folder).spawn(); + } + None => {} + } + let f = app.dl.folder.trim().to_string(); + if f != app.settings.get_str("download.output_dir") && !f.is_empty() && !ui.memory(|m| m.focused().is_some()) { + app.settings.set_str("download.output_dir", &f); + } + }); +} + +/// Format / quality / bit depth / sample rate (and lyrics) dropdowns bound to the download settings. +pub fn quality_controls(app: &mut App, ui: &mut Ui, with_lyrics: bool) { + let fmt = app.settings.get_str("download.format"); + let rates = bitrates_for(&fmt); + let lossless = LOSSLESS.contains(&fmt.as_str()); + // keep the bitrate valid for the format + if !rates.is_empty() && !rates.iter().any(|r| r.0 == app.settings.get_str("download.bitrate")) { + app.settings.set_str("download.bitrate", rates[0].0); + } + let w = ((ui.available_width() - 12.0 * 4.0) / if with_lyrics { 5.0 } else { 4.0 }).clamp(120.0, 240.0); + ui.horizontal_wrapped(|ui| { + ui.spacing_mut().item_spacing = Vec2::new(12.0, 10.0); + let mut pick = |ui: &mut Ui, app: &mut App, id: &str, label: &str, key: &str, list: &[(&str, &str)]| { + let cur = app.settings.get_str(key); + ui.vertical(|ui| { + if let Some(v) = dropdown(ui, &mut app.g, ui.id().with(id), label, &cur, &items(list), w) { + app.settings.set_str(key, &v); + } + }); + }; + let formats: Vec<(&str, &str)> = FORMATS.iter().map(|f| (f.0, f.1)).collect(); + pick(ui, app, "fmt", "Format", "download.format", &formats); + if !rates.is_empty() { + pick(ui, app, "br", "Quality", "download.bitrate", rates); + } + if lossless { + pick(ui, app, "bd", "Bit depth", "download.bit_depth", BIT_DEPTHS); + } + if fmt != "best" { + pick(ui, app, "sr", "Sample rate", "download.sample_rate", SAMPLE_RATES); + } + if with_lyrics { + pick(ui, app, "lyr", "Lyrics", "lyrics.embed", &[("synced", "Synced (LRC timing)"), ("plain", "Plain text"), ("off", "Don't embed")]); + } + }); +} + +pub fn template_field(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + let mut tpl = app.settings.get_str("download.filename_template"); + let w = ui.available_width(); + let (_, clicked) = field(ui, &mut app.g, "File name", &mut tpl, w, "{artist} - {title}", &[("help", "What can I put here?")]); + if tpl != app.settings.get_str("download.filename_template") { + app.settings.set_str("download.filename_template", &tpl); + } + if clicked.is_some() { + app.dl.tokens_open = !app.dl.tokens_open; + } + // live preview with the first selected song (or a sample) + let sample = selected(app).into_iter().next().unwrap_or_else(template::sample_track); + let fmt = app.settings.get_str("download.format"); + let q = quality_label(&fmt, &app.settings.get_str("download.bitrate"), &app.settings.get_str("download.sample_rate"), &app.settings.get_str("download.bit_depth")); + let ext = format_ext(&fmt).unwrap_or("m4a"); + if let Some(err) = template::validate(&tpl) { + ui.label(RichText::new(err).size(13.0).color(t.error)); + } else { + let sep = Some(app.settings.get_str("download.artist_separator")).filter(|s| !s.is_empty()).unwrap_or_else(|| ", ".into()); + let path = template::render(&tpl, &template::track_values(&sample, ext, &q, &sep)); + ui.label(RichText::new(format!("→ {path}.{ext}")).size(13.0).color(t.on_surface_variant)); + } + if app.dl.tokens_open { + egui::Frame::NONE.fill(t.surface_container_high).corner_radius(cr(16.0)).inner_margin(egui::Margin::same(14)).show(ui, |ui| { + ui.label(RichText::new("Click a token to add it. “/” makes folders; {track:02} pads numbers; {album|Singles} gives a fallback.").size(13.0).color(t.on_surface_variant)); + ui.add_space(4.0); + ui.horizontal_wrapped(|ui| { + for (name, desc, ex) in TOKENS { + if chip(ui, &mut app.g, None, &format!("{{{name}}}"), false).on_hover_text(format!("{desc} (e.g. {ex})")).clicked() { + let cur = app.settings.get_str("download.filename_template"); + app.settings.set_str("download.filename_template", &format!("{cur}{{{name}}}")); + } + } + }); + }); + } +} + +pub fn start_download_pub(app: &mut App) { + start_download(app); +} diff --git a/src/ui/pages/editor.rs b/src/ui/pages/editor.rs new file mode 100644 index 0000000..0a3e0db --- /dev/null +++ b/src/ui/pages/editor.rs @@ -0,0 +1,429 @@ +//! The tag editor: edits a song in the download list (applied when it downloads) or a file on disk. + +use crate::app::*; +use crate::core::lyrics::{self, Lyrics}; +use crate::core::metadata::{self, provider_name, Candidate}; +use crate::core::models::{ResolveResult, Track}; +use crate::core::settings::{get_i64, lookup}; +use crate::core::{covers, tagger}; +use crate::ui::controls::*; +use crate::ui::gfx::*; +use crate::ui::images::{Images, Source}; +use crate::ui::widgets::*; +use eframe::egui::{self, Color32, RichText, Vec2}; +use std::collections::{BTreeMap, HashMap}; + +const FIELDS: &[(&str, &str)] = &[ + ("title", "Title"), ("artist", "Artist"), ("album_artist", "Album artist"), ("album", "Album"), ("track_number", "Track"), + ("track_total", "Of"), ("disc_number", "Disc"), ("year", "Year"), ("genre", "Genre"), ("isrc", "ISRC"), ("comment", "Comment"), +]; + +pub enum Target { + Track(usize), + File(String), +} + +pub struct Editor { + pub target: Target, + pub values: Vec, + pub cover: Option>, + cover_changed: bool, + cover_removed: bool, + cover_key: String, + cover_url: String, + pub lyrics: String, + pub lyrics_touched: bool, + pub lyrics_state: String, + pub lyrics_busy: bool, + pub candidates: Option>>, + pub lookup_busy: bool, + pub error: String, + duration: Option, + subtitle: String, +} + +impl Editor { + pub fn for_track(result: &ResolveResult, row: Option) -> Editor { + let idx = row.unwrap_or(0); + let t: &Track = &result.tracks[idx]; + let values = FIELDS.iter().map(|(k, _)| t.value(k)).collect(); + Editor { + target: Target::Track(idx), + values, + cover: t.cover_override.clone(), + cover_changed: false, + cover_removed: false, + cover_key: format!("editor:{}", t.uid), + cover_url: if t.cover_url.is_empty() { result.cover_url.clone() } else { t.cover_url.clone() }, + lyrics: t.lyrics_override.clone().unwrap_or_default(), + lyrics_touched: false, + lyrics_state: String::new(), + lyrics_busy: false, + candidates: None, + lookup_busy: false, + error: String::new(), + duration: t.duration, + subtitle: "These tags are written when the download finishes".into(), + } + } + + pub fn for_file(path: &str) -> Editor { + let t = tagger::read(path, true); + let n = |v: Option| v.map(|x| x.to_string()).unwrap_or_default(); + let values = FIELDS + .iter() + .map(|(k, _)| match *k { + "title" => t.title.clone(), + "artist" => t.artist.clone(), + "album_artist" => t.album_artist.clone(), + "album" => t.album.clone(), + "track_number" => n(t.track_number), + "track_total" => n(t.track_total), + "disc_number" => n(t.disc_number), + "year" => t.year.clone(), + "genre" => t.genre.clone(), + "isrc" => t.isrc.clone(), + _ => t.comment.clone(), + }) + .collect(); + Editor { + target: Target::File(path.into()), + values, + cover: t.cover.clone(), + cover_changed: false, + cover_removed: false, + cover_key: format!("editor-file:{path}"), + cover_url: String::new(), + lyrics: t.lyrics.clone(), + lyrics_touched: false, + lyrics_state: String::new(), + lyrics_busy: false, + candidates: None, + lookup_busy: false, + error: String::new(), + duration: t.duration, + subtitle: std::path::Path::new(path).file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(), + } + } + + pub fn set_cover(&mut self, images: &mut Images, bytes: Vec, changed: bool) { + images.forget(&self.cover_key); + let b = bytes.clone(); + images.request(&self.cover_key, move || Source::Bytes(b), 600); + self.cover = Some(bytes); + if changed { + self.cover_changed = true; + self.cover_removed = false; + } + } + + fn get(&self, key: &str) -> String { + FIELDS.iter().position(|f| f.0 == key).map(|i| self.values[i].trim().to_string()).unwrap_or_default() + } + fn put(&mut self, key: &str, v: String) { + if let Some(i) = FIELDS.iter().position(|f| f.0 == key) { + self.values[i] = v; + } + } +} + +enum Out { + None, + Close, + Save, + Lookup, + FetchLyrics, + PickCover, + RemoveCover, + Use(Candidate), +} + +pub fn show(app: &mut App, ctx: &egui::Context) { + let Some(mut ed) = app.editor.take() else { return }; + // first frame: make sure the cover has a texture + if ed.cover.is_some() && app.images.get(&ed.cover_key).is_none() { + let b = ed.cover.clone().unwrap(); + app.images.request(&ed.cover_key, move || Source::Bytes(b), 600); + } + let tex = if ed.cover.is_some() { app.images.get(&ed.cover_key) } else if ed.cover_removed { None } else { app.images.url(&ed.cover_url, 600) }; + let t = app.g.theme.clone(); + let mut out = Out::None; + let fr = egui::Frame::NONE.fill(t.surface_container_high).corner_radius(cr(28.0)).inner_margin(egui::Margin::symmetric(28, 24)); + let avail = ctx.content_rect(); + egui::Modal::new(egui::Id::new("tag-editor")).frame(fr).backdrop_color(Color32::from_black_alpha(130)).show(ctx, |ui| { + let w = (avail.width() - 80.0).min(820.0); + ui.set_width(w); + ui.spacing_mut().item_spacing = Vec2::new(12.0, 12.0); + ui.label(RichText::new("Edit tags").font(disp_semi(26.0)).color(t.on_surface)); + ui.label(RichText::new(&ed.subtitle).color(t.on_surface_variant).size(13.5)); + egui::ScrollArea::vertical().max_height((avail.height() - 260.0).max(300.0)).auto_shrink([false, true]).show(ui, |ui| { + ui.horizontal_top(|ui| { + ui.spacing_mut().item_spacing.x = 24.0; + ui.vertical(|ui| { + ui.set_width(200.0); + cover(ui, &mut app.g, tex, 200.0, 20.0); + ui.horizontal(|ui| { + if button_h(ui, &mut app.g, Some("image"), "Change", Kind::Tonal, 34.0).clicked() { + out = Out::PickCover; + } + if button_h(ui, &mut app.g, Some("hide_image"), "", Kind::Text, 34.0).on_hover_text("Remove cover").clicked() { + out = Out::RemoveCover; + } + }); + ui.add_enabled_ui(!ed.lookup_busy, |ui| { + if button_h(ui, &mut app.g, Some("travel_explore"), if ed.lookup_busy { "Searching…" } else { "Look up online" }, Kind::Outlined, 36.0).clicked() { + out = Out::Lookup; + } + }); + }); + ui.vertical(|ui| { + let fw = ui.available_width(); + let half = (fw - 12.0) / 2.0; + let quarter = (fw - 36.0) / 4.0; + let g = &mut app.g; + let mut f = |ui: &mut egui::Ui, i: usize, w: f32| { + ui.vertical(|ui| { + field(ui, g, FIELDS[i].1, &mut ed.values[i], w, "", &[]); + }); + }; + ui.horizontal(|ui| f(ui, 0, fw)); + ui.horizontal(|ui| { + f(ui, 1, half); + f(ui, 2, half); + }); + ui.horizontal(|ui| f(ui, 3, fw)); + ui.horizontal(|ui| { + f(ui, 4, quarter); + f(ui, 5, quarter); + f(ui, 6, quarter); + f(ui, 7, quarter); + }); + ui.horizontal(|ui| { + f(ui, 8, half); + f(ui, 9, half); + }); + ui.horizontal(|ui| f(ui, 10, fw)); + }); + }); + if let Some(c) = &ed.candidates { + let mut cands: Vec<&Candidate> = c.values().flat_map(|v| v.iter().take(4)).collect(); + cands.sort_by(|a, b| b.score.partial_cmp(&a.score).unwrap_or(std::cmp::Ordering::Equal)); + cands.truncate(8); + egui::Frame::NONE.fill(t.surface_container_highest).corner_radius(cr(16.0)).inner_margin(egui::Margin::same(14)).show(ui, |ui| { + ui.set_width(ui.available_width()); + ui.label(RichText::new(if cands.is_empty() { "No matches found" } else { "Matches" }).font(font_semi(15.0)).color(t.on_surface)); + for cand in cands { + ui.horizontal(|ui| { + ui.vertical(|ui| { + ui.set_width(ui.available_width() - 80.0); + ui.label(RichText::new(format!("{} – {}", cand.artist(), cand.title)).font(font_semi(14.0)).color(t.on_surface)); + let mut sub = cand.album.clone(); + if !cand.year.is_empty() { + sub += &format!(" · {}", cand.year); + } + sub += &format!(" · {} · {:.0}% match", provider_name(&cand.provider), cand.score * 100.0); + ui.label(RichText::new(sub).size(12.5).color(t.on_surface_variant)); + }); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + if button_h(ui, &mut app.g, None, "Use", Kind::Tonal, 30.0).clicked() { + out = Out::Use(cand.clone()); + } + }); + }); + } + }); + } + ui.separator(); + ui.horizontal(|ui| { + ui.label(RichText::new("Lyrics").font(disp_semi(19.0)).color(t.on_surface)); + let state = if !ed.lyrics_state.is_empty() { ed.lyrics_state.clone() } else if ed.lyrics.trim().is_empty() { if matches!(ed.target, Target::File(_)) { "None yet".into() } else { "Fetched automatically unless you add some".into() } } else if lyrics::is_synced(&ed.lyrics) { "Synced (LRC)".into() } else { "Plain text".into() }; + ui.label(RichText::new(state).size(12.5).color(t.on_surface_variant)); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + ui.add_enabled_ui(!ed.lyrics_busy, |ui| { + if button_h(ui, &mut app.g, Some("lyrics"), "Fetch from LRCLIB", Kind::Tonal, 34.0).clicked() { + out = Out::FetchLyrics; + } + }); + if ed.lyrics_busy { + spinner(ui, &app.g, 22.0); + } + }); + }); + let before = ed.lyrics.clone(); + let w = ui.available_width(); + text_area(ui, &app.g, &mut ed.lyrics, w, 8); + if ed.lyrics != before { + ed.lyrics_touched = true; + ed.lyrics_state.clear(); + } + }); + ui.horizontal(|ui| { + ui.label(RichText::new(&ed.error).color(t.error)); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + if button(ui, &mut app.g, Some("check"), "Save", Kind::Filled).clicked() { + out = Out::Save; + } + if button(ui, &mut app.g, None, "Cancel", Kind::Text).clicked() { + out = Out::Close; + } + }); + }); + }); + if ctx.input(|i| i.key_pressed(egui::Key::Escape)) && matches!(out, Out::None) { + out = Out::Close; + } + match out { + Out::None => app.editor = Some(ed), + Out::Close => {} + Out::PickCover => { + if let Some(p) = rfd::FileDialog::new().add_filter("Images", &["jpg", "jpeg", "png", "webp", "bmp"]).set_title("Choose cover art").pick_file() { + if let Ok(data) = std::fs::read(&p) { + let size = get_i64(&app.settings.snapshot(), "metadata.cover_size").max(300) as u32; + match covers::process(&data, size, false) { + Some((jpg, _)) => ed.set_cover(&mut app.images, jpg, true), + None => ed.error = "That file isn't a picture Audiphi can read".into(), + } + } + } + app.editor = Some(ed); + } + Out::RemoveCover => { + ed.cover = None; + ed.cover_changed = true; + ed.cover_removed = true; + ed.cover_url.clear(); + app.images.forget(&ed.cover_key); + app.editor = Some(ed); + } + Out::Lookup => { + ed.lookup_busy = true; + ed.error.clear(); + let snap = app.settings.snapshot(); + let mut providers: Vec = lookup(&snap, "metadata.providers").and_then(|v| v.as_object()).map(|o| o.iter().filter(|(_, v)| v.as_bool().unwrap_or(false)).map(|(k, _)| k.clone()).collect()).unwrap_or_default(); + if providers.is_empty() { + providers = vec!["deezer".into(), "itunes".into()]; + } + let mut tr = Track::new(); + tr.title = ed.get("title"); + tr.artists = Some(ed.get("artist")).filter(|a| !a.is_empty()).into_iter().collect(); + tr.album = ed.get("album"); + tr.duration = ed.duration; + let size = get_i64(&snap, "metadata.cover_size").max(300); + app.spawn(move || Ok::<_, String>(metadata::search_all(&tr, &providers, size, &|_, _| {})), Ev::Candidates); + app.editor = Some(ed); + } + Out::Use(c) => { + for (k, v) in [("title", c.title.clone()), ("album", c.album.clone()), ("album_artist", c.album_artist.clone()), ("genre", c.genre.clone()), ("isrc", c.isrc.clone()), ("year", c.year.clone())] { + if !v.is_empty() { + ed.put(k, v); + } + } + if !c.artists.is_empty() { + ed.put("artist", c.artist()); + } + for (k, v) in [("track_number", c.track_number), ("track_total", c.track_total), ("disc_number", c.disc_number)] { + if let Some(n) = v.filter(|n| *n > 0) { + ed.put(k, n.to_string()); + } + } + if !c.cover_url.is_empty() { + let (url, size) = (c.cover_url.clone(), get_i64(&app.settings.snapshot(), "metadata.cover_size").max(300) as u32); + app.spawn(move || covers::fetch(&url).and_then(|d| covers::process(&d, size, true)).map(|r| r.0), Ev::EditorCover); + } + ed.candidates = None; + app.editor = Some(ed); + } + Out::FetchLyrics => { + ed.lyrics_busy = true; + ed.lyrics_state.clear(); + let (title, artist, album, dur) = (ed.get("title"), ed.get("artist"), ed.get("album"), ed.duration); + app.spawn(move || lyrics::fetch(&title, &artist, &album, dur), |r: Result| Ev::EditorLyrics(r)); + app.editor = Some(ed); + } + Out::Save => { + for k in ["track_number", "track_total", "disc_number"] { + let v = ed.get(k); + if !v.is_empty() && !v.chars().all(|c| c.is_ascii_digit()) { + ed.error = format!("{} must be a number", FIELDS.iter().find(|f| f.0 == k).map(|f| f.1).unwrap_or(k)); + app.editor = Some(ed); + return; + } + } + match save(app, &ed) { + Ok(()) => {} + Err(e) => { + ed.error = format!("Couldn't save: {e}"); + app.editor = Some(ed); + } + } + } + } +} + +fn save(app: &mut App, ed: &Editor) -> Result<(), String> { + let values: HashMap<&str, String> = FIELDS.iter().map(|(k, _)| (*k, ed.get(k))).collect(); + match &ed.target { + Target::Track(idx) => { + let Some(res) = &mut app.dl.result else { return Ok(()) }; + let Some(t) = res.tracks.get_mut(*idx) else { return Ok(()) }; + for (k, v) in &values { + let original = match *k { + "artist" => t.artist(), + "track_number" => t.track_number.map(|n| n.to_string()).unwrap_or_default(), + "track_total" => t.track_total.map(|n| n.to_string()).unwrap_or_default(), + "disc_number" => t.disc_number.map(|n| n.to_string()).unwrap_or_default(), + "title" => t.title.clone(), + "album" => t.album.clone(), + "album_artist" => t.album_artist.clone(), + "year" => t.year.clone(), + "genre" => t.genre.clone(), + "isrc" => t.isrc.clone(), + _ => t.comment.clone(), + }; + if original != *v { + t.overrides.insert(k.to_string(), v.clone()); + } else { + t.overrides.remove(*k); + } + } + if ed.cover_changed { + t.cover_override = ed.cover.clone(); + t.skip_fields.retain(|f| f != "cover"); + if ed.cover_removed { + t.skip_fields.push("cover".into()); + } + app.images.forget(&format!("override:{}", t.uid)); + } + if ed.lyrics_touched { + let text = ed.lyrics.trim().to_string(); + t.lyrics_override = Some(text).filter(|s| !s.is_empty()); + } + Ok(()) + } + Target::File(path) => { + let old = tagger::read(path, true); + let num = |k: &str| values[k].parse::().ok(); + let lyrics_text = ed.lyrics.trim().to_string(); + let tags = tagger::Tags { + title: values["title"].clone(), artist: values["artist"].clone(), album: values["album"].clone(), album_artist: values["album_artist"].clone(), + track_number: num("track_number"), track_total: num("track_total"), disc_number: num("disc_number"), year: values["year"].clone(), + genre: values["genre"].clone(), isrc: values["isrc"].clone(), comment: values["comment"].clone(), lyrics: lyrics_text.clone(), + cover: if ed.cover_changed { ed.cover.clone() } else { old.cover }, + ..Default::default() + }; + tagger::write(path, &tags, if lyrics::is_synced(&lyrics_text) { "synced" } else { "plain" })?; + let lrc = std::path::Path::new(path).with_extension("lrc"); + if lrc.is_file() && ed.lyrics_touched && lyrics::is_synced(&lyrics_text) { + let _ = std::fs::write(lrc, &lyrics_text); + } + crate::core::library::forget(path); + if *path == app.player.path { + app.player.reload_tags(); + app.images.forget(&app.player.cover_key.clone()); + } + app.rescan_library(); + app.toast("Tags saved"); + Ok(()) + } + } +} diff --git a/src/ui/pages/mod.rs b/src/ui/pages/mod.rs new file mode 100644 index 0000000..8d51564 --- /dev/null +++ b/src/ui/pages/mod.rs @@ -0,0 +1,21 @@ +pub mod download; +pub mod editor; +pub mod player_page; +pub mod queue; +pub mod settings_page; + +use eframe::egui::Ui; + +/// A centred column no wider than `max_w`. +pub fn column(ui: &mut Ui, max_w: f32, add: impl FnOnce(&mut Ui)) { + let avail = ui.available_width(); + let w = (avail - 48.0).min(max_w).max(300.0); + let m = ((avail - w) / 2.0).max(0.0); + ui.horizontal_top(|ui| { + ui.add_space(m); + ui.vertical(|ui| { + ui.set_width(w); + add(ui); + }); + }); +} diff --git a/src/ui/pages/player_page.rs b/src/ui/pages/player_page.rs new file mode 100644 index 0000000..382e76a --- /dev/null +++ b/src/ui/pages/player_page.rs @@ -0,0 +1,432 @@ +//! The quick player: cover with a spectrum ring, wavy seek bar, synced lyrics and the library. + +use crate::app::*; +use crate::core::library::LibraryItem; +use crate::core::settings::{get_bool, get_str}; +use crate::core::textutil::{format_duration, normalize}; +use crate::core::{lyrics as lyr, tagger}; +use crate::ui::controls::*; +use crate::ui::gfx::*; +use crate::ui::theme::with_alpha; +use crate::ui::widgets::*; +use eframe::egui::{self, Align2, Pos2, Rect, RichText, Sense, Ui, Vec2}; + +pub struct State { + pub items: Vec, + pub query: String, + pub sort: String, + pub scanning: bool, + pub find_busy: bool, + pub lyrics_msg: String, + rot: f32, + speed: f32, + last_line: usize, + vol_hint: Option, +} + +impl Default for State { + fn default() -> Self { + State { items: vec![], query: String::new(), sort: "recent".into(), scanning: false, find_busy: false, lyrics_msg: String::new(), rot: 0.0, speed: 0.0, last_line: usize::MAX, vol_hint: None } + } +} + +impl State { + pub fn set_items(&mut self, items: Vec) { + self.items = items; + } + + pub fn visible_items(&self) -> Vec { + let q = normalize(&self.query); + let mut v: Vec = self.items.iter().filter(|i| q.is_empty() || normalize(&format!("{} {} {}", i.title, i.artist, i.album)).contains(&q)).cloned().collect(); + match self.sort.as_str() { + "title" => v.sort_by_key(|i| normalize(&i.title)), + "artist" => v.sort_by_key(|i| (normalize(&i.artist), normalize(&i.album), normalize(&i.title))), + _ => v.sort_by(|a, b| b.mtime.partial_cmp(&a.mtime).unwrap_or(std::cmp::Ordering::Equal)), + } + v + } +} + +pub fn on_track_changed(app: &mut App) { + app.pl.lyrics_msg.clear(); + app.pl.last_line = usize::MAX; +} + +pub fn lyrics_found(app: &mut App, path: &str, r: Result, String>) { + app.pl.find_busy = false; + if path != app.player.path { + return; + } + match r { + Ok(Some(text)) => { + app.player.set_lyrics_text(&text); + app.pl.lyrics_msg.clear(); + app.rescan_library(); + } + Ok(None) => app.pl.lyrics_msg = "LRCLIB doesn't have lyrics for this one.".into(), + Err(e) => app.pl.lyrics_msg = e, + } +} + +/// Fetch lyrics for a file, embed them (per settings) and write a .lrc when synced. +fn fetch_and_save_lyrics(path: &str, snap: &serde_json::Value) -> Result, String> { + let mut tags = tagger::read(path, true); + let found = lyr::fetch(&tags.title, &tags.artist, &tags.album, tags.duration)?; + if !found.found() || found.instrumental { + return Ok(None); + } + let mode = Some(get_str(snap, "lyrics.embed")).filter(|s| !s.is_empty()).unwrap_or_else(|| "synced".into()); + let text = if found.synced.is_empty() { found.plain.clone() } else { found.synced.clone() }; + if mode != "off" { + tags.lyrics = if mode == "synced" && !found.synced.is_empty() { found.synced.clone() } else if !found.plain.is_empty() { found.plain.clone() } else { lyr::lrc_to_plain(&found.synced) }; + let _ = tagger::write(path, &tags, &mode); + } + if !found.synced.is_empty() && (get_bool(snap, "lyrics.save_lrc") || mode == "off") { + let _ = std::fs::write(std::path::Path::new(path).with_extension("lrc"), &found.synced); + } + Ok(Some(text)) +} + +pub fn find_lyrics(app: &mut App, path: &str) { + if app.pl.find_busy { + return; + } + app.pl.find_busy = true; + app.pl.lyrics_msg = "Looking on LRCLIB…".into(); + let (p, snap) = (path.to_string(), app.settings.snapshot()); + let p2 = p.clone(); + app.spawn(move || fetch_and_save_lyrics(&p, &snap), move |r| Ev::LyricsFound(p2, r)); +} + +pub fn draw(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + let wide = ui.available_width() > 980.0; + egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| { + ui.add_space(14.0); + super::column(ui, 1240.0, |ui| { + if let Some(e) = app.player.error.clone() { + ui.label(RichText::new(e).color(t.error)); + } + if wide { + ui.horizontal_top(|ui| { + ui.spacing_mut().item_spacing.x = 28.0; + ui.vertical(|ui| { + ui.set_width(380.0); + now_playing(app, ui, 380.0); + }); + ui.vertical(|ui| { + let w = ui.available_width(); + ui.set_width(w); + lyrics_panel(app, ui, 300.0); + ui.add_space(14.0); + library(app, ui); + }); + }); + } else { + now_playing(app, ui, ui.available_width().min(420.0)); + lyrics_panel(app, ui, 260.0); + ui.add_space(14.0); + library(app, ui); + } + ui.add_space(14.0); + }); + }); +} + +fn now_playing(app: &mut App, ui: &mut Ui, width: f32) { + let t = app.g.theme.clone(); + let has = !app.player.path.is_empty(); + let dt = ui.input(|i| i.stable_dt).min(0.1); + // cover + visualizer + let size = width.min(380.0); + let (rect, resp) = ui.allocate_exact_size(Vec2::new(width, size), Sense::click()); + let center = rect.center(); + let base_r = size * 0.30; + let target_speed = if app.player.playing { std::f32::consts::TAU / 10.0 } else { 0.0 }; + app.pl.speed += (target_speed - app.pl.speed) * (1.0 - (-dt * 3.0).exp()); + app.pl.rot += app.pl.speed * dt; + let bars = app.player.spectrum.bars.clone(); + let vis = app.settings.get_bool("player.visualizer"); + if vis && !bars.is_empty() { + let n = bars.len(); + for (i, v) in bars.iter().enumerate() { + let th = i as f32 / n as f32 * std::f32::consts::TAU - std::f32::consts::FRAC_PI_2; + let outline = base_r * (1.0 + 0.065 * (12.0 * (th + std::f32::consts::FRAC_PI_2 - app.pl.rot)).cos()); + let a = Pos2::new(center.x + (outline + 4.0) * th.cos(), center.y + (outline + 4.0) * th.sin()); + let len = 3.0 + v * (size * 0.5 - base_r - 12.0); + let b = Pos2::new(center.x + (outline + 4.0 + len) * th.cos(), center.y + (outline + 4.0 + len) * th.sin()); + ui.painter().line_segment([a, b], egui::Stroke::new((size * 0.5 * std::f32::consts::TAU / n as f32 * 0.5).clamp(2.0, 6.0), with_alpha(t.primary, 0.35 + 0.65 * v))); + } + } + let tex = if has { app.images.get(&app.player.cover_key) } else { None }; + match tex { + Some((id, sz)) => cookie_image(ui.painter(), center, base_r, app.pl.rot, 12, 0.065, id, sz), + None => { + ui.painter().add(egui::Shape::convex_polygon(cookie_points(center, base_r, app.pl.rot, 12, 0.065), t.surface_container_highest, egui::Stroke::NONE)); + app.g.icon(ui.painter(), Rect::from_center_size(center, Vec2::splat(base_r * 0.8)), "music_note", with_alpha(t.on_surface_variant, 0.6)); + } + } + if resp.clicked() && has { + app.player.toggle(); + } + if resp.hovered() { + let scroll = ui.input(|i| i.smooth_scroll_delta.y); + if scroll.abs() > 0.5 { + let v = app.player.volume + if scroll > 0.0 { 5 } else { -5 }; + app.player.set_volume(v); + app.settings.set("player.volume", serde_json::json!(app.player.volume)); + app.pl.vol_hint = Some(std::time::Instant::now()); + } + } + if let Some(at) = app.pl.vol_hint { + if at.elapsed().as_millis() < 1200 { + let r = Rect::from_center_size(Pos2::new(center.x, rect.bottom() - 14.0), Vec2::new(90.0, 28.0)); + ui.painter().rect_filled(r, cr(14.0), with_alpha(t.inverse_surface, 0.9)); + ui.painter().text(r.center(), Align2::CENTER_CENTER, format!("{}%", app.player.volume), font_semi(13.0), t.inverse_on_surface); + ui.ctx().request_repaint_after(std::time::Duration::from_millis(100)); + } + } + ui.add_space(8.0); + let (title, artist, album) = match (&app.player.tags, has) { + (Some(tg), true) => ( + if tg.title.is_empty() { std::path::Path::new(&app.player.path).file_stem().map(|s| s.to_string_lossy().into_owned()).unwrap_or_default() } else { tg.title.clone() }, + if tg.artist.is_empty() { "Unknown artist".to_string() } else { tg.artist.clone() }, + tg.album.clone(), + ), + _ => ("Nothing playing".into(), "Pick a song from your library".into(), String::new()), + }; + ui.vertical_centered(|ui| { + let p = ui.painter().clone(); + let (r, _) = ui.allocate_exact_size(Vec2::new(width, 34.0), Sense::hover()); + text_elided(&p, r.center(), Align2::CENTER_CENTER, &title, disp_semi(24.0), t.on_surface, width); + let (r, _) = ui.allocate_exact_size(Vec2::new(width, 24.0), Sense::hover()); + text_elided(&p, r.center(), Align2::CENTER_CENTER, &artist, font(15.5), t.on_surface_variant, width); + if !album.is_empty() { + let (r, _) = ui.allocate_exact_size(Vec2::new(width, 20.0), Sense::hover()); + text_elided(&p, r.center(), Align2::CENTER_CENTER, &album, font(13.0), with_alpha(t.on_surface_variant, 0.8), width); + } + }); + ui.add_space(6.0); + // seek bar + let frac = if app.player.dur > 0.0 { (app.player.pos / app.player.dur) as f32 } else { 0.0 }; + let wavy = app.settings.get_bool("player.wavy_progress"); + let out = { + let (playing, id) = (app.player.playing && wavy, ui.id().with("seek")); + wavy_slider(ui, &mut app.g, id, width, frac, playing, has) + }; + if let Some(f) = out.seek { + app.player.seek(f as f64 * app.player.dur); + } + let shown = out.dragging.map(|f| f as f64 * app.player.dur).unwrap_or(app.player.pos); + ui.horizontal(|ui| { + ui.add_space(8.0); + ui.label(RichText::new(format_duration(Some(shown))).size(12.5).color(t.on_surface_variant)); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + ui.add_space(8.0); + ui.label(RichText::new(format_duration(Some(app.player.dur))).size(12.5).color(t.on_surface_variant)); + }); + }); + ui.add_space(4.0); + // controls + ui.horizontal(|ui| { + let total = 52.0 + 52.0 + 76.0 + 52.0 + 52.0 + 4.0 * 8.0; + ui.add_space(((width - total) / 2.0).max(0.0)); + ui.spacing_mut().item_spacing.x = 8.0; + let shuffle = app.player.shuffle; + if icon_button(ui, &mut app.g, IconBtn::new("shuffle", Variant::Standard, 52.0, 24.0).checked(shuffle).tip("Shuffle")).clicked() { + app.player.shuffle = !shuffle; + app.settings.set_bool("player.shuffle", !shuffle); + } + if icon_button(ui, &mut app.g, IconBtn::new("skip_previous_fill", Variant::Tonal, 52.0, 26.0).tip("Previous")).clicked() { + app.player.previous(); + } + let playing = app.player.playing; + let b = IconBtn::new(if playing { "pause_fill" } else { "play_arrow_fill" }, Variant::Filled, 64.0, 32.0).wide(76.0).morph(playing).tip(if playing { "Pause" } else { "Play" }); + if icon_button(ui, &mut app.g, b).clicked() { + app.player.toggle(); + } + if icon_button(ui, &mut app.g, IconBtn::new("skip_next_fill", Variant::Tonal, 52.0, 26.0).tip("Next")).clicked() { + app.player.next(false); + } + let rep = app.player.repeat.clone(); + let tip = match rep.as_str() { "all" => "Repeat: all", "one" => "Repeat: this song", _ => "Repeat: off" }; + if icon_button(ui, &mut app.g, IconBtn::new(if rep == "one" { "repeat_one" } else { "repeat" }, Variant::Standard, 52.0, 24.0).checked(rep != "off").tip(tip)).clicked() { + app.player.repeat = match rep.as_str() { "off" => "all", "all" => "one", _ => "off" }.into(); + let r = app.player.repeat.clone(); + app.settings.set_str("player.repeat", &r); + } + }); + ui.add_space(4.0); + ui.horizontal(|ui| { + ui.add_space(((width - 240.0) / 2.0).max(0.0)); + let (r, _) = ui.allocate_exact_size(Vec2::splat(22.0), Sense::hover()); + app.g.icon(ui.painter(), r, if app.player.volume == 0 { "volume_off" } else { "volume_up" }, t.on_surface_variant); + if let Some(v) = volume_slider(ui, &mut app.g, 200.0, app.player.volume) { + app.player.set_volume(v); + app.settings.set("player.volume", serde_json::json!(v)); + } + }); +} + +fn lyrics_panel(app: &mut App, ui: &mut Ui, height: f32) { + let t = app.g.theme.clone(); + let mode = app.player.lyrics_mode(); + ui.horizontal(|ui| { + ui.label(RichText::new("Lyrics").font(disp_semi(20.0)).color(t.on_surface)); + ui.label(RichText::new(match mode { "synced" => "Synced", "plain" => "Plain text", _ => "" }).size(12.5).color(t.on_surface_variant)); + if mode == "none" && !app.player.path.is_empty() { + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + ui.add_enabled_ui(!app.pl.find_busy, |ui| { + if button_h(ui, &mut app.g, Some("lyrics"), "Find lyrics", Kind::Tonal, 34.0).clicked() { + let p = app.player.path.clone(); + find_lyrics(app, &p); + } + }); + if app.pl.find_busy { + spinner(ui, &app.g, 22.0); + } + }); + } + }); + egui::Frame::NONE.fill(t.surface_container_low).corner_radius(cr(24.0)).inner_margin(egui::Margin::symmetric(18, 12)).show(ui, |ui| { + ui.set_width(ui.available_width()); + ui.set_min_height(height); + match mode { + "synced" => { + let cur_ms = (app.player.pos * 1000.0) as i64; + let cur = app.player.lyrics.iter().rposition(|(ms, _)| *ms <= cur_ms); + let mut seek = None; + egui::ScrollArea::vertical().id_salt("lyrics").max_height(height).auto_shrink([false, false]).show(ui, |ui| { + ui.add_space(height * 0.35); + for (i, (ms, line)) in app.player.lyrics.iter().enumerate() { + let is_cur = Some(i) == cur; + let text = if line.is_empty() { "♪" } else { line }; + let rt = if is_cur { RichText::new(text).font(disp_semi(24.0)).color(t.primary) } else { RichText::new(text).font(disp(20.0)).color(with_alpha(t.on_surface_variant, 0.75)) }; + let r = ui.add(egui::Label::new(rt).sense(Sense::click()).wrap()); + if r.clicked() { + seek = Some(*ms as f64 / 1000.0); + } + if r.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + if is_cur && app.pl.last_line != i { + r.scroll_to_me(Some(egui::Align::Center)); + app.pl.last_line = i; + } + } + ui.add_space(height * 0.5); + }); + if let Some(s) = seek { + app.player.seek(s); + } + } + "plain" => { + egui::ScrollArea::vertical().id_salt("lyrics-plain").max_height(height).auto_shrink([false, false]).show(ui, |ui| { + ui.label(RichText::new(&app.player.lyrics_plain).font(font(16.0)).color(t.on_surface)); + }); + } + _ => { + ui.add_space(height * 0.35); + let msg = if app.pl.lyrics_msg.is_empty() { if app.player.path.is_empty() { "Lyrics show up here while a song plays." } else { "No lyrics for this song yet." } } else { app.pl.lyrics_msg.as_str() }; + ui.vertical_centered(|ui| ui.label(RichText::new(msg).color(t.on_surface_variant))); + } + } + }); +} + +fn library(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + let items = app.pl.visible_items(); + ui.horizontal(|ui| { + ui.label(RichText::new("Library").font(disp_semi(20.0)).color(t.on_surface)); + let dir = std::path::Path::new(&app.settings.library_dir()).file_name().map(|n| n.to_string_lossy().into_owned()).unwrap_or_default(); + ui.label(RichText::new(if app.pl.scanning { "Scanning…".into() } else { format!("{} songs · {dir}", app.pl.items.len()) }).size(12.5).color(t.on_surface_variant)); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + if tool_button(ui, &mut app.g, "folder_open", "Choose library folder", true).clicked() { + if let Some(p) = rfd::FileDialog::new().set_directory(app.settings.library_dir()).set_title("Library folder").pick_folder() { + app.settings.set_str("player.library_dir", &p.to_string_lossy()); + app.rescan_library(); + } + } + if tool_button(ui, &mut app.g, "refresh", "Rescan", true).clicked() { + app.rescan_library(); + } + for (k, label) in [("artist", "Artist"), ("title", "Title"), ("recent", "Recent")] { + if chip(ui, &mut app.g, None, label, app.pl.sort == k).clicked() { + app.pl.sort = k.into(); + } + } + }); + }); + let w = ui.available_width(); + let _ = field(ui, &mut app.g, "", &mut app.pl.query, w, "Search your library…", &[]); + ui.add_space(4.0); + if items.is_empty() { + ui.label(RichText::new("No music here yet. Downloads land in your library automatically.").color(t.on_surface_variant)); + return; + } + app.player.set_queue(&items); + enum A { + Play(String), + Edit(String), + Lyrics(String), + Folder(String), + } + let mut act = None; + egui::ScrollArea::vertical().id_salt("library").max_height(420.0).auto_shrink([false, true]).show_rows(ui, 54.0, items.len(), |ui, range| { + for i in range { + let it = &items[i]; + let (rect, resp) = ui.allocate_exact_size(Vec2::new(ui.available_width(), 54.0), Sense::click()); + let playing = it.path == app.player.path; + let inner = rect.shrink2(Vec2::new(2.0, 2.0)); + if playing { + ui.painter().rect_filled(inner, cr(14.0), t.secondary_container); + } else if resp.hovered() { + ui.painter().rect_filled(inner, cr(14.0), with_alpha(t.on_surface, 0.06)); + } + let key = format!("file:{}", it.path); + app.images.request(&key, || crate::ui::images::Source::File(it.path.clone()), 120); + let tex = app.images.get(&key); + let cr_ = Rect::from_min_size(Pos2::new(inner.left() + 8.0, inner.center().y - 20.0), Vec2::splat(40.0)); + paint_cover(ui, &mut app.g, cr_, tex, 8.0); + if playing { + ui.painter().rect_filled(cr_, cr(8.0), with_alpha(Color32::BLACK, 0.4)); + app.g.icon(ui.painter(), Rect::from_center_size(cr_.center(), Vec2::splat(22.0)), if app.player.playing { "graphic_eq" } else { "play_arrow_fill" }, Color32::WHITE); + } + let x = cr_.right() + 12.0; + let right = inner.right() - 12.0; + ui.painter().text(Pos2::new(right, inner.center().y), Align2::RIGHT_CENTER, if it.duration > 0.0 { format_duration(Some(it.duration)) } else { String::new() }, font(13.0), if playing { t.on_secondary_container } else { t.on_surface_variant }); + let tw = right - 60.0 - x; + text_elided(ui.painter(), Pos2::new(x, inner.center().y - 9.0), Align2::LEFT_CENTER, &it.title, font_semi(14.0), if playing { t.on_secondary_container } else { t.on_surface }, tw); + let sub = [it.artist.clone(), it.album.clone()].into_iter().filter(|s| !s.is_empty()).collect::>().join(" · "); + text_elided(ui.painter(), Pos2::new(x, inner.center().y + 10.0), Align2::LEFT_CENTER, &sub, font(12.5), if playing { t.on_secondary_container } else { t.on_surface_variant }, tw); + if resp.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + if resp.double_clicked() || resp.clicked() { + act = Some(A::Play(it.path.clone())); + } + egui::Popup::context_menu(&resp).frame(menu_frame(&app.g)).show(|ui| { + ui.spacing_mut().item_spacing = Vec2::ZERO; + for (text, icon, a) in [("Play", "play_arrow", 0), ("Edit tags…", "edit", 1), ("Find lyrics", "lyrics", 2), ("Show in folder", "folder_open", 3)] { + if menu_item(ui, &mut app.g, Some(icon), text, true, None).clicked() { + act = Some(match a { 0 => A::Play(it.path.clone()), 1 => A::Edit(it.path.clone()), 2 => A::Lyrics(it.path.clone()), _ => A::Folder(it.path.clone()) }); + ui.close(); + } + } + }); + } + }); + match act { + Some(A::Play(p)) => app.play_file(&p), + Some(A::Edit(p)) => app.edit_file(&p), + Some(A::Lyrics(p)) => find_lyrics(app, &p), + Some(A::Folder(p)) => { + let dir = std::path::Path::new(&p).parent().map(|d| d.to_string_lossy().into_owned()).unwrap_or(p); + let _ = std::process::Command::new("xdg-open").arg(dir).spawn(); + } + None => {} + } +} + +use eframe::egui::Color32; diff --git a/src/ui/pages/queue.rs b/src/ui/pages/queue.rs new file mode 100644 index 0000000..5eb9ad6 --- /dev/null +++ b/src/ui/pages/queue.rs @@ -0,0 +1,202 @@ +//! The downloads list with progress, and the terminal-style output panel. + +use super::column; +use crate::app::*; +use crate::core::models::JobState; +use crate::ui::controls::*; +use crate::ui::gfx::*; +use crate::ui::theme::with_alpha; +use eframe::egui::{self, Align2, Color32, Pos2, Rect, RichText, Sense, Ui, Vec2}; + +#[derive(Default)] +pub struct State { + pub only_job: Option, +} + +enum Act { + Cancel(u64), + Retry(u64), + Remove(u64), + Play(String), + Edit(String), + Open(String), +} + +pub fn draw(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + let show_term = app.settings.get_bool("ui.show_terminal"); + if show_term { + egui::Panel::bottom("terminal").resizable(true).default_size(230.0).size_range(120.0..=600.0).frame(egui::Frame::NONE.fill(t.surface_container_lowest).inner_margin(egui::Margin::symmetric(16, 10))).show(ui, |ui| terminal(app, ui)); + } + egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| { + ui.add_space(14.0); + column(ui, 1040.0, |ui| { + ui.spacing_mut().item_spacing.y = 12.0; + let (active, done, failed) = app.manager.counts(); + ui.horizontal(|ui| { + ui.label(RichText::new("Downloads").font(disp_semi(30.0)).color(t.on_surface)); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + if chip(ui, &mut app.g, Some("terminal"), "Show output", show_term).on_hover_text("yt-dlp and ffmpeg output (Ctrl+`)").clicked() { + app.settings.set_bool("ui.show_terminal", !show_term); + } + if active > 0 && button_h(ui, &mut app.g, Some("close"), "Cancel all", Kind::Text, 34.0).clicked() { + app.manager.cancel_all(); + } + if done > 0 && button_h(ui, &mut app.g, Some("clear_all"), "Clear finished", Kind::Text, 34.0).clicked() { + app.manager.clear_finished(); + } + if failed > 0 && button_h(ui, &mut app.g, Some("refresh"), "Retry failed", Kind::Tonal, 34.0).clicked() { + let snap = app.settings.snapshot(); + let ids: Vec = app.manager.jobs.iter().filter(|h| h.job.lock().unwrap().state == JobState::Failed).map(|h| h.uid).collect(); + for id in ids { + app.manager.retry(id, &snap); + } + } + }); + }); + if app.manager.jobs.is_empty() { + egui::Frame::NONE.fill(t.surface_container_low).corner_radius(cr(24.0)).inner_margin(egui::Margin::symmetric(24, 40)).show(ui, |ui| { + ui.set_width(ui.available_width()); + ui.vertical_centered(|ui| { + icon_badge(ui, &mut app.g, "downloading", 72.0, false); + ui.label(RichText::new("Nothing downloading").font(disp_semi(22.0)).color(t.on_surface)); + ui.label(RichText::new("Fetch something on the Download tab and it shows up here.").color(t.on_surface_variant)); + }); + }); + return; + } + ui.label(RichText::new(format!("{active} active · {done} done{}", if failed > 0 { format!(" · {failed} failed") } else { String::new() })).size(13.5).color(t.on_surface_variant)); + let mut acts = vec![]; + let jobs: Vec<_> = app.manager.jobs.iter().rev().map(|h| h.job.lock().unwrap().clone()).collect(); + for j in &jobs { + job_row(app, ui, j, &mut acts); + } + let snap = app.settings.snapshot(); + for a in acts { + match a { + Act::Cancel(id) => app.manager.cancel(id), + Act::Retry(id) => app.manager.retry(id, &snap), + Act::Remove(id) => app.manager.remove(id), + Act::Play(p) => app.play_file(&p), + Act::Edit(p) => app.edit_file(&p), + Act::Open(p) => { + let dir = std::path::Path::new(&p).parent().map(|d| d.to_string_lossy().into_owned()).unwrap_or(p); + let _ = std::process::Command::new("xdg-open").arg(dir).spawn(); + } + } + } + ui.add_space(10.0); + }); + }); + if app.manager.counts().0 > 0 { + ui.ctx().request_repaint_after(std::time::Duration::from_millis(100)); + } +} + +fn job_row(app: &mut App, ui: &mut Ui, j: &crate::core::models::Job, acts: &mut Vec) { + let t = app.g.theme.clone(); + let (bg, fg) = status_color(&app.g, j.state); + egui::Frame::NONE.fill(t.surface_container).corner_radius(cr(20.0)).inner_margin(egui::Margin::symmetric(14, 10)).show(ui, |ui| { + ui.set_width(ui.available_width()); + ui.horizontal(|ui| { + let tex = app.images.url(&j.track.cover_url, 120); + cover(ui, &mut app.g, tex, 52.0, 10.0); + ui.vertical(|ui| { + ui.set_width((ui.available_width() - 170.0).max(160.0)); + ui.spacing_mut().item_spacing.y = 3.0; + ui.label(RichText::new(j.track.display_title()).font(font_semi(15.0)).color(t.on_surface)); + let sub = [j.track.display_artist(), j.track.value("album")].into_iter().filter(|s| !s.is_empty()).collect::>().join(" · "); + ui.label(RichText::new(sub).size(13.0).color(t.on_surface_variant)); + let detail = if j.state == JobState::Failed && !j.error.is_empty() { j.status.clone() } else { j.status.clone() }; + match j.state { + JobState::Downloading => progress_bar(ui, &app.g, ui.available_width().min(560.0), j.progress, None), + s if s.active() => progress_indeterminate(ui, &app.g, ui.available_width().min(560.0)), + _ => {} + } + ui.label(RichText::new(detail).size(12.5).color(if j.state == JobState::Failed { t.error } else { t.on_surface_variant })); + if let Some(m) = &j.track.matched { + ui.label(RichText::new(format!("Matched with {} – {} on {} ({:.0}%)", m.artist, m.title, service_label(&m.service), m.score * 100.0)).size(12.0).color(with_alpha(t.on_surface_variant, 0.8))); + } + }); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + ui.horizontal(|ui| { + let mut icon = |ui: &mut Ui, g: &mut Gfx, name: &str, tip: &str| crate::ui::widgets::tool_button(ui, g, name, tip, true).clicked(); + match j.state { + JobState::Done | JobState::Skipped => { + if icon(ui, &mut app.g, "close", "Remove from list") { + acts.push(Act::Remove(j.uid)); + } + if icon(ui, &mut app.g, "folder_open", "Show in folder") { + acts.push(Act::Open(j.output_path.clone())); + } + if icon(ui, &mut app.g, "edit", "Edit tags") { + acts.push(Act::Edit(j.output_path.clone())); + } + if icon(ui, &mut app.g, "play_arrow", "Play") { + acts.push(Act::Play(j.output_path.clone())); + } + } + JobState::Failed | JobState::Cancelled => { + if icon(ui, &mut app.g, "close", "Remove from list") { + acts.push(Act::Remove(j.uid)); + } + if icon(ui, &mut app.g, "refresh", "Try again") { + acts.push(Act::Retry(j.uid)); + } + } + _ => { + if icon(ui, &mut app.g, "close", "Cancel") { + acts.push(Act::Cancel(j.uid)); + } + } + } + let fnt = font_semi(12.5); + let label = j.state.label(); + let tw = ui.painter().layout_no_wrap(label.to_string(), fnt.clone(), Color32::WHITE).size().x; + let (r, _) = ui.allocate_exact_size(Vec2::new(tw + 22.0, 26.0), Sense::hover()); + ui.painter().rect_filled(r, cr(8.0), bg); + ui.painter().text(r.center(), Align2::CENTER_CENTER, label, fnt, fg); + }); + }); + }); + }); +} + +fn service_label(s: &str) -> String { + crate::core::resolvers::service_name(s) +} + +fn terminal(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + ui.horizontal(|ui| { + ui.label(RichText::new("Output").font(font_semi(14.0)).color(t.on_surface)); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + if button_h(ui, &mut app.g, Some("clear_all"), "Clear", Kind::Text, 30.0).clicked() { + app.logs.clear(); + } + if button_h(ui, &mut app.g, Some("content_copy"), "Copy", Kind::Text, 30.0).clicked() { + let text = app.logs.iter().map(|l| l.text.clone()).collect::>().join("\n"); + ui.ctx().copy_text(text); + } + }); + }); + egui::ScrollArea::both().stick_to_bottom(true).auto_shrink([false, false]).show_rows(ui, 16.0, app.logs.len(), |ui, range| { + for i in range { + let l = &app.logs[i]; + let col = match l.kind.as_str() { + "error" => t.error, + "warning" => Color32::from_rgb(0xe0, 0xb0, 0x40), + "success" => Color32::from_rgb(0x6c, 0xc9, 0x7a), + "match" | "meta" => t.tertiary, + "progress" | "debug" => with_alpha(t.on_surface_variant, 0.7), + "info" => t.primary, + _ => t.on_surface_variant, + }; + let prefix = if l.job > 0 { format!("#{} ", l.job % 1000) } else { String::new() }; + ui.label(RichText::new(format!("{prefix}{}", l.text)).monospace().size(12.0).color(col)); + } + }); +} + +#[allow(dead_code)] +fn _unused(_: Pos2, _: Rect) {} diff --git a/src/ui/pages/settings_page.rs b/src/ui/pages/settings_page.rs new file mode 100644 index 0000000..a66f25e --- /dev/null +++ b/src/ui/pages/settings_page.rs @@ -0,0 +1,346 @@ +//! Settings: downloads, tags, lyrics, player, appearance, Spotify, advanced, about. + +use super::column; +use super::download::{quality_controls, template_field}; +use crate::app::*; +use crate::core::settings::{FIELD_SOURCES, METADATA_FIELDS}; +use crate::core::spotify; +use crate::core::{paths, ytdlp}; +use crate::ui::controls::*; +use crate::ui::gfx::*; +use crate::ui::theme::{hex, SEED_SWATCHES, VARIANTS}; +use crate::ui::widgets::*; +use eframe::egui::{self, Align2, Color32, Id, RichText, Sense, Ui, Vec2}; + +#[derive(Default)] +pub struct State { + pub spotify_status: String, + pub spotify_busy: bool, + pub ytdlp_note: String, + pub ytdlp_busy: bool, + pub seed_text: String, +} + +fn card(app: &mut App, ui: &mut Ui, title: &str, subtitle: &str, body: impl FnOnce(&mut App, &mut Ui)) { + let t = app.g.theme.clone(); + ui.add_space(8.0); + egui::Frame::NONE.fill(t.surface_container).corner_radius(cr(24.0)).inner_margin(egui::Margin::symmetric(24, 18)).show(ui, |ui| { + ui.set_width(ui.available_width()); + ui.spacing_mut().item_spacing.y = 10.0; + ui.label(RichText::new(title).font(disp_semi(20.0)).color(t.on_surface)); + if !subtitle.is_empty() { + ui.label(RichText::new(subtitle).size(13.5).color(t.on_surface_variant)); + } + body(app, ui); + }); +} + +/// A settings row: title and description on the left, the control on the right. +fn row(app: &App, ui: &mut Ui, title: &str, desc: &str, add: impl FnOnce(&mut Ui)) { + let t = &app.g.theme; + ui.horizontal(|ui| { + ui.vertical(|ui| { + ui.set_width((ui.available_width() - 300.0).max(200.0)); + ui.label(RichText::new(title).font(font_semi(14.5)).color(t.on_surface)); + if !desc.is_empty() { + ui.label(RichText::new(desc).size(12.5).color(t.on_surface_variant)); + } + }); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), add); + }); +} + +fn toggle(app: &mut App, ui: &mut Ui, title: &str, desc: &str, key: &str) { + let mut on = app.settings.get_bool(key); + let changed = { + let mut ch = false; + row(app, ui, title, desc, |ui| ch = switch(ui, &app.g, &mut on)); + ch + }; + if changed { + app.settings.set_bool(key, on); + } +} + +fn choice(app: &mut App, ui: &mut Ui, title: &str, desc: &str, key: &str, list: &[(&str, &str)], width: f32) { + let cur = app.settings.get_str(key); + let mut picked = None; + { + let App { g, .. } = app; + let it = items(list); + let id = ui.id().with(key); + let t = g.theme.clone(); + ui.horizontal(|ui| { + ui.vertical(|ui| { + ui.set_width((ui.available_width() - width - 20.0).max(200.0)); + ui.label(RichText::new(title).font(font_semi(14.5)).color(t.on_surface)); + if !desc.is_empty() { + ui.label(RichText::new(desc).size(12.5).color(t.on_surface_variant)); + } + }); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + picked = combo(ui, g, id, &cur, &it, width); + }); + }); + } + if let Some(v) = picked { + if key == "download.concurrent" { + app.settings.set(key, serde_json::json!(v.parse::().unwrap_or(3))); + app.manager.set_concurrent(v.parse().unwrap_or(3)); + } else if key == "player.visualizer_bars" { + app.settings.set(key, serde_json::json!(v.parse::().unwrap_or(56))); + } else if key == "metadata.cover_size" { + app.settings.set(key, serde_json::json!(v.parse::().unwrap_or(1200))); + } else { + app.settings.set_str(key, &v); + } + } +} + +fn folder_row(app: &mut App, ui: &mut Ui, label: &str, key: &str, current: String) { + let mut text = current; + let w = ui.available_width(); + let (_, clicked) = field(ui, &mut app.g, label, &mut text, w, "", &[("folder_open", "Choose folder")]); + if clicked.is_some() { + if let Some(p) = rfd::FileDialog::new().set_directory(&text).set_title(label).pick_folder() { + text = p.to_string_lossy().into_owned(); + } + } + if text != app.settings.get_str(key) && (text != app.settings.output_dir() || key != "download.output_dir") { + app.settings.set_str(key, &text); + if key == "player.library_dir" { + app.rescan_library(); + } + if key == "download.output_dir" { + app.dl.folder = text; + } + } +} + +pub fn draw(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + egui::ScrollArea::vertical().auto_shrink([false, false]).show(ui, |ui| { + ui.add_space(14.0); + column(ui, 860.0, |ui| { + ui.label(RichText::new("Settings").font(disp_semi(30.0)).color(t.on_surface)); + card(app, ui, "Downloads", "Where files go and how they are named.", |app, ui| { + let out = app.dl.folder.clone(); + folder_row(app, ui, "Download folder", "download.output_dir", if out.is_empty() { app.settings.output_dir() } else { out }); + quality_controls(app, ui, true); + template_field(app, ui); + toggle(app, ui, "Folders for albums and playlists", "Put each playlist or album you download into a folder named after it.", "download.collection_folder"); + choice(app, ui, "When the file already exists", "", "download.existing", &[("rename", "Keep both (rename)"), ("skip", "Skip it"), ("overwrite", "Overwrite")], 200.0); + choice(app, ui, "Downloads at once", "How many songs download in parallel.", "download.concurrent", &[("1", "1"), ("2", "2"), ("3", "3"), ("4", "4"), ("5", "5"), ("6", "6"), ("8", "8")], 120.0); + choice(app, ui, "Find songs on", "Where audio comes from for Spotify, Apple Music, Deezer, Tidal and other links.", "download.search_source", &[("ytmusic", "YouTube Music"), ("soundcloud", "SoundCloud")], 200.0); + choice(app, ui, "Separate multiple artists with", "", "download.artist_separator", &[(", ", "Comma (A, B)"), ("; ", "Semicolon (A; B)"), (" / ", "Slash (A / B)"), (" & ", "Ampersand (A & B)")], 220.0); + toggle(app, ui, "Save the source link as a comment", "Writes the page you downloaded from into the comment tag.", "download.write_source_comment"); + }); + card(app, ui, "Tags", "Looked up on free databases; no keys needed.", |app, ui| { + toggle(app, ui, "Look up tags online", "", "metadata.enabled"); + for (key, name, desc) in [("deezer", "Deezer", "Track numbers, genres, ISRC and covers."), ("itunes", "iTunes", "Genres, album details and large covers."), ("musicbrainz", "MusicBrainz", "Open database; slower (one request per second).")] { + toggle(app, ui, name, desc, &format!("metadata.providers.{key}")); + } + ui.label(RichText::new("Where each tag comes from").font(font_semi(15.0)).color(t.on_surface)); + ui.label(RichText::new("“Best match” uses the most confident database match and keeps what the link itself provides for titles and artists.").size(12.5).color(t.on_surface_variant)); + ui.horizontal_wrapped(|ui| { + ui.spacing_mut().item_spacing = Vec2::new(12.0, 10.0); + for (key, name) in METADATA_FIELDS { + let k = format!("metadata.fields.{key}"); + let cur = app.settings.get_str(&k); + ui.vertical(|ui| { + if let Some(v) = dropdown(ui, &mut app.g, ui.id().with(&k), name, &cur, &items(FIELD_SOURCES), 190.0) { + app.settings.set_str(&k, &v); + } + }); + } + }); + let mut strict = app.settings.get_f64("metadata.match_threshold") * 100.0; + let mut changed = false; + row(app, ui, "Match strictness", "How sure a database match must be before its tags are used.", |ui| changed = hslider(ui, &app.g, &mut strict, 40.0, 95.0, 1.0, 200.0, |v| format!("{v:.0}%"))); + if changed { + app.settings.set("metadata.match_threshold", serde_json::json!(strict / 100.0)); + } + toggle(app, ui, "Embed cover art", "", "metadata.embed_cover"); + choice(app, ui, "Cover size", "Largest side in pixels.", "metadata.cover_size", &[("600", "600 px"), ("800", "800 px"), ("1000", "1000 px"), ("1200", "1200 px"), ("1600", "1600 px"), ("3000", "3000 px")], 140.0); + toggle(app, ui, "Crop video thumbnails to square", "YouTube thumbnails are 16:9; album art is square.", "metadata.cover_square"); + toggle(app, ui, "Save cover.jpg in album folders", "", "metadata.save_cover_file"); + }); + card(app, ui, "Lyrics", "From LRCLIB, free.", |app, ui| { + choice(app, ui, "Embed lyrics", "Synced lyrics keep the [mm:ss] timing (shown line by line in the player).", "lyrics.embed", &[("synced", "Synced (LRC)"), ("plain", "Plain text"), ("off", "Don't embed")], 200.0); + toggle(app, ui, "Save a .lrc file next to each song", "For players that read sidecar lyric files.", "lyrics.save_lrc"); + toggle(app, ui, "Use plain lyrics when there are no synced ones", "", "lyrics.fallback_plain"); + }); + card(app, ui, "Player", "", |app, ui| { + let lib = app.settings.library_dir(); + folder_row(app, ui, "Library folder", "player.library_dir", lib); + toggle(app, ui, "Visualizer around the cover", "", "player.visualizer"); + choice(app, ui, "Visualizer bars", "", "player.visualizer_bars", &[("32", "32"), ("48", "48"), ("56", "56"), ("72", "72"), ("96", "96")], 120.0); + toggle(app, ui, "Wavy progress bar", "The seek bar waves while music plays.", "player.wavy_progress"); + }); + + card(app, ui, "Appearance", "", appearance); + card(app, ui, "Spotify", "Optional. Without keys Audiphi reads Spotify's public page, which lists the first 100 songs of a playlist.", spotify_section); + card(app, ui, "Advanced", "", advanced); + card(app, ui, "About", "", about); + ui.add_space(20.0); + }); + }); +} + +fn appearance(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + let note = format!("Using: {}", if t.source.is_empty() { "your colour" } else { &t.source }); + choice(app, ui, "Colours from", ¬e, "appearance.theme_source", &[("auto", "Automatic (Caelestia, then system)"), ("system", "System accent colour"), ("caelestia", "Caelestia scheme"), ("cover", "Album art of what's playing"), ("seed", "A colour I pick")], 300.0); + ui.horizontal_wrapped(|ui| { + ui.label(RichText::new("Custom colour").font(font_semi(14.5)).color(t.on_surface)); + let cur = app.settings.get_str("appearance.seed_color").to_lowercase(); + for sw in SEED_SWATCHES { + let c = hex(sw).unwrap_or(Color32::GRAY); + let (r, resp) = ui.allocate_exact_size(Vec2::splat(30.0), Sense::click()); + ui.painter().circle_filled(r.center(), 13.0, c); + if cur == *sw { + ui.painter().circle_stroke(r.center(), 15.0, egui::Stroke::new(2.0, t.on_surface)); + } + if resp.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + if resp.clicked() { + app.settings.set_str("appearance.seed_color", sw); + app.settings.set_str("appearance.theme_source", "seed"); + } + } + if app.st.seed_text.is_empty() { + app.st.seed_text = cur.clone(); + } + let mut txt = app.st.seed_text.clone(); + let resp = ui.add(egui::TextEdit::singleline(&mut txt).desired_width(90.0).hint_text("#rrggbb")); + app.st.seed_text = txt.clone(); + if resp.lost_focus() { + if let Some(c) = hex(&txt) { + let s = format!("#{:02x}{:02x}{:02x}", c.r(), c.g(), c.b()); + app.settings.set_str("appearance.seed_color", &s); + app.settings.set_str("appearance.theme_source", "seed"); + } + } + }); + let v: Vec<(&str, &str)> = VARIANTS.to_vec(); + choice(app, ui, "Scheme style", "Material You variant for custom and album-art colours.", "appearance.variant", &v, 200.0); + choice(app, ui, "Mode", "“System” follows your desktop's light or dark setting.", "appearance.mode", &[("system", "System"), ("dark", "Dark"), ("light", "Light")], 160.0); + toggle(app, ui, "Animations", "Morphing shapes and wavy progress.", "appearance.animations"); +} + +fn spotify_section(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + ui.label(RichText::new("For complete playlists create a free app at developer.spotify.com/dashboard and paste its Client ID and secret here. Spotify only lets such apps read playlists the app owner owns or collaborates on, the owner needs Premium, and Spotify-made playlists stay hidden — in all those cases Audiphi quietly falls back to the public page.").size(12.5).color(t.on_surface_variant)); + let mut id = app.settings.get_str("spotify.client_id"); + let mut secret = app.settings.get_str("spotify.client_secret"); + let w = ui.available_width(); + ui.horizontal(|ui| { + ui.spacing_mut().item_spacing.x = 12.0; + ui.vertical(|ui| { field(ui, &mut app.g, "Client ID", &mut id, w / 2.0 - 8.0, "", &[]); }); + ui.vertical(|ui| { field(ui, &mut app.g, "Client secret", &mut secret, w / 2.0 - 8.0, "", &[]); }); + }); + let (id, secret) = (id.trim().to_string(), secret.trim().to_string()); + if id != app.settings.get_str("spotify.client_id") { + app.settings.set_str("spotify.client_id", &id); + } + if secret != app.settings.get_str("spotify.client_secret") { + app.settings.set_str("spotify.client_secret", &secret); + } + ui.horizontal(|ui| { + ui.add_enabled_ui(!app.st.spotify_busy && !id.is_empty() && !secret.is_empty(), |ui| { + if button(ui, &mut app.g, Some("key"), "Test keys", Kind::Tonal).clicked() { + app.st.spotify_busy = true; + app.st.spotify_status = "Checking…".into(); + let (i, s) = (id.clone(), secret.clone()); + app.spawn(move || spotify::Api::new(&i, &s).test(), Ev::SpotifyTest); + } + }); + if app.st.spotify_busy { + spinner(ui, &app.g, 22.0); + } + ui.label(RichText::new(&app.st.spotify_status).size(13.0).color(t.on_surface_variant)); + }); +} + +fn advanced(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + let browsers: Vec<(&str, &str)> = vec![("none", "Don't use cookies"), ("firefox", "Firefox"), ("chrome", "Chrome"), ("chromium", "Chromium"), ("brave", "Brave"), ("edge", "Edge"), ("opera", "Opera"), ("vivaldi", "Vivaldi")]; + choice(app, ui, "Cookies from browser", "Lets yt-dlp use your browser's sign-in for age-restricted or “confirm you're not a bot” videos.", "download.cookies_browser", &browsers, 220.0); + let mut ff = app.settings.get_str("download.ffmpeg_path"); + let w = ui.available_width(); + let (_, clicked) = field(ui, &mut app.g, "ffmpeg location (leave empty to use the one on your PATH)", &mut ff, w, "", &[("folder_open", "Choose ffmpeg")]); + if clicked.is_some() { + if let Some(p) = rfd::FileDialog::new().set_title("ffmpeg").pick_file() { + ff = p.to_string_lossy().into_owned(); + } + } + if ff != app.settings.get_str("download.ffmpeg_path") { + app.settings.set_str("download.ffmpeg_path", &ff); + app.ffmpeg_ok = paths::find_ffmpeg(&ff).is_some(); + } + let ffmpeg = paths::find_ffmpeg(&ff); + let js = paths::js_runtimes(); + let ver = ytdlp::version(); + let mut status = vec![]; + status.push(match &ffmpeg { Some(p) => format!("ffmpeg: {p}"), None => "ffmpeg: not found".into() }); + status.push(match &ver { Some(v) => format!("yt-dlp {v}"), None => "yt-dlp: not found".into() }); + status.push(if js.is_empty() { "JavaScript runtime: none (install deno for YouTube)".into() } else { format!("JavaScript runtime: {}", js.join(", ")) }); + ui.label(RichText::new(status.join(" · ")).size(12.5).color(t.on_surface_variant)); + ui.horizontal(|ui| { + ui.add_enabled_ui(!app.st.ytdlp_busy && ver.is_some(), |ui| { + if button(ui, &mut app.g, Some("system_update_alt"), "Update yt-dlp", Kind::Tonal).clicked() { + app.st.ytdlp_busy = true; + app.st.ytdlp_note = "Updating…".into(); + app.spawn( + || { + let Some(bin) = paths::find_ytdlp() else { return "yt-dlp wasn't found".to_string() }; + match std::process::Command::new(bin).arg("-U").output() { + Ok(o) => { + let txt = format!("{}{}", String::from_utf8_lossy(&o.stdout), String::from_utf8_lossy(&o.stderr)); + let line = txt.lines().rev().find(|l| !l.trim().is_empty()).unwrap_or("").trim().to_string(); + if txt.contains("package manager") || txt.contains("pacman") || txt.contains("apt") { "yt-dlp was installed by your package manager; update it there (e.g. “sudo pacman -Syu yt-dlp”).".to_string() } else { line } + } + Err(e) => e.to_string(), + } + }, + Ev::YtdlpUpdate, + ); + } + }); + if app.st.ytdlp_busy { + spinner(ui, &app.g, 22.0); + } + ui.label(RichText::new(&app.st.ytdlp_note).size(12.5).color(t.on_surface_variant)); + }); + let mut reset = false; + ui.horizontal(|ui| { + ui.vertical(|ui| { + ui.label(RichText::new("Reset").font(font_semi(14.5)).color(t.on_surface)); + ui.label(RichText::new("Put every setting back to its default.").size(12.5).color(t.on_surface_variant)); + }); + ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| { + reset = button_h(ui, &mut app.g, Some("restart_alt"), "Reset all", Kind::Outlined, 34.0).clicked(); + }); + }); + if reset { + let keep = app.settings.get_str("download.output_dir"); + for s in ["download", "metadata", "lyrics", "player", "appearance"] { + app.settings.reset(s); + } + app.settings.set_str("download.output_dir", &keep); + app.toast("Settings reset"); + } +} + +fn about(app: &mut App, ui: &mut Ui) { + let t = app.g.theme.clone(); + ui.label(RichText::new(format!("{} {} — a Material 3 music downloader and quick player.", crate::APP_NAME, crate::VERSION)).color(t.on_surface)); + ui.label(RichText::new("Built on yt-dlp and ffmpeg. Tags from Deezer, iTunes and MusicBrainz; lyrics from LRCLIB. The player follows the look of Caelestia's media panel. Bundled fonts: Material Symbols (Apache 2.0) and Rubik (SIL OFL 1.1).").size(13.0).color(t.on_surface_variant)); + ui.horizontal(|ui| { + if button_h(ui, &mut app.g, Some("open_in_new"), "Project page", Kind::Text, 34.0).clicked() { + let _ = std::process::Command::new("xdg-open").arg(crate::HOMEPAGE).spawn(); + } + }); + let _ = (Align2::CENTER_CENTER, Id::NULL); +} diff --git a/src/ui/theme.rs b/src/ui/theme.rs new file mode 100644 index 0000000..fa15b62 --- /dev/null +++ b/src/ui/theme.rs @@ -0,0 +1,443 @@ +//! Material You colour scheme generated from the system colours. +//! +//! Reads ~/.config/kdeglobals (accent, window background) when present, builds tonal +//! palettes in OKLCH space (tone == CIE L*) and produces the Material 3 colour roles. + +use serde_json::Value; +use eframe::egui::Color32; +use std::path::PathBuf; + +// ------------------------------------------------------------------ colour math +fn srgb_to_lin(c: f64) -> f64 { + if c <= 0.04045 { + c / 12.92 + } else { + ((c + 0.055) / 1.055).powf(2.4) + } +} + +fn lin_to_srgb(c: f64) -> f64 { + if c <= 0.0031308 { + 12.92 * c + } else { + 1.055 * c.powf(1.0 / 2.4) - 0.055 + } +} + +pub fn rgb_to_oklch(r: u8, g: u8, b: u8) -> (f64, f64, f64) { + let (r, g, b) = (srgb_to_lin(r as f64 / 255.0), srgb_to_lin(g as f64 / 255.0), srgb_to_lin(b as f64 / 255.0)); + let l = 0.4122214708 * r + 0.5363325363 * g + 0.0514459929 * b; + let m = 0.2119034982 * r + 0.6806995451 * g + 0.1073969566 * b; + let s = 0.0883024619 * r + 0.2817188376 * g + 0.6299787005 * b; + let (l, m, s) = (l.cbrt(), m.cbrt(), s.cbrt()); + let ll = 0.2104542553 * l + 0.7936177850 * m - 0.0040720468 * s; + let a = 1.9779984951 * l - 2.4285922050 * m + 0.4505937099 * s; + let bb = 0.0259040371 * l + 0.7827717662 * m - 0.8086757660 * s; + (ll, a.hypot(bb), bb.atan2(a).to_degrees().rem_euclid(360.0)) +} + +fn oklch_to_lin(l: f64, c: f64, h: f64) -> (f64, f64, f64) { + let a = c * h.to_radians().cos(); + let b = c * h.to_radians().sin(); + let l_ = (l + 0.3963377774 * a + 0.2158037573 * b).powi(3); + let m_ = (l - 0.1055613458 * a - 0.0638541728 * b).powi(3); + let s_ = (l - 0.0894841775 * a - 1.2914855480 * b).powi(3); + ( + 4.0767416621 * l_ - 3.3077115913 * m_ + 0.2309699292 * s_, + -1.2684380046 * l_ + 2.6097574011 * m_ - 0.3413193965 * s_, + -0.0041960863 * l_ - 0.7034186147 * m_ + 1.7076147010 * s_, + ) +} + +fn in_gamut(rgb: (f64, f64, f64)) -> bool { + [rgb.0, rgb.1, rgb.2].iter().all(|x| (-1e-4..=1.0001).contains(x)) +} + +/// Convert with gamut mapping (reduce chroma until it fits sRGB). +pub fn oklch_to_color(l: f64, c: f64, h: f64) -> Color32 { + let mut rgb = oklch_to_lin(l, c, h); + if !in_gamut(rgb) { + let (mut lo, mut hi) = (0.0, c); + for _ in 0..18 { + let mid = (lo + hi) / 2.0; + if in_gamut(oklch_to_lin(l, mid, h)) { + lo = mid; + } else { + hi = mid; + } + } + rgb = oklch_to_lin(l, lo, h); + } + let q = |x: f64| (lin_to_srgb(x.clamp(0.0, 1.0)) * 255.0).round().clamp(0.0, 255.0) as u8; + Color32::from_rgb(q(rgb.0), q(rgb.1), q(rgb.2)) +} + +fn tone_to_l(t: f64) -> f64 { + if t <= 8.0 { + (t / 903.2963).cbrt() + } else { + (t + 16.0) / 116.0 + } +} + +fn l_to_tone(l: f64) -> f64 { + let y = l.powi(3); + if y <= 0.008856 { + 903.2963 * y + } else { + 116.0 * l - 16.0 + } +} + +#[derive(Clone, Copy)] +struct Tonal { + h: f64, + c: f64, +} + +impl Tonal { + fn at(&self, tone: f64) -> Color32 { + oklch_to_color(tone_to_l(tone), self.c, self.h) + } +} + +pub fn mix(a: Color32, b: Color32, t: f32) -> Color32 { + let l = |x: u8, y: u8| (x as f32 + (y as f32 - x as f32) * t).round().clamp(0.0, 255.0) as u8; + Color32::from_rgba_unmultiplied(l(a.r(), b.r()), l(a.g(), b.g()), l(a.b(), b.b()), l(a.a(), b.a())) +} + +/// The same colour with its alpha replaced (straight alpha, 0..1). +pub fn with_alpha(c: Color32, a: f32) -> Color32 { + Color32::from_rgba_unmultiplied(c.r(), c.g(), c.b(), (a.clamp(0.0, 1.0) * 255.0).round() as u8) +} + +/// Multiply the existing alpha. +pub fn fade(c: Color32, a: f32) -> Color32 { + with_alpha(c, a * c.a() as f32 / 255.0) +} + +pub fn hex(s: &str) -> Option { + let s = s.trim().trim_start_matches('#'); + if s.len() != 6 { + return None; + } + let v = u32::from_str_radix(s, 16).ok()?; + Some(Color32::from_rgb((v >> 16) as u8, (v >> 8) as u8, v as u8)) +} + +pub fn lightness(c: Color32) -> f32 { + let (r, g, b) = (c.r() as f32 / 255.0, c.g() as f32 / 255.0, c.b() as f32 / 255.0); + (r.max(g).max(b) + r.min(g).min(b)) / 2.0 +} + +/// Pick a vivid representative colour from artwork (Material "score" style). +pub fn dominant_color(img: &image::RgbaImage) -> Option { + let small = image::imageops::resize(img, 48, 48, image::imageops::FilterType::Triangle); + let mut buckets = [[0.0f64; 4]; 24]; + let mut any = false; + for p in small.pixels() { + let (l, c, h) = rgb_to_oklch(p[0], p[1], p[2]); + if c < 0.03 || l < 0.2 || l > 0.95 { + continue; + } + any = true; + let b = &mut buckets[((h / 15.0) as usize).min(23)]; + let w = c * c; + b[0] += w; + b[1] += h.to_radians().cos() * w; + b[2] += h.to_radians().sin() * w; + b[3] += c * w; + } + if !any { + return None; + } + let best = buckets.iter().max_by(|a, b| a[0].partial_cmp(&b[0]).unwrap())?; + let hue = best[2].atan2(best[1]).to_degrees().rem_euclid(360.0); + let chroma = best[3] / best[0]; + Some(oklch_to_color(0.65, chroma.max(0.1), hue)) +} + +// ------------------------------------------------------------------ system colours +#[derive(Default, Clone)] +pub struct SystemColors { + pub accent: Option, + pub dark: Option, + pub source: String, +} + +fn kdeglobals_path() -> PathBuf { + let base = std::env::var_os("XDG_CONFIG_HOME").filter(|v| !v.is_empty()).map(PathBuf::from).unwrap_or_else(|| dirs::home_dir().unwrap_or_default().join(".config")); + base.join("kdeglobals") +} + +fn parse_rgb(s: &str) -> Option { + let p: Vec = s.split(',').take(3).filter_map(|x| x.trim().parse().ok()).collect(); + if p.len() == 3 { + Some(Color32::from_rgb(p[0], p[1], p[2])) + } else { + hex(s) + } +} + +fn read_kde() -> SystemColors { + let mut out = SystemColors::default(); + let Ok(txt) = std::fs::read_to_string(kdeglobals_path()) else { return out }; + let mut section = String::new(); + let (mut accent, mut sel, mut win) = (None, None, None); + for line in txt.lines() { + let line = line.trim(); + if let Some(s) = line.strip_prefix('[').and_then(|l| l.strip_suffix(']')) { + section = s.to_string(); + } else if let Some((k, v)) = line.split_once('=') { + match (section.as_str(), k) { + ("General", "AccentColor") => accent = parse_rgb(v), + ("Colors:Selection", "BackgroundNormal") => sel = parse_rgb(v), + ("Colors:Window", "BackgroundNormal") => win = parse_rgb(v), + _ => {} + } + } + } + out.accent = accent.or(sel); + out.dark = win.map(|w| lightness(w) < 0.5); + if out.accent.is_some() || out.dark.is_some() { + out.source = "Plasma accent colour".into(); + } + out +} + +fn gsettings(key: &str) -> String { + std::process::Command::new("gsettings").args(["get", "org.gnome.desktop.interface", key]).output().map(|o| String::from_utf8_lossy(&o.stdout).trim().trim_matches('\'').to_string()).unwrap_or_default() +} + +fn read_gnome() -> SystemColors { + let accent = match gsettings("accent-color").as_str() { + "blue" => hex("#3584e4"), + "teal" => hex("#2190a4"), + "green" => hex("#3a944a"), + "yellow" => hex("#c88800"), + "orange" => hex("#ed5b00"), + "red" => hex("#e62d42"), + "pink" => hex("#d56199"), + "purple" => hex("#9141ac"), + "slate" => hex("#6f8396"), + _ => None, + }; + let dark = match gsettings("color-scheme").as_str() { + "prefer-dark" => Some(true), + "prefer-light" => Some(false), + _ => None, + }; + SystemColors { accent, dark, source: "GNOME accent colour".into() } +} + +pub fn read_system() -> SystemColors { + static CACHE: std::sync::Mutex> = std::sync::Mutex::new(None); + let mut c = CACHE.lock().unwrap(); + if let Some((t, v)) = c.as_ref() { + if t.elapsed() < std::time::Duration::from_secs(4) { + return v.clone(); + } + } + let v = read_system_uncached(); + *c = Some((std::time::Instant::now(), v.clone())); + v +} + +fn read_system_uncached() -> SystemColors { + let kde = read_kde(); + if kde.accent.is_some() { + return kde; + } + let g = read_gnome(); + SystemColors { accent: g.accent, dark: kde.dark.or(g.dark), source: g.source } +} + +pub fn system_mtime() -> Option { + let a = std::fs::metadata(kdeglobals_path()).ok()?.modified().ok(); + let b = crate::core::paths::caelestia_scheme().and_then(|p| std::fs::metadata(p).ok()?.modified().ok()); + a.max(b) +} + +pub const SEED_SWATCHES: &[&str] = &["#7e6bc9", "#4f6bd8", "#2a8fbd", "#2e9e83", "#6f9a3a", "#c89a2c", "#d0672f", "#c9465c", "#b04fa6"]; +pub const VARIANTS: &[(&str, &str)] = &[ + ("tonal_spot", "Tonal spot"), ("vibrant", "Vibrant"), ("expressive", "Expressive"), ("fidelity", "Fidelity"), ("content", "Content"), + ("neutral", "Neutral"), ("monochrome", "Monochrome"), ("rainbow", "Rainbow"), ("fruit_salad", "Fruit salad"), +]; + +// ------------------------------------------------------------------ theme +#[derive(Clone)] +pub struct Theme { + pub dark: bool, + pub source: String, + pub primary: Color32, + pub on_primary: Color32, + pub primary_container: Color32, + pub on_primary_container: Color32, + pub secondary: Color32, + pub on_secondary: Color32, + pub secondary_container: Color32, + pub on_secondary_container: Color32, + pub tertiary: Color32, + pub on_tertiary: Color32, + pub tertiary_container: Color32, + pub on_tertiary_container: Color32, + pub error: Color32, + pub on_error: Color32, + pub error_container: Color32, + pub on_error_container: Color32, + pub surface: Color32, + pub surface_bright: Color32, + pub surface_container_lowest: Color32, + pub surface_container_low: Color32, + pub surface_container: Color32, + pub surface_container_high: Color32, + pub surface_container_highest: Color32, + pub on_surface: Color32, + pub on_surface_variant: Color32, + pub outline: Color32, + pub outline_variant: Color32, + pub inverse_surface: Color32, + pub inverse_on_surface: Color32, +} + +/// (primary chroma, secondary chroma, tertiary hue shift, tertiary chroma, neutral chroma) for a scheme style. +fn variant_params(variant: &str, seed_c: f64) -> (f64, f64, f64, f64, f64) { + match variant { + "vibrant" => (0.2, 0.09, 60.0, 0.12, 0.02), + "expressive" => (0.16, 0.07, 120.0, 0.12, 0.025), + "fidelity" | "content" => (seed_c.clamp(0.05, 0.3), seed_c * 0.35, 60.0, seed_c * 0.6, 0.012), + "neutral" => (0.03, 0.02, 60.0, 0.03, 0.008), + "monochrome" => (0.0, 0.0, 0.0, 0.0, 0.0), + "rainbow" => (0.05, 0.04, 90.0, 0.08, 0.01), + "fruit_salad" => (0.13, 0.07, 150.0, 0.1, 0.015), + _ => (seed_c.clamp(0.085, 0.15), 0.04, 60.0, 0.075, 0.014), + } +} + +fn from_caelestia(path: &std::path::Path) -> Option { + let data: Value = serde_json::from_str(&std::fs::read_to_string(path).ok()?).ok()?; + let colours = data.get("colours").or_else(|| data.get("colors"))?; + let get = |k: &str| colours.get(k).and_then(|v| v.as_str()).and_then(hex); + let primary = get("primary")?; + let dark = data.get("mode").and_then(|m| m.as_str()).unwrap_or("dark") != "light"; + let mut base = Theme::generate(primary, dark, "tonal_spot", None); + macro_rules! set { + ($f:ident, $k:expr) => { + if let Some(c) = get($k) { + base.$f = c; + } + }; + } + set!(primary, "primary"); + set!(on_primary, "onPrimary"); + set!(primary_container, "primaryContainer"); + set!(on_primary_container, "onPrimaryContainer"); + set!(secondary, "secondary"); + set!(on_secondary, "onSecondary"); + set!(secondary_container, "secondaryContainer"); + set!(on_secondary_container, "onSecondaryContainer"); + set!(tertiary, "tertiary"); + set!(on_tertiary, "onTertiary"); + set!(tertiary_container, "tertiaryContainer"); + set!(on_tertiary_container, "onTertiaryContainer"); + set!(error, "error"); + set!(on_error, "onError"); + set!(error_container, "errorContainer"); + set!(on_error_container, "onErrorContainer"); + set!(surface, "surface"); + set!(surface_bright, "surfaceBright"); + set!(surface_container_lowest, "surfaceContainerLowest"); + set!(surface_container_low, "surfaceContainerLow"); + set!(surface_container, "surfaceContainer"); + set!(surface_container_high, "surfaceContainerHigh"); + set!(surface_container_highest, "surfaceContainerHighest"); + set!(on_surface, "onSurface"); + set!(on_surface_variant, "onSurfaceVariant"); + set!(outline, "outline"); + set!(outline_variant, "outlineVariant"); + set!(inverse_surface, "inverseSurface"); + set!(inverse_on_surface, "inverseOnSurface"); + base.source = "Caelestia scheme".into(); + Some(base) +} + +impl Theme { + /// Build the scheme from the settings, the desktop and (optionally) the album art seed. + pub fn build(snap: &Value, cover_seed: Option) -> Theme { + let get = |k: &str| crate::core::settings::get_str(snap, k); + let source = get("appearance.theme_source"); + let mode = get("appearance.mode"); + let variant = get("appearance.variant"); + let sys = read_system(); + let sys_dark = sys.dark.unwrap_or(true); + let dark = match mode.as_str() { + "dark" => true, + "light" => false, + _ => sys_dark, + }; + if matches!(source.as_str(), "auto" | "caelestia") { + if let Some(t) = crate::core::paths::caelestia_scheme().and_then(|p| from_caelestia(&p)) { + return t; + } + } + let seed_custom = hex(&get("appearance.seed_color")).unwrap_or(Color32::from_rgb(0x7e, 0x6b, 0xc9)); + let (seed, label) = match source.as_str() { + "cover" => match cover_seed { + Some(c) => (c, "Album art"), + None => (sys.accent.unwrap_or(seed_custom), "Album art (waiting for a song)"), + }, + "seed" => (seed_custom, "Custom colour"), + _ => match sys.accent { + Some(a) => (a, "System accent colour"), + None => (seed_custom, "Custom colour"), + }, + }; + let mut t = Theme::generate(seed, dark, &variant, None); + t.source = if source == "auto" && sys.accent.is_some() { sys.source } else { label.to_string() }; + t + } + + pub fn generate(seed: Color32, dark: bool, variant: &str, _unused: Option<()>) -> Theme { + let (_, sc, sh) = rgb_to_oklch(seed.r(), seed.g(), seed.b()); + let (pc, secc, tshift, tc, nc) = variant_params(variant, sc); + let primary = Tonal { h: sh, c: pc }; + let secondary = Tonal { h: sh, c: secc }; + let tertiary = Tonal { h: (sh + tshift) % 360.0, c: tc }; + let err = Tonal { h: 25.0, c: 0.17 }; + let neutral = Tonal { h: sh, c: nc }; + let nvar = Tonal { h: sh, c: (nc * 1.8).max(if variant == "monochrome" { 0.0 } else { 0.02 }) }; + let mut t = if dark { + let st = 6.0; + Theme { + dark, source: String::new(), + primary: primary.at(80.0), on_primary: primary.at(20.0), primary_container: primary.at(30.0), on_primary_container: primary.at(90.0), + secondary: secondary.at(80.0), on_secondary: secondary.at(20.0), secondary_container: secondary.at(30.0), on_secondary_container: secondary.at(90.0), + tertiary: tertiary.at(80.0), on_tertiary: tertiary.at(20.0), tertiary_container: tertiary.at(30.0), on_tertiary_container: tertiary.at(90.0), + error: err.at(80.0), on_error: err.at(20.0), error_container: err.at(30.0), on_error_container: err.at(90.0), + surface: neutral.at(st), surface_bright: neutral.at(st + 18.0), surface_container_lowest: neutral.at(st - 2.0), + surface_container_low: neutral.at(st + 4.0), surface_container: neutral.at(st + 6.0), surface_container_high: neutral.at(st + 11.0), surface_container_highest: neutral.at(st + 16.0), + on_surface: neutral.at(90.0), on_surface_variant: nvar.at(80.0), outline: nvar.at(60.0), outline_variant: nvar.at(30.0), + inverse_surface: neutral.at(90.0), inverse_on_surface: neutral.at(20.0), + } + } else { + let st = 98.0; + Theme { + dark, source: String::new(), + primary: primary.at(40.0), on_primary: primary.at(100.0), primary_container: primary.at(90.0), on_primary_container: primary.at(10.0), + secondary: secondary.at(40.0), on_secondary: secondary.at(100.0), secondary_container: secondary.at(90.0), on_secondary_container: secondary.at(10.0), + tertiary: tertiary.at(40.0), on_tertiary: tertiary.at(100.0), tertiary_container: tertiary.at(90.0), on_tertiary_container: tertiary.at(10.0), + error: err.at(40.0), on_error: err.at(100.0), error_container: err.at(90.0), on_error_container: err.at(10.0), + surface: neutral.at(st), surface_bright: neutral.at(st), surface_container_lowest: neutral.at(100.0), + surface_container_low: neutral.at(st - 2.0), surface_container: neutral.at(st - 4.0), surface_container_high: neutral.at(st - 6.0), surface_container_highest: neutral.at(st - 8.0), + on_surface: neutral.at(10.0), on_surface_variant: nvar.at(30.0), outline: nvar.at(50.0), outline_variant: nvar.at(80.0), + inverse_surface: neutral.at(20.0), inverse_on_surface: neutral.at(95.0), + } + }; + t.source = String::new(); + t + } + + pub fn same_colors(&self, o: &Theme) -> bool { + self.dark == o.dark && self.primary == o.primary && self.surface == o.surface && self.surface_container == o.surface_container && self.secondary_container == o.secondary_container + } +} diff --git a/src/ui/widgets.rs b/src/ui/widgets.rs new file mode 100644 index 0000000..b030b6e --- /dev/null +++ b/src/ui/widgets.rs @@ -0,0 +1,595 @@ +//! Hand-painted Material 3 (Expressive) components. + +use super::gfx::*; +use crate::ui::theme::{fade, mix, with_alpha}; +use eframe::egui::{self, emath::easing, Align2, Color32, Id, Key, Pos2, Rect, Response, Sense, Shape, Stroke, StrokeKind, Ui, Vec2}; + +// ---------------------------------------------------------------------- icon buttons +#[derive(Clone, Copy, PartialEq, Eq)] +pub enum Variant { + Standard, + Tonal, + Filled, + Outlined, +} + +pub struct IconBtn<'a> { + pub icon: &'a str, + pub variant: Variant, + pub size: f32, + pub icon_px: f32, + pub wide: f32, + pub checked: Option, + pub morph: Option, + pub tip: &'a str, +} + +impl<'a> IconBtn<'a> { + pub fn new(icon: &'a str, variant: Variant, size: f32, icon_px: f32) -> Self { + IconBtn { icon, variant, size, icon_px, wide: 0.0, checked: None, morph: None, tip: "" } + } + pub fn wide(mut self, w: f32) -> Self { + self.wide = w; + self + } + pub fn checked(mut self, c: bool) -> Self { + self.checked = Some(c); + self + } + pub fn morph(mut self, m: bool) -> Self { + self.morph = Some(m); + self + } + pub fn tip(mut self, t: &'a str) -> Self { + self.tip = t; + self + } +} + +pub fn icon_button(ui: &mut Ui, g: &mut Gfx, b: IconBtn) -> Response { + let size = Vec2::new(if b.wide > 0.0 { b.wide } else { b.size }, b.size); + let (rect, mut resp) = ui.allocate_exact_size(size, Sense::click()); + if !b.tip.is_empty() { + resp = resp.on_hover_text(b.tip); + } + if ui.is_rect_visible(rect) { + let t = &g.theme; + let on = b.checked.unwrap_or(false); + let (bg, fg) = match b.variant { + Variant::Filled => (t.primary, t.on_primary), + Variant::Tonal => { + if on { + (t.primary, t.on_primary) + } else { + (t.secondary_container, t.on_secondary_container) + } + } + Variant::Outlined => (Color32::TRANSPARENT, t.on_surface_variant), + Variant::Standard => { + if on { + (Color32::TRANSPARENT, t.primary) + } else { + (Color32::TRANSPARENT, t.on_surface_variant) + } + } + }; + let (bg, fg) = if ui.is_enabled() { (bg, fg) } else { (if bg.a() > 0 { with_alpha(t.on_surface, 0.12) } else { bg }, with_alpha(t.on_surface, 0.38)) }; + let id = resp.id; + let hover = ui.ctx().animate_bool_with_time(id.with("h"), resp.hovered() && ui.is_enabled(), 0.12); + let morph = match b.morph { + Some(m) => ui.ctx().animate_bool_with_time_and_easing(id.with("m"), m, 0.22, easing::cubic_out), + None => 0.0, + }; + let r = rect.shrink(1.0); + let h = r.height(); + let rad = if b.wide > 0.0 || b.morph.is_some() { h / 2.0 - (h / 2.0 - h * 0.3) * morph } else { h / 2.0 }; + let p = ui.painter(); + if bg.a() > 0 { + p.rect_filled(r, cr(rad), bg); + } + if b.variant == Variant::Outlined { + p.rect_stroke(r, cr(rad), Stroke::new(1.0, t.outline_variant), StrokeKind::Inside); + } + let state = hover * 0.08 + if resp.is_pointer_button_down_on() { 0.1 } else { 0.0 }; + if state > 0.0 && ui.is_enabled() { + p.rect_filled(r, cr(rad), with_alpha(fg, state)); + } + let c = r.center(); + let ip = b.icon_px; + g.icon(ui.painter(), Rect::from_center_size(c, Vec2::splat(ip)), b.icon, fg); + } + if resp.hovered() && ui.is_enabled() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + resp +} + +/// Round icon-only toolbar button (standard variant) with a tooltip. +pub fn tool_button(ui: &mut Ui, g: &mut Gfx, icon: &str, tip: &str, enabled: bool) -> Response { + ui.add_enabled_ui(enabled, |ui| icon_button(ui, g, IconBtn::new(icon, Variant::Standard, 36.0, 20.0).tip(tip))).inner +} + +// ---------------------------------------------------------------------- text buttons +pub fn text_button(ui: &mut Ui, g: &mut Gfx, icon: Option<&str>, text: &str, primary: bool) -> Response { + let fnt = font_semi(14.0); + let tw = ui.painter().layout_no_wrap(text.to_string(), fnt.clone(), Color32::WHITE).size().x; + let iw = if icon.is_some() { 26.0 } else { 0.0 }; + let w = tw + iw + 36.0; + let (rect, resp) = ui.allocate_exact_size(Vec2::new(w, 36.0), Sense::click()); + let t = &g.theme; + let (bg, fg) = if primary { (t.primary, t.on_primary) } else { (t.secondary_container, t.on_secondary_container) }; + let (bg, fg) = if ui.is_enabled() { (bg, fg) } else { (with_alpha(t.on_surface, 0.12), with_alpha(t.on_surface, 0.38)) }; + let hover = ui.ctx().animate_bool_with_time(resp.id.with("h"), resp.hovered() && ui.is_enabled(), 0.12); + let p = ui.painter(); + p.rect_filled(rect, cr(18.0), bg); + p.rect_filled(rect, cr(18.0), with_alpha(fg, hover * 0.08 + if resp.is_pointer_button_down_on() { 0.1 } else { 0.0 })); + let cx = rect.center().x - (tw + iw) / 2.0; + if let Some(ic) = icon { + g.icon(ui.painter(), Rect::from_center_size(Pos2::new(cx + 10.0, rect.center().y), Vec2::splat(20.0)), ic, fg); + } + ui.painter().text(Pos2::new(cx + iw, rect.center().y), Align2::LEFT_CENTER, text, fnt, fg); + if resp.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + resp +} + +/// Tonal pill with icon + text and an optional split dropdown part. Returns (main clicked, dropdown clicked). +pub fn pill_split(ui: &mut Ui, g: &mut Gfx, icon: &str, text: &str, checked: bool, split: bool) -> (bool, bool) { + let h = 40.0; + let w = ui.available_width(); + let (rect, _) = ui.allocate_exact_size(Vec2::new(w, h), Sense::hover()); + let drop_w = if split { 44.0 } else { 0.0 }; + let main = Rect::from_min_max(rect.min, Pos2::new(rect.max.x - if split { drop_w + 2.0 } else { 0.0 }, rect.max.y)); + let dr = Rect::from_min_max(Pos2::new(rect.max.x - drop_w, rect.min.y), rect.max); + let r1 = ui.interact(main, ui.id().with(("pill", text, "m")), Sense::click()); + let r2 = if split { Some(ui.interact(dr, ui.id().with(("pill", text, "d")), Sense::click())) } else { None }; + let t = &g.theme; + let (bg, fg) = if checked { (t.primary_container, t.on_primary_container) } else { (t.secondary_container, t.on_secondary_container) }; + let p = ui.painter().clone(); + let big = 20.0; + let small = 5.0; + let left = egui::CornerRadius { nw: big as u8, sw: big as u8, ne: if split { small as u8 } else { big as u8 }, se: if split { small as u8 } else { big as u8 } }; + p.rect_filled(main, left, bg); + if r1.hovered() { + p.rect_filled(main, left, with_alpha(fg, 0.08)); + } + let fnt = font_semi(14.0); + let tw = p.layout_no_wrap(text.to_string(), fnt.clone(), Color32::WHITE).size().x; + let x = main.center().x - (28.0 + tw) / 2.0; + g.icon(&p, Rect::from_center_size(Pos2::new(x + 10.0, main.center().y), Vec2::splat(20.0)), icon, fg); + p.text(Pos2::new(x + 28.0, main.center().y), Align2::LEFT_CENTER, text, fnt, fg); + if split { + let right = egui::CornerRadius { nw: small as u8, sw: small as u8, ne: big as u8, se: big as u8 }; + p.rect_filled(dr, right, bg); + if r2.as_ref().map(|r| r.hovered()).unwrap_or(false) { + p.rect_filled(dr, right, with_alpha(fg, 0.08)); + } + g.icon(&p, Rect::from_center_size(dr.center(), Vec2::splat(22.0)), "expand_more", fg); + } + if r1.hovered() || r2.as_ref().map(|r| r.hovered()).unwrap_or(false) { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + (r1.clicked(), r2.map(|r| r.clicked()).unwrap_or(false)) +} + +// ---------------------------------------------------------------------- wavy slider +pub struct WaveOut { + /// Fraction 0..1 to seek to (on release). + pub seek: Option, + /// Fraction while dragging. + pub dragging: Option, +} + +/// M3 Expressive wavy progress/seek bar. `value` is the already-smooth playback fraction +/// (it comes straight from the monotonic position clock, never integrated here). +pub fn wavy_slider(ui: &mut Ui, g: &mut Gfx, id: Id, width: f32, value: f32, playing: bool, enabled: bool) -> WaveOut { + let (rect, resp) = ui.allocate_exact_size(Vec2::new(width, 28.0), Sense::click_and_drag()); + let ctx = ui.ctx().clone(); + let m = 8.0; + let w = rect.width() - 2.0 * m; + let cy = rect.center().y; + let val_at = |x: f32| ((x - rect.left() - m) / w.max(1.0)).clamp(0.0, 1.0); + + // drag state lives in egui's temp memory so the widget stays stateless for callers + let key = id.with("drag"); + let mut drag: Option = ctx.data(|d| d.get_temp(key)); + let mut out = WaveOut { seek: None, dragging: None }; + if enabled { + if resp.is_pointer_button_down_on() { + if let Some(p) = resp.interact_pointer_pos().or(ctx.pointer_interact_pos()) { + drag = Some(val_at(p.x)); + } + } else if let Some(v) = drag.take() { + out.seek = Some(v); + } + } else { + drag = None; + } + ctx.data_mut(|d| { + if let Some(v) = drag { + d.insert_temp(key, v); + } else { + d.remove::(key); + } + }); + out.dragging = drag; + let v = drag.unwrap_or(value).clamp(0.0, 1.0); + + let amp_anim = ctx.animate_bool_with_time_and_easing(id.with("amp"), playing, 0.4, easing::quadratic_out); + let t = &g.theme; + let (prim, track) = (t.primary, t.secondary_container); + let tx = rect.left() + m + w * v; + let gap = 6.0; + let stroke = 4.0; + let p = ui.painter_at(rect.expand(6.0)); + let right = rect.left() + m + w; + if tx + gap < right { + p.line_segment([Pos2::new(tx + gap, cy), Pos2::new(right, cy)], Stroke::new(stroke, track)); + p.circle_filled(Pos2::new(tx + gap, cy), stroke / 2.0, track); + p.circle_filled(Pos2::new(right, cy), stroke / 2.0, track); + p.circle_filled(Pos2::new(right - 2.0, cy), 2.0, prim); // stop indicator + } + let x0 = rect.left() + m; + let x_end = tx - gap; + if x_end > x0 { + // wave phase comes from absolute time, so it can never stutter with the frame rate + let phase = ((ctx.input(|i| i.time) * 6.6) % (2.0 * std::f64::consts::PI)) as f32; + let amp = 3.4 * amp_anim; + let (wl, ramp, step) = (34.0f32, 14.0f32, 1.5f32); + let mut pts: Vec = Vec::with_capacity(((x_end - x0) / step) as usize + 3); + let mut x = x0; + pts.push(Pos2::new(x0, cy)); + while x < x_end { + x = (x + step).min(x_end); + let mut env = ((x - x0) / ramp).min((x_end - x) / ramp).min(1.0); + env = env * env * (3.0 - 2.0 * env); + let y = cy + amp * env * ((x - x0) / wl * std::f32::consts::TAU - phase).sin(); + pts.push(Pos2::new(x, y)); + } + p.add(Shape::line(pts.clone(), Stroke::new(stroke, prim))); + p.circle_filled(pts[0], stroke / 2.0, prim); + p.circle_filled(*pts.last().unwrap(), stroke / 2.0, prim); + } + let hot = resp.hovered() || drag.is_some(); + let th = ctx.animate_value_with_time(id.with("th"), if hot { 22.0 } else { 18.0 }, 0.1); + p.rect_filled(Rect::from_center_size(Pos2::new(tx, cy), Vec2::new(5.0, th)), cr(2.5), prim); + if resp.hovered() && enabled { + ctx.set_cursor_icon(egui::CursorIcon::PointingHand); + } + out +} + +// ---------------------------------------------------------------------- volume slider +pub fn volume_slider(ui: &mut Ui, g: &mut Gfx, width: f32, value: i64) -> Option { + let (rect, resp) = ui.allocate_exact_size(Vec2::new(width, 28.0), Sense::click_and_drag()); + let m = 6.0; + let w = rect.width() - 2.0 * m; + let cy = rect.center().y; + let mut out = None; + if resp.hovered() { + let scroll = ui.input(|i| i.smooth_scroll_delta.y); + if scroll.abs() > 0.5 { + out = Some((value + if scroll > 0.0 { 5 } else { -5 }).clamp(0, 100)); + } + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + if resp.is_pointer_button_down_on() { + if let Some(pos) = resp.interact_pointer_pos() { + let v = (((pos.x - rect.left() - m) / w.max(1.0)).clamp(0.0, 1.0) * 100.0).round() as i64; + if v != value { + out = Some(v); + } + } + } + let t = &g.theme; + let v = out.unwrap_or(value) as f32 / 100.0; + let tx = rect.left() + m + w * v; + let p = ui.painter(); + let (gap, th) = (4.0, 12.0); + p.rect_filled(Rect::from_min_max(Pos2::new((tx + gap).min(rect.right() - m), cy - th / 2.0), Pos2::new(rect.right() - m, cy + th / 2.0)), cr(th / 2.0), t.secondary_container); + if tx - gap > rect.left() + m { + p.rect_filled(Rect::from_min_max(Pos2::new(rect.left() + m, cy - th / 2.0), Pos2::new(tx - gap, cy + th / 2.0)), cr(th / 2.0), t.primary); + } + p.rect_filled(Rect::from_center_size(Pos2::new(tx, cy), Vec2::new(4.0, 22.0)), cr(2.0), t.primary); + out +} + +// ---------------------------------------------------------------------- search field +pub fn search_field(ui: &mut Ui, g: &mut Gfx, text: &mut String, hint: &str, width: f32, id: Id) -> Response { + let h = 38.0; + let (rect, _) = ui.allocate_exact_size(Vec2::new(width, h), Sense::hover()); + let focused = ui.memory(|m| m.has_focus(id)); + let t = &g.theme; + let bg = if focused { t.surface_container_highest } else { t.surface_container_high }; + ui.painter().rect_filled(rect, cr(h / 2.0), bg); + g.icon(ui.painter(), Rect::from_center_size(Pos2::new(rect.left() + 22.0, rect.center().y), Vec2::splat(20.0)), "search", g.theme.on_surface_variant); + let inner = Rect::from_min_max(Pos2::new(rect.left() + 38.0, rect.top() + 4.0), Pos2::new(rect.right() - if text.is_empty() { 12.0 } else { 36.0 }, rect.bottom() - 4.0)); + let mut child = ui.new_child(egui::UiBuilder::new().max_rect(inner).layout(egui::Layout::left_to_right(egui::Align::Center))); + child.visuals_mut().widgets.inactive.bg_fill = Color32::TRANSPARENT; + child.visuals_mut().widgets.hovered.bg_fill = Color32::TRANSPARENT; + child.visuals_mut().widgets.active.bg_fill = Color32::TRANSPARENT; + child.visuals_mut().selection.bg_fill = g.theme.primary; + child.visuals_mut().selection.stroke = Stroke::new(1.0, g.theme.on_primary); + let resp = child.add( + egui::TextEdit::singleline(text) + .id(id) + .hint_text(egui::RichText::new(hint).color(with_alpha(g.theme.on_surface_variant, 0.7))) + .frame(egui::Frame::NONE) + .desired_width(inner.width()) + .margin(egui::Margin::symmetric(0, 6)) + .text_color(g.theme.on_surface), + ); + if !text.is_empty() { + let cr_ = Rect::from_center_size(Pos2::new(rect.right() - 20.0, rect.center().y), Vec2::splat(24.0)); + let r = ui.interact(cr_, id.with("clear"), Sense::click()); + g.icon(ui.painter(), Rect::from_center_size(cr_.center(), Vec2::splat(18.0)), "close", if r.hovered() { g.theme.on_surface } else { g.theme.on_surface_variant }); + if r.clicked() { + text.clear(); + } + } + resp +} + +// ---------------------------------------------------------------------- menus +pub fn menu_frame(g: &Gfx) -> egui::Frame { + egui::Frame::NONE + .fill(g.theme.surface_container) + .stroke(Stroke::new(1.0, with_alpha(g.theme.outline_variant, 0.5))) + .corner_radius(cr(14.0)) + .inner_margin(egui::Margin::symmetric(0, 5)) +} + +pub fn menu_sep(ui: &mut Ui, g: &Gfx) { + let (rect, _) = ui.allocate_exact_size(Vec2::new(ui.min_size().x.max(180.0), 9.0), Sense::hover()); + ui.painter().line_segment([Pos2::new(rect.left() + 14.0, rect.center().y), Pos2::new(rect.right() - 14.0, rect.center().y)], Stroke::new(1.0, g.theme.outline_variant)); +} + +/// A menu row: optional icon, text, optional trailing check or chevron. +pub fn menu_item(ui: &mut Ui, g: &mut Gfx, icon: Option<&str>, text: &str, enabled: bool, checked: Option) -> Response { + menu_item_h(ui, g, icon, text, "", enabled, checked) +} + +/// Menu row with a right-aligned shortcut hint. +pub fn menu_item_h(ui: &mut Ui, g: &mut Gfx, icon: Option<&str>, text: &str, hint: &str, enabled: bool, checked: Option) -> Response { + let fnt = font(13.5); + let tw = ui.painter().layout_no_wrap(text.to_string(), fnt.clone(), Color32::WHITE).size().x; + let hw = if hint.is_empty() { 0.0 } else { ui.painter().layout_no_wrap(hint.to_string(), font(12.5), Color32::WHITE).size().x + 28.0 }; + let want = (tw + 40.0 + 30.0 + hw).max(190.0); + let want = want.max(ui.min_size().x); + let (rect, resp) = ui.allocate_exact_size(Vec2::new(want, 30.0), Sense::click()); + let t = &g.theme; + let row = rect.shrink2(Vec2::new(6.0, 0.0)); + if resp.hovered() && enabled { + ui.painter().rect_filled(row, cr(10.0), with_alpha(t.on_surface, 0.08)); + } + let fg = if enabled { t.on_surface } else { with_alpha(t.on_surface, 0.38) }; + let ic = if enabled { t.on_surface_variant } else { with_alpha(t.on_surface, 0.38) }; + if let Some(name) = icon { + g.icon(ui.painter(), Rect::from_center_size(Pos2::new(row.left() + 22.0, row.center().y), Vec2::splat(18.0)), name, ic); + } + ui.painter().text(Pos2::new(row.left() + 40.0, row.center().y), Align2::LEFT_CENTER, text, fnt, fg); + if !hint.is_empty() { + ui.painter().text(Pos2::new(row.right() - 14.0, row.center().y), Align2::RIGHT_CENTER, hint, font(12.5), with_alpha(g.theme.on_surface_variant, if enabled { 0.9 } else { 0.4 })); + } + if let Some(c) = checked { + if c { + g.icon(ui.painter(), Rect::from_center_size(Pos2::new(row.right() - 22.0, row.center().y), Vec2::splat(18.0)), "check", g.theme.primary); + } + } + if resp.hovered() && enabled { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + if enabled { resp } else { resp.on_hover_cursor(egui::CursorIcon::Default) } +} + +/// Submenu row; returns the response of the row (the submenu body is shown by egui). +pub fn submenu(ui: &mut Ui, g: &mut Gfx, icon: Option<&str>, text: &str, add: impl FnOnce(&mut Ui, &mut Gfx) -> R) { + let fnt = font(14.0); + let (rect, resp) = ui.allocate_exact_size(Vec2::new(ui.min_size().x.max(190.0), 30.0), Sense::click()); + let row = rect.shrink2(Vec2::new(6.0, 0.0)); + let open_id = resp.id.with("open"); + let is_open = ui.ctx().data(|d| d.get_temp::(open_id)).unwrap_or(false); + if resp.hovered() || is_open { + ui.painter().rect_filled(row, cr(10.0), with_alpha(g.theme.on_surface, 0.08)); + } + if let Some(name) = icon { + g.icon(ui.painter(), Rect::from_center_size(Pos2::new(row.left() + 24.0, row.center().y), Vec2::splat(20.0)), name, g.theme.on_surface_variant); + } + ui.painter().text(Pos2::new(row.left() + 40.0, row.center().y), Align2::LEFT_CENTER, text, fnt, g.theme.on_surface); + g.icon(ui.painter(), Rect::from_center_size(Pos2::new(row.right() - 20.0, row.center().y), Vec2::splat(20.0)), "chevron_right", g.theme.on_surface_variant); + // open on hover/click, stay open while the pointer is over the row or the submenu + let sub_id = resp.id.with("sub"); + let sub_rect: Option = ui.ctx().data(|d| d.get_temp(sub_id)); + let pointer = ui.ctx().pointer_latest_pos(); + let over_sub = matches!((pointer, sub_rect), (Some(p), Some(r)) if r.expand(4.0).contains(p)); + let should_open = resp.hovered() || resp.clicked() || (is_open && over_sub); + ui.ctx().data_mut(|d| d.insert_temp(open_id, should_open)); + if should_open { + // open to the right, or to the left when there is no room + let last_w: f32 = ui.ctx().data(|d| d.get_temp::(sub_id)).map(|r| r.width()).unwrap_or(260.0); + let screen = ui.ctx().content_rect(); + let x = if rect.right() + last_w - 4.0 > screen.right() { rect.left() - last_w + 4.0 } else { rect.right() - 4.0 }; + let area = egui::Area::new(sub_id.with("area")) + .order(egui::Order::Foreground) + .fixed_pos(Pos2::new(x.max(screen.left()), rect.top() - 8.0)) + .constrain(true); + let inner = area.show(ui.ctx(), |ui| { + let frame = menu_frame(g); + frame.show(ui, |ui| { + ui.set_min_width(220.0); + ui.spacing_mut().item_spacing = Vec2::ZERO; + add(ui, g) + }); + }); + ui.ctx().data_mut(|d| d.insert_temp(sub_id, inner.response.rect)); + } +} + +// ---------------------------------------------------------------------- form controls +pub fn checkbox(ui: &mut Ui, g: &mut Gfx, checked: &mut bool, label: &str) -> bool { + let fnt = font(14.0); + let tw = ui.painter().layout_no_wrap(label.to_string(), fnt.clone(), Color32::WHITE).size().x; + let (rect, resp) = ui.allocate_exact_size(Vec2::new(tw + 38.0, 28.0), Sense::click()); + let t = &g.theme; + let cb = Rect::from_center_size(Pos2::new(rect.left() + 11.0, rect.center().y), Vec2::splat(18.0)); + if *checked { + ui.painter().rect_filled(cb, cr(4.0), t.primary); + g.icon(ui.painter(), cb.shrink(1.0), "check", g.theme.on_primary); + } else { + ui.painter().rect_stroke(cb.shrink(1.0), cr(4.0), Stroke::new(2.0, t.on_surface_variant), StrokeKind::Inside); + } + ui.painter().text(Pos2::new(rect.left() + 30.0, rect.center().y), Align2::LEFT_CENTER, label, fnt, g.theme.on_surface); + if resp.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + if resp.clicked() { + *checked = !*checked; + return true; + } + false +} + +pub fn radio(ui: &mut Ui, g: &mut Gfx, selected: bool, label: &str) -> bool { + let fnt = font(14.0); + let tw = ui.painter().layout_no_wrap(label.to_string(), fnt.clone(), Color32::WHITE).size().x; + let (rect, resp) = ui.allocate_exact_size(Vec2::new(tw + 38.0, 28.0), Sense::click()); + let t = &g.theme; + let c = Pos2::new(rect.left() + 11.0, rect.center().y); + ui.painter().circle_stroke(c, 8.0, Stroke::new(2.0, if selected { t.primary } else { t.on_surface_variant })); + if selected { + ui.painter().circle_filled(c, 4.5, t.primary); + } + ui.painter().text(Pos2::new(rect.left() + 30.0, rect.center().y), Align2::LEFT_CENTER, label, fnt, g.theme.on_surface); + if resp.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + resp.clicked() +} + +/// Filled text field in the Material "filled" style. +pub fn text_field(ui: &mut Ui, g: &Gfx, text: &mut String, width: f32) -> Response { + let t = &g.theme; + egui::Frame::NONE + .fill(t.surface_container_highest) + .corner_radius(egui::CornerRadius { nw: 6, ne: 6, sw: 0, se: 0 }) + .inner_margin(egui::Margin::symmetric(8, 2)) + .show(ui, |ui| { + ui.visuals_mut().widgets.inactive.bg_fill = Color32::TRANSPARENT; + ui.visuals_mut().widgets.hovered.bg_fill = Color32::TRANSPARENT; + ui.visuals_mut().widgets.active.bg_fill = Color32::TRANSPARENT; + ui.visuals_mut().selection.bg_fill = t.primary; + ui.add(egui::TextEdit::singleline(text).frame(egui::Frame::NONE).desired_width(width - 16.0).margin(egui::Margin::symmetric(0, 6))) + }) + .inner +} + +pub fn card(g: &Gfx) -> egui::Frame { + egui::Frame::NONE.fill(g.theme.surface_container_low).corner_radius(cr(16.0)).inner_margin(egui::Margin::same(12)) +} + +/// Section label ("muted" caption). +pub fn muted(ui: &mut Ui, g: &Gfx, text: &str) { + ui.label(egui::RichText::new(text).color(g.theme.on_surface_variant).size(13.0)); +} + +pub fn key_pressed(ui: &Ui, k: Key) -> bool { + ui.input(|i| i.key_pressed(k)) +} + +pub fn gradient_mix(a: Color32, b: Color32, t: f32) -> Color32 { + mix(a, b, t) +} + +pub fn dim(c: Color32, a: f32) -> Color32 { + fade(c, a) +} + + +/// Dropdown selector. Returns the chosen key when the user picks something. +pub fn combo(ui: &mut Ui, g: &mut Gfx, id: Id, current: &str, items: &[(String, String)], width: f32) -> Option { + let label = items.iter().find(|(k, _)| k == current).map(|(_, l)| l.as_str()).unwrap_or(""); + let (rect, resp) = ui.allocate_exact_size(Vec2::new(width, 36.0), Sense::click()); + let t = &g.theme; + ui.painter().rect_filled(rect, cr(10.0), if resp.hovered() { with_alpha(t.surface_container_highest, 0.85) } else { t.surface_container_highest }); + text_elided(ui.painter(), Pos2::new(rect.left() + 12.0, rect.center().y), Align2::LEFT_CENTER, label, font(14.0), t.on_surface, width - 44.0); + g.icon(ui.painter(), Rect::from_center_size(Pos2::new(rect.right() - 18.0, rect.center().y), Vec2::splat(18.0)), "expand_more", g.theme.on_surface_variant); + if resp.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + let mut out = None; + let _ = id; + egui::Popup::menu(&resp).frame(menu_frame(g)).width(width.max(200.0)).show(|ui| { + ui.spacing_mut().item_spacing = Vec2::ZERO; + for (k, l) in items { + if menu_item(ui, g, None, l, true, Some(k == current)).clicked() { + out = Some(k.clone()); + ui.close(); + } + } + }); + out +} + +/// A plain section heading inside dialogs / settings. +pub fn heading(ui: &mut Ui, g: &Gfx, text: &str) { + ui.add_space(6.0); + ui.label(egui::RichText::new(text).color(g.theme.primary).size(14.0).strong()); + ui.add_space(2.0); +} + +/// Toggle switch (Material 3 style). +pub fn switch(ui: &mut Ui, g: &Gfx, on: &mut bool) -> bool { + let (rect, resp) = ui.allocate_exact_size(Vec2::new(52.0, 32.0), Sense::click()); + let t = &g.theme; + let k = ui.ctx().animate_bool_with_time(resp.id, *on, 0.15); + let track = mix(t.surface_container_highest, t.primary, k); + ui.painter().rect_filled(rect, cr(16.0), track); + if k < 1.0 { + ui.painter().rect_stroke(rect, cr(16.0), Stroke::new(2.0 * (1.0 - k), t.outline), StrokeKind::Inside); + } + let r = 8.0 + 4.0 * k; + let x = rect.left() + 16.0 + 20.0 * k; + ui.painter().circle_filled(Pos2::new(x, rect.center().y), r, mix(t.outline, t.on_primary, k)); + if resp.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + if resp.clicked() { + *on = !*on; + return true; + } + false +} + + +/// Horizontal Material slider with a value label. Returns true when the value changed. +pub fn hslider(ui: &mut Ui, g: &Gfx, v: &mut f64, lo: f64, hi: f64, step: f64, width: f32, fmt: impl Fn(f64) -> String) -> bool { + let (rect, resp) = ui.allocate_exact_size(Vec2::new(width + 70.0, 30.0), Sense::click_and_drag()); + let t = &g.theme; + let (x0, x1) = (rect.left() + 8.0, rect.left() + width - 8.0); + let cy = rect.center().y; + let mut changed = false; + if resp.is_pointer_button_down_on() { + if let Some(p) = resp.interact_pointer_pos() { + let f = ((p.x - x0) / (x1 - x0)).clamp(0.0, 1.0) as f64; + let nv = (((lo + (hi - lo) * f) / step).round() * step).clamp(lo, hi); + if (nv - *v).abs() > 1e-9 { + *v = nv; + changed = true; + } + } + } + let f = ((*v - lo) / (hi - lo)) as f32; + let tx = x0 + (x1 - x0) * f; + let p = ui.painter(); + p.rect_filled(Rect::from_min_max(Pos2::new((tx + 6.0).min(x1), cy - 5.0), Pos2::new(x1, cy + 5.0)), cr(5.0), t.secondary_container); + if tx - 6.0 > x0 { + p.rect_filled(Rect::from_min_max(Pos2::new(x0, cy - 5.0), Pos2::new(tx - 6.0, cy + 5.0)), cr(5.0), t.primary); + } + p.rect_filled(Rect::from_center_size(Pos2::new(tx, cy), Vec2::new(4.0, 22.0)), cr(2.0), t.primary); + p.text(Pos2::new(rect.left() + width + 8.0, cy), Align2::LEFT_CENTER, fmt(*v), font(13.0), t.on_surface_variant); + if resp.hovered() { + ui.ctx().set_cursor_icon(egui::CursorIcon::PointingHand); + } + changed +} diff --git a/tools/gen_icons.py b/tools/gen_icons.py new file mode 100644 index 0000000..8b54ac1 --- /dev/null +++ b/tools/gen_icons.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +"""Regenerate src/icondata.rs from the Material Symbols subset font (Apache 2.0) plus Mulberry-style extras. + + python tools/gen_icons.py path/to/AudiphiSymbols.ttf [extra_icondata.rs] +""" +import re, sys +from fontTools.ttLib import TTFont +from fontTools.pens.svgPathPen import SVGPathPen +from fontTools.pens.transformPen import TransformPen +from fontTools.pens.boundsPen import BoundsPen + +font = TTFont(sys.argv[1]) +gs = font.getGlyphSet() +skip = {".notdef", "underscore"} | {f"digit_{n}" for n in "zero one two three four five six seven eight nine".split()} +out = {} +for name in font.getGlyphOrder(): + if name in skip or name.startswith(".") or len(name) < 3: + continue + bp = BoundsPen(gs) + gs[name].draw(bp) + if not bp.bounds: + continue + # Google SVGs use viewBox "0 -960 960 960" with the icon box on y in [-960, 0] (y down) + pen = SVGPathPen(gs, ntos=lambda v: ("%.1f" % v).rstrip("0").rstrip(".")) + tp = TransformPen(pen, (1, 0, 0, -1, 0, 96)) # flip; descent offset puts the 960 box at y in [-960, 0] + gs[name].draw(tp) + out[name.replace(".fill", "_fill")] = pen.getCommands() +if len(sys.argv) > 2: + for m in re.finditer(r'\("([a-z_0-9]+)", "([^"]*)"\)', open(sys.argv[2]).read()): + out.setdefault(m.group(1), m.group(2)) +with open("src/icondata.rs", "w") as f: + f.write('//! Material Symbols Rounded (Apache 2.0) path data, viewBox 0 -960 960 960. Generated by tools/gen_icons.py.\n\n') + f.write("pub const ICONS: &[(&str, &str)] = &[\n") + for k in sorted(out): + f.write(f' ("{k}", "{out[k]}"),\n') + f.write("];\n") +print(len(out), "icons")