Skip to content

Commit d3b7362

Browse files
committed
fix: fix color fetching bug with some cards + minor code improvements
- minor code improvements - fix a bug with some cards not having `div.color` directly inside `div.backCol`
1 parent baa52c1 commit d3b7362

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
A CLI utility to retrieve data for the One Piece Trading Cards Game (TCG).
66

7+
The CLI directly goes against the [onepiece-cardgame.com](onepiece-cardgame.com) website and attempts to scrap information such as packs, cards and images.
8+
79
## Where is the data?
810

911
For practical reasons, data is kept in a separate repository: https://github.com/Coko7/vegapull-records

src/card/scraper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl CardScraper {
122122
}
123123

124124
pub fn fetch_colors(localizer: &Localizer, element: ElementRef) -> Result<Vec<CardColor>> {
125-
let sel = "dd>div.backCol>div.color";
125+
let sel = "dd>div.backCol div.color";
126126
trace!("fetching card.colors ({})...", sel);
127127

128128
let raw_colors = Self::get_child_node(element, sel.to_string())?.inner_html();

src/pack.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,22 +33,19 @@ impl Pack {
3333
fn process_title_parts(raw_title: &str) -> Result<TitleParts> {
3434
let mut processed_title: String = raw_title.to_string();
3535

36-
let label = Self::get_label_from_title(&raw_title)?;
36+
let label = Self::get_label_from_title(raw_title)?;
3737
if let Some(ref label) = label {
38-
processed_title = Self::remove_label_from_title(&processed_title, &label)?
38+
processed_title = Self::remove_label_from_title(&processed_title, label)?
3939
.trim()
4040
.to_string();
4141
}
4242

43-
let prefix = Self::get_prefix_from_title(&raw_title)?;
43+
let prefix = Self::get_prefix_from_title(raw_title)?;
4444
if let Some(ref prefix) = prefix {
4545
processed_title = processed_title.replace(prefix, "");
4646
}
4747

48-
let prefix = match prefix {
49-
Some(val) => Some(val.trim().to_string()),
50-
None => None,
51-
};
48+
let prefix = prefix.map(|val| val.trim().to_string());
5249

5350
if processed_title.starts_with("-") {
5451
processed_title = processed_title[1..].to_string();

0 commit comments

Comments
 (0)