Fixe Amazon-Plugin mit einigen URLs (warum hat Amazon so verdammt viele verschiedene Produkt-URLs?)

This commit is contained in:
Andreas Bielawski 2017-01-14 14:25:00 +01:00
parent 248ab78062
commit 6e211474c9

View File

@ -19,7 +19,12 @@ function cln_amzn:action(msg, config, matches)
local ok, response_code, response_headers = http.request(request_constructor)
local long_url = response_headers.location
local domain, product_id = long_url:match('amazon.(%w+)/gp/product/(.+)/(.+)')
if not long_url then return end
local domain, product_id = long_url:match('amazon.(%w+)/gp/product/(.+)/.+')
if not product_id then
domain, product_id = long_url:match('amazon.(%w+)/.+/dp/(.+)/')
end
if not product_id then return end
utilities.send_reply(msg, 'Ohne Ref: https://amazon.'..domain..'/dp/'..product_id)
return
end