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
16
src/main.rs
16
src/main.rs
@ -129,9 +129,18 @@ 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());
|
||||||
|
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 {
|
match desktop {
|
||||||
Ok(desktop) => {
|
Ok(desktop) => {
|
||||||
for item in desktop.items {
|
for item in desktop.items {
|
||||||
@ -143,6 +152,7 @@ async fn main() {
|
|||||||
},
|
},
|
||||||
Err(e) => error!(e),
|
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 {
|
||||||
let _ = task.await;
|
let _ = task.await;
|
||||||
@ -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