mirror of
https://github.com/FliegendeWurst/KIT-ILIAS-downloader.git
synced 2024-08-28 04:04:18 +00:00
Warn the user if a video has been updated
This also 'detects' duplicated videos.
This commit is contained in:
parent
a3f84aa6fb
commit
d6f635b442
20
src/main.rs
20
src/main.rs
@ -695,12 +695,6 @@ fn process(ilias: Arc<ILIAS>, path: PathBuf, obj: Object) -> impl std::future::F
|
|||||||
if ilias.opt.no_videos {
|
if ilias.opt.no_videos {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
if !ilias.opt.force && fs::metadata(&path).is_ok() {
|
|
||||||
if ilias.opt.verbose > 1 {
|
|
||||||
println!("Skipping download, file exists already");
|
|
||||||
}
|
|
||||||
return Ok(());
|
|
||||||
}
|
|
||||||
let url = format!("{}{}", ILIAS_URL, url.url);
|
let url = format!("{}{}", ILIAS_URL, url.url);
|
||||||
let data = ilias.download(&url);
|
let data = ilias.download(&url);
|
||||||
let html = data.await?.text().await?;
|
let html = data.await?.text().await?;
|
||||||
@ -724,6 +718,20 @@ fn process(ilias: Arc<ILIAS>, path: PathBuf, obj: Object) -> impl std::future::F
|
|||||||
.map(|x| x.as_str())
|
.map(|x| x.as_str())
|
||||||
.ok_or(anyhow!("video src not found"))?
|
.ok_or(anyhow!("video src not found"))?
|
||||||
.ok_or(anyhow!("video src not string"))?;
|
.ok_or(anyhow!("video src not string"))?;
|
||||||
|
if let Ok(meta) = fs::metadata(&path) {
|
||||||
|
let head = ilias.client.head(url).send().await.context("HEAD request failed")?;
|
||||||
|
if let Some(len) = head.headers().get("content-length") {
|
||||||
|
if meta.len() != len.to_str()?.parse::<u64>()? {
|
||||||
|
println!("Warning: {} was updated, consider moving the outdated file", relative_path.to_string_lossy());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ilias.opt.verbose > 1 {
|
||||||
|
println!("Skipping download, file exists already");
|
||||||
|
}
|
||||||
|
if !ilias.opt.force {
|
||||||
|
return Ok(());
|
||||||
|
}
|
||||||
|
}
|
||||||
let resp = ilias.download(&url).await?;
|
let resp = ilias.download(&url).await?;
|
||||||
let mut reader = stream_reader(resp.bytes_stream().map_err(|x| {
|
let mut reader = stream_reader(resp.bytes_stream().map_err(|x| {
|
||||||
io::Error::new(io::ErrorKind::Other, x)
|
io::Error::new(io::ErrorKind::Other, x)
|
||||||
|
Loading…
Reference in New Issue
Block a user