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,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?;
|
||||||
|
@ -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?;
|
||||||
|
Loading…
Reference in New Issue
Block a user