Module:Sandbox/Alex.osheter/listtest explained
local p =
function parseDate(totalSeconds) local seconds = math.fmod(tonumber(totalSeconds),60) local minutes = math.floor(tonumber(totalSeconds) / 60) local hours = math.floor(minutes / 60) if hours
0 then return string.format("%d:%02d", minutes, seconds) else return string.format("%d:%02d:%02d", hours, minutes, seconds) endend
function p.parseNames(frame) local wikiEntity = mw.wikibase.getEntity if frame.args[1]
"" then if (wikiEntity:getAllStatements('tracklist')
nil) then return end else wikiEntity = mw.wikibase.getEntity(frame.args[1]) end local funcArgs = for index, table in pairs(wikiEntity:getAllStatements('tracklist')) do local trackEntity = mw.wikibase.getEntity(table["mainsnak"]["datavalue"]["value"]["id"]) if trackEntity:getSitelink
nil then funcArgs["title" .. index] = trackEntity:getLabel else funcArgs["title" .. index] = frame:preprocess("" .. trackEntity:getLabel .. "") end if table["qualifiers"] ~= nil then if table["qualifiers"]["P2047"] ~= nil then local timeInSeconds = table["qualifiers"]["P2047"][1]["datavalue"]["value"]["amount"] funcArgs["length" .. index] = parseDate(timeInSeconds) end end end if wikiEntity:getAllStatements('duration') ~= nil then local totalTime = tonumber(wikiEntity:getAllStatements('duration')[1]["mainsnak"]["datavalue"]["value"]["amount"]) funcArgs["total_length"] = parseDate(totalTime) end return frame:expandTemplate end
return p