未登录
登录
请求账号
BinWiki
搜索
查看“︁模块:Bilibili”︁的源代码
来自BinWiki
命名空间
模块
讨论
更多
更多
页面操作
阅读
查看源代码
历史
←
模块:Bilibili
因为以下原因,您没有权限编辑该页面:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
local p = {} local function validateBvid(bvid) return bvid and string.match(bvid, "^[Bb][Vv][0-9A-Za-z]+$") ~= nil end function p.getTitle(frame) local bvid = frame.args[1] if not validateBvid(bvid) then return "无效 BV 号" end local url = "https://api.bilibili.com/x/web-interface/view?bvid=" .. bvid local response = mw.ext.externalData.getWebData{ url = url, format = "json" } if not response or response.code ~= 0 or not response.data then return "获取信息失败" end return response.data.title or "无标题" end -- 新增:生成 Bilibili 播放器 HTML(安全嵌入) function p.getPlayer(frame) local bvid = frame.args[1] if not validateBvid(bvid) then return '<div class="error">错误:无效的 BV 号(示例:BV1GJ411x7h7)</div>' end -- 获取标题(复用你的 getTitle 方法) local title = p.getTitle(frame) -- 返回播放器 HTML return string.format([[ <div class="bilibili-player" style="max-width:600px; margin:1em auto; border-radius:4px; overflow:hidden; box-shadow:0 2px 5px rgba(0,0,0,0.1);"> <div style="background:#FB7299; color:white; padding:8px 12px; font-weight:bold;"> <a href="https://www.bilibili.com/video/%s" target="_blank" style="color:white; text-decoration:none;"> %s </a> </div> <div style="position:relative; padding-bottom:56.25%%; height:0; background:#000;"> <iframe src="https://player.bilibili.com/player.html?bvid=%s&high_quality=1&danmaku=0" style="position:absolute; top:0; left:0; width:100%%; height:100%%; border:none;" allowfullscreen scrolling="no" ></iframe> </div> </div> ]], bvid, title, bvid) end return p
该页面使用的模板:
模块:Bilibili/doc
(
查看源代码
)
返回
模块:Bilibili
。
导航
导航
首页
最近更改
随机页面
MediaWiki帮助
特殊页面
wiki工具
wiki工具
页面工具
页面工具
用户页面工具
更多
链入页面
相关更改
页面信息
页面日志