Site Notice
hello, world
Difference between revisions of "Module:SongsInAnime"
From Project-EPB Commons
([InPageEdit] 没有编辑摘要) |
|||
Line 27: | Line 27: | ||
end | end | ||
-- 创建列表 | -- 创建列表 | ||
− | local text = '<ul class="songs-table songs-in-anime">' | + | local text = |
+ | '<i class="songs-table-description">动画《[[' .. episode .. ']]》使用了以下音乐:</i><ul class="songs-table songs-in-anime">' | ||
for k, v in pairs(songs) do | for k, v in pairs(songs) do | ||
local song = k | local song = k | ||
Line 58: | Line 59: | ||
for k, v in pairs(songsTable) do | for k, v in pairs(songsTable) do | ||
local thisEp = songsTable[k] | local thisEp = songsTable[k] | ||
− | |||
− | |||
− | |||
if util.hasKey(thisEp, song) then | if util.hasKey(thisEp, song) then | ||
table.insert(episodes, k) | table.insert(episodes, k) | ||
Line 66: | Line 64: | ||
end | end | ||
-- 没有剧集使用该音乐 | -- 没有剧集使用该音乐 | ||
− | |||
− | |||
if util.tableLength(episodes) < 1 then | if util.tableLength(episodes) < 1 then | ||
return '注意:没有动画剧集使用音乐[[' .. song .. ']]。' | return '注意:没有动画剧集使用音乐[[' .. song .. ']]。' | ||
end | end | ||
-- 创建列表 | -- 创建列表 | ||
− | local text = '<ul class="songs-table animes-have-song">' | + | local text = |
+ | '<i class="songs-table-description">音乐《[[' .. song .. ']]》出现在以下动画剧集中:</i><ul class="songs-table animes-have-song">' | ||
for k, v in ipairs(episodes) do | for k, v in ipairs(episodes) do | ||
local episode = episodes[k] | local episode = episodes[k] | ||
Line 79: | Line 76: | ||
text = | text = | ||
text .. | text .. | ||
− | '<li class="episode one-line"> | + | '<li class="episode one-line">[[' .. |
− | + | episode .. | |
− | '< | + | '|<b class="episode-name">' .. |
episode .. | episode .. | ||
− | ' | + | '</b>]]' .. |
− | + | ' ' .. | |
+ | '<span class="time-appear">' .. | ||
+ | time .. '</span> <i class="song-description">' .. description .. '</i></li>' | ||
end | end | ||
-- 结束,返回列表 | -- 结束,返回列表 |
Revision as of 02:04, 11 April 2020
-- Module Name: 动画音乐表
-- Author: 机智的小鱼君
-- Description:
--- 动画出现的全部音乐都可以使用这个模块查询,
--- 完善歌曲信息请前往子页面[[Module:SongsInAnime/table]]
local p = {}
local getArgs = require('Module:Arguments').getArgs
local util = require('Module:Util')
local songsTable = require('Module:SongsInAnime/table')
-- 某集动画中的全部歌曲
function p.anime(frame)
local args = getArgs(frame)
local episode = args['episode'] or args[1]
-- 参数错误
if episode == nil then
return '[[Module:Songs]]模块错误:未指定剧集。'
end
local songs = songsTable[episode]
-- 没有该集信息
if songs == nil then
return '注意:没有找到动画剧集[[' .. episode .. ']]!'
end
-- 没有音乐
if util.tableLength(songs) < 1 then
return '注意:动画[[' .. episode .. ']]中未找到相关音乐!'
end
-- 创建列表
local text =
'<i class="songs-table-description">动画《[[' .. episode .. ']]》使用了以下音乐:</i><ul class="songs-table songs-in-anime">'
for k, v in pairs(songs) do
local song = k
local time = songs[k]['time'] or '未知时间'
local description = songs[k]['description'] or ''
text =
text ..
'<li class="song one-line"><b class="time-appear">' ..
time ..
'</b> [[' ..
song ..
'|<span class="song-name">' ..
song .. '</span>]] <i class="song-description">' .. description .. '</i></li>'
end
-- 结束,返回列表
text = text .. '</ul>'
return text
end
-- 出现某歌曲的动画剧集
function p.song(frame)
local args = getArgs(frame)
local song = args['song'] or args[1]
-- 参数错误
if song == nil then
return '[[Module:Songs]]模块错误:未指定音乐名。'
end
-- 查询哪些剧集有该歌曲
local episodes = {}
for k, v in pairs(songsTable) do
local thisEp = songsTable[k]
if util.hasKey(thisEp, song) then
table.insert(episodes, k)
end
end
-- 没有剧集使用该音乐
if util.tableLength(episodes) < 1 then
return '注意:没有动画剧集使用音乐[[' .. song .. ']]。'
end
-- 创建列表
local text =
'<i class="songs-table-description">音乐《[[' .. song .. ']]》出现在以下动画剧集中:</i><ul class="songs-table animes-have-song">'
for k, v in ipairs(episodes) do
local episode = episodes[k]
local time = songsTable[episode][song]['time']
local description = songsTable[episode][song]['description']
text =
text ..
'<li class="episode one-line">[[' ..
episode ..
'|<b class="episode-name">' ..
episode ..
'</b>]]' ..
' ' ..
'<span class="time-appear">' ..
time .. '</span> <i class="song-description">' .. description .. '</i></li>'
end
-- 结束,返回列表
text = text .. '</ul>'
return text
end
function p.main()
return '[[Module:Songs]]模块说明:\n* 使用<code>anime</code>显示某集动画中的全部歌曲。\n* 使用<code>song</code>显示出现某歌曲的动画剧集。'
end
return p