KikoPlayProject / KikoPlay

KikoPlay - NOT ONLY A Full-Featured Danmu Player 不仅仅是全功能弹幕播放器
https://kikoplay.fun
GNU General Public License v3.0
1.57k stars 96 forks source link

从BV号添加的Bilibili弹幕失效 #148

Closed Rrjgo closed 3 months ago

Rrjgo commented 3 months ago

问题描述

KikoPlay 版本1.0.1 Bilibili弹幕脚本版本 0.3

在使用从URL添加弹幕时,如果使用BV号添加会出现已添加0条URL的通知,并且也不会加载到已选弹幕中

个人解决方法

经测试旧的 0.2 版本的BV号URL添加没有问题 于是将新的 _urlinfo(url)_内 bv相关替换回旧版本的内容,可以正常使用

    elseif matched == "bv" then
        local _, _, bvid = string.find(url, "(BV[%dA-Za-z]+)")
        local query = { ["bvid"] = bvid }
        local header = { ["Accept"]="application/json" }
        local err, reply = kiko.httpget("http://api.bilibili.com/x/web-interface/view", query, header)
        if err ~= nil then error(err) end
        local content = reply["content"]
        local err, obj = kiko.json2table(content)
        if err ~= nil then error(err) end
        local obj = obj["data"]
        local aid = string.format("%d", obj["aid"])
        local results = {}
        for _, bobj in ipairs(obj["pages"]) do
            local data = {
                ["aid"] = aid,
                ["cid"] = string.format("%d", bobj["cid"]),
                ["bvid"] = bvid,
                ["stype"] = "video"
            }
            local _, data_str = kiko.table2json(data)
            table.insert(results, {
                ["title"] = bobj["part"],
                ["duration"] = bobj["duration"] or 0,
                ["data"] = data_str
            })
        end
        return results
    end
Protostars commented 3 months ago

脚本已更新