Module:Sandbox/Jc86035/3 Explained

require('strict')

local infobox = require('Module:Infobox').infobox

local p =

local function getProperty(entity, property, value) if entity and entity.claims then local claims = entity.claims[property] if claims and claims[1] then if value

'string' then return claims[1].mainsnak.datavalue.value, claims[1].qualifiers end return claims[1].mainsnak.datavalue.value.id, claims[1].qualifiers end endend

local function getQualifier(qualifiers, property, value) local claims = qualifiers[property] if claims and claims[1] then if value

'string' then return claims[1].datavalue.value end return claims[1].datavalue.value.id endend

function p.test(frame) local args = frame.args local entity = mw.wikibase.getEntity(args.qid) local data = local recording if not data.data10 or not data.data21 then local artist, qualifiers = getProperty(entity, 'P175') if artist then data.data10 = data.data10 or mw.wikibase.getLabel(artist) end local subject_of = getQualifier(qualifiers, 'P805') if subject_of then recording = mw.wikibase.getEntity(subject_of) local isrc = getProperty(recording, 'P1243', 'string') data.data21 = data.data21 or isrc end end return infobox(data)end

return p