-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #192 from Xbai-hang/master
fix kuaishou、bilibili、kugou、huajiao & update yy & update README.md
- Loading branch information
Showing
10 changed files
with
295 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,52 @@ | ||
const axios = require("axios"); | ||
|
||
export function main(url: string) { | ||
return new Promise(function (resolve, reject) { | ||
const rid: any = url.match(/[0-9]+/g); | ||
const tt: any = Date.now(); | ||
axios | ||
.get( | ||
`https://h.huajiao.com/api/getFeedInfo?sid=${tt}&liveid=${rid}` | ||
) | ||
.then(function (response: any) { | ||
const jsons: any = response.data; | ||
if (jsons["data"]) { | ||
resolve(jsons["data"]["live"]["main"]); | ||
} else { | ||
return new Promise((resolve, reject) => { | ||
if (url.indexOf('user') != -1) { | ||
// 主页地址,可以多次获取直播流 | ||
const uid = url.match(/(?<=user\/)(\d+)/g)![0]; | ||
axios.get(`https://webh.huajiao.com/User/getUserFeeds?_callback=padding&uid=${uid}&fmt=jsonp&_=${Date.now()}`) | ||
.then((response: any) => { | ||
const data = response.data.replace('/**/padding(', '').replace(');','') | ||
const feedInfos = JSON.parse(data).data['feeds'] | ||
const feedInfo = feedInfos.find((feedInfo: any) => feedInfo.type === 1) | ||
if (!feedInfo || !feedInfo['relay']) { | ||
reject( | ||
"HUAJIAO=>No match results:Maybe the roomid is error,or this room is not open!" | ||
); | ||
} | ||
const streamUrl: string = `http://al2-flv.live.huajiao.com/${feedInfo['relay']['channel']}/${feedInfo['feed']['sn']}.flv` | ||
resolve(streamUrl) | ||
}) | ||
.catch(function (error: any) { | ||
.catch((error: any) => { | ||
reject(error); | ||
}); | ||
}) | ||
} else if (url.indexOf('l') != -1) { | ||
// 当次直播地址,只能获取该次直播的直播流 | ||
const rid = url.match(/(?<=l\/)(\d+)/g)![0]; | ||
axios.get(`https://www.huajiao.com/l/${rid}`) | ||
.then((response: any) => { | ||
const data: any = response.data; | ||
const feedInfo: any = JSON.parse(data.split('var feed = ')[1].split(';\n')[0]) | ||
const uid = feedInfo['author']['uid'] | ||
// 提醒用户更换主页链接 | ||
global.app.logger.warn(`HUAJIAO => roomUrl: ${url} 只能录制当次直播,请更换 roomUrl 为 https://www.huajiao.com/user/${uid}`) | ||
if (feedInfo && feedInfo['feed']['duration'] != '00:00:00') { | ||
reject( | ||
"HUAJIAO=>No match results:Maybe the roomid is error,or this room is not open!" | ||
); | ||
} | ||
const streamUrl: string = `http://al2-flv.live.huajiao.com/${feedInfo['relay']['channel']}/${feedInfo['feed']['sn']}.flv` | ||
resolve(streamUrl) | ||
}) | ||
.catch((error: any) => { | ||
global.app.logger.warn(`HUAJIAO => roomUrl: ${url} 只能录制当次直播,请更换 roomUrl 为 https://www.huajiao.com/user/xxxx`) | ||
reject(error); | ||
}); | ||
} else { | ||
reject( | ||
"HUAJIAO=>No match results:Maybe the roomid is error,or this room is not open!" | ||
); | ||
} | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.