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)] #[structopt(long)]
pub combine_videos: bool, pub combine_videos: bool,
/// Save overview pages of ILIAS courses and folders
#[structopt(long)]
pub save_ilias_pages: bool,
/// Verbose logging /// Verbose logging
#[structopt(short, multiple = true, parse(from_occurrences))] #[structopt(short, multiple = true, parse(from_occurrences))]
pub verbose: usize, pub verbose: usize,

View File

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