diff --git a/changedetectionio/processors/restock_diff/__init__.py b/changedetectionio/processors/restock_diff/__init__.py index 0cad3db1..1aeca8af 100644 --- a/changedetectionio/processors/restock_diff/__init__.py +++ b/changedetectionio/processors/restock_diff/__init__.py @@ -45,13 +45,10 @@ class Restock(dict): def __setitem__(self, key, value): # Custom logic to handle setting price and original_price - if key == 'price': + if key == 'price' or key == 'original_price': if isinstance(value, str): value = self.parse_currency(raw_value=value) - if value and not self.get('original_price'): - self['original_price'] = value - super().__setitem__(key, value) class Watch(BaseWatch): diff --git a/changedetectionio/processors/restock_diff/processor.py b/changedetectionio/processors/restock_diff/processor.py index e3ee6247..790241e5 100644 --- a/changedetectionio/processors/restock_diff/processor.py +++ b/changedetectionio/processors/restock_diff/processor.py @@ -177,6 +177,11 @@ class perform_site_check(difference_detection_processor): # Main detection method fetched_md5 = None + # store original price if not set + if itemprop_availability and itemprop_availability.get('price') and not itemprop_availability.get('original_price'): + itemprop_availability['original_price'] = itemprop_availability.get('price') + update_obj['restock']["original_price"] = itemprop_availability.get('price') + if not self.fetcher.instock_data and not itemprop_availability.get('availability'): raise ProcessorException( message=f"Unable to extract restock data for this page unfortunately. (Got code {self.fetcher.get_last_status_code()} from server), no embedded stock information was found and nothing interesting in the text, try using this watch with Chrome.",