打开/关闭菜单
打开/关闭外观设置菜单
打开/关闭个人菜单
未登录
未登录用户的IP地址会在进行任意编辑后公开展示。

模块:SongPlayer:修订间差异

来自Rizline中文维基
卡介菌
卡介菌留言 | 贡献 (ai大人救救我)
第17行: 第17行:
     local encodedTitle = mw.uri.encode(sanitizedTitle, 'PATH')
     local encodedTitle = mw.uri.encode(sanitizedTitle, 'PATH')
     local imagePath = frame:preprocess('{{filepath:' .. imageName .. '}}')
     local imagePath = frame:preprocess('{{filepath:' .. imageName .. '}}')
     local songUrl = 'http://pan.rizwiki.cn/d/song/' .. encodedTitle .. '.mp3'
     local songUrl = 'https://pan.rizwiki.cn/d/song/' .. encodedTitle .. '.mp3'


     local data_div = mw.html.create('div')
     local data_div = mw.html.create('div')

2025年11月29日 (六) 19:54的版本

此模块的文档可以在模块:SongPlayer/doc创建

local p = {}

function p.player(frame)
    local args = frame:getParent().args
    local title = args.title
    local artist = args.artist
    local imageName = args.image

    if not title or title == '' or not imageName or imageName == '' then
        return ''
    end

    local sanitizedTitle = title
    sanitizedTitle = sanitizedTitle:gsub(' ', '_')
    sanitizedTitle = sanitizedTitle:gsub('[\\/:*?"<>|]', '-')

    local encodedTitle = mw.uri.encode(sanitizedTitle, 'PATH')
    local imagePath = frame:preprocess('{{filepath:' .. imageName .. '}}')
    local songUrl = 'https://pan.rizwiki.cn/d/song/' .. encodedTitle .. '.mp3'

    local data_div = mw.html.create('div')
        :attr('id', 'song-player-data')
        :attr('style', 'display:none;')
        :attr('data-name', title)
        :attr('data-artist', artist or 'Unknown Artist')
        :attr('data-url', songUrl)
        :attr('data-cover', imagePath)
        :done()

    local html = {
        '<div id="song-player-fixed"></div>',
        tostring(data_div)
    }

    return table.concat(html, '\n')
end

return p