コンテンツにスキップ

モジュール:81プロフィール

モジュールの解説[表示] [編集] [履歴] [キャッシュを破棄]

Template:81使

使[]

[]


{{#invoke:81|getid|}}

Template:81/81URL


local listpage = 'Template:81プロフィール/一覧'
local urlFormat = 'https://www.81produce.co.jp/actor_search/index.php/item?id=%s'
local yesno = require('モジュール:Yesno')

local function getId(title, frame)
	local count = 0
	local text = frame:expandTemplate{ title = listpage }
	for linktitle in text:gmatch('%[%[(.-)[%]|]') do
		count = count + 1
		if title == linktitle then
			return urlFormat:format(count), title
		end
	end
end

local function main(frame)
	local title = mw.text.trim(frame.args[1] or '')
	if title == '' then
		title = mw.title.getCurrentTitle().subpageText
	end
	
	local url = getId(title, frame)
	if not url then
		return ''	-- 'IDの取得に失敗'
	elseif yesno(frame.args.plainurl) then
		return url
	end
	
	local label = mw.text.trim(frame.args[2] or '')
	if label == '' then
		label = title
	end
	label = label:gsub('[ _]%(.-%)$', '')
	return string.format('[%s %s] - [[81プロデュース]]の公式サイト', url, label)
end
		
return { main = main }