1 Commits
0.8.2 ... 0.9.0

Author SHA1 Message Date
c2e653b3ea [0.9.0] new parser 2024-08-04 18:03:21 +02:00
12 changed files with 2913 additions and 41 deletions

2
.gitignore vendored
View File

@@ -1,3 +1,3 @@
/target
**/target
.env

3
.gitmodules vendored
View File

@@ -1,3 +0,0 @@
[submodule "src/spotify-parser"]
path = src/spotify-parser
url = https://github.com/eRgo35/spotify-parser

679
Cargo.lock generated
View File

@@ -27,6 +27,19 @@ dependencies = [
"generic-array",
]
[[package]]
name = "ahash"
version = "0.8.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011"
dependencies = [
"cfg-if",
"getrandom 0.2.15",
"once_cell",
"version_check",
"zerocopy 0.7.35",
]
[[package]]
name = "aho-corasick"
version = "1.1.3"
@@ -71,6 +84,12 @@ dependencies = [
"syn 2.0.72",
]
[[package]]
name = "atomic-waker"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
[[package]]
name = "audiopus"
version = "0.3.0-rc.0"
@@ -364,6 +383,29 @@ dependencies = [
"zeroize",
]
[[package]]
name = "cssparser"
version = "0.31.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b3df4f93e5fbbe73ec01ec8d3f68bba73107993a5b1e7519273c32db9b0d5be"
dependencies = [
"cssparser-macros",
"dtoa-short",
"itoa",
"phf 0.11.2",
"smallvec",
]
[[package]]
name = "cssparser-macros"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13b588ba4ac1a99f7f2964d24b3d896ddc6bf847ee3855dbd4366f058cfcd331"
dependencies = [
"quote",
"syn 2.0.72",
]
[[package]]
name = "darling"
version = "0.10.2"
@@ -539,6 +581,27 @@ version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77c90badedccf4105eca100756a0b1289e191f6fcbdadd3cee1d2f614f97da8f"
[[package]]
name = "dtoa"
version = "1.0.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcbb2bf8e87535c23f7a8a321e364ce21462d0ff10cb6407820e8e96dfff6653"
[[package]]
name = "dtoa-short"
version = "0.3.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cd1511a7b6a56299bd043a9c167a6d2bfb37bf84a6dfceaba651168adfb43c87"
dependencies = [
"dtoa",
]
[[package]]
name = "ego-tree"
version = "0.6.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3a68a4904193147e0a8dec3314640e6db742afd5f6e634f428a6af230d9b3591"
[[package]]
name = "encoding_rs"
version = "0.8.34"
@@ -657,6 +720,16 @@ dependencies = [
"hashmap_derive",
]
[[package]]
name = "futf"
version = "0.1.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df420e2e84819663797d1ec6544b13c5be84629e7bb00dc960d6917db2987843"
dependencies = [
"mac",
"new_debug_unreachable",
]
[[package]]
name = "futures"
version = "0.3.30"
@@ -779,6 +852,15 @@ dependencies = [
"zeroize",
]
[[package]]
name = "getopts"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "14dbbfd5c71d70241ecf9e6f13737f7b5ce823821063188d7e46c41d371eebd5"
dependencies = [
"unicode-width",
]
[[package]]
name = "getrandom"
version = "0.1.16"
@@ -834,6 +916,25 @@ dependencies = [
"tracing",
]
[[package]]
name = "h2"
version = "0.4.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa82e28a107a8cc405f0839610bdc9b15f1e25ec7d696aa5cf173edbcb1486ab"
dependencies = [
"atomic-waker",
"bytes",
"fnv",
"futures-core",
"futures-sink",
"http 1.1.0",
"indexmap",
"slab",
"tokio",
"tokio-util",
"tracing",
]
[[package]]
name = "hashbrown"
version = "0.14.5"
@@ -887,6 +988,20 @@ dependencies = [
"thiserror",
]
[[package]]
name = "html5ever"
version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c13771afe0e6e846f1e67d038d4cb29998a6779f93c809212e4e9c32efd244d4"
dependencies = [
"log",
"mac",
"markup5ever",
"proc-macro2",
"quote",
"syn 2.0.72",
]
[[package]]
name = "http"
version = "0.2.12"
@@ -920,6 +1035,29 @@ dependencies = [
"pin-project-lite",
]
[[package]]
name = "http-body"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
dependencies = [
"bytes",
"http 1.1.0",
]
[[package]]
name = "http-body-util"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f"
dependencies = [
"bytes",
"futures-util",
"http 1.1.0",
"http-body 1.0.1",
"pin-project-lite",
]
[[package]]
name = "httparse"
version = "1.9.4"
@@ -942,9 +1080,9 @@ dependencies = [
"futures-channel",
"futures-core",
"futures-util",
"h2",
"h2 0.3.26",
"http 0.2.12",
"http-body",
"http-body 0.4.6",
"httparse",
"httpdate",
"itoa",
@@ -956,6 +1094,26 @@ dependencies = [
"want",
]
[[package]]
name = "hyper"
version = "1.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50dfd22e0e76d0f662d429a5f80fcaf3855009297eab6a0a9f8543834744ba05"
dependencies = [
"bytes",
"futures-channel",
"futures-util",
"h2 0.4.5",
"http 1.1.0",
"http-body 1.0.1",
"httparse",
"itoa",
"pin-project-lite",
"smallvec",
"tokio",
"want",
]
[[package]]
name = "hyper-rustls"
version = "0.24.2"
@@ -964,12 +1122,30 @@ checksum = "ec3efd23720e2049821a693cbc7e65ea87c72f1c58ff2f9522ff332b1491e590"
dependencies = [
"futures-util",
"http 0.2.12",
"hyper",
"hyper 0.14.30",
"rustls 0.21.12",
"tokio",
"tokio-rustls 0.24.1",
]
[[package]]
name = "hyper-rustls"
version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5ee4be2c948921a1a5320b629c4193916ed787a7f7f293fd3f7f5a6c9de74155"
dependencies = [
"futures-util",
"http 1.1.0",
"hyper 1.4.1",
"hyper-util",
"rustls 0.23.12",
"rustls-pki-types",
"tokio",
"tokio-rustls 0.26.0",
"tower-service",
"webpki-roots 0.26.3",
]
[[package]]
name = "hyper-tls"
version = "0.5.0"
@@ -977,12 +1153,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [
"bytes",
"hyper",
"hyper 0.14.30",
"native-tls",
"tokio",
"tokio-native-tls",
]
[[package]]
name = "hyper-tls"
version = "0.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
dependencies = [
"bytes",
"http-body-util",
"hyper 1.4.1",
"hyper-util",
"native-tls",
"tokio",
"tokio-native-tls",
"tower-service",
]
[[package]]
name = "hyper-util"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3ab92f4f49ee4fb4f997c784b7a2e0fa70050211e0b6a287f898c3c9785ca956"
dependencies = [
"bytes",
"futures-channel",
"futures-util",
"http 1.1.0",
"http-body 1.0.1",
"hyper 1.4.1",
"pin-project-lite",
"socket2",
"tokio",
"tower",
"tower-service",
"tracing",
]
[[package]]
name = "iana-time-zone"
version = "0.1.60"
@@ -1080,6 +1292,18 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "db13adb97ab515a3691f56e4dbab09283d0b86cb45abd991d8634a9d6f501760"
[[package]]
name = "lib-spotify-parser"
version = "1.0.0"
dependencies = [
"regex",
"reqwest 0.12.5",
"scraper",
"serde",
"serde_json",
"tokio",
]
[[package]]
name = "libc"
version = "0.2.155"
@@ -1125,17 +1349,18 @@ dependencies = [
[[package]]
name = "lyra"
version = "0.8.2"
version = "0.9.0"
dependencies = [
"dotenv",
"fancy-regex",
"json",
"lib-spotify-parser",
"openssl",
"owoify",
"poise",
"rand 0.8.5",
"regex",
"reqwest",
"reqwest 0.11.27",
"serde",
"serde_json",
"serenity",
@@ -1148,6 +1373,26 @@ dependencies = [
"url",
]
[[package]]
name = "mac"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4"
[[package]]
name = "markup5ever"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16ce3abbeba692c8b8441d036ef91aea6df8da2c6b6e21c7e14d3c18e526be45"
dependencies = [
"log",
"phf 0.11.2",
"phf_codegen 0.11.2",
"string_cache",
"string_cache_codegen",
"tendril",
]
[[package]]
name = "matchers"
version = "0.1.0"
@@ -1241,6 +1486,12 @@ 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 = "no-std-compat"
version = "0.2.0"
@@ -1450,6 +1701,96 @@ version = "2.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]]
name = "phf"
version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fabbf1ead8a5bcbc20f5f8b939ee3f5b0f6f281b6ad3468b84656b658b455259"
dependencies = [
"phf_shared 0.10.0",
]
[[package]]
name = "phf"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ade2d8b8f33c7333b51bcf0428d37e217e9f32192ae4772156f65063b8ce03dc"
dependencies = [
"phf_macros",
"phf_shared 0.11.2",
]
[[package]]
name = "phf_codegen"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4fb1c3a8bc4dd4e5cfce29b44ffc14bedd2ee294559a294e2a4d4c9e9a6a13cd"
dependencies = [
"phf_generator 0.10.0",
"phf_shared 0.10.0",
]
[[package]]
name = "phf_codegen"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8d39688d359e6b34654d328e262234662d16cc0f60ec8dcbe5e718709342a5a"
dependencies = [
"phf_generator 0.11.2",
"phf_shared 0.11.2",
]
[[package]]
name = "phf_generator"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5d5285893bb5eb82e6aaf5d59ee909a06a16737a8970984dd7746ba9283498d6"
dependencies = [
"phf_shared 0.10.0",
"rand 0.8.5",
]
[[package]]
name = "phf_generator"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48e4cc64c2ad9ebe670cb8fd69dd50ae301650392e81c05f9bfcb2d5bdbc24b0"
dependencies = [
"phf_shared 0.11.2",
"rand 0.8.5",
]
[[package]]
name = "phf_macros"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3444646e286606587e49f3bcf1679b8cef1dc2c5ecc29ddacaffc305180d464b"
dependencies = [
"phf_generator 0.11.2",
"phf_shared 0.11.2",
"proc-macro2",
"quote",
"syn 2.0.72",
]
[[package]]
name = "phf_shared"
version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6796ad771acdc0123d2a88dc428b5e38ef24456743ddb1744ed628f9815c096"
dependencies = [
"siphasher",
]
[[package]]
name = "phf_shared"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90fcb95eef784c2ac79119d1dd819e162b5da872ce6f3c3abe1e8ca1c082f72b"
dependencies = [
"siphasher",
]
[[package]]
name = "pin-project"
version = "1.1.5"
@@ -1570,9 +1911,15 @@ version = "0.2.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dee4364d9f3b902ef14fab8a1ddffb783a1cb6b4bba3bfc1fa3922732c7de97f"
dependencies = [
"zerocopy",
"zerocopy 0.6.6",
]
[[package]]
name = "precomputed-hash"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
[[package]]
name = "primal-check"
version = "0.3.4"
@@ -1602,6 +1949,52 @@ dependencies = [
"unicase",
]
[[package]]
name = "quinn"
version = "0.11.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e4ceeeeabace7857413798eb1ffa1e9c905a9946a57d81fb69b4b71c4d8eb3ad"
dependencies = [
"bytes",
"pin-project-lite",
"quinn-proto",
"quinn-udp",
"rustc-hash",
"rustls 0.23.12",
"thiserror",
"tokio",
"tracing",
]
[[package]]
name = "quinn-proto"
version = "0.11.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ddf517c03a109db8100448a4be38d498df8a210a99fe0e1b9eaf39e78c640efe"
dependencies = [
"bytes",
"rand 0.8.5",
"ring 0.17.8",
"rustc-hash",
"rustls 0.23.12",
"slab",
"thiserror",
"tinyvec",
"tracing",
]
[[package]]
name = "quinn-udp"
version = "0.5.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8bffec3605b73c6f1754535084a85229fa8a30f86014e6c81aeec4abb68b0285"
dependencies = [
"libc",
"once_cell",
"socket2",
"windows-sys 0.52.0",
]
[[package]]
name = "quote"
version = "1.0.36"
@@ -1755,12 +2148,12 @@ dependencies = [
"encoding_rs",
"futures-core",
"futures-util",
"h2",
"h2 0.3.26",
"http 0.2.12",
"http-body",
"hyper",
"hyper-rustls",
"hyper-tls",
"http-body 0.4.6",
"hyper 0.14.30",
"hyper-rustls 0.24.2",
"hyper-tls 0.5.0",
"ipnet",
"js-sys",
"log",
@@ -1771,11 +2164,11 @@ dependencies = [
"percent-encoding",
"pin-project-lite",
"rustls 0.21.12",
"rustls-pemfile",
"rustls-pemfile 1.0.4",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper",
"sync_wrapper 0.1.2",
"system-configuration",
"tokio",
"tokio-native-tls",
@@ -1788,7 +2181,56 @@ dependencies = [
"wasm-streams",
"web-sys",
"webpki-roots 0.25.4",
"winreg",
"winreg 0.50.0",
]
[[package]]
name = "reqwest"
version = "0.12.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7d6d2a27d57148378eb5e111173f4276ad26340ecc5c49a4a2152167a2d6a37"
dependencies = [
"base64 0.22.1",
"bytes",
"encoding_rs",
"futures-channel",
"futures-core",
"futures-util",
"h2 0.4.5",
"http 1.1.0",
"http-body 1.0.1",
"http-body-util",
"hyper 1.4.1",
"hyper-rustls 0.27.2",
"hyper-tls 0.6.0",
"hyper-util",
"ipnet",
"js-sys",
"log",
"mime",
"native-tls",
"once_cell",
"percent-encoding",
"pin-project-lite",
"quinn",
"rustls 0.23.12",
"rustls-pemfile 2.1.2",
"rustls-pki-types",
"serde",
"serde_json",
"serde_urlencoded",
"sync_wrapper 1.0.1",
"system-configuration",
"tokio",
"tokio-native-tls",
"tokio-rustls 0.26.0",
"tower-service",
"url",
"wasm-bindgen",
"wasm-bindgen-futures",
"web-sys",
"webpki-roots 0.26.3",
"winreg 0.52.0",
]
[[package]]
@@ -1848,6 +2290,12 @@ version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
[[package]]
name = "rustc-hash"
version = "1.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
[[package]]
name = "rustc_version"
version = "0.4.0"
@@ -1923,6 +2371,20 @@ dependencies = [
"zeroize",
]
[[package]]
name = "rustls"
version = "0.23.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c58f8c84392efc0a126acce10fa59ff7b3d2ac06ab451a33f2741989b806b044"
dependencies = [
"once_cell",
"ring 0.17.8",
"rustls-pki-types",
"rustls-webpki 0.102.6",
"subtle",
"zeroize",
]
[[package]]
name = "rustls-native-certs"
version = "0.6.3"
@@ -1930,7 +2392,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9aace74cb666635c918e9c12bc0d348266037aa8eb599b5cba565709a8dff00"
dependencies = [
"openssl-probe",
"rustls-pemfile",
"rustls-pemfile 1.0.4",
"schannel",
"security-framework",
]
@@ -1944,6 +2406,16 @@ dependencies = [
"base64 0.21.7",
]
[[package]]
name = "rustls-pemfile"
version = "2.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "29993a25686778eb88d4189742cd713c9bce943bc54251a33509dc63cbacf73d"
dependencies = [
"base64 0.22.1",
"rustls-pki-types",
]
[[package]]
name = "rustls-pki-types"
version = "1.7.0"
@@ -2035,6 +2507,22 @@ version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "scraper"
version = "0.19.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "761fb705fdf625482d2ed91d3f0559dcfeab2798fe2771c69560a774865d0802"
dependencies = [
"ahash",
"cssparser",
"ego-tree",
"getopts",
"html5ever",
"once_cell",
"selectors",
"tendril",
]
[[package]]
name = "sct"
version = "0.7.1"
@@ -2078,6 +2566,25 @@ dependencies = [
"libc",
]
[[package]]
name = "selectors"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb30575f3638fc8f6815f448d50cb1a2e255b0897985c8c59f4d37b72a07b06"
dependencies = [
"bitflags 2.6.0",
"cssparser",
"derive_more",
"fxhash",
"log",
"new_debug_unreachable",
"phf 0.10.1",
"phf_codegen 0.10.0",
"precomputed-hash",
"servo_arc",
"smallvec",
]
[[package]]
name = "semver"
version = "1.0.23"
@@ -2193,7 +2700,7 @@ dependencies = [
"mime_guess",
"parking_lot",
"percent-encoding",
"reqwest",
"reqwest 0.11.27",
"secrecy",
"serde",
"serde_cow",
@@ -2222,6 +2729,15 @@ dependencies = [
"serde_repr",
]
[[package]]
name = "servo_arc"
version = "0.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d036d71a959e00c77a63538b90a6c2390969f9772b096ea837205c6bd0491a44"
dependencies = [
"stable_deref_trait",
]
[[package]]
name = "sha1"
version = "0.10.6"
@@ -2263,6 +2779,12 @@ dependencies = [
"libc",
]
[[package]]
name = "siphasher"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38b58827f4464d87d377d175e90bf58eb00fd8716ff0a62f80356b5e61555d0d"
[[package]]
name = "skeptic"
version = "0.13.7"
@@ -2324,7 +2846,7 @@ dependencies = [
"parking_lot",
"pin-project",
"rand 0.8.5",
"reqwest",
"reqwest 0.11.27",
"ringbuf",
"rubato",
"rusty_pool",
@@ -2373,6 +2895,12 @@ dependencies = [
"no-std-compat",
]
[[package]]
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "static_assertions"
version = "1.1.0"
@@ -2390,7 +2918,7 @@ dependencies = [
"futures-util",
"hls_m3u8",
"patricia_tree",
"reqwest",
"reqwest 0.11.27",
"tokio",
"tracing",
"url",
@@ -2413,6 +2941,32 @@ version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe895eb47f22e2ddd4dabc02bce419d2e643c8e3b585c78158b349195bc24d82"
[[package]]
name = "string_cache"
version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f91138e76242f575eb1d3b38b4f1362f10d3a43f47d182a5b359af488a02293b"
dependencies = [
"new_debug_unreachable",
"once_cell",
"parking_lot",
"phf_shared 0.10.0",
"precomputed-hash",
"serde",
]
[[package]]
name = "string_cache_codegen"
version = "0.5.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bb30289b722be4ff74a408c3cc27edeaad656e06cb1fe8fa9231fa59c728988"
dependencies = [
"phf_generator 0.10.0",
"phf_shared 0.10.0",
"proc-macro2",
"quote",
]
[[package]]
name = "strsim"
version = "0.9.3"
@@ -2663,6 +3217,12 @@ version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
[[package]]
name = "sync_wrapper"
version = "1.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a7065abeca94b6a8a577f9bd45aa0867a2238b74e8eb67cf10d492bc39351394"
[[package]]
name = "system-configuration"
version = "0.5.1"
@@ -2703,6 +3263,17 @@ dependencies = [
"windows-sys 0.52.0",
]
[[package]]
name = "tendril"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d24a120c5fc464a3458240ee02c299ebcb9d67b5249c8848b09d639dca8d7bb0"
dependencies = [
"futf",
"mac",
"utf-8",
]
[[package]]
name = "thiserror"
version = "1.0.63"
@@ -2850,6 +3421,17 @@ dependencies = [
"tokio",
]
[[package]]
name = "tokio-rustls"
version = "0.26.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c7bc40d0e5a97695bb96e27995cd3a08538541b0a846f65bba7a359f36700d4"
dependencies = [
"rustls 0.23.12",
"rustls-pki-types",
"tokio",
]
[[package]]
name = "tokio-tungstenite"
version = "0.18.0"
@@ -2895,6 +3477,27 @@ dependencies = [
"tokio",
]
[[package]]
name = "tower"
version = "0.4.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c"
dependencies = [
"futures-core",
"futures-util",
"pin-project",
"pin-project-lite",
"tokio",
"tower-layer",
"tower-service",
]
[[package]]
name = "tower-layer"
version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c20c8dbed6283a09604c3e69b4b7eeb54e298b8a600d4d5ecb5ad39de609f1d0"
[[package]]
name = "tower-service"
version = "0.3.2"
@@ -3157,6 +3760,12 @@ version = "1.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202"
[[package]]
name = "unicode-width"
version = "0.1.13"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d"
[[package]]
name = "universal-hash"
version = "0.5.1"
@@ -3582,6 +4191,16 @@ dependencies = [
"windows-sys 0.48.0",
]
[[package]]
name = "winreg"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5"
dependencies = [
"cfg-if",
"windows-sys 0.48.0",
]
[[package]]
name = "zerocopy"
version = "0.6.6"
@@ -3589,7 +4208,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6"
dependencies = [
"byteorder",
"zerocopy-derive",
"zerocopy-derive 0.6.6",
]
[[package]]
name = "zerocopy"
version = "0.7.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
dependencies = [
"zerocopy-derive 0.7.35",
]
[[package]]
@@ -3603,6 +4231,17 @@ dependencies = [
"syn 2.0.72",
]
[[package]]
name = "zerocopy-derive"
version = "0.7.35"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.72",
]
[[package]]
name = "zeroize"
version = "1.8.1"

View File

@@ -1,6 +1,6 @@
[package]
name = "lyra"
version = "0.8.2"
version = "0.9.0"
authors = ["Michał Czyż <mike@c2yz.com>"]
edition = "2021"
description = "A featureful Discord bot written in Rust."
@@ -12,6 +12,7 @@ keywords = ["discord", "bot", "rust", "music", "featureful"]
[dependencies]
lib-spotify-parser = { path = "libs/spotify-parser" }
dotenv = "0.15.0"
fancy-regex = "0.13.0"
json = "0.12.4"

1906
libs/spotify-parser/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
[package]
name = "lib-spotify-parser"
version = "1.0.0"
edition = "2021"
[dependencies]
regex = "1.10.6"
reqwest = { version = "0.12.5", features = ["blocking", "rustls-tls"] }
scraper = "0.19.1"
serde = "1.0.204"
serde_json = "1.0.122"
tokio = { version = "1.39.2", features = ["macros"] }

View File

@@ -0,0 +1,14 @@
use std::fmt;
#[derive(Debug)]
pub enum ParseError {
InvalidUrl,
}
impl fmt::Display for ParseError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Invalid URL")
}
}
impl std::error::Error for ParseError {}

View File

@@ -0,0 +1,154 @@
mod error;
mod parser;
mod retriever;
use error::ParseError;
use parser::{parse_list, parse_single, USER_AGENT};
use regex::Regex;
use reqwest;
use retriever::{retrieve_async_track, retrieve_async_tracks, retrieve_track, retrieve_tracks};
pub fn retrieve_url(url: &str) -> Result<Vec<String>, ParseError> {
let spotify_regex: Regex = Regex::new(r"https?:\/\/(?:embed\.|open\.)spotify\.com\/(track|album|playlist)\/([a-zA-Z0-9]+)(?:\?si=[\w-]+)?").unwrap();
if let Some(captures) = spotify_regex.captures(url) {
let category = captures.get(1).unwrap().as_str();
let id = captures.get(2).unwrap().as_str();
match category {
"track" => {
let track = retrieve_track(category, id).unwrap();
Ok(vec![track])
}
"playlist" | "album" => {
let tracks = retrieve_tracks(category, id).unwrap();
Ok(tracks)
}
_ => Err(ParseError::InvalidUrl),
}
} else {
Err(ParseError::InvalidUrl)
}
}
pub async fn retrieve_async_url(url: &str) -> Result<Vec<String>, ParseError> {
let spotify_regex: Regex = Regex::new(r"https?:\/\/(?:embed\.|open\.)spotify\.com\/(track|album|playlist)\/([a-zA-Z0-9]+)(?:\?si=[\w-]+)?").unwrap();
if let Some(captures) = spotify_regex.captures(url) {
let category = captures.get(1).unwrap().as_str();
let id = captures.get(2).unwrap().as_str();
match category {
"track" => {
let track = retrieve_async_track(category, id).await.unwrap();
Ok(vec![track])
}
"playlist" | "album" => {
let tracks = retrieve_async_tracks(category, id).await.unwrap();
Ok(tracks)
}
_ => Err(ParseError::InvalidUrl),
}
} else {
Err(ParseError::InvalidUrl)
}
}
#[cfg(test)]
mod tests {
use super::*;
const TRACK: &str = "https://open.spotify.com/track/4PTG3Z6ehGkBFwjybzWkR8?si=e0a8c8ada8284e43";
const MULTIPLE_ARTISTS_TRACK: &str =
"https://open.spotify.com/track/1O0SdrryPeGp6eSSUibdgo?si=4ae58febe9e74eae";
const PLAYLIST: &str =
"https://open.spotify.com/playlist/37i9dQZF1DZ06evO05tE88?si=e0c6f44d176f44e6";
const ALBUM: &str =
"https://open.spotify.com/album/6eUW0wxWtzkFdaEFsTJto6?si=_grLtlNySNyfJTZr8tP44Q";
#[test]
fn check_track() {
let track: Vec<&str> = vec!["Rick Astley - Never Gonna Give You Up"];
assert_eq!(retrieve_url(TRACK).unwrap(), track);
}
#[test]
fn check_multiple_artists_track() {
let track: Vec<&str> = vec!["Will o' the wisp, Rick Astley - Blood on My Tie"];
assert_eq!(retrieve_url(MULTIPLE_ARTISTS_TRACK).unwrap(), track);
}
#[test]
fn check_playlist() {
let playlist: Vec<&str> = vec![
"Rick Astley - Never Gonna Give You Up",
"Rick Astley - Take Me to Your Heart (2023 Remaster)",
"Rick Astley - Cry for Help - Single Edit",
"Rick Astley - Never Gonna Stop",
"Rick Astley - Together Forever",
"Rick Astley - Hold Me in Your Arms (7\" Version)",
"Rick Astley - Angels on My Side",
"New Kids On The Block, Salt-N-Pepa, Rick Astley, En Vogue - Bring Back The Time",
"Rick Astley - Whenever You Need Somebody",
"Rick Astley - She Wants to Dance with Me (2023 Remaster)",
"Rick Astley - Dippin My Feet",
"Rick Astley - My Arms Keep Missing You",
"Rick Astley - Don't Say Goodbye",
"Rick Astley - Dance",
"Rick Astley - Giving Up On Love (7'' Pop Version)",
"Rick Astley - Never Gonna Give You Up (Cake Mix)",
"Rick Astley - It Would Take a Strong Strong Man",
"Rick Astley - Driving Me Crazy",
"Rick Astley - Beautiful Life",
"Rick Astley - I Don't Want to Lose Her",
"Rick Astley - Keep Singing",
"Rick Astley - Forever and More",
"Rick Astley - Hopelessly",
"Rick Astley - When I Fall in Love",
"Rick Astley - Every One of Us",
"Rick Astley - High Enough",
"Rick Astley - Ain't Too Proud to Beg (2023 Remaster)",
"Rick Astley - I'll Never Let You Down",
"Trevor Horn, Rick Astley - Owner Of A Lonely Heart",
"Rick Astley - Letting Go",
"Rick Astley - Never Knew Love",
"Rick Astley - Lights Out - Radio Edit",
"Rick Astley - Try",
"Rick Astley - Dial My Number (2023 Remaster)",
"Rick Astley - Wish Away",
"Rick Astley - Giant",
"Rick Astley - Move Right Out",
"Rick Astley - Till Then (Time Stands Still) (2023 Remaster)",
"Rick Astley - Pray with Me",
"Rick Astley - I Don't Want to Be Your Lover",
"Will o' the wisp, Rick Astley - Blood on My Tie",
"Rick Astley - Can't Help Falling in Love",
"Rick Astley - I Like the Sun",
"Rick Astley - She Makes Me",
"Rick Astley - Body and Soul",
"Rick Astley - (They Long to Be) Close to You",
"Rick Astley - Unwanted (Official Song from the Podcast)",
"Rick Astley - Last Night on Earth",
"Rick Astley - Everlong - Acoustic Version",
"Rick Astley - Superman",
];
assert_eq!(retrieve_url(PLAYLIST).unwrap(), playlist);
}
#[test]
fn check_album() {
let album: Vec<&str> = vec![
"Rick Astley - Never Gonna Give You Up",
"Rick Astley - Whenever You Need Somebody",
"Rick Astley - Together Forever",
"Rick Astley - It Would Take a Strong Strong Man",
"Rick Astley - The Love Has Gone",
"Rick Astley - Don't Say Goodbye",
"Rick Astley - Slipping Away",
"Rick Astley - No More Looking for Love",
"Rick Astley - You Move Me",
"Rick Astley - When I Fall in Love",
];
assert_eq!(retrieve_url(ALBUM).unwrap(), album);
}
}

View File

@@ -0,0 +1,70 @@
use scraper::{Html, Selector};
use serde_json::Value;
use std::error::Error;
#[derive(Debug, Clone)]
pub(crate) struct SpotifyTrack {
pub title: String,
pub artist: String,
}
pub(crate) const USER_AGENT: &str = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36";
pub(crate) fn parse_single(content: String) -> Result<SpotifyTrack, Box<dyn Error>> {
let document = Html::parse_document(&content);
let selector = Selector::parse("#__NEXT_DATA__").unwrap();
if let Some(script_element) = document.select(&selector).next() {
let json_str = script_element.inner_html();
let json_value: Value = serde_json::from_str(&json_str)?;
let metadata = &json_value["props"]["pageProps"]["state"]["data"]["entity"];
// println!("{metadata:?}");
let title = metadata["title"].as_str().unwrap().to_string();
let artists = metadata["artists"].as_array().unwrap();
let artists_list: Vec<String> = artists
.iter()
.map(|artist| artist["name"].as_str().unwrap().to_string())
.collect();
let artist: String = artists_list.join(", ").to_string();
let track = SpotifyTrack { title, artist };
Ok(track)
} else {
Err("Could not find element".into())
}
}
pub(crate) fn parse_list(content: String) -> Result<Vec<SpotifyTrack>, Box<dyn Error>> {
let document = Html::parse_document(&content);
let selector = Selector::parse("#__NEXT_DATA__").unwrap();
if let Some(script_element) = document.select(&selector).next() {
let json_str = script_element.inner_html();
let json_value: Value = serde_json::from_str(&json_str)?;
let metadata = &json_value["props"]["pageProps"]["state"]["data"]["entity"]["trackList"]
.as_array()
.unwrap();
// println!("{metadata:?}");
let tracks: Vec<SpotifyTrack> = metadata
.iter()
.map(|track| {
let title = track["title"].as_str().unwrap().to_string();
let artist = track["subtitle"].as_str().unwrap().to_string();
SpotifyTrack { title, artist }
})
.collect();
// println!("{tracks:?}");
Ok(tracks)
} else {
Err("Could not find element".into())
}
}

View File

@@ -0,0 +1,85 @@
use crate::*;
pub fn retrieve_track(category: &str, id: &str) -> Result<String, String> {
let embed_url = format!("https://embed.spotify.com/?uri=spotify:{}:{}", category, id);
let client = reqwest::blocking::Client::builder()
.use_rustls_tls()
.user_agent(USER_AGENT)
.build()
.unwrap();
let response = client.get(&embed_url).send().unwrap();
let content = response.text().unwrap();
let parsed_content = parse_single(content).unwrap();
Ok(format!(
"{} - {}",
parsed_content.artist, parsed_content.title
))
}
pub fn retrieve_tracks(category: &str, id: &str) -> Result<Vec<String>, String> {
let embed_url = format!("https://embed.spotify.com/?uri=spotify:{}:{}", category, id);
let client = reqwest::blocking::Client::builder()
.use_rustls_tls()
.user_agent(USER_AGENT)
.build()
.unwrap();
let response = client.get(&embed_url).send().unwrap();
let content = response.text().unwrap();
let parsed_content = parse_list(content).unwrap();
let tracks: Vec<String> = parsed_content
.iter()
.map(|track| format!("{} - {}", track.artist, track.title))
.collect();
Ok(tracks)
}
pub async fn retrieve_async_track(category: &str, id: &str) -> Result<String, String> {
let embed_url = format!("https://embed.spotify.com/?uri=spotify:{}:{}", category, id);
let client = reqwest::Client::builder()
.use_rustls_tls()
.user_agent(USER_AGENT)
.build()
.unwrap();
let response = client.get(&embed_url).send().await.unwrap();
let content = response.text().await.unwrap();
let parsed_content = parse_single(content).unwrap();
Ok(format!(
"{} - {}",
parsed_content.artist, parsed_content.title
))
}
pub async fn retrieve_async_tracks(category: &str, id: &str) -> Result<Vec<String>, String> {
let embed_url = format!("https://embed.spotify.com/?uri=spotify:{}:{}", category, id);
let client = reqwest::Client::builder()
.use_rustls_tls()
.user_agent(USER_AGENT)
.build()
.unwrap();
let response = client.get(&embed_url).send().await.unwrap();
let content = response.text().await.unwrap();
let parsed_content = parse_list(content).unwrap();
let tracks: Vec<String> = parsed_content
.iter()
.map(|track| format!("{} - {}", track.artist, track.title))
.collect();
Ok(tracks)
}

View File

@@ -2,6 +2,7 @@ use crate::commands::music::metadata::Metadata;
use crate::{commands::embeds::error_embed, Context, Error};
use fancy_regex::Regex;
use lib_spotify_parser;
use poise::serenity_prelude::model::Timestamp;
use poise::serenity_prelude::Colour;
use poise::serenity_prelude::CreateEmbed;
@@ -87,14 +88,7 @@ pub async fn play(
handler.add_global_event(TrackEvent::Error.into(), TrackErrorNotifier);
if is_playlist && is_spotify {
let raw_list = Command::new("node")
.args(["./src/spotify-parser", &song])
.output()
.expect("failed to execute process")
.stdout;
let list = String::from_utf8(raw_list.clone()).expect("Invalid UTF-8");
let tracks: Vec<String> = list.split("\n").map(str::to_string).collect();
let tracks: Vec<String> = lib_spotify_parser::retrieve_async_url(&song).await.unwrap();
for (index, url) in tracks.clone().iter().enumerate() {
if url.is_empty() {
@@ -161,13 +155,14 @@ pub async fn play(
}
if is_spotify {
let query = Command::new("node")
.args(["./src/spotify-parser", &song])
.output()
.expect("failed to execute process")
.stdout;
let query_str = String::from_utf8(query.clone()).expect("Invalid UTF-8");
song = format!("ytsearch:{}", query_str.to_string());
song = format!(
"ytsearch:{}",
lib_spotify_parser::retrieve_async_url(&song)
.await
.unwrap()
.first()
.unwrap()
);
}
if is_query {