local p={}
local getArgs
local mathModule=require('Module:Math')
local imageSwitch={
['VOCALOID']=function(args)
local nrank=args['nrank']
local brank=args['brank']
local yrank=args['yrank']
return mathModule._max(nrank,brank,yrank) ==1 and '初音 殿堂曲题头.jpg' or '29392987.jpg'
end
,['VOCALOID中文']=function(args)
local nrank=args['nrank']
local brank=args['brank']
local yrank=args['yrank']
local rankmax=mathModule._max(nrank,brank,yrank)
if rankmax==1 then return 'VOCALOID中文殿堂曲题头.jpg'
elseif rankmax==2 then return 'Vocaloid中文传说曲成就标题图(3-2)修正.png'
elseif rankmax==3 then return 'Vocaloid中文神话曲成就标题图(3-2)修正.png'
else return 'VOCALOID中文殿堂曲题头.jpg'
end
end
,['UTAU']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or '3818258 Kasane Teto.jpg' end
,['CeVIO']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or 'CeVIO.jpg' end
,['VOICEROID']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or '琴葉.png' end
,['Sharpkey']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or '幻晓伊立绘.jpg' end
,['MUTA']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or 'Yx04.png' end
,['Synthesizer V']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or '爱莲娜芙缇info.jpeg' end
,['DeepVocal']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or '起氏双子.png' end
,['X Studio']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or '微软小冰201809051054.jpg' end
,['ACE']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or 'ACE虚拟歌姬.png' end
,['NEUTRINO']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or 'Kiritan_1.png' end
,['袅袅虚拟歌手']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or '余袅袅1.jpg' end
,['初音未来 NT']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or 'MikuNewType_main.png' end
,['Alter/Ego']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or 'Alter_Ego_logo.jpeg' end
,['MAIDLOID']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or '阿久女Iku_1.png' end
,['VOICEVOX']=function(args) return args[2] and '初音 殿堂曲题头.jpg' or 'Chara_zunmon_2.png' end
,['#default']=function(args) return '初音 殿堂曲题头.jpg' end
}
local colorSwitch={
['VOCALOID']=function(args) return '#009999' end
,['VOCALOID中文']=function(args)
local nrank=args['nrank']
local brank=args['brank']
local yrank=args['yrank']
local rankmax=mathModule._max(nrank,brank,yrank)
if rankmax==1 then return '#66ccff'
elseif rankmax==2 then return '#1f75ed'
elseif rankmax==3 then return '#0A68A0'
else return '#66ccff'
end
end
,['UTAU']=function(args) return args[2] and '#009999' or '#d93a49' end
,['CeVIO']=function(args) return args[2] and '#009999' or '#f5eeAf' end
,['VOICEROID']=function(args) return args[2] and '#009999' or '#E1F0F7' end
,['Sharpkey']=function(args) return args[2] and '#009999' or '#FF7799' end
,['MUTA']=function(args) return args[2] and '#009999' or '#FF6600' end
,['Synthesizer V']=function(args) return args[2] and '#009999' or '#ecebf0' end
,['DeepVocal']=function(args) return args[2] and '#009999' or '#31a7ff' end
,['X Studio']=function(args) return args[2] and '#009999' or '#E480A8' end
,['ACE']=function(args) return args[2] and '#009999' or '#9699D6' end
,['NEUTRINO']=function(args) return args[2] and '#009999' or '#24222A' end
,['袅袅虚拟歌手']=function(args) return args[2] and '#009999' or '#9D333D' end
,['初音未来 NT']=function(args) return args[2] and '#009999' or '#39C5BB' end
,['Alter/Ego']=function(args) return args[2] and '#009999' or '#222222' end
,['MAIDLOID']=function(args) return args[2] and '#009999' or '#488846' end
,['VOICEVOX']=function(args) return args[2] and '#009999' or '#24222A' end
,['#default']=function(args) return '#009999' end
}
function rankToRankName(rank)
rank=tonumber(rank)
if rank==1 then return '殿堂'
elseif rank==2 then return '传说'
elseif rank==3 then return '神话'
else return '' end
end
function expandAC(cate_name)
local frame=mw.getCurrentFrame()
return frame:preprocess('<includeonly>'..frame:expandTemplate{title = 'ac', args = {cate_name}}..'</includeonly>')
end
function text1Func(nrank,brank,yrank,arg_type)
local temp1
if yrank=='3' then
temp1='获得千万次播放!'
elseif yrank=='4' then
temp1='获得破亿次播放!'
else
local rankmax=mathModule._max(nrank,brank,yrank)
if rankmax==1 then temp1='殿堂'
elseif rankmax==2 then temp1='传说'
elseif rankmax==3 then temp1='神话!'
else temp1='殿堂'
end
temp1 = '进入'..temp1
end
return [[<BIG>'''本]]..arg_type..'已'..temp1..[['''</BIG><br />]]
end
function text2Func(args,numberKeys,prefix,word_yhd,word_tglist)
local rank=args[prefix..'rank']
local arg_type2 = args['type']
local arg_type= arg_type2 or '曲目'
if rank then
local text = '<br>本'..arg_type..word_yhd
if args[prefix..'view'] then text = text .. args[prefix..'view'] .. '万'
else
if rank == '1' then text = text .. '10万'
elseif rank=='2' then text = text .. '100万'
else text = text .. '1000万'
end
end
text = text .. '次播放,荣获'
if args[1] ~=nil and args[1]~=null then
local text2table = {}
for _,key in ipairs(numberKeys) do
local val_argKey = args[key]
local text2
local text3 = val_argKey .. rankToRankName(rank) .. '曲'
if arg_type2 ~='' and arg_type2 ~= nil then
text2 = val_argKey .. rankToRankName(rank) .. arg_type2
else
text2 = '[[' ..text3..word_tglist..'|'..text3.. ']]'
end
text2 = [[''']] ..text2.. [[''']] .. (expandAC(text3))
table.insert(text2table,text2)
end
text = text .. table.concat(text2table,'、')
else
text = text .. [[''']] ..rankToRankName(rank) .. (arg_type2 or '曲') .. [[''']]
end
text = text .. '称号。'
return text
end
return ''
end
function text3Func(args,numberKeys,prefix)
local rank=args[prefix..'rank']
local arg_type2 = args['type']
local arg_type= arg_type2 or '曲目'
if rank then
local text = '<br>本'..arg_type..'在YouTube已经拥有了超过'
if args[prefix..'view'] then text = text .. args[prefix..'view'] .. '万'
else
if rank == '1' then text = text .. '10万'
elseif rank=='2' then text = text .. '100万'
elseif rank=='3' then text = text .. '1000万'
else text = text .. '1亿'
end
end
text = text .. '次播放'
if arg_type2 =='' or arg_type2 ==nil then
local text2table = {}
for _,key in ipairs(numberKeys) do
local val_argKey = args[key]
local text2
if rank=='4' then
text2 = '[[YouTube上播放数量超过1亿的'..val_argKey..'歌曲|'..val_argKey..'相关列表]]'
text2 = [[''']] ..text2 ..[[''']]
else
local text3 = val_argKey .. rankToRankName(rank) .. '曲'
text2 = '[['..text3..'/YouTube投稿|'..val_argKey..'相关列表]]'
text2 = [[''']] ..text2 ..[[''']] .. (expandAC(text3))
end
table.insert(text2table,text2)
end
text = text ..',更多可参见'.. table.concat(text2table,'、')
end
text = text ..'。'
return text
end
return ''
end
function getArgsNumberKey(args)
local arrs={}
for key,_ in pairs(args) do
local num_key=tonumber(key)
if num_key ~= nil and args[key] then table.insert(arrs,num_key) end
end
return arrs
end
function p._main(args)
local arg1=args[1]
local arg2=args[2]
local nrank=args['nrank']
local brank=args['brank']
local yrank=args['yrank']
local image=args['image']
local color=args['color']
local link=args['link']
local arg_type=args['type'] or '曲目'
if image == nil then
local switchFunc= imageSwitch[arg1] ~=nil and imageSwitch[arg1] or imageSwitch['#default']
image = switchFunc(args)
end
if link == nil then
link =(arg2 and '虚拟歌手' or (arg1=='VOCALOID中文' and 'VOCALOID' or arg1))
end
if link == nil then link = '' end -- 无参数
image = '[[image:'..image..'|99px|link='..link..']]'
if color == nil then
local switchFunc= colorSwitch[arg1] ~=nil and colorSwitch[arg1] or colorSwitch['#default']
color = switchFunc(args)
end
local text = text1Func(nrank,brank,yrank,arg_type)
local numberKeys= getArgsNumberKey(args)
local currentTitle=mw.title.getCurrentTitle()
args['#inMainNS#'] = (currentTitle.namespace == 0)
text = text .. text2Func(args,numberKeys,'n','在niconico已经拥有了超过','/niconico投稿') --niconio
text = text .. text2Func(args,numberKeys,'b','在bilibili已经拥有了超过','/bilibili投稿') --bilibili
text = text .. text3Func(args,numberKeys,'y') --youtube
return mw.getCurrentFrame():expandTemplate{
title = 'info'
,args = {['leftimage']=image,['text']=text,['color']=color}
}
end
function p.main(frame)
if not getArgs then
getArgs = require('Module:Arguments').getArgs
end
args = getArgs(frame, {wrappers = {'Template:虚拟歌手歌曲荣誉题头','Template:虚拟歌手歌曲荣誉题头/sandbox'}})
return p._main(args)
end
return p