overhault to fix warnings etc

This commit is contained in:
Simon
2025-10-04 14:28:29 +00:00
parent d84cc715a8
commit 28a4c57616
29 changed files with 889 additions and 1338 deletions

View File

@@ -1,3 +1,4 @@
use crate::api::ClientVersion;
use crate::status::*;
use crate::util::parse_abbreviated_number;
use crate::DbPool;
@@ -8,6 +9,7 @@ use crate::videos::{ServerOptions, VideoItem};
use error_chain::error_chain;
use htmlentity::entity::{ICodedDataTrait, decode};
use std::vec;
use async_trait::async_trait;
error_chain! {
foreign_links {
@@ -19,15 +21,21 @@ error_chain! {
#[derive(Debug, Clone)]
pub struct OmgxxxProvider {
url: String,
sites: Vec<FilterOption>,
networks: Vec<FilterOption>,
}
impl OmgxxxProvider {
pub fn new() -> Self {
OmgxxxProvider {
url: "https://www.omg.xxx".to_string(),
sites: vec![],
networks: vec![],
}
}
async fn get_channel(&self) -> crate::status::Channel {
fn build_channel(&self, clientversion: ClientVersion) -> Channel {
let _ = clientversion;
let channel: crate::status::Channel = Channel{
id: "omgxxx".to_string(),
name: "OMG XXX".to_string(),
@@ -58,11 +66,31 @@ impl OmgxxxProvider {
},
],
multiSelect: false,
},
ChannelOption {
id: "sites".to_string(),
title: "Sites".to_string(),
description: "Sort the Videos".to_string(), //"Sort the videos by Date or Name.".to_string(),
systemImage: "list.bullet.indent".to_string(),
colorName: "green".to_string(),
options: self.sites.clone(),
multiSelect: false,
},
ChannelOption {
id: "networks".to_string(),
title: "Networks".to_string(),
description: "Sort the Videos".to_string(), //"Sort the videos by Date or Name.".to_string(),
systemImage: "list.dash".to_string(),
colorName: "purple".to_string(),
options: self.networks.clone(),
multiSelect: false,
}
],
nsfw: true,
cacheDuration: None,
};
return channel;
}
@@ -94,7 +122,6 @@ impl OmgxxxProvider {
};
let mut requester = options.requester.clone().unwrap();
let text = requester.get(&video_url).await.unwrap();
let video_items: Vec<VideoItem> = self.get_video_items_from_html(text.clone());
if !video_items.is_empty() {
@@ -158,10 +185,10 @@ impl OmgxxxProvider {
.split("class=\"item\"").collect::<Vec<&str>>()[1..]
.to_vec();
for video_segment in &raw_videos {
let vid = video_segment.split("\n").collect::<Vec<&str>>();
for (index, line) in vid.iter().enumerate() {
println!("Line {}: {}", index, line);
}
// let vid = video_segment.split("\n").collect::<Vec<&str>>();
// for (index, line) in vid.iter().enumerate() {
// println!("Line {}: {}", index, line);
// }
let video_url: String = video_segment.split("<a href=\"").collect::<Vec<&str>>()[1]
.split("\"")
.collect::<Vec<&str>>()[0].to_string();
@@ -226,6 +253,7 @@ impl OmgxxxProvider {
}
#[async_trait]
impl Provider for OmgxxxProvider {
async fn get_videos(
&self,
@@ -257,4 +285,8 @@ impl Provider for OmgxxxProvider {
}
}
}
fn get_channel(&self, clientversion: ClientVersion) -> crate::status::Channel {
println!("Getting channel for omgxxx with client version: {:?}", clientversion);
self.build_channel(clientversion)
}
}