repeat a request if it fails initially

This commit is contained in:
Simon
2026-01-21 11:32:02 +00:00
parent 5224a2eb47
commit 5a08d2afe7

View File

@@ -12,6 +12,7 @@ use error_chain::error_chain;
use futures::future::join_all;
use htmlentity::entity::{ICodedDataTrait, decode};
use std::sync::{Arc, RwLock};
use std::thread::sleep;
use std::{thread, vec};
use titlecase::Titlecase;
@@ -394,14 +395,26 @@ impl HqpornerProvider {
.and_then(|s| s.split('\'').next())
.ok_or("No player link")?
);
let text2 = requester
let mut r = requester
.get_raw_with_headers(
&player_url,
vec![("Referer".to_string(), "https://hqporner.com/".into())],
)
.await?
).await;
if let Err(_e) = &r {
sleep(std::time::Duration::from_secs(1));
r = requester
.get_raw_with_headers(
&player_url,
vec![("Referer".to_string(), "https://hqporner.com/".into())],
).await;
}
let text2 = r
.unwrap()
.text()
.await?;
.await
.map_err(|e| Error::from(format!("Text conversion failed: {}", e)))?;
// Check for error response
if text2.starts_with("ERR:"){
return Ok((tags, formats));