Skip to content

Commit

Permalink
Merge d44f0c8 into 63ffb60
Browse files Browse the repository at this point in the history
  • Loading branch information
tdtds committed Nov 30, 2019
2 parents 63ffb60 + d44f0c8 commit b680b50
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions misc/plugin/amazon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ def amazon_author(item)
end
end

def amazon_title(json)
json["ItemInfo"]["Title"]["DisplayValue"]
def amazon_title(item)
item["ItemInfo"]["Title"]["DisplayValue"]
end

def amazon_image(item)
Expand Down Expand Up @@ -149,7 +149,7 @@ def amazon_get(asin, with_image = true, label = nil, pos = 'amazon')
cache = "#{@cache_path}/amazon"
Dir::mkdir( cache ) unless File::directory?( cache )
begin
json = JSON.parse(File::read("#{cache}/#{country}#{item_id}.json"))
json = File::read("#{cache}/#{country}#{item_id}.json")
rescue Errno::ENOENT
access_key = @conf['amazon.access_key']
secret_key = @conf['amazon.secret_key']
Expand All @@ -158,14 +158,13 @@ def amazon_get(asin, with_image = true, label = nil, pos = 'amazon')
json = paapi.get_items(item_id, country.to_sym)
File::open("#{cache}/#{country}#{item_id}.json", 'wb'){|f| f.write(json)}
end
item = json["ItemsResult"]["Items"][0]
item = JSON.parse(json)["ItemsResult"]["Items"][0]
if pos == 'detail' then
amazon_detail_html(item)
else
amazon_to_html(item, with_image, label, pos)
end
rescue Net::HTTPUnauthorized
p country, item_id
@logger.error "amazon.rb: Amazon API Unauthorized."
message = asin
if @mode == 'preview' then
Expand Down

0 comments on commit b680b50

Please sign in to comment.