ba0gu0 / AllLive

一个聚合了常见直播平台视频的App.
29 stars 2 forks source link

一点点小问题 #4

Open godrolus opened 2 months ago

godrolus commented 2 months ago

下个版本除了会加入的搜索功能,希望能加入直播服务器的切换,justlive开源了可以参考借鉴下

ba0gu0 commented 2 months ago

下个版本除了会加入的搜索功能,希望能加入直播服务器的切换,justlive开源了可以参考借鉴下

直播服务器的切换和平台底层没关系,只需要自行搜集各种api接口,在设置中修改代码,返回不同数据就可以。

修改代码,比如返回 multName = 平台A-高清,liveUrl = https://...

liveData.push({
    multName: result.sDisplayName,
    liveUrl: liveUrl
})
module.exports = (data, headers) => {
    const re = new RegExp('(var hyPlayerConfig = \{.*?\};)', "sg")
    const regexResult = re.exec(data)[1]
    eval(regexResult)
    let liveName
    let liveNick
    let liveAvatar
    let liveScreenshot
    const liveData = []
    if (hyPlayerConfig) {
        liveName = hyPlayerConfig.stream.data[0].gameLiveInfo.introduction
        liveNick = hyPlayerConfig.stream.data[0].gameLiveInfo.nick
        liveAvatar = hyPlayerConfig.stream.data[0].gameLiveInfo.avatar180
        liveScreenshot = hyPlayerConfig.stream.data[0].gameLiveInfo.screenshot
        const roomNum = hyPlayerConfig.stream.data[0].gameLiveInfo.profileRoom
        const liveUrl = `https://www.goodiptv.club/huya/${roomNum}?stream=flv`
        hyPlayerConfig.stream.vMultiStreamInfo.forEach((result) => {
            liveData.push({
                multName: result.sDisplayName,
                liveUrl: liveUrl
            })
        })
    }
    return {
        liveName: liveName,
        liveNick: liveNick,
        liveAvatar: liveAvatar,
        liveScreenshot: liveScreenshot,
        liveData: liveData,
        liveType: 'http-flv',
        danMaKu: []
    }
}