From ae7b890940b84c9074d413390f86a339d5bce64a Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Fri, 21 Apr 2023 23:57:57 +0200 Subject: [PATCH 1/2] chore: update pre-commit config --- .pre-commit-config.yaml | 3 +-- Cargo.toml | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9edf2bb..c9aa181 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,6 +3,5 @@ repos: rev: v0.1.0 hooks: - id: cargo-fmt - - id: cargo-check - id: cargo-clippy - args: ["--", "-D", "warnings"] + args: ["--all", "--all-features", "--", "-D", "warnings"] diff --git a/Cargo.toml b/Cargo.toml index fd7c6bf..d46bb74 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,7 +2,7 @@ name = "musixmatch-inofficial" version = "0.1.0" edition = "2021" -authors = ["ThetaDev"] +authors = ["ThetaDev "] license = "MIT" description = "Inofficial client for the Musixmatch API" keywords = ["music", "lyrics"] @@ -21,13 +21,22 @@ rustls-tls-webpki-roots = ["reqwest/rustls-tls-webpki-roots"] rustls-tls-native-roots = ["reqwest/rustls-tls-native-roots"] [dependencies] -reqwest = {version = "0.11.11", default-features = false, features = ["json", "gzip", "cookies"]} -tokio = {version = "1.20.0"} +reqwest = { version = "0.11.11", default-features = false, features = [ + "json", + "gzip", + "cookies", +] } +tokio = { version = "1.20.0" } serde = { version = "1.0", features = ["derive"] } serde_json = "1.0.85" thiserror = "1.0.36" log = "0.4.17" -time = {version = "0.3.15", features = ["macros", "formatting", "serde", "serde-well-known"]} +time = { version = "0.3.15", features = [ + "macros", + "formatting", + "serde", + "serde-well-known", +] } hmac = "0.12.1" sha1 = "0.10.5" rand = "0.8.5" @@ -35,10 +44,10 @@ base64 = "0.13.0" [dev-dependencies] ctor = "0.1.23" -rstest = {version = "0.15.0", default-features = false} +rstest = { version = "0.15.0", default-features = false } env_logger = "0.9.1" dotenvy = "0.15.5" -tokio = {version = "1.20.0", features = ["macros"]} +tokio = { version = "1.20.0", features = ["macros"] } futures = "0.3.21" [profile.release] From 70dffdec73dc7ee5604d65202f53f5b59afa5422 Mon Sep 17 00:00:00 2001 From: ThetaDev Date: Sat, 22 Apr 2023 00:01:12 +0200 Subject: [PATCH 2/2] chore: update dependencies --- Cargo.toml | 8 ++++---- cli/src/main.rs | 7 ++----- src/lib.rs | 3 ++- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index d46bb74..17b0119 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -40,12 +40,12 @@ time = { version = "0.3.15", features = [ hmac = "0.12.1" sha1 = "0.10.5" rand = "0.8.5" -base64 = "0.13.0" +base64 = "0.21.0" [dev-dependencies] -ctor = "0.1.23" -rstest = { version = "0.15.0", default-features = false } -env_logger = "0.9.1" +ctor = "0.2.0" +rstest = { version = "0.17.0", default-features = false } +env_logger = "0.10.0" dotenvy = "0.15.5" tokio = { version = "1.20.0", features = ["macros"] } futures = "0.3.21" diff --git a/cli/src/main.rs b/cli/src/main.rs index 0a913be..a4cf8c1 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -415,15 +415,12 @@ fn input(prompt: &str) -> String { stdin().read_line(&mut input).expect("Failed to read line"); // Remove trailing newline input.pop(); - - return input; + input } fn input_pwd(prompt: &str) -> String { print!("{}", prompt); stdout().flush().expect("Failed to flush stdout!"); - let input = rpassword::read_password().expect("Failed to read password"); - - return input; + rpassword::read_password().expect("Failed to read password") } diff --git a/src/lib.rs b/src/lib.rs index 45f767b..ae4f684 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,6 +13,7 @@ use std::sync::{Arc, RwLock}; pub use error::Error; +use base64::Engine; use hmac::{Hmac, Mac}; use log::{error, info, warn}; use rand::{seq::SliceRandom, Rng}; @@ -425,7 +426,7 @@ fn sign_url_with_date(url: &mut Url, date: OffsetDateTime) { mac.update(date.format(YMD_FORMAT).unwrap_or_default().as_bytes()); let sig = mac.finalize().into_bytes(); - let sig_b64 = base64::encode(sig) + "\n"; + let sig_b64 = base64::engine::general_purpose::STANDARD.encode(sig) + "\n"; url.query_pairs_mut() .append_pair("signature", &sig_b64)