implemented tags for videos
This commit is contained in:
@@ -11,7 +11,6 @@ mod util;
|
||||
|
||||
#[ntex::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "ntex=info");
|
||||
std::env::set_var("RUST_BACKTRACE", "1");
|
||||
env_logger::init(); // You need this to actually see logs
|
||||
|
||||
|
||||
@@ -152,15 +152,17 @@ impl PerverzijaProvider {
|
||||
.split("video-item post")
|
||||
.collect::<Vec<&str>>()[1..]
|
||||
.to_vec();
|
||||
// println!("Raw Videos: {:?}", raw_videos);
|
||||
for video_segment in &raw_videos {
|
||||
let vid = video_segment.split("\n").collect::<Vec<&str>>();
|
||||
// let mut index = 0;
|
||||
if vid.len() > 20 {
|
||||
println!("Skipping video segment with unexpected length: {}", vid.len());
|
||||
continue;
|
||||
}
|
||||
|
||||
for (i, line) in vid.iter().enumerate() {
|
||||
if line.trim().is_empty() {
|
||||
println!("Empty line at index {}: {}", i, line);
|
||||
}
|
||||
}
|
||||
let mut title = vid[1].split(">").collect::<Vec<&str>>()[1]
|
||||
.split("<")
|
||||
.collect::<Vec<&str>>()[0]
|
||||
@@ -208,6 +210,17 @@ impl PerverzijaProvider {
|
||||
.collect::<Vec<&str>>()[0]
|
||||
.to_string();
|
||||
let embed = Video_Embed::new(embed_html, url.clone());
|
||||
|
||||
let mut tags: Vec<String> = Vec::new(); // Placeholder for tags, adjust as needed
|
||||
for tag in vid[0].split(" ").collect::<Vec<&str>>(){
|
||||
if tag.starts_with("tag-") {
|
||||
let tag_name = tag.split("tag-").collect::<Vec<&str>>()[1]
|
||||
.to_string();
|
||||
if !tag_name.is_empty() {
|
||||
tags.push(tag_name.replace("-", " ").to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
let mut video_item = Video_Item::new(
|
||||
id,
|
||||
title,
|
||||
@@ -215,8 +228,8 @@ impl PerverzijaProvider {
|
||||
"perverzija".to_string(),
|
||||
thumb,
|
||||
duration,
|
||||
);
|
||||
video_item.embed = Some(embed);
|
||||
).tags(tags)
|
||||
.embed(embed.clone());
|
||||
let mut format =
|
||||
videos::Video_Format::new(url.clone(), "1080".to_string(), "m3u8".to_string());
|
||||
format.add_http_header("Referer".to_string(), referer_url.clone());
|
||||
@@ -268,7 +281,6 @@ impl PerverzijaProvider {
|
||||
18 => 14,
|
||||
13 => 8,
|
||||
_ => {
|
||||
println!("Unexpected video segment length: {}", vid.len());
|
||||
continue;
|
||||
}
|
||||
};
|
||||
@@ -296,6 +308,17 @@ impl PerverzijaProvider {
|
||||
.collect::<Vec<&str>>()[0]
|
||||
.to_string();
|
||||
let embed = Video_Embed::new(embed_html, url.clone());
|
||||
let mut tags: Vec<String> = Vec::new(); // Placeholder for tags, adjust as needed
|
||||
for tag in vid[0].split(" ").collect::<Vec<&str>>(){
|
||||
if tag.starts_with("tag-") {
|
||||
let tag_name = tag.split("tag-").collect::<Vec<&str>>()[1]
|
||||
.to_string();
|
||||
if !tag_name.is_empty() {
|
||||
tags.push(tag_name.replace("-", " ").to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut video_item = Video_Item::new(
|
||||
id,
|
||||
title,
|
||||
@@ -303,8 +326,9 @@ impl PerverzijaProvider {
|
||||
"perverzija".to_string(),
|
||||
thumb,
|
||||
duration,
|
||||
);
|
||||
video_item.embed = Some(embed);
|
||||
)
|
||||
.tags(tags)
|
||||
.embed(embed.clone());
|
||||
let mut format =
|
||||
videos::Video_Format::new(url.clone(), "1080".to_string(), "m3u8".to_string());
|
||||
format.add_http_header("Referer".to_string(), referer_url.clone());
|
||||
|
||||
@@ -76,6 +76,42 @@ impl Video_Item {
|
||||
embed: None, // Placeholder for embed information
|
||||
}
|
||||
}
|
||||
pub fn tags(mut self, tags: Vec<String>) -> Self {
|
||||
self.tags = Some(tags);
|
||||
self
|
||||
}
|
||||
pub fn uploader(mut self, uploader: String) -> Self {
|
||||
self.uploader = Some(uploader);
|
||||
self
|
||||
}
|
||||
pub fn uploader_url(mut self, uploader_url: String) -> Self {
|
||||
self.uploaderUrl = Some(uploader_url);
|
||||
self
|
||||
}
|
||||
pub fn verified(mut self, verified: bool) -> Self {
|
||||
self.verified = Some(verified);
|
||||
self
|
||||
}
|
||||
pub fn views(mut self, views: u32) -> Self {
|
||||
self.views = Some(views);
|
||||
self
|
||||
}
|
||||
pub fn rating(mut self, rating: f32) -> Self {
|
||||
self.rating = Some(rating);
|
||||
self
|
||||
}
|
||||
pub fn uploaded_at(mut self, uploaded_at: u64) -> Self {
|
||||
self.uploadedAt = Some(uploaded_at);
|
||||
self
|
||||
}
|
||||
pub fn formats(mut self, formats: Vec<Video_Format>) -> Self {
|
||||
self.formats = Some(formats);
|
||||
self
|
||||
}
|
||||
pub fn embed(mut self, embed: Video_Embed) -> Self {
|
||||
self.embed = Some(embed);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(serde::Serialize, Debug, Clone)]
|
||||
|
||||
Reference in New Issue
Block a user