|
|
@ -1,8 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
import hashlib
|
|
|
|
|
|
|
|
import urllib3
|
|
|
|
|
|
|
|
from . import difference_detection_processor
|
|
|
|
from . import difference_detection_processor
|
|
|
|
from copy import deepcopy
|
|
|
|
from copy import deepcopy
|
|
|
|
|
|
|
|
from loguru import logger
|
|
|
|
|
|
|
|
import hashlib
|
|
|
|
|
|
|
|
import urllib3
|
|
|
|
|
|
|
|
|
|
|
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
|
|
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
|
|
|
|
|
|
|
|
|
|
|
@ -43,11 +44,13 @@ class perform_site_check(difference_detection_processor):
|
|
|
|
fetched_md5 = hashlib.md5(self.fetcher.instock_data.encode('utf-8')).hexdigest()
|
|
|
|
fetched_md5 = hashlib.md5(self.fetcher.instock_data.encode('utf-8')).hexdigest()
|
|
|
|
# 'Possibly in stock' comes from stock-not-in-stock.js when no string found above the fold.
|
|
|
|
# 'Possibly in stock' comes from stock-not-in-stock.js when no string found above the fold.
|
|
|
|
update_obj["in_stock"] = True if self.fetcher.instock_data == 'Possibly in stock' else False
|
|
|
|
update_obj["in_stock"] = True if self.fetcher.instock_data == 'Possibly in stock' else False
|
|
|
|
|
|
|
|
logger.debug(f"Watch UUID {uuid} restock check returned '{self.fetcher.instock_data}' from JS scraper.")
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
raise UnableToExtractRestockData(status_code=self.fetcher.status_code)
|
|
|
|
raise UnableToExtractRestockData(status_code=self.fetcher.status_code)
|
|
|
|
|
|
|
|
|
|
|
|
# The main thing that all this at the moment comes down to :)
|
|
|
|
# The main thing that all this at the moment comes down to :)
|
|
|
|
changed_detected = False
|
|
|
|
changed_detected = False
|
|
|
|
|
|
|
|
logger.debug(f"Watch UUID {uuid} restock check - Previous MD5: {watch.get('previous_md5')}, Fetched MD5 {fetched_md5}")
|
|
|
|
|
|
|
|
|
|
|
|
if watch.get('previous_md5') and watch.get('previous_md5') != fetched_md5:
|
|
|
|
if watch.get('previous_md5') and watch.get('previous_md5') != fetched_md5:
|
|
|
|
# Yes if we only care about it going to instock, AND we are in stock
|
|
|
|
# Yes if we only care about it going to instock, AND we are in stock
|
|
|
@ -60,5 +63,4 @@ class perform_site_check(difference_detection_processor):
|
|
|
|
|
|
|
|
|
|
|
|
# Always record the new checksum
|
|
|
|
# Always record the new checksum
|
|
|
|
update_obj["previous_md5"] = fetched_md5
|
|
|
|
update_obj["previous_md5"] = fetched_md5
|
|
|
|
|
|
|
|
|
|
|
|
return changed_detected, update_obj, self.fetcher.instock_data.encode('utf-8').strip()
|
|
|
|
return changed_detected, update_obj, self.fetcher.instock_data.encode('utf-8').strip()
|
|
|
|