Module:Sandbox/Jc86035/3

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
	end
end

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
	end
end

function p.test(frame)
	local args = frame.args
	local entity = mw.wikibase.getEntity(args.qid)
	local data = {
		title = 'Title',
		aboveclass = 'summary',
		
		label3 = 'Language', data3 = args.language,
		
		label10 = 'Artist', data10 = args.artist,
		
		label20 = 'ISWC', data20 = (args.ISWC or args.iswc or getProperty(entity, 'P1827', 'string')),
		
		label21 = 'ISRC', data21 = (args.ISRC or args.isrc),
	}
	
	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

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.