Module:Country anthem
ظٲہِریَتھ
"یَمہٕ ماڈیوٗلُک دَستاویز ییٚہِ Module:Country anthem/دَستاویز جاے بَناونہٕ"
local p = {}
function p.play(frame)
-- 1. Get the QID (from arguments or current page)
local qid = frame.args.qid
if not qid or qid == "" then
qid = mw.wikibase.getEntityIdForCurrentPage()
end
if not qid then return "" end
-- 2. Get ONLY the best-ranked statements for Anthem (P85)
-- "Best" means Preferred claims; if none, then Normal claims.
local statements = mw.wikibase.getBestStatements(qid, 'P85')
-- 3. strict "First Maxval" Logic:
-- We check ONLY the very first statement in the best-ranked list.
if not statements or #statements == 0 then return "" end
local claim = statements[1]
local filename = nil
-- Check 1: Does this specific statement have an Audio Qualifier (P51)?
if claim.qualifiers and claim.qualifiers['P51'] then
filename = claim.qualifiers['P51'][1].datavalue.value
end
-- Check 2: If no qualifier, follow the link to the Anthem Item (Fallback)
if not filename and claim.mainsnak.snaktype == "value" then
local anthemQid = claim.mainsnak.datavalue.value.id
-- Look for audio (P51) on the anthem item itself
local anthemAudio = mw.wikibase.getBestStatements(anthemQid, 'P51')
if anthemAudio and #anthemAudio > 0 then
if anthemAudio[1].mainsnak.snaktype == "value" then
filename = anthemAudio[1].mainsnak.datavalue.value
end
end
end
-- 4. Return the Player or Empty String
if filename then
return "[[File:" .. filename .. "|noicon]]"
else
return ""
end
end
return p