mirror of
https://github.com/FliegendeWurst/KIT-ILIAS-downloader.git
synced 2024-08-28 04:04:18 +00:00
Add option to save ILIAS pages (fix #22)
This commit is contained in:
parent
1c41c95773
commit
3e0a2bf154
@ -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,
|
||||||
|
@ -34,12 +34,14 @@ 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 ilias.opt.save_ilias_pages {
|
||||||
if let Some(s) = content.1.as_ref() {
|
if let Some(s) = content.1.as_ref() {
|
||||||
let path = path.join("course.html");
|
let path = path.join("course.html");
|
||||||
write_file_data(&path, &mut s.as_bytes())
|
write_file_data(&path, &mut s.as_bytes())
|
||||||
.await
|
.await
|
||||||
.context("failed to write course page html")?;
|
.context("failed to write course page html")?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for item in content.0 {
|
for item in content.0 {
|
||||||
let item = item?;
|
let item = item?;
|
||||||
let path = path.join(file_escape(item.name()));
|
let path = path.join(file_escape(item.name()));
|
||||||
|
@ -12,12 +12,14 @@ 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 ilias.opt.save_ilias_pages {
|
||||||
if let Some(s) = content.1.as_ref() {
|
if let Some(s) = content.1.as_ref() {
|
||||||
let path = path.join("folder.html");
|
let path = path.join("folder.html");
|
||||||
write_file_data(&path, &mut s.as_bytes())
|
write_file_data(&path, &mut s.as_bytes())
|
||||||
.await
|
.await
|
||||||
.context("failed to write folder page html")?;
|
.context("failed to write folder page html")?;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for item in content.0 {
|
for item in content.0 {
|
||||||
let item = item?;
|
let item = item?;
|
||||||
let path = path.join(file_escape(ilias.course_names.get(item.name()).map(|x| &**x).unwrap_or(item.name())));
|
let path = path.join(file_escape(ilias.course_names.get(item.name()).map(|x| &**x).unwrap_or(item.name())));
|
||||||
|
Loading…
Reference in New Issue
Block a user