yasserqureshi1 / Sneaker-Monitors

A collection of web monitors that notify of restocks or updates on sneaker related sites through Discord Webhook. This includes Shopify, Nike SNKRS (supports 42 countries), Supreme and now Footsite monitors!
GNU General Public License v3.0
462 stars 126 forks source link

Shopify monitor - small issue after refactor with KEYWORDS setting in config.py #146

Closed DaILLOut closed 1 year ago

DaILLOut commented 1 year ago

Firstly, thank you for your excellent work on these. I have been using an older version of the Shopify ones for a long time, and was super stoked to see them get refactored recently. They seem to be much lighter load on the CPU so far. Really appreciate your work on these.

I have about 10 copies of these running as services on an Ubuntu Server under python3. Tonight I went to try and refresh them to use the refactored version, and using a products.json URL to one of my own Shopify sites, adding and removing a product to the /collections/all/products.json did not appear to create a discord notification. I am using the same webhook URL that worked with the previous version. I am not seeing anything in the logs either that lists a new product being found, though I can see the change in the products.json when loading the URL in a browser.

In the middle of typing this, I decided to put my very amateur Python knowledge to the test by doing some very ugly "print() statements everywhere" debugging.

I found the culprit - it looks like the default setting of:

KEYWORDS = []

in config.py is forcing the "else" section on line 193 of monitor.py:

`else:

For each keyword, checks whether particular item status has changed

                for key in KEYWORDS:
                    if key.lower() in product['title'].lower():
                        comparitor(product, start)`

If I set config.py to...

KEYWORDS = None

... the new item is detected successfully and the discord webhook request is sent properly. Looking online, it looks like the logic in Python is that even if a list is defined and empty, that doesn't meet the "None" qualification. It would have to be set to None in the config. Should be an easy fix, hope this helps. Wanted to at least post it in case others were having the same issue since it isn't mentioned in the comments.

Sorry for the long winded post, thank you again sincerely for all your work on these! They have been super useful.

yasserqureshi1 commented 1 year ago

Many thanks for sharing this - it made it really easy for me to fix. I found that this same issue is rife within all the other monitors too and may be the cause of some issues! I've recently updated the monitors to fix this