Compare commits
No commits in common. "0dc6f09a7421307e51a0ca9cf5453d5d8f80b3bd" and "f50182585207cec1e2bfee30650b5bd9f218e151" have entirely different histories.
0dc6f09a74
...
f501825852
16
Cargo.lock
generated
16
Cargo.lock
generated
@ -677,21 +677,6 @@ version = "0.2.155"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "linked-hash-map"
|
|
||||||
version = "0.5.6"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f"
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "linked_hash_set"
|
|
||||||
version = "0.1.4"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "47186c6da4d81ca383c7c47c1bfc80f4b95f4720514d860a5407aaf4233f9588"
|
|
||||||
dependencies = [
|
|
||||||
"linked-hash-map",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linux-raw-sys"
|
name = "linux-raw-sys"
|
||||||
version = "0.4.14"
|
version = "0.4.14"
|
||||||
@ -1453,7 +1438,6 @@ dependencies = [
|
|||||||
"anyhow",
|
"anyhow",
|
||||||
"clap",
|
"clap",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"linked_hash_set",
|
|
||||||
"log",
|
"log",
|
||||||
"regex",
|
"regex",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
|
@ -7,7 +7,6 @@ edition = "2021"
|
|||||||
anyhow = "1.0.86"
|
anyhow = "1.0.86"
|
||||||
clap = { version = "4.5.13", features = ["derive"] }
|
clap = { version = "4.5.13", features = ["derive"] }
|
||||||
env_logger = "0.11.5"
|
env_logger = "0.11.5"
|
||||||
linked_hash_set = "0.1.4"
|
|
||||||
log = "0.4.22"
|
log = "0.4.22"
|
||||||
regex = "1.10.6"
|
regex = "1.10.6"
|
||||||
reqwest = { version = "0.12.5", features = ["json"] }
|
reqwest = { version = "0.12.5", features = ["json"] }
|
||||||
|
35
src/main.rs
35
src/main.rs
@ -1,21 +1,10 @@
|
|||||||
use std::{env, fmt::Display};
|
|
||||||
|
|
||||||
use clap;
|
use clap;
|
||||||
use linked_hash_set::{self, LinkedHashSet};
|
use log::{error, info};
|
||||||
use log::{error, info, LevelFilter};
|
|
||||||
use svtl::{get_base_url, get_content, get_relative_links, YtDlpWrapper};
|
use svtl::{get_base_url, get_content, get_relative_links, YtDlpWrapper};
|
||||||
|
|
||||||
fn init_logger() {
|
|
||||||
let mut builder = env_logger::Builder::from_env("RUST_LOG");
|
|
||||||
if env::var("RUST_LOG").is_err() {
|
|
||||||
builder.filter_level(LevelFilter::Info);
|
|
||||||
}
|
|
||||||
builder.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
init_logger();
|
env_logger::init();
|
||||||
|
|
||||||
let matches = clap::Command::new("Svt Links")
|
let matches = clap::Command::new("Svt Links")
|
||||||
.version("1.0")
|
.version("1.0")
|
||||||
@ -54,11 +43,8 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let aux_for_unique =
|
let links = get_relative_links(&content);
|
||||||
LinkedHashSet::<String>::from_iter(get_relative_links(&content).into_iter());
|
info!("Found the following links: {}", links.join(", "));
|
||||||
let links = aux_for_unique.into_iter().collect::<Vec<_>>();
|
|
||||||
|
|
||||||
info!("Found the following unqiue links: \n{}", join_long(&links));
|
|
||||||
|
|
||||||
for link_part in links {
|
for link_part in links {
|
||||||
let link = format!("{}{}", base_url, link_part);
|
let link = format!("{}{}", base_url, link_part);
|
||||||
@ -69,16 +55,3 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn join_long<S: Display>(strings: &Vec<S>) -> String {
|
|
||||||
let mut ret = String::new();
|
|
||||||
for (idx, s) in strings.iter().enumerate() {
|
|
||||||
let mut to_push = format!(" {}: {}", idx + 1, s);
|
|
||||||
if idx != strings.len() - 1 {
|
|
||||||
to_push.push('\n');
|
|
||||||
}
|
|
||||||
ret.push_str(&to_push);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user