本网站正在建设中(~ ̄▽ ̄)~
- 你好~!欢迎来到中文歌声合成个人收集站-VCPedia.cn!
- 若发现页面信息有误或投稿至本站,请联系管理员。
Module:BilibiliVideoIDValidator
跳到导航
跳到搜索
- return {
- validation = function(frame)
- local flag = false
- local id = mw.text.trim(frame.args.id or "")
- local regex = "[A-HJ-NP-Za-km-z1-9]+$"
- -- 1. 有明确的 av 前缀且符合 aid 规则
- if mw.ustring.match(id, "^[Aa][Vv][1-9]%d*$") then
- flag = true
- -- 2. 有明确的 bv 前缀且符合 bvid 规则
- elseif string.len(id) == 12 and mw.ustring.match(id, "^[bB][vV]1" .. regex) then
- flag = true
- -- 3. 没有明确的前缀,但符合 aid 规则
- elseif mw.ustring.match(id, "^[1-9]%d*$") then
- flag = true
- -- 4. 没有明确的前缀,但符合 bvid 规则且不符合 aid 规则
- elseif string.len(id) == 10 and mw.ustring.match(id, "^1" .. regex)
- or string.len(id) == 9 and mw.ustring.match(id, "^" .. regex) then
- flag = true
- -- 5. 无法判断
- end
- if flag then
- return ""
- else
- return frame.args.result or frame:expandTemplate { title = "ArticleCategory", args = { "Bilibili视频ID错误", }, } ..
- '<strong class="error BilibiliVideoIDValidatorArgument" style="display:none">' ..
- frame.args.id .. "</strong>"
- end
- end,
- }
- -- 同步自MGP,来自萌娘百科用户鬼影233、AnnAngela、Dreammu的编辑