Adapt to new version bahamut API.

This commit is contained in:
NobyDa 2023-02-27 08:38:38 +08:00
parent 503bf08e9d
commit 97504925bb
No known key found for this signature in database
GPG Key ID: E6B0AC788D373C5B
1 changed files with 11 additions and 5 deletions

View File

@ -19,11 +19,17 @@ runs().catch((err) => {
}));
async function runs() {
if (req.url.includes('token.php') && rsp.ad) {
rsp.ad.minor = [];
rsp.ad.major = [];
if (req.url.includes('token.php')) {
if (rsp.ad) {
rsp.ad.minor = [];
rsp.ad.major = [];
}
if (rsp.data && rsp.data.ad) {
rsp.data.ad.minor = [];
rsp.data.ad.major = [];
}
}
if (req.url.includes('m3u8.php') && rsp.message) {
if (req.url.includes('m3u8.php') && (rsp.message || rsp.error)) {
await adURL('');
await new Promise(r => setTimeout(r, 25000));
await adURL('end');
@ -34,7 +40,7 @@ async function runs() {
function adURL(str) {
return new Promise((res) => {
get({
url: `https://api.gamer.com.tw/mobile_app/anime/v1/stat_ad.php?ad=${str}&schedule=0&sn=${req.url.split(/sn=(\d+)/)[1]}`,
url: `https://api.gamer.com.tw/mobile_app/anime/v1/stat_ad.php?ad=${str}&schedule=0&sn=${req.url.split(/sn=(\d+)/i)[1]}`,
headers: req.headers
}, (err, resp, data) => res())
})