Skip to content

Commit

Permalink
fix datasheet download as LCSC changed the view on their end
Browse files Browse the repository at this point in the history
  • Loading branch information
markusdd committed Mar 29, 2024
1 parent 5cefd97 commit b6000b3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "easyeda_to_kicad_lib_ui"
version = "1.2.0"
version = "1.3.0"
authors = ["Markus Krause <[email protected]>"]
edition = "2021"
rust-version = "1.72"
Expand Down
8 changes: 7 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,18 @@ impl eframe::App for MyApp {
let _ = create_dir_all(dlpath);
}
if let Some(url) = self.current_part.get("meta_datasheeturl") {
// the datasheet url points to an integrated parts view frame with an embedded pdf viewer
// we need to modify it for the download of the actual file
// https://datasheet.lcsc.com/lcsc/2206010216_UNI-ROYAL-Uniroyal-Elec-0402WGF1001TCE_C11702.pdf
// https://wmsc.lcsc.com/wmsc/upload/file/pdf/v2/lcsc/2206010216_UNI-ROYAL-Uniroyal-Elec-0402WGF1001TCE_C11702.pdf
let dl = Downloader::builder()
.download_folder(&dlpath)

Check failure on line 355 in src/app.rs

View workflow job for this annotation

GitHub Actions / Clippy

this expression creates a reference which is immediately dereferenced by the compiler

Check failure on line 355 in src/app.rs

View workflow job for this annotation

GitHub Actions / Clippy

this expression creates a reference which is immediately dereferenced by the compiler
.build()
.ok();
let pdf_url = url.replace("https://datasheet.lcsc.com/lcsc", "https://wmsc.lcsc.com/wmsc/upload/file/pdf/v2/lcsc");
// debug only println!("PDF-URL: {}", pdf_url);
if let Some(mut dl) = dl {
let _ = dl.download(&[Download::new(url)]);
let _ = dl.download(&[Download::new(&pdf_url)]);
}
}
}
Expand Down

0 comments on commit b6000b3

Please sign in to comment.