模块:SongPlayer:修订间差异
来自Rizline中文维基
更多操作
小 |
|||
| 第1行: | 第1行: | ||
local p = {} | local p = {} | ||
local getArgs = require('Module:Arguments').getArgs | |||
function p.player(frame) | function p.player(frame) | ||
local args = frame | local args = getArgs(frame) | ||
local title = args.title | local title = args.title | ||
local artist = args.artist | local artist = args.artist | ||
| 第12行: | 第14行: | ||
local c4 = args.color4 or '#D5F3FE' | local c4 = args.color4 or '#D5F3FE' | ||
if not title | if not title or not imageName then | ||
return '' | return '' | ||
end | end | ||
| 第18行: | 第20行: | ||
local sanitizedTitle = title:gsub(' ', '_'):gsub('[\\/:*?"<>|]', '-') | local sanitizedTitle = title:gsub(' ', '_'):gsub('[\\/:*?"<>|]', '-') | ||
local encodedTitle = mw.uri.encode(sanitizedTitle, 'PATH') | local encodedTitle = mw.uri.encode(sanitizedTitle, 'PATH') | ||
local songUrl = 'https://pan.rizwiki.cn/d/song/' .. encodedTitle .. '.mp3' | |||
local rawImagePath = frame:preprocess('{{filepath:' .. imageName .. '}}') | local rawImagePath = frame:preprocess('{{filepath:' .. imageName .. '}}') | ||
local imagePath = rawImagePath:gsub('^https?:', '') | local imagePath = rawImagePath:gsub('^https?:', '') | ||
local html = mw.html.create('div') | local html = mw.html.create('div') | ||
:attr('id', 'riz-player') | :attr('id', 'riz-player') | ||
| 第41行: | 第41行: | ||
local info = html:tag('div'):addClass('rp-info') | local info = html:tag('div'):addClass('rp-info') | ||
info:tag('div'):addClass('rp-title'):wikitext(title) | info:tag('div'):addClass('rp-title'):wikitext(title) | ||
info:tag('div'):addClass('rp-artist'):wikitext(artist or '') | info:tag('div'):addClass('rp-artist'):wikitext(artist or '') | ||