mirror of
https://github.com/FliegendeWurst/KIT-ILIAS-downloader.git
synced 2024-08-28 04:04:18 +00:00
Properly extract dashboard items
This commit is contained in:
parent
cf28db189f
commit
4a97f0a659
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -12,6 +12,7 @@ dependencies = [
|
|||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"colored",
|
"colored",
|
||||||
"cookie_store",
|
"cookie_store",
|
||||||
|
"ego-tree",
|
||||||
"futures",
|
"futures",
|
||||||
"futures-channel",
|
"futures-channel",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
@ -35,3 +35,4 @@ reqwest_cookie_store = "0.2.0"
|
|||||||
bytes = "1.0.1"
|
bytes = "1.0.1"
|
||||||
toml = "0.5.8"
|
toml = "0.5.8"
|
||||||
tempfile = "3.2.0"
|
tempfile = "3.2.0"
|
||||||
|
ego-tree = "0.6.2"
|
||||||
|
@ -28,8 +28,9 @@ static ALERT_DANGER: Lazy<Selector> = Lazy::new(|| Selector::parse("div.alert-da
|
|||||||
static IL_CONTENT_CONTAINER: Lazy<Selector> = Lazy::new(|| Selector::parse("#il_center_col").unwrap());
|
static IL_CONTENT_CONTAINER: Lazy<Selector> = Lazy::new(|| Selector::parse("#il_center_col").unwrap());
|
||||||
static BLOCK_FAVORITES: Lazy<Selector> = Lazy::new(|| Selector::parse("#block_pditems_0").unwrap());
|
static BLOCK_FAVORITES: Lazy<Selector> = Lazy::new(|| Selector::parse("#block_pditems_0").unwrap());
|
||||||
static ITEM_PROP: Lazy<Selector> = Lazy::new(|| Selector::parse("span.il_ItemProperty").unwrap());
|
static ITEM_PROP: Lazy<Selector> = Lazy::new(|| Selector::parse("span.il_ItemProperty").unwrap());
|
||||||
static CONTAINER_ITEMS: Lazy<Selector> = Lazy::new(|| Selector::parse("div.il_ContainerListItem").unwrap());
|
static CONTAINER_ITEMS: Lazy<Selector> = Lazy::new(|| Selector::parse("div.il_ContainerListItem, .il-std-item").unwrap());
|
||||||
static CONTAINER_ITEM_TITLE: Lazy<Selector> = Lazy::new(|| Selector::parse("a.il_ContainerItemTitle").unwrap());
|
static CONTAINER_ITEM_TITLE: Lazy<Selector> = Lazy::new(|| Selector::parse("a.il_ContainerItemTitle").unwrap());
|
||||||
|
static CONTAINER_ITEM_TITLE_ALTERNATIVE: Lazy<Selector> = Lazy::new(|| Selector::parse(".il-item-title > a").unwrap());
|
||||||
|
|
||||||
pub struct ILIAS {
|
pub struct ILIAS {
|
||||||
pub opt: Opt,
|
pub opt: Opt,
|
||||||
@ -251,10 +252,16 @@ impl ILIAS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_items(html: &Html) -> Vec<Result<Object>> {
|
pub fn get_items(html: &Html) -> Vec<Result<Object>> {
|
||||||
|
let html = if let Some(favorites) = html.select(&BLOCK_FAVORITES).next() {
|
||||||
|
favorites
|
||||||
|
} else {
|
||||||
|
html.root_element()
|
||||||
|
};
|
||||||
html.select(&CONTAINER_ITEMS)
|
html.select(&CONTAINER_ITEMS)
|
||||||
.flat_map(|item| {
|
.flat_map(|item| {
|
||||||
item.select(&CONTAINER_ITEM_TITLE)
|
item.select(&CONTAINER_ITEM_TITLE)
|
||||||
.next()
|
.next()
|
||||||
|
.or_else(|| item.select(&CONTAINER_ITEM_TITLE_ALTERNATIVE).next())
|
||||||
.map(|link| Object::from_link(item, link))
|
.map(|link| Object::from_link(item, link))
|
||||||
// items without links are ignored
|
// items without links are ignored
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user