Fix issue with user agent being blocked

main
trivernis 12 months ago
parent 43aa8db090
commit 2aac6c1f4a
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

53
Cargo.lock generated

@ -636,6 +636,19 @@ dependencies = [
"synstructure",
]
[[package]]
name = "fakeit"
version = "1.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "853c484c6a2a2a7e7d5f0d7863b4a64b90875b60cea1ccab68cc4da21c785656"
dependencies = [
"chrono",
"libmath",
"rand 0.6.5",
"simplerand",
"uuid 0.8.2",
]
[[package]]
name = "fastrand"
version = "1.9.0"
@ -999,6 +1012,7 @@ dependencies = [
"config",
"directories",
"egg-mode",
"fakeit",
"hydrus-api",
"lazy-regex",
"pixiv-rs",
@ -1288,6 +1302,15 @@ version = "0.2.139"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79"
[[package]]
name = "libmath"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfd3416934a853ae80d5c3b006f632dfcbaf320300c5167e88a469e9ac214502"
dependencies = [
"rand 0.3.23",
]
[[package]]
name = "link-cplusplus"
version = "1.0.8"
@ -1784,6 +1807,16 @@ dependencies = [
"proc-macro2",
]
[[package]]
name = "rand"
version = "0.3.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "64ac302d8f83c0c1974bf758f6b041c6c8ada916fbb44a609158ca8b064cc76c"
dependencies = [
"libc",
"rand 0.4.6",
]
[[package]]
name = "rand"
version = "0.4.6"
@ -2033,7 +2066,7 @@ dependencies = [
"tokio-threadpool",
"tokio-timer",
"url 1.7.2",
"uuid",
"uuid 0.7.4",
"winreg 0.6.2",
]
@ -2305,6 +2338,15 @@ dependencies = [
"lazy_static",
]
[[package]]
name = "simplerand"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70455a0a21cb984df0f86033ca19f37cced497deb779603e7fa7b032f5b8897b"
dependencies = [
"lazy_static",
]
[[package]]
name = "slab"
version = "0.4.8"
@ -2844,6 +2886,15 @@ dependencies = [
"rand 0.6.5",
]
[[package]]
name = "uuid"
version = "0.8.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc5cf98d8186244414c848017f0e2676b3fcb46807f6668a97dfe67359a3c4b7"
dependencies = [
"getrandom",
]
[[package]]
name = "valuable"
version = "0.1.0"

@ -27,6 +27,7 @@ directories = "4.0.1"
color-eyre = "0.6.2"
egg-mode = "0.16.1"
lazy-regex = "2.4.1"
fakeit = "1.1.1"
[dependencies.tokio]
version = "1.25.0"

@ -3,6 +3,7 @@ use std::collections::HashMap;
use crate::Result;
use lazy_regex::regex;
use reqwest::ClientBuilder;
use reqwest::{redirect::Policy, StatusCode};
use serde::Deserialize;
use serde_json::Value;
@ -84,7 +85,15 @@ async fn get_post(url: &str) -> Result<T3Data> {
if !url.ends_with('/') {
url.push('/');
}
let mut response: Vec<DataEntry> = reqwest::get(format!("{}.json", url)).await?.json().await?;
let client = ClientBuilder::default()
.user_agent(fakeit::user_agent::random_platform())
.build()?;
let mut response: Vec<DataEntry> = client
.get(format!("{}.json", url))
.send()
.await?
.json()
.await?;
response.reverse();
let first_entry = response.pop().unwrap();
let mut first_listing = match first_entry {

Loading…
Cancel
Save