Compare commits
7 Commits
Author | SHA1 | Date | |
---|---|---|---|
113416432b | |||
bd351b1157 | |||
106867e5ee | |||
a2128f99e6 | |||
5636f82b29 | |||
3bb7fb1010 | |||
98f1c8bdf6 |
272
Cargo.lock
generated
272
Cargo.lock
generated
@@ -2,15 +2,6 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "addr2line"
|
|
||||||
version = "0.25.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "1b5d307320b3181d6d7954e663bd7c774a838b8220fe0593c86d9fb09f498b4b"
|
|
||||||
dependencies = [
|
|
||||||
"gimli",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "adler2"
|
name = "adler2"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
@@ -38,21 +29,6 @@ version = "1.1.2"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "backtrace"
|
|
||||||
version = "0.3.76"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "bb531853791a215d7c62a30daf0dde835f381ab5de4589cfe7c649d2cbe92bd6"
|
|
||||||
dependencies = [
|
|
||||||
"addr2line",
|
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
"miniz_oxide",
|
|
||||||
"object",
|
|
||||||
"rustc-demangle",
|
|
||||||
"windows-link 0.2.1",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.22.1"
|
version = "0.22.1"
|
||||||
@@ -61,9 +37,9 @@ checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bitflags"
|
name = "bitflags"
|
||||||
version = "2.9.4"
|
version = "2.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394"
|
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
@@ -94,10 +70,21 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cfg-if"
|
name = "cfb"
|
||||||
version = "1.0.3"
|
version = "0.7.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
|
checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
"fnv",
|
||||||
|
"uuid",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "const_format"
|
name = "const_format"
|
||||||
@@ -351,27 +338,21 @@ checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
"wasi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "getrandom"
|
name = "getrandom"
|
||||||
version = "0.3.3"
|
version = "0.3.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
|
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"libc",
|
"libc",
|
||||||
"r-efi",
|
"r-efi",
|
||||||
"wasi 0.14.7+wasi-0.2.4",
|
"wasip2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gimli"
|
|
||||||
version = "0.32.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e629b9b98ef3dd8afe6ca2bd0f89306cec16d43d907889945bc5d6687f2f13c7"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "h2"
|
name = "h2"
|
||||||
version = "0.4.12"
|
version = "0.4.12"
|
||||||
@@ -528,16 +509,19 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus_meta"
|
name = "icarus_meta"
|
||||||
version = "0.4.0"
|
version = "0.4.3"
|
||||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_meta.git?tag=v0.4.0#f372d059155691c0bac52594fa0d14867078e461"
|
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_meta.git?tag=v0.4.3#c0607597f196eb71f8069f23c91359968ef639ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"imghdr",
|
||||||
|
"infer",
|
||||||
"lofty",
|
"lofty",
|
||||||
|
"rand",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus_models"
|
name = "icarus_models"
|
||||||
version = "0.7.0"
|
version = "0.8.0"
|
||||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_models.git?tag=v0.7.0#11e5b1745cdb256b027cb8ce3e18e949351ea9ea"
|
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_models.git?tag=v0.8.0#860d684e7b340b05d43d1fc3e6bd36b7cc45d81b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"josekit",
|
"josekit",
|
||||||
"rand",
|
"rand",
|
||||||
@@ -656,10 +640,16 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indexmap"
|
name = "imghdr"
|
||||||
version = "2.11.4"
|
version = "0.7.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5"
|
checksum = "c8b35f3ad95576ac81603375dfe47a0450b70a368aa34d2b6e5bb0a0d7f02428"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "indexmap"
|
||||||
|
version = "2.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6717a8d2a5a929a1a2eb43a12812498ed141a0bcfb7e8f7844fbdbe4303bba9f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"equivalent",
|
"equivalent",
|
||||||
"hashbrown",
|
"hashbrown",
|
||||||
@@ -668,14 +658,12 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "io-uring"
|
name = "infer"
|
||||||
version = "0.7.10"
|
version = "0.19.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b"
|
checksum = "a588916bfdfd92e71cacef98a63d9b1f0d74d6599980d11894290e7ddefffcf7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"cfb",
|
||||||
"cfg-if",
|
|
||||||
"libc",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -820,13 +808,13 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "1.0.4"
|
version = "1.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c"
|
checksum = "69d83b0086dc8ecf3ce9ae2874b2d1290252e2a30720bea58a5c6639b0092873"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"wasi 0.11.1+wasi-snapshot-preview1",
|
"wasi",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -852,15 +840,6 @@ version = "0.1.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "object"
|
|
||||||
version = "0.37.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "ff76201f031d8863c38aa7f905eca4f53abbfa15f609db4277d44cd8938f33fe"
|
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ogg_pager"
|
name = "ogg_pager"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
@@ -878,9 +857,9 @@ checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl"
|
name = "openssl"
|
||||||
version = "0.10.73"
|
version = "0.10.74"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
|
checksum = "24ad14dd45412269e1a30f52ad8f0664f0f4f4a89ee8fe28c3b3527021ebb654"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
@@ -910,9 +889,9 @@ checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openssl-sys"
|
name = "openssl-sys"
|
||||||
version = "0.9.109"
|
version = "0.9.110"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571"
|
checksum = "0a9f0075ba3c21b09f8e8b2026584b1d18d49388648f2fbbf3c97ea8deced8e2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cc",
|
"cc",
|
||||||
"libc",
|
"libc",
|
||||||
@@ -1047,7 +1026,7 @@ version = "0.9.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.3.3",
|
"getrandom 0.3.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1061,9 +1040,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.12.1"
|
version = "1.12.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4a52d8d02cacdb176ef4678de6c052efb4b3da14b78e4db683a4252762be5433"
|
checksum = "843bc0191f75f3e22651ae5f1e72939ab2f72a4bc30fa80a066bd66edefc24d4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -1073,9 +1052,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-automata"
|
name = "regex-automata"
|
||||||
version = "0.4.12"
|
version = "0.4.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "722166aa0d7438abbaa4d5cc2c649dac844e8c56d82fb3d33e9c34b5cd268fc6"
|
checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aho-corasick",
|
"aho-corasick",
|
||||||
"memchr",
|
"memchr",
|
||||||
@@ -1084,15 +1063,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex-syntax"
|
name = "regex-syntax"
|
||||||
version = "0.8.7"
|
version = "0.8.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c3160422bbd54dd5ecfdca71e5fd59b7b8fe2b1697ab2baf64f6d05dcc66d298"
|
checksum = "7a2d987857b319362043e95f5353c0535c1f58eec5336fdfcf626430af7def58"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest"
|
name = "reqwest"
|
||||||
version = "0.12.23"
|
version = "0.12.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d429f34c8092b2d42c7c93cec323bb4adeb7c67698f70839adec842ec10c7ceb"
|
checksum = "9d0946410b9f7b082a427e4ef5c8ff541a88b357bc6c637c40db3a68ac70a36f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -1146,12 +1125,6 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "rustc-demangle"
|
|
||||||
version = "0.1.26"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustix"
|
name = "rustix"
|
||||||
version = "1.1.2"
|
version = "1.1.2"
|
||||||
@@ -1167,9 +1140,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustls"
|
name = "rustls"
|
||||||
version = "0.23.32"
|
version = "0.23.33"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cd3c25631629d034ce7cd9940adc9d45762d46de2b0f57193c4443b92c6d4d40"
|
checksum = "751e04a496ca00bb97a5e043158d23d66b5aabf2e1d5aa2a0aaebb1aafe6f82c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustls-pki-types",
|
"rustls-pki-types",
|
||||||
@@ -1339,17 +1312,17 @@ checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "socket2"
|
name = "socket2"
|
||||||
version = "0.6.0"
|
version = "0.6.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807"
|
checksum = "17129e116933cf371d018bb80ae557e889637989d8638274fb25622827b03881"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"libc",
|
"libc",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.60.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "songparser"
|
name = "songparser"
|
||||||
version = "0.4.1"
|
version = "0.4.8"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"icarus_envy",
|
"icarus_envy",
|
||||||
@@ -1378,9 +1351,9 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.106"
|
version = "2.0.107"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
|
checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -1435,7 +1408,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
|
checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"getrandom 0.3.3",
|
"getrandom 0.3.4",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix",
|
"rustix",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
@@ -1504,29 +1477,26 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.47.1"
|
version = "1.48.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038"
|
checksum = "ff360e02eab121e0bc37a2d3b4d4dc622e6eda3a8e5253d5435ecf5bd4c68408"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
|
||||||
"bytes",
|
"bytes",
|
||||||
"io-uring",
|
|
||||||
"libc",
|
"libc",
|
||||||
"mio",
|
"mio",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"slab",
|
|
||||||
"socket2",
|
"socket2",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"windows-sys 0.59.0",
|
"windows-sys 0.61.2",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio-macros"
|
name = "tokio-macros"
|
||||||
version = "2.5.0"
|
version = "2.6.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
|
checksum = "af407857209536a95c8e56f8231ef2c2e2aff839b22e07a1ffcbc617e9db9fa5"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -1708,7 +1678,7 @@ version = "1.18.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
|
checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.3.3",
|
"getrandom 0.3.4",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
"serde",
|
"serde",
|
||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
@@ -1735,15 +1705,6 @@ version = "0.11.1+wasi-snapshot-preview1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "wasi"
|
|
||||||
version = "0.14.7+wasi-0.2.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c"
|
|
||||||
dependencies = [
|
|
||||||
"wasip2",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasip2"
|
name = "wasip2"
|
||||||
version = "1.0.1+wasi-0.2.4"
|
version = "1.0.1+wasi-0.2.4"
|
||||||
@@ -1895,16 +1856,16 @@ version = "0.52.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-targets 0.52.6",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows-sys"
|
name = "windows-sys"
|
||||||
version = "0.59.0"
|
version = "0.60.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
checksum = "f2f500e4d28234f72040990ec9d39e3a6b950f9f22d3dba18416c35882612bcb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows-targets",
|
"windows-targets 0.53.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1922,14 +1883,31 @@ version = "0.52.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"windows_aarch64_gnullvm",
|
"windows_aarch64_gnullvm 0.52.6",
|
||||||
"windows_aarch64_msvc",
|
"windows_aarch64_msvc 0.52.6",
|
||||||
"windows_i686_gnu",
|
"windows_i686_gnu 0.52.6",
|
||||||
"windows_i686_gnullvm",
|
"windows_i686_gnullvm 0.52.6",
|
||||||
"windows_i686_msvc",
|
"windows_i686_msvc 0.52.6",
|
||||||
"windows_x86_64_gnu",
|
"windows_x86_64_gnu 0.52.6",
|
||||||
"windows_x86_64_gnullvm",
|
"windows_x86_64_gnullvm 0.52.6",
|
||||||
"windows_x86_64_msvc",
|
"windows_x86_64_msvc 0.52.6",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows-targets"
|
||||||
|
version = "0.53.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "4945f9f551b88e0d65f3db0bc25c33b8acea4d9e41163edf90dcd0b19f9069f3"
|
||||||
|
dependencies = [
|
||||||
|
"windows-link 0.2.1",
|
||||||
|
"windows_aarch64_gnullvm 0.53.1",
|
||||||
|
"windows_aarch64_msvc 0.53.1",
|
||||||
|
"windows_i686_gnu 0.53.1",
|
||||||
|
"windows_i686_gnullvm 0.53.1",
|
||||||
|
"windows_i686_msvc 0.53.1",
|
||||||
|
"windows_x86_64_gnu 0.53.1",
|
||||||
|
"windows_x86_64_gnullvm 0.53.1",
|
||||||
|
"windows_x86_64_msvc 0.53.1",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1938,48 +1916,96 @@ version = "0.52.6"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_gnullvm"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a9d8416fa8b42f5c947f8482c43e7d89e73a173cead56d044f6a56104a6d1b53"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_aarch64_msvc"
|
name = "windows_aarch64_msvc"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_aarch64_msvc"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b9d782e804c2f632e395708e99a94275910eb9100b2114651e04744e9b125006"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnu"
|
name = "windows_i686_gnu"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnu"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "960e6da069d81e09becb0ca57a65220ddff016ff2d6af6a223cf372a506593a3"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_gnullvm"
|
name = "windows_i686_gnullvm"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_gnullvm"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fa7359d10048f68ab8b09fa71c3daccfb0e9b559aed648a8f95469c27057180c"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_i686_msvc"
|
name = "windows_i686_msvc"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_i686_msvc"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1e7ac75179f18232fe9c285163565a57ef8d3c89254a30685b57d83a38d326c2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnu"
|
name = "windows_x86_64_gnu"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnu"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c3842cdd74a865a8066ab39c8a7a473c0778a3f29370b5fd6b4b9aa7df4a499"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_gnullvm"
|
name = "windows_x86_64_gnullvm"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_gnullvm"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0ffa179e2d07eee8ad8f57493436566c7cc30ac536a3379fdf008f47f6bb7ae1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "windows_x86_64_msvc"
|
name = "windows_x86_64_msvc"
|
||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "windows_x86_64_msvc"
|
||||||
|
version = "0.53.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wit-bindgen"
|
name = "wit-bindgen"
|
||||||
version = "0.46.0"
|
version = "0.46.0"
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "songparser"
|
name = "songparser"
|
||||||
version = "0.4.1"
|
version = "0.4.8"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.90"
|
rust-version = "1.90"
|
||||||
|
|
||||||
@@ -13,6 +13,6 @@ serde_json = { version = "1.0.145" }
|
|||||||
time = { version = "0.3.44", features = ["macros", "serde"] }
|
time = { version = "0.3.44", features = ["macros", "serde"] }
|
||||||
uuid = { version = "1.18.1", features = ["v4", "serde"] }
|
uuid = { version = "1.18.1", features = ["v4", "serde"] }
|
||||||
rand = { version = "0.9.2" }
|
rand = { version = "0.9.2" }
|
||||||
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.4.0" }
|
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.4.3" }
|
||||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.7.0" }
|
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.8.0" }
|
||||||
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.5.0" }
|
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.5.0" }
|
||||||
|
28
src/api.rs
28
src/api.rs
@@ -158,6 +158,7 @@ pub mod get_coverart_queue {
|
|||||||
#[derive(Debug, Deserialize, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct CoverArtQueue {
|
pub struct CoverArtQueue {
|
||||||
pub id: uuid::Uuid,
|
pub id: uuid::Uuid,
|
||||||
|
pub file_type: String,
|
||||||
pub song_queue_id: uuid::Uuid,
|
pub song_queue_id: uuid::Uuid,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,21 +193,19 @@ pub mod refresh_token {
|
|||||||
pub mod update_queued_song {
|
pub mod update_queued_song {
|
||||||
pub async fn update_queued_song(
|
pub async fn update_queued_song(
|
||||||
app: &crate::config::App,
|
app: &crate::config::App,
|
||||||
song_path: &String,
|
queued_song: &crate::queued_item::QueuedSong,
|
||||||
song_queue_id: &uuid::Uuid,
|
|
||||||
) -> Result<reqwest::Response, reqwest::Error> {
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
let client = reqwest::Client::builder().build()?;
|
let client = reqwest::Client::builder().build()?;
|
||||||
|
|
||||||
println!("Song path: {song_path:?}");
|
println!("Queued song path: {:?}", queued_song.path);
|
||||||
|
|
||||||
// TODO: Make the filename random
|
|
||||||
let form = reqwest::multipart::Form::new().part(
|
let form = reqwest::multipart::Form::new().part(
|
||||||
"file",
|
"file",
|
||||||
reqwest::multipart::Part::bytes(std::fs::read(song_path).unwrap())
|
reqwest::multipart::Part::bytes(std::fs::read(&queued_song.path).unwrap())
|
||||||
.file_name("track01.flac"),
|
.file_name(queued_song.song.filename.clone()),
|
||||||
);
|
);
|
||||||
|
|
||||||
let url = format!("{}/api/v2/song/queue/{song_queue_id}", app.uri);
|
let url = format!("{}/api/v2/song/queue/{}", app.uri, queued_song.id);
|
||||||
println!("Url: {url:?}");
|
println!("Url: {url:?}");
|
||||||
|
|
||||||
let (key, header) = crate::api::auth_header(app).await;
|
let (key, header) = crate::api::auth_header(app).await;
|
||||||
@@ -273,15 +272,14 @@ pub mod create_song {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub mod create_coverart {
|
pub mod create_coverart {
|
||||||
|
|
||||||
pub async fn create(
|
pub async fn create(
|
||||||
app: &crate::config::App,
|
app: &crate::config::App,
|
||||||
song_id: &uuid::Uuid,
|
song: &icarus_models::song::Song,
|
||||||
coverart_queue_id: &uuid::Uuid,
|
queued_coverart: &crate::queued_item::QueuedCoverArt,
|
||||||
) -> Result<reqwest::Response, reqwest::Error> {
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
let client = reqwest::Client::builder().build()?;
|
let client = reqwest::Client::builder().build()?;
|
||||||
let url = format!("{}/api/v2/coverart", app.uri);
|
let url = format!("{}/api/v2/coverart", app.uri);
|
||||||
let payload = get_payload(song_id, coverart_queue_id);
|
let payload = get_payload(&song.id, &queued_coverart.id);
|
||||||
let (key, header) = crate::api::auth_header(app).await;
|
let (key, header) = crate::api::auth_header(app).await;
|
||||||
let request = client.post(url).json(&payload).header(key, header);
|
let request = client.post(url).json(&payload).header(key, header);
|
||||||
|
|
||||||
@@ -308,12 +306,12 @@ pub mod wipe_data {
|
|||||||
pub mod song_queue {
|
pub mod song_queue {
|
||||||
pub async fn wipe_data(
|
pub async fn wipe_data(
|
||||||
app: &crate::config::App,
|
app: &crate::config::App,
|
||||||
song_queue_id: &uuid::Uuid,
|
queued_song: &crate::queued_item::QueuedSong,
|
||||||
) -> Result<reqwest::Response, reqwest::Error> {
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
let client = reqwest::Client::builder().build()?;
|
let client = reqwest::Client::builder().build()?;
|
||||||
let url = format!("{}/api/v2/song/queue/data/wipe", app.uri);
|
let url = format!("{}/api/v2/song/queue/data/wipe", app.uri);
|
||||||
let payload = serde_json::json!({
|
let payload = serde_json::json!({
|
||||||
"song_queue_id": song_queue_id
|
"song_queue_id": queued_song.id
|
||||||
});
|
});
|
||||||
let (key, header) = crate::api::auth_header(app).await;
|
let (key, header) = crate::api::auth_header(app).await;
|
||||||
let request = client.patch(url).json(&payload).header(key, header);
|
let request = client.patch(url).json(&payload).header(key, header);
|
||||||
@@ -332,12 +330,12 @@ pub mod wipe_data {
|
|||||||
pub mod coverart_queue {
|
pub mod coverart_queue {
|
||||||
pub async fn wipe_data(
|
pub async fn wipe_data(
|
||||||
app: &crate::config::App,
|
app: &crate::config::App,
|
||||||
coverart_queue_id: &uuid::Uuid,
|
queued_coverart: &crate::queued_item::QueuedCoverArt,
|
||||||
) -> Result<reqwest::Response, reqwest::Error> {
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
let client = reqwest::Client::builder().build()?;
|
let client = reqwest::Client::builder().build()?;
|
||||||
let url = format!("{}/api/v2/coverart/queue/data/wipe", app.uri);
|
let url = format!("{}/api/v2/coverart/queue/data/wipe", app.uri);
|
||||||
let payload = serde_json::json!({
|
let payload = serde_json::json!({
|
||||||
"coverart_queue_id": coverart_queue_id
|
"coverart_queue_id": queued_coverart.id
|
||||||
});
|
});
|
||||||
let (key, header) = crate::api::auth_header(app).await;
|
let (key, header) = crate::api::auth_header(app).await;
|
||||||
let request = client.patch(url).json(&payload).header(key, header);
|
let request = client.patch(url).json(&payload).header(key, header);
|
||||||
|
57
src/auth/mod.rs
Normal file
57
src/auth/mod.rs
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
pub async fn get_token(
|
||||||
|
app: &crate::config::App,
|
||||||
|
) -> Result<icarus_models::login_result::LoginResult, std::io::Error> {
|
||||||
|
let client = reqwest::Client::new();
|
||||||
|
let endpoint = String::from("api/v2/service/login");
|
||||||
|
let api_url = format!("{}/{endpoint}", app.auth_uri);
|
||||||
|
|
||||||
|
let payload = serde_json::json!({
|
||||||
|
"passphrase": icarus_envy::environment::get_service_passphrase().await.value,
|
||||||
|
});
|
||||||
|
|
||||||
|
match client.post(api_url).json(&payload).send().await {
|
||||||
|
Ok(response) => match response
|
||||||
|
.json::<crate::api::service_token::response::Response>()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(resp) => {
|
||||||
|
if resp.data.is_empty() {
|
||||||
|
Err(std::io::Error::other(String::from("No token returned")))
|
||||||
|
} else {
|
||||||
|
Ok(resp.data[0].clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
},
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn get_refresh_token(
|
||||||
|
app: &crate::config::App,
|
||||||
|
) -> Result<icarus_models::login_result::LoginResult, std::io::Error> {
|
||||||
|
let client = reqwest::Client::new();
|
||||||
|
let endpoint = String::from("api/v2/token/refresh");
|
||||||
|
let api_url = format!("{}/{endpoint}", app.auth_uri);
|
||||||
|
|
||||||
|
let payload = serde_json::json!({
|
||||||
|
"access_token": app.token.token
|
||||||
|
});
|
||||||
|
|
||||||
|
match client.post(api_url).json(&payload).send().await {
|
||||||
|
Ok(response) => match response
|
||||||
|
.json::<crate::api::refresh_token::response::Response>()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(resp) => {
|
||||||
|
if resp.data.is_empty() {
|
||||||
|
Err(std::io::Error::other(String::from("No token returned")))
|
||||||
|
} else {
|
||||||
|
Ok(resp.data[0].clone())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
},
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
}
|
||||||
|
}
|
537
src/main.rs
537
src/main.rs
@@ -1,5 +1,10 @@
|
|||||||
pub mod api;
|
pub mod api;
|
||||||
|
pub mod auth;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
|
pub mod metadata;
|
||||||
|
pub mod parser;
|
||||||
|
pub mod queue;
|
||||||
|
pub mod queued_item;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
pub const SECONDS_TO_SLEEP: u64 = 5;
|
pub const SECONDS_TO_SLEEP: u64 = 5;
|
||||||
@@ -31,7 +36,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
loop {
|
loop {
|
||||||
println!("Token: {:?}", app.token);
|
println!("Token: {:?}", app.token);
|
||||||
|
|
||||||
if auth::did_token_expire(&app.token).await {
|
if app.token.token_expired() {
|
||||||
println!("Token expired");
|
println!("Token expired");
|
||||||
app.token = match auth::get_refresh_token(&app).await {
|
app.token = match auth::get_refresh_token(&app).await {
|
||||||
Ok(login_result) => login_result,
|
Ok(login_result) => login_result,
|
||||||
@@ -47,7 +52,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
println!("Token did not expire");
|
println!("Token did not expire");
|
||||||
}
|
}
|
||||||
|
|
||||||
match is_queue_empty(&app).await {
|
match queue::is_queue_empty(&app).await {
|
||||||
Ok((empty, song_queue_item)) => {
|
Ok((empty, song_queue_item)) => {
|
||||||
if !empty {
|
if !empty {
|
||||||
println!("Queue is not empty");
|
println!("Queue is not empty");
|
||||||
@@ -56,17 +61,12 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let song_queue_id = song_queue_item.data[0].id;
|
let song_queue_id = song_queue_item.data[0].id;
|
||||||
let user_id = song_queue_item.data[0].user_id;
|
let user_id = song_queue_item.data[0].user_id;
|
||||||
|
|
||||||
match some_work(&app, &song_queue_id, &user_id).await {
|
match parser::some_work(&app, &song_queue_id, &user_id).await {
|
||||||
Ok((
|
Ok((song, coverart, _metadata, queued_song, queued_coverart)) => {
|
||||||
song,
|
match queue::wipe_data_from_queues(&app, &queued_song, &queued_coverart)
|
||||||
coverart,
|
|
||||||
(song_queue_id, _song_queue_path),
|
|
||||||
(coverart_queue_id, _coverart_queue_path),
|
|
||||||
)) => {
|
|
||||||
match wipe_data_from_queues(&app, &song_queue_id, &coverart_queue_id)
|
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => match cleanup(&song, &coverart).await {
|
Ok(_) => match parser::cleanup(&song, &coverart).await {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!("Successful cleanup");
|
println!("Successful cleanup");
|
||||||
}
|
}
|
||||||
@@ -96,518 +96,3 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
tokio::time::sleep(tokio::time::Duration::from_secs(SECONDS_TO_SLEEP)).await;
|
tokio::time::sleep(tokio::time::Duration::from_secs(SECONDS_TO_SLEEP)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mod auth {
|
|
||||||
pub async fn get_token(
|
|
||||||
app: &crate::config::App,
|
|
||||||
) -> Result<icarus_models::login_result::LoginResult, std::io::Error> {
|
|
||||||
let client = reqwest::Client::new();
|
|
||||||
let endpoint = String::from("api/v2/service/login");
|
|
||||||
let api_url = format!("{}/{endpoint}", app.auth_uri);
|
|
||||||
|
|
||||||
let payload = serde_json::json!({
|
|
||||||
"passphrase": icarus_envy::environment::get_service_passphrase().await.value,
|
|
||||||
});
|
|
||||||
|
|
||||||
match client.post(api_url).json(&payload).send().await {
|
|
||||||
Ok(response) => match response
|
|
||||||
.json::<crate::api::service_token::response::Response>()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(resp) => {
|
|
||||||
if resp.data.is_empty() {
|
|
||||||
Err(std::io::Error::other(String::from("No token returned")))
|
|
||||||
} else {
|
|
||||||
Ok(resp.data[0].clone())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
},
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Might want to put the functionality within icarus_models at some point
|
|
||||||
pub async fn did_token_expire(login_result: &icarus_models::login_result::LoginResult) -> bool {
|
|
||||||
let current_time = time::OffsetDateTime::now_utc();
|
|
||||||
let expire_time =
|
|
||||||
time::OffsetDateTime::from_unix_timestamp(login_result.expiration).unwrap();
|
|
||||||
current_time > expire_time
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn get_refresh_token(
|
|
||||||
app: &crate::config::App,
|
|
||||||
) -> Result<icarus_models::login_result::LoginResult, std::io::Error> {
|
|
||||||
let client = reqwest::Client::new();
|
|
||||||
let endpoint = String::from("api/v2/token/refresh");
|
|
||||||
let api_url = format!("{}/{endpoint}", app.auth_uri);
|
|
||||||
|
|
||||||
let payload = serde_json::json!({
|
|
||||||
"access_token": app.token.token
|
|
||||||
});
|
|
||||||
|
|
||||||
match client.post(api_url).json(&payload).send().await {
|
|
||||||
Ok(response) => match response
|
|
||||||
.json::<crate::api::refresh_token::response::Response>()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(resp) => {
|
|
||||||
if resp.data.is_empty() {
|
|
||||||
Err(std::io::Error::other(String::from("No token returned")))
|
|
||||||
} else {
|
|
||||||
Ok(resp.data[0].clone())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
},
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn wipe_data_from_queues(
|
|
||||||
app: &config::App,
|
|
||||||
song_queue_id: &uuid::Uuid,
|
|
||||||
coverart_queue_id: &uuid::Uuid,
|
|
||||||
) -> Result<(), std::io::Error> {
|
|
||||||
match api::wipe_data::song_queue::wipe_data(app, song_queue_id).await {
|
|
||||||
Ok(response) => match response
|
|
||||||
.json::<api::wipe_data::song_queue::response::Response>()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(_resp) => {
|
|
||||||
match api::wipe_data::coverart_queue::wipe_data(app, coverart_queue_id).await {
|
|
||||||
Ok(inner_response) => match inner_response
|
|
||||||
.json::<api::wipe_data::coverart_queue::response::Response>()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(_inner_resp) => {
|
|
||||||
println!("Wiped data from CoverArt queue");
|
|
||||||
println!("Resp: {_inner_resp:?}");
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
},
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
},
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn cleanup(
|
|
||||||
song: &icarus_models::song::Song,
|
|
||||||
coverart: &icarus_models::coverart::CoverArt,
|
|
||||||
) -> Result<(), std::io::Error> {
|
|
||||||
match song.remove_from_filesystem() {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(err) => {
|
|
||||||
eprintln!("Error: Problem cleaning up SongQueue files {err:?}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
match coverart.remove_from_filesystem() {
|
|
||||||
Ok(_) => Ok(()),
|
|
||||||
Err(err) => Err(err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn is_queue_empty(
|
|
||||||
app: &config::App,
|
|
||||||
) -> Result<(bool, api::fetch_next_queue_item::response::SongQueueItem), reqwest::Error> {
|
|
||||||
match api::fetch_next_queue_item::fetch_next_queue_item(app).await {
|
|
||||||
Ok(response) => {
|
|
||||||
match response
|
|
||||||
.json::<api::fetch_next_queue_item::response::SongQueueItem>()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(response) => {
|
|
||||||
if response.data.is_empty() {
|
|
||||||
Ok((true, response))
|
|
||||||
} else {
|
|
||||||
Ok((false, response))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn some_work(
|
|
||||||
app: &crate::config::App,
|
|
||||||
song_queue_id: &uuid::Uuid,
|
|
||||||
user_id: &uuid::Uuid,
|
|
||||||
) -> Result<
|
|
||||||
(
|
|
||||||
icarus_models::song::Song,
|
|
||||||
icarus_models::coverart::CoverArt,
|
|
||||||
(uuid::Uuid, String),
|
|
||||||
(uuid::Uuid, String),
|
|
||||||
),
|
|
||||||
std::io::Error,
|
|
||||||
> {
|
|
||||||
match prep_song(app, song_queue_id).await {
|
|
||||||
Ok(((song_directory, song_filename), coverart_queue_path, metadata, coverart_queue_id)) => {
|
|
||||||
let mut song_queue_path: String = String::new();
|
|
||||||
let p = std::path::Path::new(&song_directory);
|
|
||||||
let sp = p.join(&song_filename);
|
|
||||||
song_queue_path.push_str(sp.to_str().unwrap_or_default());
|
|
||||||
|
|
||||||
match apply_metadata(&song_queue_path, &coverart_queue_path, &metadata).await {
|
|
||||||
Ok(_applied) => {
|
|
||||||
match api::update_queued_song::update_queued_song(
|
|
||||||
app,
|
|
||||||
&song_queue_path,
|
|
||||||
song_queue_id,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(response) => {
|
|
||||||
match response
|
|
||||||
.json::<api::update_queued_song::response::Response>()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(_inner_response) => {
|
|
||||||
println!("Response: {_inner_response:?}");
|
|
||||||
|
|
||||||
// TODO: Place this somewhere else
|
|
||||||
let song_type = String::from("flac");
|
|
||||||
|
|
||||||
match api::create_song::create(
|
|
||||||
app, &metadata, user_id, &song_type,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(response) => match response
|
|
||||||
.json::<api::create_song::response::Response>()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(resp) => {
|
|
||||||
println!("Response: {resp:?}");
|
|
||||||
|
|
||||||
let mut song = resp.data[0].clone();
|
|
||||||
song.directory = song_directory;
|
|
||||||
song.filename = song_filename;
|
|
||||||
|
|
||||||
match api::create_coverart::create(app, &song.id, &coverart_queue_id).await {
|
|
||||||
Ok(response) => match response.json::<api::create_coverart::response::Response>().await {
|
|
||||||
Ok(resp) => {
|
|
||||||
println!("CoverArt sent and successfully parsed response");
|
|
||||||
println!("json: {resp:?}");
|
|
||||||
let mut coverart = resp.data[0].clone();
|
|
||||||
coverart.path = coverart_queue_path.clone();
|
|
||||||
Ok((song.clone(), coverart.clone(), (metadata.song_queue_id, song_queue_path), (coverart_queue_id, coverart_queue_path)))
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
Err(std::io::Error::other(err.to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
Err(std::io::Error::other(err.to_string()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
},
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn prep_song(
|
|
||||||
app: &crate::config::App,
|
|
||||||
song_queue_id: &uuid::Uuid,
|
|
||||||
) -> Result<
|
|
||||||
(
|
|
||||||
(String, String),
|
|
||||||
String,
|
|
||||||
api::get_metadata_queue::response::Metadata,
|
|
||||||
uuid::Uuid,
|
|
||||||
),
|
|
||||||
reqwest::Error,
|
|
||||||
> {
|
|
||||||
match api::fetch_song_queue_data::get_data(app, song_queue_id).await {
|
|
||||||
Ok(response) => {
|
|
||||||
// Process data here...
|
|
||||||
match api::parsing::parse_response_into_bytes(response).await {
|
|
||||||
Ok(song_bytes) => {
|
|
||||||
let (song_directory, song_filename) =
|
|
||||||
generate_song_queue_dir_and_filename().await;
|
|
||||||
let song = icarus_models::song::Song {
|
|
||||||
directory: song_directory,
|
|
||||||
filename: song_filename,
|
|
||||||
data: song_bytes,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
let songpath = song.song_path().unwrap_or_default();
|
|
||||||
let song_queue_path = match song.save_to_filesystem() {
|
|
||||||
Ok(_) => std::path::Path::new(&songpath),
|
|
||||||
Err(_err) => std::path::Path::new(""),
|
|
||||||
};
|
|
||||||
|
|
||||||
println!("Saved at: {song_queue_path:?}");
|
|
||||||
|
|
||||||
match api::get_metadata_queue::get(app, song_queue_id).await {
|
|
||||||
Ok(response) => {
|
|
||||||
match response
|
|
||||||
.json::<api::get_metadata_queue::response::Response>()
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(response) => {
|
|
||||||
let id = &response.data[0].id;
|
|
||||||
let created_at = &response.data[0].created_at;
|
|
||||||
let metadata = &response.data[0].metadata;
|
|
||||||
println!("Id: {id:?}");
|
|
||||||
println!("Metadata: {metadata:?}");
|
|
||||||
println!("Created at: {created_at:?}");
|
|
||||||
|
|
||||||
println!("Getting coverart queue");
|
|
||||||
match api::get_coverart_queue::get(app, song_queue_id).await {
|
|
||||||
Ok(response) => {
|
|
||||||
match response.json::<api::get_coverart_queue::response::Response>().await {
|
|
||||||
Ok(response) => {
|
|
||||||
let coverart_queue_id = &response.data[0].id;
|
|
||||||
println!("Coverart queue Id: {coverart_queue_id:?}");
|
|
||||||
|
|
||||||
match api::get_coverart_queue::get_data(app, coverart_queue_id).await {
|
|
||||||
Ok(response) => match api::parsing::parse_response_into_bytes(response).await {
|
|
||||||
Ok(coverart_queue_bytes) => {
|
|
||||||
let (directory, filename) = generate_coverart_queue_dir_and_filename().await;
|
|
||||||
let coverart = icarus_models::coverart::CoverArt {
|
|
||||||
path: directory + "/" + &filename,
|
|
||||||
data: coverart_queue_bytes,
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
coverart.save_to_filesystem().unwrap();
|
|
||||||
let coverart_queue_path = std::path::Path::new(&coverart.path);
|
|
||||||
println!("Saved coverart queue file at: {coverart_queue_path:?}");
|
|
||||||
|
|
||||||
let c_path = util::path_buf_to_string(coverart_queue_path);
|
|
||||||
Ok(((song.directory, song.filename), c_path, metadata.clone(), *coverart_queue_id))
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
Err(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
Err(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
Err(err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Consider having something like this in icarus_models
|
|
||||||
pub async fn generate_song_queue_dir_and_filename() -> (String, String) {
|
|
||||||
let mut song = icarus_models::song::Song::default();
|
|
||||||
song.filename = icarus_models::song::generate_filename(
|
|
||||||
icarus_models::types::MusicTypes::FlacExtension,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
|
|
||||||
song.directory = icarus_envy::environment::get_root_directory().await.value;
|
|
||||||
|
|
||||||
(song.directory, song.filename)
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Consider having something like this in icarus_models
|
|
||||||
pub async fn generate_coverart_queue_dir_and_filename() -> (String, String) {
|
|
||||||
use rand::Rng;
|
|
||||||
|
|
||||||
let mut filename: String = String::new();
|
|
||||||
let filename_len = 10;
|
|
||||||
|
|
||||||
let some_chars: String = String::from("abcdefghij0123456789");
|
|
||||||
let mut rng = rand::rng();
|
|
||||||
|
|
||||||
for _i in 0..filename_len {
|
|
||||||
let random_number: i32 = rng.random_range(0..=19);
|
|
||||||
let index = random_number as usize;
|
|
||||||
let rando_char = some_chars.chars().nth(index);
|
|
||||||
|
|
||||||
if let Some(c) = rando_char {
|
|
||||||
filename.push(c);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Do not hard code the file extension
|
|
||||||
filename += ".jpeg";
|
|
||||||
|
|
||||||
// TODO: Consider separating song and coverart when saving to the filesystem
|
|
||||||
let directory = icarus_envy::environment::get_root_directory().await.value;
|
|
||||||
|
|
||||||
(directory, filename)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn apply_metadata(
|
|
||||||
song_queue_path: &String,
|
|
||||||
coverart_queue_path: &String,
|
|
||||||
metadata: &api::get_metadata_queue::response::Metadata,
|
|
||||||
) -> Result<bool, std::io::Error> {
|
|
||||||
// Apply metadata fields
|
|
||||||
let types = icarus_meta::types::all_metadata_types();
|
|
||||||
|
|
||||||
for t in types {
|
|
||||||
match t {
|
|
||||||
icarus_meta::types::Type::Album => {
|
|
||||||
let meta_type =
|
|
||||||
icarus_meta::types::MetadataType::from_string(metadata.album.clone());
|
|
||||||
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(_err) => {
|
|
||||||
return Err(_err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
icarus_meta::types::Type::AlbumArtist => {
|
|
||||||
let meta_type =
|
|
||||||
icarus_meta::types::MetadataType::from_string(metadata.album_artist.clone());
|
|
||||||
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(_err) => {
|
|
||||||
return Err(_err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
icarus_meta::types::Type::Artist => {
|
|
||||||
let meta_type =
|
|
||||||
icarus_meta::types::MetadataType::from_string(metadata.artist.clone());
|
|
||||||
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(_err) => {
|
|
||||||
return Err(_err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
icarus_meta::types::Type::Date => {
|
|
||||||
// TODO: Do something about this discrepancy
|
|
||||||
let meta_type =
|
|
||||||
icarus_meta::types::MetadataType::from_string(metadata.year.to_string());
|
|
||||||
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(_err) => {
|
|
||||||
return Err(_err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
icarus_meta::types::Type::Disc => {
|
|
||||||
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.disc);
|
|
||||||
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(_err) => {
|
|
||||||
return Err(_err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
icarus_meta::types::Type::Genre => {
|
|
||||||
let meta_type =
|
|
||||||
icarus_meta::types::MetadataType::from_string(metadata.genre.clone());
|
|
||||||
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(_err) => {
|
|
||||||
return Err(_err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
icarus_meta::types::Type::Title => {
|
|
||||||
let meta_type =
|
|
||||||
icarus_meta::types::MetadataType::from_string(metadata.title.clone());
|
|
||||||
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(_err) => {
|
|
||||||
return Err(_err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
icarus_meta::types::Type::Track => {
|
|
||||||
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.track);
|
|
||||||
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(_err) => {
|
|
||||||
return Err(_err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
icarus_meta::types::Type::TrackCount => {
|
|
||||||
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.track_count);
|
|
||||||
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(_err) => {
|
|
||||||
return Err(_err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
icarus_meta::types::Type::DiscCount => {
|
|
||||||
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.disc_count);
|
|
||||||
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(_err) => {
|
|
||||||
return Err(_err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply coverart
|
|
||||||
match icarus_meta::meta::coverart::contains_coverart(song_queue_path) {
|
|
||||||
Ok((exists, size)) => {
|
|
||||||
if exists {
|
|
||||||
println!("Coverart exists: {size:?} size");
|
|
||||||
match icarus_meta::meta::coverart::remove_coverart(song_queue_path) {
|
|
||||||
Ok(_data) => {}
|
|
||||||
Err(err) => {
|
|
||||||
return Err(err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
match icarus_meta::meta::coverart::set_coverart(song_queue_path, coverart_queue_path) {
|
|
||||||
Ok(_data) => {
|
|
||||||
if _data.is_empty() {
|
|
||||||
println!("There was an issue");
|
|
||||||
Ok(false)
|
|
||||||
} else {
|
|
||||||
println!("Success in applying coverart to song");
|
|
||||||
Ok(true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(err) => Err(err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
143
src/metadata/mod.rs
Normal file
143
src/metadata/mod.rs
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
/// Applies metadata to the queued song
|
||||||
|
pub async fn apply_metadata(
|
||||||
|
queued_song: &crate::queued_item::QueuedSong,
|
||||||
|
queued_coverart: &crate::queued_item::QueuedCoverArt,
|
||||||
|
metadata: &crate::api::get_metadata_queue::response::Metadata,
|
||||||
|
) -> Result<bool, std::io::Error> {
|
||||||
|
// Apply metadata fields
|
||||||
|
let types = icarus_meta::types::all_metadata_types();
|
||||||
|
|
||||||
|
for t in types {
|
||||||
|
match t {
|
||||||
|
icarus_meta::types::Type::Album => {
|
||||||
|
let meta_type =
|
||||||
|
icarus_meta::types::MetadataType::from_string(metadata.album.clone());
|
||||||
|
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(_err) => {
|
||||||
|
return Err(_err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
icarus_meta::types::Type::AlbumArtist => {
|
||||||
|
let meta_type =
|
||||||
|
icarus_meta::types::MetadataType::from_string(metadata.album_artist.clone());
|
||||||
|
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(_err) => {
|
||||||
|
return Err(_err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
icarus_meta::types::Type::Artist => {
|
||||||
|
let meta_type =
|
||||||
|
icarus_meta::types::MetadataType::from_string(metadata.artist.clone());
|
||||||
|
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(_err) => {
|
||||||
|
return Err(_err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
icarus_meta::types::Type::Date => {
|
||||||
|
// TODO: Do something about this discrepancy
|
||||||
|
let meta_type =
|
||||||
|
icarus_meta::types::MetadataType::from_string(metadata.year.to_string());
|
||||||
|
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(_err) => {
|
||||||
|
return Err(_err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
icarus_meta::types::Type::Disc => {
|
||||||
|
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.disc);
|
||||||
|
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(_err) => {
|
||||||
|
return Err(_err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
icarus_meta::types::Type::Genre => {
|
||||||
|
let meta_type =
|
||||||
|
icarus_meta::types::MetadataType::from_string(metadata.genre.clone());
|
||||||
|
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(_err) => {
|
||||||
|
return Err(_err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
icarus_meta::types::Type::Title => {
|
||||||
|
let meta_type =
|
||||||
|
icarus_meta::types::MetadataType::from_string(metadata.title.clone());
|
||||||
|
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(_err) => {
|
||||||
|
return Err(_err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
icarus_meta::types::Type::Track => {
|
||||||
|
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.track);
|
||||||
|
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(_err) => {
|
||||||
|
return Err(_err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
icarus_meta::types::Type::TrackCount => {
|
||||||
|
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.track_count);
|
||||||
|
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(_err) => {
|
||||||
|
return Err(_err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
icarus_meta::types::Type::DiscCount => {
|
||||||
|
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.disc_count);
|
||||||
|
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(_err) => {
|
||||||
|
return Err(_err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply coverart
|
||||||
|
match icarus_meta::meta::coverart::contains_coverart(&queued_song.path) {
|
||||||
|
Ok((exists, size)) => {
|
||||||
|
if exists {
|
||||||
|
println!("Coverart exists: {size:?} size");
|
||||||
|
match icarus_meta::meta::coverart::remove_coverart(&queued_song.path) {
|
||||||
|
Ok(_data) => {}
|
||||||
|
Err(err) => {
|
||||||
|
return Err(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
match icarus_meta::meta::coverart::set_coverart(
|
||||||
|
&queued_song.path,
|
||||||
|
&queued_coverart.path,
|
||||||
|
) {
|
||||||
|
Ok(_data) => {
|
||||||
|
if _data.is_empty() {
|
||||||
|
println!("There was an issue");
|
||||||
|
Ok(false)
|
||||||
|
} else {
|
||||||
|
println!("Success in applying coverart to song");
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
234
src/parser/mod.rs
Normal file
234
src/parser/mod.rs
Normal file
@@ -0,0 +1,234 @@
|
|||||||
|
pub async fn some_work(
|
||||||
|
app: &crate::config::App,
|
||||||
|
song_queue_id: &uuid::Uuid,
|
||||||
|
user_id: &uuid::Uuid,
|
||||||
|
) -> Result<
|
||||||
|
(
|
||||||
|
icarus_models::song::Song,
|
||||||
|
icarus_models::coverart::CoverArt,
|
||||||
|
crate::api::get_metadata_queue::response::Metadata,
|
||||||
|
crate::queued_item::QueuedSong,
|
||||||
|
crate::queued_item::QueuedCoverArt,
|
||||||
|
),
|
||||||
|
std::io::Error,
|
||||||
|
> {
|
||||||
|
match prep_song(app, song_queue_id).await {
|
||||||
|
Ok((queued_song, queued_coverart, metadata)) => {
|
||||||
|
println!("Prepping song");
|
||||||
|
|
||||||
|
match crate::metadata::apply_metadata(&queued_song, &queued_coverart, &metadata).await {
|
||||||
|
Ok(_applied) => {
|
||||||
|
match crate::api::update_queued_song::update_queued_song(app, &queued_song)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(response) => {
|
||||||
|
match response
|
||||||
|
.json::<crate::api::update_queued_song::response::Response>()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(_inner_response) => {
|
||||||
|
println!("Updated queued song");
|
||||||
|
println!("Response: {_inner_response:?}");
|
||||||
|
|
||||||
|
let song_type = String::from(
|
||||||
|
icarus_meta::detection::song::constants::FLAC_TYPE,
|
||||||
|
);
|
||||||
|
|
||||||
|
match crate::api::create_song::create(
|
||||||
|
app, &metadata, user_id, &song_type,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(response) => match response
|
||||||
|
.json::<crate::api::create_song::response::Response>()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(resp) => {
|
||||||
|
println!("Response: {resp:?}");
|
||||||
|
|
||||||
|
let mut song = resp.data[0].clone();
|
||||||
|
song.directory = queued_song.song.directory.clone();
|
||||||
|
song.filename = queued_song.song.filename.clone();
|
||||||
|
|
||||||
|
match crate::api::create_coverart::create(app, &song, &queued_coverart).await {
|
||||||
|
Ok(response) => match response.json::<crate::api::create_coverart::response::Response>().await {
|
||||||
|
Ok(resp) => {
|
||||||
|
println!("CoverArt sent and successfully parsed response");
|
||||||
|
println!("json: {resp:?}");
|
||||||
|
let mut coverart = resp.data[0].clone();
|
||||||
|
coverart.directory = queued_coverart.coverart.directory.clone();
|
||||||
|
coverart.filename = queued_coverart.coverart.filename.clone();
|
||||||
|
|
||||||
|
Ok((song.clone(), coverart.clone(), metadata, queued_song.clone(), queued_coverart.clone()))
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
Err(std::io::Error::other(err.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
Err(std::io::Error::other(err.to_string()))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
},
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn prep_song(
|
||||||
|
app: &crate::config::App,
|
||||||
|
song_queue_id: &uuid::Uuid,
|
||||||
|
) -> Result<
|
||||||
|
(
|
||||||
|
crate::queued_item::QueuedSong,
|
||||||
|
crate::queued_item::QueuedCoverArt,
|
||||||
|
crate::api::get_metadata_queue::response::Metadata,
|
||||||
|
),
|
||||||
|
reqwest::Error,
|
||||||
|
> {
|
||||||
|
match crate::api::fetch_song_queue_data::get_data(app, song_queue_id).await {
|
||||||
|
Ok(response) => {
|
||||||
|
// Process data here...
|
||||||
|
match crate::api::parsing::parse_response_into_bytes(response).await {
|
||||||
|
Ok(song_bytes) => {
|
||||||
|
let song = icarus_models::song::Song {
|
||||||
|
directory: icarus_envy::environment::get_root_directory().await.value,
|
||||||
|
filename: icarus_models::song::generate_filename(
|
||||||
|
icarus_models::types::MusicTypes::FlacExtension,
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
data: song_bytes,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let songpath = song.song_path().unwrap_or_default();
|
||||||
|
|
||||||
|
let queued_song: crate::queued_item::QueuedSong =
|
||||||
|
match song.save_to_filesystem() {
|
||||||
|
Ok(_) => crate::queued_item::QueuedSong {
|
||||||
|
id: *song_queue_id,
|
||||||
|
song,
|
||||||
|
path: songpath,
|
||||||
|
},
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Error: {err:?}");
|
||||||
|
crate::queued_item::QueuedSong {
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("Saved at: {:?}", queued_song.path);
|
||||||
|
|
||||||
|
match crate::api::get_metadata_queue::get(app, &queued_song.id).await {
|
||||||
|
Ok(response) => {
|
||||||
|
match response
|
||||||
|
.json::<crate::api::get_metadata_queue::response::Response>()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(response) => {
|
||||||
|
let id = &response.data[0].id;
|
||||||
|
let created_at = &response.data[0].created_at;
|
||||||
|
let metadata = &response.data[0].metadata;
|
||||||
|
println!("Id: {id:?}");
|
||||||
|
println!("Metadata: {metadata:?}");
|
||||||
|
println!("Created at: {created_at:?}");
|
||||||
|
|
||||||
|
println!("Getting coverart queue");
|
||||||
|
match crate::api::get_coverart_queue::get(app, &queued_song.id).await {
|
||||||
|
Ok(response) => {
|
||||||
|
match response.json::<crate::api::get_coverart_queue::response::Response>().await {
|
||||||
|
Ok(response) => {
|
||||||
|
let coverart_queue = &response.data[0];
|
||||||
|
let coverart_queue_id = coverart_queue.id;
|
||||||
|
println!("Coverart queue Id: {coverart_queue_id:?}");
|
||||||
|
|
||||||
|
match crate::api::get_coverart_queue::get_data(app, &coverart_queue_id).await {
|
||||||
|
Ok(response) => match crate::api::parsing::parse_response_into_bytes(response).await {
|
||||||
|
Ok(coverart_queue_bytes) => {
|
||||||
|
let (directory, filename) = crate::util::generate_coverart_queue_dir_and_filename(&coverart_queue.file_type).await;
|
||||||
|
let coverart = icarus_models::coverart::CoverArt {
|
||||||
|
directory,
|
||||||
|
filename,
|
||||||
|
data: coverart_queue_bytes,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
coverart.save_to_filesystem().unwrap();
|
||||||
|
let coverart_queue_fs_path = match coverart.get_path() {
|
||||||
|
Ok(path) => {
|
||||||
|
path
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Error: {err:?}");
|
||||||
|
std::process::exit(-1);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let queued_coverart = crate::queued_item::QueuedCoverArt {
|
||||||
|
id: coverart_queue_id,
|
||||||
|
coverart,
|
||||||
|
path: coverart_queue_fs_path
|
||||||
|
};
|
||||||
|
|
||||||
|
println!("Saved coverart queue file at: {:?}", queued_coverart.path);
|
||||||
|
|
||||||
|
Ok((queued_song, queued_coverart, metadata.clone()))
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
Err(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
Err(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
Err(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn cleanup(
|
||||||
|
song: &icarus_models::song::Song,
|
||||||
|
coverart: &icarus_models::coverart::CoverArt,
|
||||||
|
) -> Result<(), std::io::Error> {
|
||||||
|
match song.remove_from_filesystem() {
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(err) => {
|
||||||
|
eprintln!("Error: Problem cleaning up SongQueue files {err:?}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
match coverart.remove_from_filesystem() {
|
||||||
|
Ok(_) => Ok(()),
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
60
src/queue/mod.rs
Normal file
60
src/queue/mod.rs
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
pub async fn wipe_data_from_queues(
|
||||||
|
app: &crate::config::App,
|
||||||
|
queued_song: &crate::queued_item::QueuedSong,
|
||||||
|
queued_coverart: &crate::queued_item::QueuedCoverArt,
|
||||||
|
) -> Result<(), std::io::Error> {
|
||||||
|
match crate::api::wipe_data::song_queue::wipe_data(app, queued_song).await {
|
||||||
|
Ok(response) => match response
|
||||||
|
.json::<crate::api::wipe_data::song_queue::response::Response>()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(_resp) => {
|
||||||
|
match crate::api::wipe_data::coverart_queue::wipe_data(app, queued_coverart).await {
|
||||||
|
Ok(inner_response) => match inner_response
|
||||||
|
.json::<crate::api::wipe_data::coverart_queue::response::Response>()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(_inner_resp) => {
|
||||||
|
println!("Wiped data from CoverArt queue");
|
||||||
|
println!("Resp: {_inner_resp:?}");
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
},
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
},
|
||||||
|
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn is_queue_empty(
|
||||||
|
app: &crate::config::App,
|
||||||
|
) -> Result<
|
||||||
|
(
|
||||||
|
bool,
|
||||||
|
crate::api::fetch_next_queue_item::response::SongQueueItem,
|
||||||
|
),
|
||||||
|
reqwest::Error,
|
||||||
|
> {
|
||||||
|
match crate::api::fetch_next_queue_item::fetch_next_queue_item(app).await {
|
||||||
|
Ok(response) => {
|
||||||
|
match response
|
||||||
|
.json::<crate::api::fetch_next_queue_item::response::SongQueueItem>()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(response) => {
|
||||||
|
if response.data.is_empty() {
|
||||||
|
Ok((true, response))
|
||||||
|
} else {
|
||||||
|
Ok((false, response))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(err) => Err(err),
|
||||||
|
}
|
||||||
|
}
|
13
src/queued_item.rs
Normal file
13
src/queued_item.rs
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
#[derive(Clone, Debug, Default)]
|
||||||
|
pub struct QueuedSong {
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
pub song: icarus_models::song::Song,
|
||||||
|
pub path: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Default)]
|
||||||
|
pub struct QueuedCoverArt {
|
||||||
|
pub id: uuid::Uuid,
|
||||||
|
pub coverart: icarus_models::coverart::CoverArt,
|
||||||
|
pub path: String,
|
||||||
|
}
|
36
src/util.rs
36
src/util.rs
@@ -4,3 +4,39 @@ pub fn path_buf_to_string(path: &std::path::Path) -> String {
|
|||||||
None => String::new(),
|
None => String::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Consider having something like this in icarus_models
|
||||||
|
pub async fn generate_coverart_queue_dir_and_filename(file_type: &str) -> (String, String) {
|
||||||
|
use rand::Rng;
|
||||||
|
|
||||||
|
let mut filename: String = String::new();
|
||||||
|
let filename_len = 10;
|
||||||
|
|
||||||
|
let some_chars: String = String::from("abcdefghij0123456789");
|
||||||
|
let mut rng = rand::rng();
|
||||||
|
|
||||||
|
for _ in 0..filename_len {
|
||||||
|
let random_number: i32 = rng.random_range(0..=19);
|
||||||
|
let index = random_number as usize;
|
||||||
|
let rando_char = some_chars.chars().nth(index);
|
||||||
|
|
||||||
|
if let Some(c) = rando_char {
|
||||||
|
filename.push(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
filename += if file_type == icarus_meta::detection::coverart::constants::JPEG_TYPE
|
||||||
|
|| file_type == icarus_meta::detection::coverart::constants::JPG_TYPE
|
||||||
|
{
|
||||||
|
icarus_models::constants::file_extensions::image::JPEGEXTENSION
|
||||||
|
} else if file_type == icarus_meta::detection::coverart::constants::PNG_TYPE {
|
||||||
|
icarus_models::constants::file_extensions::image::PNGEXTENSION
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
};
|
||||||
|
|
||||||
|
// TODO: Consider separating song and coverart when saving to the filesystem
|
||||||
|
let directory = icarus_envy::environment::get_root_directory().await.value;
|
||||||
|
|
||||||
|
(directory, filename)
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user