--sync-url option

This commit is contained in:
FliegendeWurst 2021-04-19 10:33:46 +02:00
parent 450b0d9284
commit a05ea16d83

View File

@ -129,9 +129,18 @@ async fn main() {
}
}
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<()>>();
*TASKS.lock() = Some(tx.clone());
if let Some(url) = ilias.opt.sync_url.as_ref() {
for item in ilias.get_course_content(&URL::from_href(url).expect("invalid URL")).await.expect("invalid response") {
let item = item.expect("invalid item");
let ilias = Arc::clone(&ilias);
let mut path = ilias.opt.output.clone();
path.push(file_escape(item.name()));
tx.unbounded_send(task::spawn(process_gracefully(ilias, path, item))).unwrap();
}
} else {
let desktop = ilias.personal_desktop().await.context("Failed to load personal desktop");
match desktop {
Ok(desktop) => {
for item in desktop.items {
@ -143,6 +152,7 @@ async fn main() {
},
Err(e) => error!(e),
}
}
while let Either::Left((task, _)) = future::select(rx.next(), future::ready(())).await {
if let Some(task) = task {
let _ = task.await;
@ -837,6 +847,10 @@ struct Opt {
/// KIT account password
#[structopt(short = "P", long)]
password: Option<String>,
/// ILIAS page to download
#[structopt(long)]
sync_url: Option<String>,
}
struct ILIAS {