diff --git a/changedetectionio/processors/restock_diff/processor.py b/changedetectionio/processors/restock_diff/processor.py index 4defd433..42dd9bd4 100644 --- a/changedetectionio/processors/restock_diff/processor.py +++ b/changedetectionio/processors/restock_diff/processor.py @@ -53,15 +53,19 @@ def get_itemprop_availability(html_content) -> Restock: value = Restock() if data: logger.debug(f"Using jsonpath to find price/availability/etc") - price_parse = parse('$..(price|Price|highPrice)') + price_parse = parse('$..(price|Price)') pricecurrency_parse = parse('$..(pricecurrency|currency|priceCurrency )') availability_parse = parse('$..(availability|Availability)') price_result = price_parse.find(data) if price_result: - if len(price_result) > 1 and len(set(str(item.value).replace('$', '') for item in price_result)) > 1: + # Right now, we just support single product items, maybe we will store the whole actual metadata seperately in teh future and + # parse that for the UI? + prices_found = set(str(item.value).replace('$', '') for item in price_result) + if len(price_result) > 1 and len(prices_found) > 1: # See of all prices are different, in the case that one product has many embedded data types with the same price # One might have $121.95 and another 121.95 etc + logger.warning(f"More than one price found {prices_found}, throwing exception, cant use this plugin.") raise MoreThanOnePriceFound() value['price'] = price_result[0].value diff --git a/changedetectionio/tests/test_automatic_follow_ldjson_price.py b/changedetectionio/tests/test_automatic_follow_ldjson_price.py index 8c1ff68f..686584d4 100644 --- a/changedetectionio/tests/test_automatic_follow_ldjson_price.py +++ b/changedetectionio/tests/test_automatic_follow_ldjson_price.py @@ -100,12 +100,8 @@ def test_check_ldjson_price_autodetect(client, live_server, measure_memory_usage # Accept it uuid = extract_UUID_from_client(client) - time.sleep(1) + #time.sleep(1) client.get(url_for('price_data_follower.accept', uuid=uuid, follow_redirects=True)) - wait_for_all_checks(client) - - # Trigger a check - time.sleep(1) client.get(url_for("form_watch_checknow"), follow_redirects=True) wait_for_all_checks(client) # Offer should be gone @@ -120,8 +116,8 @@ def test_check_ldjson_price_autodetect(client, live_server, measure_memory_usage headers={'x-api-key': api_key}, ) - # Should see this (dont know where the whitespace came from) - assert b'"highPrice": 8099900' in res.data + assert b'8097000' in res.data + # And not this cause its not the ld-json assert b"So let's see what happens" not in res.data