local p = {}

function p.IMDb(frame)
    local tipo = frame.args['tipo']
    local id = frame.args['id']
    local pagina = mw.title.getCurrentTitle() --nome della pagina
    local result = '* (\'\'\'EN\'\'\') Scheda su \'\'[http://www.imdb.com/'
    if tipo == 'titolo' or tipo == 'film' then
        tipo = 'title/tt'
        wpIMDb = tt .. id -- codice IMDb presente su Wikipedia
    elseif tipo == 'compagnia' then
        tipo = 'company/co'
        wpIMDb = co .. id -- codice IMDb presente su Wikipedia
    elseif tipo == 'nome' then
        tipo = 'name/nm'
        wpIMDb = nm .. id -- codice IMDb presente su Wikipedia
    elseif tipo == 'personaggio' then
        tipo = 'character/ch'
        wpIMDb = ch .. id
    end
    
    local wdIMDb = frame:preprocess("{{#property:P345}}") -- codice IMDb presente su Wikidata
    if wdIMDB == '' then
        Categoria = '[[Categoria:Codice IMDB non presente in Wikidata]]'
    elseif wdIMDB ~= wpIMDb then
        Categoria = '[[Categoria:Codice IMDB in Wikidata differente]]'
    else
        Categoria = '[[Categoria:Codice IMDB uguale in Wikidata]]'
    end
    
    result = result .. tipo .. id
    result = result .. '/ ' 
    result = result .. pagina.text
    result = result .. ']\'\' dell\'\[\[Internet Movie Database\]\]'
    result = result .. Categoria
    return result
end

return p