diff --git a/Cargo.lock b/Cargo.lock index 0918bb3..eed6b25 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,6 +32,12 @@ dependencies = [ "memchr", ] +[[package]] +name = "aligned-vec" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4aa90d7ce82d4be67b64039a3d588d38dbcc6736577de4a847025ce5b0c468d1" + [[package]] name = "allocator-api2" version = "0.2.21" @@ -53,6 +59,35 @@ dependencies = [ "libc", ] +[[package]] +name = "anyhow" +version = "1.0.96" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6b964d184e89d9b6b67dd2715bc8e74cf3107fb2b529990c90cf517326150bf4" + +[[package]] +name = "arbitrary" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dde20b3d026af13f561bdd0f15edf01fc734f0dafcedbaf42bba506a9517f223" + +[[package]] +name = "arg_enum_proc_macro" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "arrayvec" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" + [[package]] name = "atomic-waker" version = "1.1.2" @@ -96,6 +131,29 @@ version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" +[[package]] +name = "av1-grain" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6678909d8c5d46a42abcf571271e15fdbc0a225e3646cf23762cd415046c78bf" +dependencies = [ + "anyhow", + "arrayvec", + "log", + "nom", + "num-rational", + "v_frame", +] + +[[package]] +name = "avif-serialize" +version = "0.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e335041290c43101ca215eed6f43ec437eb5a42125573f600fc3fa42b9bddd62" +dependencies = [ + "arrayvec", +] + [[package]] name = "backtrace" version = "0.3.71" @@ -126,24 +184,60 @@ dependencies = [ "serde", ] +[[package]] +name = "bit_field" +version = "0.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bitflags" version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" +[[package]] +name = "bitstream-io" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2" + +[[package]] +name = "built" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56ed6191a7e78c36abdb16ab65341eefd73d64d303fffccdbb00d51e4205967b" + [[package]] name = "bumpalo" version = "3.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf" +[[package]] +name = "bytemuck" +version = "1.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef657dfab802224e671f5818e9a4935f9b1957ed18e58292690cc39e7a4092a3" + [[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.10.0" @@ -171,9 +265,21 @@ version = "1.2.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7777341816418c02e033934a09f20dc0ccaf65a5201ef8a450ae0105a573fda" dependencies = [ + "jobserver", + "libc", "shlex", ] +[[package]] +name = "cfg-expr" +version = "0.15.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02" +dependencies = [ + "smallvec", + "target-lexicon", +] + [[package]] name = "cfg-if" version = "1.0.0" @@ -221,6 +327,12 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + [[package]] name = "compact_str" version = "0.8.1" @@ -260,13 +372,38 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9dd111b7b7f7d55b72c0a6ae361660ee5853c9af73f70c3c2ef6858b950e2e51" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" + [[package]] name = "crossterm" version = "0.28.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "829d955a0bb380ef178a640b91779e3987da38c9aea133b20614cfed8cdea9c6" dependencies = [ - "bitflags", + "bitflags 2.8.0", "crossterm_winapi", "futures-core", "mio", @@ -286,6 +423,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "crunchy" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" + [[package]] name = "darling" version = "0.20.10" @@ -437,6 +580,21 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "exr" +version = "1.73.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0" +dependencies = [ + "bit_field", + "half", + "lebe", + "miniz_oxide 0.8.4", + "rayon-core", + "smallvec", + "zune-inflate", +] + [[package]] name = "eyre" version = "0.6.12" @@ -453,6 +611,15 @@ version = "2.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" +[[package]] +name = "fdeflate" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e6853b52649d4ac5c0bd02320cddc5ba956bdb407c4b75a2c6b75bf51500f8c" +dependencies = [ + "simd-adler32", +] + [[package]] name = "flate2" version = "1.0.35" @@ -617,6 +784,16 @@ dependencies = [ "windows-targets", ] +[[package]] +name = "gif" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2" +dependencies = [ + "color_quant", + "weezl", +] + [[package]] name = "gimli" version = "0.28.1" @@ -642,6 +819,16 @@ dependencies = [ "tracing", ] +[[package]] +name = "half" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if", + "crunchy", +] + [[package]] name = "hashbrown" version = "0.15.2" @@ -939,7 +1126,7 @@ version = "1.16.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "472295f55960dd48e38c89442fa5d5423f5cf0ed2c665485be78e129231a39e9" dependencies = [ - "bitflags", + "bitflags 2.8.0", "byteorder", "flate2", ] @@ -971,6 +1158,45 @@ dependencies = [ "icu_properties", ] +[[package]] +name = "image" +version = "0.25.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b" +dependencies = [ + "bytemuck", + "byteorder-lite", + "color_quant", + "exr", + "gif", + "image-webp", + "num-traits", + "png", + "qoi", + "ravif", + "rayon", + "rgb", + "tiff", + "zune-core", + "zune-jpeg", +] + +[[package]] +name = "image-webp" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b77d01e822461baa8409e156015a1d91735549f0f2c17691bd2d996bef238f7f" +dependencies = [ + "byteorder-lite", + "quick-error", +] + +[[package]] +name = "imgref" +version = "1.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0263a3d970d5c054ed9312c0057b4f3bde9c0b33836d3637361d4a9e6e7a408" + [[package]] name = "indenter" version = "0.3.3" @@ -1006,12 +1232,32 @@ dependencies = [ "syn", ] +[[package]] +name = "interpolate_name" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "ipnet" version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + [[package]] name = "itertools" version = "0.13.0" @@ -1038,8 +1284,8 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "itunesdb" -version = "0.1.69" -source = "git+https://gitea.awain.net/alterwain/ITunesDB.git#03263e0d02f45062238f020e2c58faa91a4a59ab" +version = "0.1.89" +source = "git+https://gitea.awain.net/alterwain/ITunesDB.git#2a867778b7bbd82956247f2f17b98fdb6865a910" dependencies = [ "bincode", "env_logger", @@ -1049,6 +1295,21 @@ dependencies = [ "serde_json", ] +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + +[[package]] +name = "jpeg-decoder" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0" + [[package]] name = "js-sys" version = "0.3.77" @@ -1065,19 +1326,35 @@ version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +[[package]] +name = "lebe" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03087c2bad5e1034e8cace5926dec053fb3790248370865f5117a7d0213354c8" + [[package]] name = "libc" version = "0.2.169" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" +[[package]] +name = "libfuzzer-sys" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf78f52d400cf2d84a3a973a78a592b4adc535739e0a5597a0da6f0c357adc75" +dependencies = [ + "arbitrary", + "cc", +] + [[package]] name = "libredox" version = "0.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d" dependencies = [ - "bitflags", + "bitflags 2.8.0", "libc", ] @@ -1121,6 +1398,15 @@ version = "0.4.25" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f" +[[package]] +name = "loop9" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062" +dependencies = [ + "imgref", +] + [[package]] name = "lru" version = "0.12.5" @@ -1140,6 +1426,7 @@ dependencies = [ "crossterm", "dirs", "futures", + "image", "itunesdb", "rand", "ratatui", @@ -1156,6 +1443,16 @@ dependencies = [ "tui-big-text", ] +[[package]] +name = "maybe-rayon" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519" +dependencies = [ + "cfg-if", + "rayon", +] + [[package]] name = "memchr" version = "2.7.4" @@ -1178,6 +1475,12 @@ version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + [[package]] name = "miniz_oxide" version = "0.7.4" @@ -1194,6 +1497,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3b1c9bd4fe1f0f8b387f6eb9eb3b4a1aa26185e5750efb9140301703f62cd1b" dependencies = [ "adler2", + "simd-adler32", ] [[package]] @@ -1241,12 +1545,75 @@ dependencies = [ "tempfile", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "noop_proc_macro" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8" + +[[package]] +name = "num-bigint" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5e44f723f1133c9deac646763579fdb3ac745e418f2a7af9cd0c431da1f20b9" +dependencies = [ + "num-integer", + "num-traits", +] + [[package]] name = "num-conv" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" +[[package]] +name = "num-derive" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "num-integer" +version = "0.1.46" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7969661fd2958a5cb096e56c8e1ad0444ac2bbcd0061bd28660485a44879858f" +dependencies = [ + "num-traits", +] + +[[package]] +name = "num-rational" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824" +dependencies = [ + "num-bigint", + "num-integer", + "num-traits", +] + [[package]] name = "num-traits" version = "0.2.19" @@ -1286,7 +1653,7 @@ version = "0.10.70" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "61cfb4e166a8bb8c9b55c500bc2308550148ece889be90f609377e58140f42c6" dependencies = [ - "bitflags", + "bitflags 2.8.0", "cfg-if", "foreign-types", "libc", @@ -1389,6 +1756,19 @@ version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" +[[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.4", +] + [[package]] name = "powerfmt" version = "0.2.0" @@ -1413,6 +1793,40 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "profiling" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "afbdc74edc00b6f6a218ca6a5364d6226a259d4b8ea1af4a0ea063f27e179f4d" +dependencies = [ + "profiling-procmacros", +] + +[[package]] +name = "profiling-procmacros" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a65f2e60fbf1063868558d69c6beacf412dc755f9fc020f514b7955fc914fe30" +dependencies = [ + "quote", + "syn", +] + +[[package]] +name = "qoi" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7f6d64c71eb498fe9eae14ce4ec935c555749aef511cca85b5568910d6e48001" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "quick-error" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a993555f31e5a609f617c12db6250dedcac1b0a85076912c436e6fc9b2c8e6a3" + [[package]] name = "quote" version = "1.0.38" @@ -1458,7 +1872,7 @@ version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabd94c2f37801c20583fc49dd5cd6b0ba68c716787c2dd6ed18571e1e63117b" dependencies = [ - "bitflags", + "bitflags 2.8.0", "cassowary", "compact_str", "crossterm", @@ -1474,6 +1888,76 @@ dependencies = [ "unicode-width 0.2.0", ] +[[package]] +name = "rav1e" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9" +dependencies = [ + "arbitrary", + "arg_enum_proc_macro", + "arrayvec", + "av1-grain", + "bitstream-io", + "built", + "cfg-if", + "interpolate_name", + "itertools 0.12.1", + "libc", + "libfuzzer-sys", + "log", + "maybe-rayon", + "new_debug_unreachable", + "noop_proc_macro", + "num-derive", + "num-traits", + "once_cell", + "paste", + "profiling", + "rand", + "rand_chacha", + "simd_helpers", + "system-deps", + "thiserror 1.0.69", + "v_frame", + "wasm-bindgen", +] + +[[package]] +name = "ravif" +version = "0.11.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2413fd96bd0ea5cdeeb37eaf446a22e6ed7b981d792828721e74ded1980a45c6" +dependencies = [ + "avif-serialize", + "imgref", + "loop9", + "quick-error", + "rav1e", + "rayon", + "rgb", +] + +[[package]] +name = "rayon" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b418a60154510ca1a002a752ca9714984e21e4241e804d32555251faf8b78ffa" +dependencies = [ + "either", + "rayon-core", +] + +[[package]] +name = "rayon-core" +version = "1.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1465873a3dfdaa8ae7cb14b4383657caab0b3e8a0aa9ae8e04b044854c8dfce2" +dependencies = [ + "crossbeam-deque", + "crossbeam-utils", +] + [[package]] name = "readme-rustdocifier" version = "0.1.1" @@ -1486,7 +1970,7 @@ version = "0.5.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834" dependencies = [ - "bitflags", + "bitflags 2.8.0", ] [[package]] @@ -1573,6 +2057,12 @@ dependencies = [ "windows-registry", ] +[[package]] +name = "rgb" +version = "0.8.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57397d16646700483b67d2dd6511d79318f9d057fdbd21a4066aeac8b41d310a" + [[package]] name = "ring" version = "0.17.8" @@ -1610,7 +2100,7 @@ version = "0.38.44" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" dependencies = [ - "bitflags", + "bitflags 2.8.0", "errno", "libc", "linux-raw-sys", @@ -1689,7 +2179,7 @@ version = "2.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" dependencies = [ - "bitflags", + "bitflags 2.8.0", "core-foundation", "core-foundation-sys", "libc", @@ -1816,6 +2306,21 @@ dependencies = [ "libc", ] +[[package]] +name = "simd-adler32" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe" + +[[package]] +name = "simd_helpers" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6" +dependencies = [ + "quote", +] + [[package]] name = "slab" version = "0.4.9" @@ -1943,7 +2448,7 @@ version = "0.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" dependencies = [ - "bitflags", + "bitflags 2.8.0", "core-foundation", "system-configuration-sys", ] @@ -1958,6 +2463,25 @@ dependencies = [ "libc", ] +[[package]] +name = "system-deps" +version = "6.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349" +dependencies = [ + "cfg-expr", + "heck", + "pkg-config", + "toml", + "version-compare", +] + +[[package]] +name = "target-lexicon" +version = "0.12.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1" + [[package]] name = "tempfile" version = "3.16.0" @@ -2041,6 +2565,17 @@ dependencies = [ "ratatui", ] +[[package]] +name = "tiff" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e" +dependencies = [ + "flate2", + "jpeg-decoder", + "weezl", +] + [[package]] name = "time" version = "0.3.37" @@ -2318,6 +2853,17 @@ version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" +[[package]] +name = "v_frame" +version = "0.3.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6f32aaa24bacd11e488aa9ba66369c7cd514885742c9fe08cfe85884db3e92b" +dependencies = [ + "aligned-vec", + "num-traits", + "wasm-bindgen", +] + [[package]] name = "valuable" version = "0.1.1" @@ -2330,6 +2876,12 @@ version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" +[[package]] +name = "version-compare" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b" + [[package]] name = "want" version = "0.3.1" @@ -2435,6 +2987,12 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "weezl" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082" + [[package]] name = "winapi" version = "0.3.9" @@ -2602,7 +3160,7 @@ version = "0.33.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" dependencies = [ - "bitflags", + "bitflags 2.8.0", ] [[package]] @@ -2716,3 +3274,27 @@ dependencies = [ "quote", "syn", ] + +[[package]] +name = "zune-core" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a" + +[[package]] +name = "zune-inflate" +version = "0.2.54" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "73ab332fe2f6680068f3582b16a24f90ad7096d5d39b974d1c0aff0125116f02" +dependencies = [ + "simd-adler32", +] + +[[package]] +name = "zune-jpeg" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "99a5bab8d7dedf81405c4bb1f2b83ea057643d9cb28778cea9eecddeedd2e028" +dependencies = [ + "zune-core", +] diff --git a/Cargo.toml b/Cargo.toml index 601d602..c850c24 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,8 +21,9 @@ futures = "0.3" tokio = { version = "1", features = ["full"] } tokio-util = { version = "0.7.12", features = ["codec"] } soundcloud = { version = "0.1.8", git = "https://gitea.awain.net/alterwain/soundcloud_api.git" } -itunesdb = { version = "0.1.69", git = "https://gitea.awain.net/alterwain/ITunesDB.git" } +itunesdb = { version = "0.1.89", git = "https://gitea.awain.net/alterwain/ITunesDB.git" } rand = "0.8.5" tui-big-text = "0.7.1" throbber-widgets-tui = "0.8.0" -audiotags = "0.5.0" \ No newline at end of file +audiotags = "0.5.0" +image = "0.25.5" \ No newline at end of file diff --git a/src/sync.rs b/src/sync.rs index 26ba79c..94d7b16 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -1,10 +1,14 @@ -use audiotags::Tag; +use audiotags::{Picture, Tag}; use color_eyre::owo_colors::OwoColorize; +use image::imageops::FilterType; +use image::ImageReader; +use itunesdb::artworkdb::aobjects::ADatabase; use itunesdb::objects::{ListSortOrder, PlaylistItem}; use itunesdb::serializer; use itunesdb::xobjects::{XDatabase, XPlArgument, XPlaylist, XTrackItem}; use soundcloud::sobjects::{CloudPlaylist, CloudPlaylists, CloudTrack}; -use std::io::Write; +use std::io::Read; +use std::io::{Cursor, Write}; use std::path::{Path, PathBuf}; use tokio::{ fs::File, @@ -13,6 +17,7 @@ use tokio::{ }; use tokio_util::sync::CancellationToken; +use crate::util::IPodImage; use crate::{ config::{ get_config_path, get_configs_dir, get_temp_dl_dir, get_temp_itunesdb, LyricaConfiguration, @@ -325,6 +330,8 @@ async fn load_from_fs( .unwrap(); let audio_info = &audio_file.audio_file.tracks.track; + let song_dbid = hash(); + let mut track = XTrackItem::new( id, audio_info.audio_bytes as u32, @@ -332,7 +339,7 @@ async fn load_from_fs( tag.year().unwrap_or(0) as u32, (audio_info.bit_rate / 1000) as u32, audio_info.sample_rate as u32, - hash(), + song_dbid, 0, ); @@ -352,6 +359,26 @@ async fn load_from_fs( track.set_artist(artist.to_string()); } + if let Some(cover) = tag.album_cover() { + let mut adb = get_artwork_db(&ipod_path); + + let (small_img_name, large_img_name) = adb.add_images(song_dbid, id); + + let mut dst = PathBuf::from(&ipod_path); + dst.push("iPod_Control"); + dst.push("Artwork"); + + make_small_image(cover.clone(), &ipod_path, &small_img_name); + make_large_image(cover, &ipod_path, &large_img_name); + + write_artwork_db(adb, &ipod_path); + + track.data.artwork_size = 1134428; + track.data.mhii_link = 0; + track.data.has_artwork = 1; + track.data.artwork_count = 1; + } + if let Some(album) = tag.album() { track.set_album(album.title.to_string()); // TODO: Add new album into iTunesDB @@ -362,8 +389,6 @@ async fn load_from_fs( audio_file.get_audio_extension(), )); - //let cover = tag.album().unwrap().cover.unwrap(); - let dest = get_full_track_location( PathBuf::from(ipod_path.clone()), track.data.unique_id, @@ -387,6 +412,73 @@ async fn load_from_fs( id } +fn write_artwork_db(adb: ADatabase, ipod_path: &str) { + let mut dst = PathBuf::from(ipod_path); + dst.push("iPod_Control"); + dst.push("Artwork"); + dst.push("ArtworkDB"); + let bytes = itunesdb::artworkdb::serializer::to_bytes(adb); + let mut f = std::fs::File::create(dst).unwrap(); + let _ = f.write(&bytes); +} + +fn get_artwork_db(ipod_path: &str) -> ADatabase { + let mut dst = PathBuf::from(ipod_path); + dst.push("iPod_Control"); + dst.push("Artwork"); + dst.push("ArtworkDB"); + + if dst.exists() { + let mut f = std::fs::File::open(dst).unwrap(); + let mut buf = Vec::new(); + match f.read_to_end(&mut buf) { + Ok(n) => { + return itunesdb::artworkdb::deserializer::parse_bytes(&buf[..n]); + } + Err(e) => {} + } + } + itunesdb::artworkdb::deserializer::new_db() +} + +fn make_small_image(cover: Picture, ipod_path: &str, file_name: &str) { + let img: IPodImage = ImageReader::new(Cursor::new(cover.data)) + .with_guessed_format() + .unwrap() + .decode() + .unwrap() + .resize_exact(100, 100, FilterType::Lanczos3) + .into(); + + let mut dst = PathBuf::from(ipod_path); + dst.push("iPod_Control"); + dst.push("Artwork"); + + let _ = std::fs::create_dir_all(dst.clone()); + + dst.push(file_name); + img.write(dst); +} + +fn make_large_image(cover: Picture, ipod_path: &str, file_name: &str) { + let img: IPodImage = ImageReader::new(Cursor::new(cover.data)) + .with_guessed_format() + .unwrap() + .decode() + .unwrap() + .resize_exact(200, 200, FilterType::Lanczos3) + .into(); + + let mut dst = PathBuf::from(ipod_path); + dst.push("iPod_Control"); + dst.push("Artwork"); + + let _ = std::fs::create_dir_all(dst.clone()); + + dst.push(file_name); + img.write(dst); +} + async fn download_track( track: CloudTrack, database: &mut XDatabase, diff --git a/src/util.rs b/src/util.rs index 7e30eec..0e9241b 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,5 +1,8 @@ -use std::{str, process::Command, error::Error, str::FromStr}; +use image::{DynamicImage, GenericImageView}; use regex::Regex; +use std::io::Write; +use std::path::PathBuf; +use std::{error::Error, process::Command, str, str::FromStr}; const VENDOR_ID: u16 = 1452; const PRODUCT_ID: u16 = 4617; @@ -8,7 +11,7 @@ pub fn search_ipod() -> Option { for device in rusb::devices().unwrap().iter() { let device_desc = device.device_descriptor().unwrap(); if VENDOR_ID == device_desc.vendor_id() && PRODUCT_ID == device_desc.product_id() { - return get_ipod_path() + return get_ipod_path(); } } None @@ -18,28 +21,33 @@ fn list() -> Result, Box> { let mut disks = Vec::new(); let r = match Command::new("diskutil").arg("list").output() { Ok(s) => s, - Err(e) => return Err(Box::new(e)) + Err(e) => return Err(Box::new(e)), }; - if !r.status.success() { return Ok(disks); } + if !r.status.success() { + return Ok(disks); + } let rg = Regex::new(r"\d:.+ [a-zA-Z0-9].+").unwrap(); let a = match str::from_utf8(&r.stdout) { Ok(r) => r, - Err(e) => return Err(Box::new(e)) + Err(e) => return Err(Box::new(e)), }; - for cap in Regex::new(r"\/dev\/.+\(external\, physical\):").unwrap().find_iter(a) { + for cap in Regex::new(r"\/dev\/.+\(external\, physical\):") + .unwrap() + .find_iter(a) + { let mut b = &a[cap.end()..]; let i = match b.find("\n\n") { Some(r) => r, - None => return Ok(disks) + None => return Ok(disks), }; b = &b[..i]; for gap in rg.find_iter(b) { let j = match gap.as_str().rfind(" ") { Some(r) => r + 1, - None => return Ok(disks) + None => return Ok(disks), }; - let g= &gap.as_str()[j..]; + let g = &gap.as_str()[j..]; disks.push(String::from_str(g).unwrap()); } } @@ -49,18 +57,20 @@ fn list() -> Result, Box> { fn is_ipod(name: &str) -> bool { let r = match Command::new("diskutil").arg("info").arg(name).output() { Ok(s) => s, - Err(_e) => return false + Err(_e) => return false, }; - if !r.status.success() { return false; } + if !r.status.success() { + return false; + } let a = match str::from_utf8(&r.stdout) { Ok(r) => r, - Err(_e) => return false + Err(_e) => return false, }; let cap = Regex::new(r"Media Type:.+\n").unwrap().find(a); if let Some(g) = cap { let mut b = g.as_str(); let f = b.rfind(" ").unwrap() + 1; - b = &b[f..b.len()-1]; + b = &b[f..b.len() - 1]; return b == "iPod"; } false @@ -69,30 +79,85 @@ fn is_ipod(name: &str) -> bool { fn get_mount_point(name: &str) -> Option { let r = match Command::new("diskutil").arg("info").arg(name).output() { Ok(s) => s, - Err(_e) => return None + Err(_e) => return None, }; - if !r.status.success() { return None; } + if !r.status.success() { + return None; + } let a = match str::from_utf8(&r.stdout) { Ok(r) => r, - Err(_e) => return None + Err(_e) => return None, }; let cap = Regex::new(r"Mount Point:.+\n").unwrap().find(a); match cap { Some(g) => { let i = g.as_str(); let j = i.rfind(" ").unwrap() + 1; - Some(i[j..i.len()-1].to_string()) - }, - None => None + Some(i[j..i.len() - 1].to_string()) + } + None => None, } } fn get_ipod_path() -> Option { match list() { - Ok(l) => l.iter() + Ok(l) => l + .iter() .filter(|d| is_ipod(d)) .filter_map(|d| get_mount_point(d)) .last(), - Err(_e) => None + Err(_e) => None, } -} \ No newline at end of file +} + +pub struct IPodImage { + pixels: Vec, +} + +impl IPodImage { + pub fn write(&self, p: PathBuf) { + let mut file = std::fs::File::create(p).unwrap(); + let _ = file.write(&self.convert_to_u8()); + } + + fn convert_to_u8(&self) -> Vec { + self.pixels + .iter() + .flat_map(|f| [*f as u8, (*f >> 8) as u8]) + .collect() + } +} + +impl From for IPodImage { + fn from(value: DynamicImage) -> Self { + let img_rgba = value.to_rgba8(); + + let (width, height) = img_rgba.dimensions(); + + let mut rgb565_data: Vec = Vec::new(); + + for y in 0..height { + for x in 0..width { + let pixel = img_rgba.get_pixel(x, y).0; + + let r = pixel[0]; + let g = pixel[1]; + let b = pixel[2]; + + rgb565_data.push(rgb_to_rgb565(r, g, b)); + } + } + + Self { + pixels: rgb565_data, + } + } +} + +fn rgb_to_rgb565(r: u8, g: u8, b: u8) -> u16 { + let r_565 = (r >> 3) & 0x1F; // Extract top 5 bits + let g_565 = (g >> 2) & 0x3F; // Extract top 6 bits + let b_565 = (b >> 3) & 0x1F; // Extract top 5 bits + + ((r_565 as u16) << 11) | ((g_565 as u16) << 5) | (b_565 as u16) // Combine to RGB565 +}