-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Amazon Price Tracker Bridge #741
Conversation
afc9975
to
228c64d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very interesting bridge 👍
I've been using different services up till now, but this looks promising.
Please find below a few comments. I don't think the typo fix is a problem here.
Is there any reason to keep this separated from the existing Amazon bridge?
bridges/AmazonPriceTrackerBridge.php
Outdated
], | ||
'defaultValue' => 'com', | ||
], | ||
]]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use array()
instead of []
Your solution is neither wrong nor incorrect, just different than all other bridges.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just force of habit. Will change here, but thoughts about shifting to short array notation everywhere? It is far more readable (I did that in #719, but that wasn't well thought out).
The lowest we support is 5.6 (5.4 with the conversion script), short array is there since 5.4
bridges/AmazonPriceTrackerBridge.php
Outdated
|
||
public function getName(){ | ||
if(!is_null($this->getInput('tld')) && !is_null($this->getInput('q'))) { | ||
return 'Amazon.'.$this->getInput('tld').': '.$this->getInput('q'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be spaces around ' . ' like the rest
bridges/AmazonPriceTrackerBridge.php
Outdated
[ | ||
'asin' => [ | ||
'name' => 'ASIN', | ||
'required' => true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any chance catching invalid user input using pattern matching?
Maybe add an example value?
'exampleValue' => 'B071GB1VMQ'
bridges/AmazonPriceTrackerBridge.php
Outdated
or returnServerError('Could not request Amazon.'); | ||
|
||
// <img class="... frontImage" data-a-dynamic-image="{"<image_url>":[$width,$height]}"> | ||
$imageHtml = $html->find('.frontImage')[0]->getAttribute('data-a-dynamic-image'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why, but my HTML looks very different from what you expect. There is no .frontImage
in my source, so this line fails on me, using this query: ?action=display&bridge=AmazonPriceTracker&asin=B071GB1VMQ&tld=com&format=Html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Went through the html and found an interesting element that we can use:
<div id="cerberus-data-metrics" style="display: none;" data-asin="B00WTHJ5SU" data-asin-price="14.99" data-asin-shipping="0" data-asin-currency-code="USD" data-substitute-count="-1" ...>
bridges/AmazonPriceTrackerBridge.php
Outdated
'title' => $title, | ||
'uri' => $uri, | ||
'content' => "<img alt='$title' src='$imageSrc'/><br/>$price $currency", | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above, please opt for the long array notation
228c64d
to
f40ab0a
Compare
General comments:
They serve distinct purpose: First is to notify you about new products that match your search criteria. The second is to notify you about price changes in a specific product. I'd want to add features like: "Minimum price" or "minimum discount" to this bridge, but they don't make much sense in the other one.
Thanks! I was using external services for this as well, but they keep shutting down. The best alternative I found was https://github.com/GaryniL/Amazon-Price-Alert, but it requires too much setup and (most importantly) doesn't do RSS. I'm planning to add a "Amazon Wishlist" adapter in https://git.captnemo.in/nemo/opml-gen, so that I can generate a bunch of RSS feeds for my entire Wishlist and import it in my feed reader at once. |
b3848dc
to
1acaed2
Compare
1acaed2
to
24a07a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few function names that don't really make sense
bridges/AmazonPriceTrackerBridge.php
Outdated
/** | ||
* Generates domain name given a amazon TLD | ||
*/ | ||
private function makeDomainName() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be named getDomainName
bridges/AmazonPriceTrackerBridge.php
Outdated
/** | ||
* Generates URI for a Amazon product page | ||
*/ | ||
private function makeUri() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
bridges/AmazonPriceTrackerBridge.php
Outdated
* Scrapes the product title from the html page | ||
* returns the default title if scraping fails | ||
*/ | ||
private function extractTitle($html) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
ffc6304
to
1397166
Compare
1397166
to
0d5927a
Compare
Merged, thanks ! |
* [amazonprice] Adds AmazonPriceTracker bridge
I'm not entirely sure of how the caching works with RSS-Bridge. I've left the cache timeout to 1h, would it start showing up with duplicate feed entries for every 1hour? (I'm hoping not). Another possible issue might be the URL not changing (and feed readers not caring about the new content).
As a hack I was considering, appending the $item['url'] with a clear query param of price:
https://www.amazon.in/dp/B00WTHJ5SU/#price=$price
That way, it would definitely get picked up as a new feed item on any feed reader.