Modulo:Controllo certificazioni: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
espando
miglioro performance
 
(9 versioni intermedie di uno stesso utente non sono mostrate)
Riga 1:
local p = {}
 
local cat = '[[Categoria:Pubblicazioni antecedenti al 2009 con templatecertificazione FIMI da spostare]]'
 
function p.main(frame)
Riga 7:
if not year or year > 2008 then return end
local content = mw.title.getCurrentTitle():getContent()
content = content:gsub('{{ *[Aa]lbum[ \n]*|', '\r{{Album\n|') .. '\r'
local awards = { "d'oro", "di platino", "di diamante" }
-- non usare gsplit, è molto più lento di gmatch
for _, v in ipairs(awards) do
local for subcontent =in string.matchgmatch(content, '{{Album\n|%s*numero dischi ' .. v .. '%s*=(.+-)$\r') do
for _, v in ipairs(awards) do
if subcontent then
local pattern = '^(.-)|%s*numero dischi ' .. v .. '%s*=(.+)$'
local n = 0
local pre, post = ('|' .. subcontent):match(pattern)
for s, c in string.gmatch(subcontent, '(.*)([|{}]+)') do
if s ~= '' and s:match('FIMI')post then
-- evita falsi positivi col template Brano musicale
return cat
if pre:match('{{ *[Bb]rano musicale *|') then break end
end
post = post:sub(1, 2000)
if n == 0 and c == '|' or c == '}}' then
returnlocal n = 0
elseiffor s, c ==in string.gmatch(post, '(.-)([|{{}]+)') thendo
nif =s:match('FIMI') n + 1then
return cat
elseif c == '}}' then
n = n - 1end
n = n + select(2, c:gsub('{{', ''))
n = n - select(2, c:gsub('}}', ''))
if n == 0 and c == :match('|$') or cn ==< '}}'0 then
break
end
end
end