local playstation_store = {} playstation_store.triggers = { 'store.playstation.com/#!/([A-Za-z]+)%-([A-Za-z]+)/.*/cid=(.+)', 'store.playstation.com/([A-Za-z]+)%-([A-Za-z]+)/product/(.+)', 'store.sonyentertainmentnetwork.com/#!/([A-Za-z]+)%-([A-Za-z]+)/.*/cid=(.+)' } local makeOurDate = function(dateString) local pattern = "(%d+)%-(%d+)%-(%d+)" local year, month, day = dateString:match(pattern) return day..'.'..month..'.'..year end function playstation_store:get_info(country_code, game_id) local url = 'https://store.playstation.com/store/api/chihiro/00_09_000/container/'..country_code..'/999/'..game_id local res, code = https.request(url) if code ~= 200 then return nil end local data = json.decode(res) if not data then return nil end local title = ''..data.name..'' if data.provider_name then publish = ' von '..data.provider_name..'' else publish = '' end if data.playable_platform then system = ' für '..data.playable_platform[1]..'' else system = '' end if data.gameContentTypesList then types = ' ['..data.gameContentTypesList[1].name..']' else types = '' end if data.skus then if data.skus[1].rewards[1] then --[[ if data.skus[1].rewards[1].isPlus ~= true then psplus = '' else psplus = ' PS+ Exklusiv!' end ]] price = '\nPreis: '..data.skus[1].rewards[1].display_price..' statt '..data.default_sku.display_price..' (Spare '..data.skus[1].rewards[1].discount..'%)'--..psplus else price = '\nPreis: '..data.default_sku.display_price --..psplus end else price = '' end local fsk = '\nFreigegeben ab: '..data.age_limit local description = '\n\n'..string.sub(unescape(data.long_desc:gsub("%b<>", "")), 1, 300)..'...' local release = '\nRelease: '..makeOurDate(data.release_date) if data.images[4].type ~= 10 then image_url = ' ' else image_url = ' ' end local text = title..publish..system..types..image_url..price..fsk..release..description return text end function playstation_store:action(msg, config, matches) local country_code = string.upper(matches[2])..'/'..matches[1] local game_id = matches[3] local text = playstation_store:get_info(country_code, game_id) if not text then utilities.send_reply(msg, config.errors.results) return end utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html') end return playstation_store