fixes and cleanup
This commit is contained in:
@@ -37,9 +37,18 @@ pub struct BeegProvider {
|
||||
impl BeegProvider {
|
||||
pub fn new() -> Self {
|
||||
let provider = BeegProvider {
|
||||
sites: Arc::new(RwLock::new(vec![FilterOption { id: "all".into(), title: "All".into() }])),
|
||||
stars: Arc::new(RwLock::new(vec![FilterOption { id: "all".into(), title: "All".into() }])),
|
||||
categories: Arc::new(RwLock::new(vec![FilterOption { id: "all".into(), title: "All".into() }])),
|
||||
sites: Arc::new(RwLock::new(vec![FilterOption {
|
||||
id: "all".into(),
|
||||
title: "All".into(),
|
||||
}])),
|
||||
stars: Arc::new(RwLock::new(vec![FilterOption {
|
||||
id: "all".into(),
|
||||
title: "All".into(),
|
||||
}])),
|
||||
categories: Arc::new(RwLock::new(vec![FilterOption {
|
||||
id: "all".into(),
|
||||
title: "All".into(),
|
||||
}])),
|
||||
};
|
||||
|
||||
provider.spawn_initial_load();
|
||||
@@ -52,7 +61,10 @@ impl BeegProvider {
|
||||
let stars = Arc::clone(&self.stars);
|
||||
|
||||
thread::spawn(move || {
|
||||
let rt = match tokio::runtime::Builder::new_current_thread().enable_all().build() {
|
||||
let rt = match tokio::runtime::Builder::new_current_thread()
|
||||
.enable_all()
|
||||
.build()
|
||||
{
|
||||
Ok(rt) => rt,
|
||||
Err(e) => {
|
||||
eprintln!("beeg runtime init failed: {}", e);
|
||||
@@ -77,14 +89,18 @@ impl BeegProvider {
|
||||
async fn fetch_tags() -> Result<Value> {
|
||||
let mut requester = util::requester::Requester::new();
|
||||
let text = match requester
|
||||
.get("https://store.externulls.com/tag/facts/tags?get_original=true&slug=index", None)
|
||||
.await {
|
||||
Ok(text) => text,
|
||||
Err(e) => {
|
||||
eprintln!("beeg fetch_tags failed: {}", e);
|
||||
return Err(ErrorKind::Parse("failed to fetch tags".into()).into());
|
||||
}
|
||||
};
|
||||
.get(
|
||||
"https://store.externulls.com/tag/facts/tags?get_original=true&slug=index",
|
||||
None,
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(text) => text,
|
||||
Err(e) => {
|
||||
eprintln!("beeg fetch_tags failed: {}", e);
|
||||
return Err(ErrorKind::Parse("failed to fetch tags".into()).into());
|
||||
}
|
||||
};
|
||||
Ok(serde_json::from_str(&text)?)
|
||||
}
|
||||
|
||||
@@ -99,7 +115,13 @@ impl BeegProvider {
|
||||
s.get("tg_name").and_then(|v| v.as_str()),
|
||||
s.get("tg_slug").and_then(|v| v.as_str()),
|
||||
) {
|
||||
Self::push_unique(&stars, FilterOption { id: id.into(), title: name.into() });
|
||||
Self::push_unique(
|
||||
&stars,
|
||||
FilterOption {
|
||||
id: id.into(),
|
||||
title: name.into(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@@ -139,7 +161,13 @@ impl BeegProvider {
|
||||
s.get("tg_name").and_then(|v| v.as_str()),
|
||||
s.get("tg_slug").and_then(|v| v.as_str()),
|
||||
) {
|
||||
Self::push_unique(&sites, FilterOption { id: id.into(), title: name.into() });
|
||||
Self::push_unique(
|
||||
&sites,
|
||||
FilterOption {
|
||||
id: id.into(),
|
||||
title: name.into(),
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@@ -178,7 +206,11 @@ impl BeegProvider {
|
||||
description: "Filter for different Networks".into(),
|
||||
systemImage: "list.dash".into(),
|
||||
colorName: "purple".into(),
|
||||
options: self.categories.read().map(|v| v.clone()).unwrap_or_default(),
|
||||
options: self
|
||||
.categories
|
||||
.read()
|
||||
.map(|v| v.clone())
|
||||
.unwrap_or_default(),
|
||||
multiSelect: false,
|
||||
},
|
||||
ChannelOption {
|
||||
@@ -220,7 +252,8 @@ impl BeegProvider {
|
||||
}
|
||||
let video_url = format!(
|
||||
"https://store.externulls.com/facts/tag?limit=100&offset={}{}",
|
||||
page - 1, match slug {
|
||||
page - 1,
|
||||
match slug {
|
||||
"" => "&id=27173".to_string(),
|
||||
_ => format!("&slug={}", slug.replace(" ", "")),
|
||||
}
|
||||
@@ -237,7 +270,8 @@ impl BeegProvider {
|
||||
vec![]
|
||||
}
|
||||
};
|
||||
let mut requester = crate::providers::requester_or_default(&options, module_path!(), "missing_requester");
|
||||
let mut requester =
|
||||
crate::providers::requester_or_default(&options, module_path!(), "missing_requester");
|
||||
let text = match requester.get(&video_url, None).await {
|
||||
Ok(text) => text,
|
||||
Err(e) => {
|
||||
@@ -289,7 +323,8 @@ impl BeegProvider {
|
||||
}
|
||||
};
|
||||
|
||||
let mut requester = crate::providers::requester_or_default(&options, module_path!(), "missing_requester");
|
||||
let mut requester =
|
||||
crate::providers::requester_or_default(&options, module_path!(), "missing_requester");
|
||||
|
||||
let text = match requester.get(&video_url, None).await {
|
||||
Ok(text) => text,
|
||||
@@ -323,14 +358,24 @@ impl BeegProvider {
|
||||
};
|
||||
|
||||
for video in array {
|
||||
let file = match video.get("file") { Some(v) => v, None => continue };
|
||||
let hls = match file.get("hls_resources") { Some(v) => v, None => continue };
|
||||
let file = match video.get("file") {
|
||||
Some(v) => v,
|
||||
None => continue,
|
||||
};
|
||||
let hls = match file.get("hls_resources") {
|
||||
Some(v) => v,
|
||||
None => continue,
|
||||
};
|
||||
let key = match hls.get("fl_cdn_multi").and_then(|v| v.as_str()) {
|
||||
Some(v) => v,
|
||||
None => continue,
|
||||
};
|
||||
|
||||
let id = file.get("id").and_then(|v| v.as_i64()).unwrap_or(0).to_string();
|
||||
let id = file
|
||||
.get("id")
|
||||
.and_then(|v| v.as_i64())
|
||||
.unwrap_or(0)
|
||||
.to_string();
|
||||
let title = file
|
||||
.get("data")
|
||||
.and_then(|v| v.get(0))
|
||||
@@ -352,7 +397,10 @@ impl BeegProvider {
|
||||
.and_then(|s| parse_abbreviated_number(s))
|
||||
.unwrap_or(0);
|
||||
|
||||
let thumb = format!("https://thumbs.externulls.com/videos/{}/0.webp?size=480x270", id);
|
||||
let thumb = format!(
|
||||
"https://thumbs.externulls.com/videos/{}/0.webp?size=480x270",
|
||||
id
|
||||
);
|
||||
|
||||
let mut item = VideoItem::new(
|
||||
id,
|
||||
|
||||
Reference in New Issue
Block a user