Module:Sandbox/Mant08/IMDb name

local p = {}
local getArgs = require('Module:Arguments').getArgs

function p.imdb_name(frame)
	local args = getArgs(frame)
	return p._imdb_name(args)
end

function p._imdb_name(args)
	local config = args
	
	local section = config["3"] or config[3] or config["section"] or nil
	local name = config["2"] or config [2] or config["name"] or mw.title.getCurrentTitle().text or "John Doe"
	local id = config["1"] or config[1] or config["id"] or nil

	local current_page_id = mw.wikibase.getEntityIdForCurrentPage()
	
	if (id == nil)
	then
		if (current_page_id ~= nil)
		then
			local p345_value_table = mw.wikibase.getBestStatements( current_page_id, 'P345' )
			if (p345_value_table ~= nil)
			then 
				if (p345_value_table[1] ~= nil)
			    then
				    id = p345_value_table[1].mainsnak.datavalue.value
			    end
			end
		end
	else
		if (tonumber(id) ~= nil)
		then
			id = "nm" .. id
		else
			id = id
		end
	    
	end
    
    local at_imdb_text = "at [[IMDb]]."
    
    if (id == nil)
    then
    	local encoded_name = mw.uri.encode(name)
    	return pronoun .. " " .. "[https://imdb.com/find/?q=" .. encoded_name .. "&s=nm" .. " " .. name .. "]" .. at_imdb_text
    else
    	local base_link_object = "[https://imdb.com/name/" .. id .. "/"
    	
    	if (section == nil)
    	then
    		return pronoun .. " " .. base_link_object .. " " .. name .. "]" .. at_imdb_text
    	elseif (section == "biography" or section == "bio")
    	then
    		return "The biography of " .. base_link_object .. "bio/ " .. name .. "]" .. at_imdb_text
    	elseif (section == "awards" or section == "award")
    	then
    		return "The awards of " .. base_link_object .. "awards/ " .. name .. "]" .. at_imdb_text
    	else
    		return '<span class="error">IMDb Name: Error: A non-valid "section" variable input was given.</span>'
    	end
    end
  
end

return p

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.