Modulo:Controllo certificazioni: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
m typo
miglioro performance
 
(Una versione intermedia di uno stesso utente non è mostrata)
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
for s, csubcontent in string.gmatch(subcontent2content, '{{Album\n|(.-)([|{}]+)\r') do
local pattern = '{{ *[Aa]lbum(.-)|%s*numero dischi ' .. v .. '%s*=(.+)$'
for _, v in ipairs(awards) do
local subcontent1, subcontent2 = content:match(pattern)
local pattern = '{{ *[Aa]lbum^(.-)|%s*numero dischi ' .. v .. '%s*=(.+)$'
if subcontent2 then
local pre, post = ('|' .. subcontent):match(pattern)
-- evita falsi positivi col template Brano musicale
if subcontent2post then
if subcontent1:match('{{ *[Bb]rano musicale *|') then break end
-- evita falsi positivi col template Brano musicale
subcontent2 = subcontent2:sub(1, 2000)
if subcontent1pre:match('{{ *[Bb]rano musicale *|') then break end
local n = 0
subcontent2 post = subcontent2post:sub(1, 2000)
for s, c in string.gmatch(subcontent2, '(.-)([|{}]+)') do
local n = 0
if s:match('FIMI') then
for s, c in string.gmatch(post, '(.-)([|{}]+)') do
return cat
if s:match('FIMI') then
end
return cat
n = n + select(2, c:gsub('{{', ''))
end
n = n -+ select(2, c:gsub('}}{{', ''))
if n == 0n and- select(2, c:matchgsub('|$}}', '') or n < 0 then)
if n == 0 and c:match('|$') or n < 0 then
break
end
end
end