mirror of
https://github.com/SkyfallWasTaken/arcade-monitor.git
synced 2024-11-10 03:49:40 +00:00
Remove a few unwraps
This commit is contained in:
parent
4c09b8e3cd
commit
507e1024d2
1 changed files with 7 additions and 3 deletions
10
src/items.rs
10
src/items.rs
|
@ -30,12 +30,16 @@ pub async fn try_fetch(shop_url: Url) -> Result<ShopItems> {
|
|||
let doc_html = response.text().await?;
|
||||
let doc = Html::parse_document(&doc_html);
|
||||
let selector = Selector::parse("#__NEXT_DATA__").unwrap();
|
||||
let json: serde_json::Value =
|
||||
serde_json::from_str(&doc.select(&selector).next().unwrap().inner_html())?;
|
||||
let json: serde_json::Value = serde_json::from_str(
|
||||
&doc.select(&selector)
|
||||
.next()
|
||||
.ok_or("no #__NEXT_DATA__ element in document")?
|
||||
.inner_html(),
|
||||
)?;
|
||||
|
||||
let available_items = serde_json::from_value(
|
||||
json.pointer("/props/pageProps/availableItems")
|
||||
.expect("availableItems not found - is the ARCADE_SHOP_URL correct?")
|
||||
.ok_or("availableItems not found - is the ARCADE_SHOP_URL correct?")?
|
||||
.clone(),
|
||||
)?;
|
||||
|
||||
|
|
Loading…
Reference in a new issue