Permalink
Browse files

Lots of updates

  • Loading branch information...
1 parent a203f36 commit 8e296af02ea97069f4ee0ec31f5bee43a8769cb7 @palfrey committed Dec 20, 2011
Showing with 42 additions and 848 deletions.
  1. +3 −0 .gitmodules
  2. +1 −0 amazon-product
  3. +18 −8 amazon.py
  4. +1 −0 amazonproduct
  5. +0 −830 amazonproduct.py
  6. +19 −10 missing_albums.py
View
@@ -0,0 +1,3 @@
+[submodule "amazon-product"]
+ path = amazon-product
+ url = git://github.com/redtoad/python-amazon-product-api.git
Submodule amazon-product added at bd65b8
View
@@ -1,21 +1,31 @@
import amazonproduct
from lxml import etree
-# AWS, then SECRET
+# AWS, then SECRET, then associate id
keys = [x.strip() for x in file(".amazonkey").readlines()]
amazon = amazonproduct.API(keys[0], keys[1], "uk")
def searchByTitle(artist, album):
ret = {}
- data = amazon.item_search("Music", Artist=artist, Title=album, ResponseGroup="Small,ItemAttributes,Images,OfferSummary")
+ try:
+ root = amazon.item_search("Music", Artist=artist, Title=album, ResponseGroup="Small,ItemAttributes,Images,Offers", AssociateTag = keys[2], MerchantId = "Amazon", Condition = "New")
+ except amazonproduct.errors.NoExactMatchesFound:
+ ret["title"] = album
+ ret["url"] = None
+ ret["image"] = None
+ ret["amazon_new"] = None
+ return ret
- binding = data.Items.Item.ItemAttributes.Binding
+ page = root.page(1)
+
+ binding = page.Items.Item.ItemAttributes.Binding
if binding!="Audio CD":
- file("dump","wb").write(etree.tostring(data, pretty_print=True))
+ file("dump","wb").write(etree.tostring(page, pretty_print=True))
raise Exception, binding
- ret["title"] = data.Items.Item.ItemAttributes.Title
- ret["url"] = data.Items.Item.DetailPageURL
- ret["image"] = data.Items.Item.LargeImage.URL
- ret["lowest_new"] = int(data.Items.Item.OfferSummary.LowestNewPrice.Amount)
+ ret["title"] = page.Items.Item.ItemAttributes.Title
+ ret["url"] = page.Items.Item.DetailPageURL
+ ret["image"] = page.Items.Item.LargeImage.URL
+ #ret["lowest_new"] = int(page.Items.Item.OfferSummary.LowestNewPrice.Amount)
+ ret["amazon_new"] = int(page.Items.Item.Offers.Offer.OfferListing.Price.Amount)
return ret
View
Oops, something went wrong.

0 comments on commit 8e296af

Please sign in to comment.