mirror of
https://github.com/FliegendeWurst/KIT-ILIAS-downloader.git
synced 2024-08-28 04:04:18 +00:00
--sync-url option
This commit is contained in:
parent
450b0d9284
commit
a05ea16d83
36
src/main.rs
36
src/main.rs
@ -129,19 +129,29 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let ilias = Arc::new(ilias);
|
let ilias = Arc::new(ilias);
|
||||||
let desktop = ilias.personal_desktop().await.context("Failed to load personal desktop");
|
|
||||||
let (tx, mut rx) = futures_channel::mpsc::unbounded::<JoinHandle<()>>();
|
let (tx, mut rx) = futures_channel::mpsc::unbounded::<JoinHandle<()>>();
|
||||||
*TASKS.lock() = Some(tx.clone());
|
*TASKS.lock() = Some(tx.clone());
|
||||||
match desktop {
|
if let Some(url) = ilias.opt.sync_url.as_ref() {
|
||||||
Ok(desktop) => {
|
for item in ilias.get_course_content(&URL::from_href(url).expect("invalid URL")).await.expect("invalid response") {
|
||||||
for item in desktop.items {
|
let item = item.expect("invalid item");
|
||||||
let mut path = ilias.opt.output.clone();
|
let ilias = Arc::clone(&ilias);
|
||||||
path.push(file_escape(item.name()));
|
let mut path = ilias.opt.output.clone();
|
||||||
let ilias = Arc::clone(&ilias);
|
path.push(file_escape(item.name()));
|
||||||
let _ = tx.unbounded_send(task::spawn(process_gracefully(ilias, path, item)));
|
tx.unbounded_send(task::spawn(process_gracefully(ilias, path, item))).unwrap();
|
||||||
}
|
}
|
||||||
},
|
} else {
|
||||||
Err(e) => error!(e),
|
let desktop = ilias.personal_desktop().await.context("Failed to load personal desktop");
|
||||||
|
match desktop {
|
||||||
|
Ok(desktop) => {
|
||||||
|
for item in desktop.items {
|
||||||
|
let mut path = ilias.opt.output.clone();
|
||||||
|
path.push(file_escape(item.name()));
|
||||||
|
let ilias = Arc::clone(&ilias);
|
||||||
|
let _ = tx.unbounded_send(task::spawn(process_gracefully(ilias, path, item)));
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => error!(e),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
while let Either::Left((task, _)) = future::select(rx.next(), future::ready(())).await {
|
while let Either::Left((task, _)) = future::select(rx.next(), future::ready(())).await {
|
||||||
if let Some(task) = task {
|
if let Some(task) = task {
|
||||||
@ -837,6 +847,10 @@ struct Opt {
|
|||||||
/// KIT account password
|
/// KIT account password
|
||||||
#[structopt(short = "P", long)]
|
#[structopt(short = "P", long)]
|
||||||
password: Option<String>,
|
password: Option<String>,
|
||||||
|
|
||||||
|
/// ILIAS page to download
|
||||||
|
#[structopt(long)]
|
||||||
|
sync_url: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ILIAS {
|
struct ILIAS {
|
||||||
|
Loading…
Reference in New Issue
Block a user