FANDOM


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 '[[imdb:nm' .. field.Value .. '|' .. field.Actor .. ']]'
	else
	return '[[imdb:' .. mw.uri.encode(field.Actor)  .. "|''" .. 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 '[[imdb:nm' .. target .. '|' .. name .. ']]'
	 else
	  return '[[imdb:' .. mw.uri.encode(name)  .. "|''" .. 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 '[[imdb:tt' .. target .. '|' .. title .. description .. ']]'
	 else
	  if not HF.isempty( description ) then description = ' ' .. description end
	  return '[[imdb:' .. mw.uri.encode(title)  .. "|''" .. 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 '[[imdb:ch' .. target .. '|' .. character .. ' ' .. description .. ']]'
	 else
	  return '[[imdb:' .. mw.uri.encode(character)  .. "|''" .. character .. "'' <sup>on IMDb</sup>]]"
	end
end
 
return IMDbLink

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.