Add option to save ILIAS pages (fix #22)

This commit is contained in:
FliegendeWurst 2021-11-01 17:40:11 +01:00
parent 1c41c95773
commit 3e0a2bf154
3 changed files with 18 additions and 10 deletions

View File

@ -41,6 +41,10 @@ pub struct Opt {
#[structopt(long)]
pub combine_videos: bool,
/// Save overview pages of ILIAS courses and folders
#[structopt(long)]
pub save_ilias_pages: bool,
/// Verbose logging
#[structopt(short, multiple = true, parse(from_occurrences))]
pub verbose: usize,

View File

@ -34,11 +34,13 @@ pub async fn download(path: PathBuf, ilias: Arc<ILIAS>, url: &URL, name: &str) -
} else {
ilias.get_course_content(&url).await?
};
if let Some(s) = content.1.as_ref() {
let path = path.join("course.html");
write_file_data(&path, &mut s.as_bytes())
.await
.context("failed to write course page html")?;
if ilias.opt.save_ilias_pages {
if let Some(s) = content.1.as_ref() {
let path = path.join("course.html");
write_file_data(&path, &mut s.as_bytes())
.await
.context("failed to write course page html")?;
}
}
for item in content.0 {
let item = item?;

View File

@ -12,11 +12,13 @@ use super::{ILIAS, URL};
pub async fn download(path: &Path, ilias: Arc<ILIAS>, url: &URL) -> Result<()> {
let content = ilias.get_course_content(&url).await?;
if let Some(s) = content.1.as_ref() {
let path = path.join("folder.html");
write_file_data(&path, &mut s.as_bytes())
.await
.context("failed to write folder page html")?;
if ilias.opt.save_ilias_pages {
if let Some(s) = content.1.as_ref() {
let path = path.join("folder.html");
write_file_data(&path, &mut s.as_bytes())
.await
.context("failed to write folder page html")?;
}
}
for item in content.0 {
let item = item?;