Skip to content

Commit 9c803b1

Browse files
committed
Update NewEgg endpoints and field names
1 parent c10aac1 commit 9c803b1

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

plugins/newegg.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
ITEM_URL = "https://www.newegg.com/Product/Product.aspx?Item={}"
2424

25-
API_PRODUCT = "https://www.ows.newegg.com/Products.egg/{}/ProductDetails"
25+
API_PRODUCT = "https://www.ows.newegg.com/Products.egg/{}"
2626
API_SEARCH = "https://www.ows.newegg.com/Search.egg/Advanced"
2727

2828
NEWEGG_RE = re.compile(r"(?:(?:www.newegg.com|newegg.com)/Product/Product\.aspx\?Item=)([-_a-zA-Z0-9]+)", re.I)
@@ -37,11 +37,11 @@ def format_item(item, show_url=True):
3737
# format the rating nicely if it exists
3838
if not item["ReviewSummary"]["TotalReviews"] == "[]":
3939
rating = "Rated {}/5 ({} ratings)".format(item["ReviewSummary"]["Rating"],
40-
item["ReviewSummary"]["TotalReviews"][1:-1])
40+
item["ReviewSummary"]["TotalReviews"])
4141
else:
4242
rating = "No Ratings"
4343

44-
if not item["FinalPrice"] == item["OriginalPrice"]:
44+
if item["OriginalPrice"] and item["FinalPrice"] != item["OriginalPrice"]:
4545
price = "{FinalPrice}, was {OriginalPrice}".format(**item)
4646
else:
4747
price = item["FinalPrice"]
@@ -53,7 +53,7 @@ def format_item(item, show_url=True):
5353
else:
5454
tags.append("\x02Out Of Stock\x02")
5555

56-
if item["FreeShippingFlag"]:
56+
if item["IsFreeShipping"]:
5757
tags.append("\x02Free Shipping\x02")
5858

5959
if item.get("IsPremierItem"):
@@ -62,9 +62,6 @@ def format_item(item, show_url=True):
6262
if item["IsFeaturedItem"]:
6363
tags.append("\x02Featured\x02")
6464

65-
if item["IsShellShockerItem"]:
66-
tags.append("\x02SHELL SHOCKER\u00AE\x02")
67-
6865
# join all the tags together in a comma separated string ("tag1, tag2, tag3")
6966
tag_text = ", ".join(tags)
7067

@@ -92,7 +89,7 @@ def newegg_url(match):
9289
}
9390

9491
item = requests.get(API_PRODUCT.format(item_id), headers=headers).json()
95-
return format_item(item, show_url=False)
92+
return format_item(item['Basic'], show_url=False)
9693

9794

9895
@hook.command()

0 commit comments

Comments
 (0)