Module:IMDb

local IMDbLink = {} local HF = require('Module:HF') local getArgs = require('Module:Arguments').getArgs local function makeInvokeFunc(funcName) return function (frame) local args = getArgs(frame) return IMDbLink[funcName](args) end end

IMDbLink.name = makeInvokeFunc('_imdb_name') IMDbLink.title = makeInvokeFunc('_imdb_title') IMDbLink.character = makeInvokeFunc('_imdb_character')

function IMDbLink.IMDBname( field, vars ) if not HF.isempty( field.Value:find('%d') ) then return  .. field.Actor ..  else return '" .. field.Actor .. "" end end

function IMDbLink._imdb_name( args ) local target = args['id'] or args[1] or '' local name = args['name'] or args[2] or '' if not HF.isempty( target ) then return  .. name ..  else return '" .. name .. "" end end

function IMDbLink._imdb_title( args ) local target = args['id'] or args[1] or '' local title = args['title'] or args[2] or '' local description = args['description'] or args[3] or '' if not HF.isempty( target ) then if not HF.isempty( description ) then description = ' ' .. description end return  .. title .. description ..  else if not HF.isempty( description ) then description = ' ' .. description end return '" .. title .. "" .. description .. '' end end

function IMDbLink._imdb_character( args ) local target = args['id'] or args[1] or '' local character = args['character'] or args[2] or '' local description = args['description'] or args[3] or '' if not HF.isempty( target ) then return  .. character .. ' ' .. description ..  else return '" .. character .. " on IMDb" end end

return IMDbLink