forked from doio/Surge-Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
surge bilibili autoarea.js
58 lines (43 loc) · 1.45 KB
/
surge bilibili autoarea.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
b站自动解除区域限制,需要自备台湾节点
[Rule]
SCRIPT,Bangumi,台湾 BGP 中继 1
[Script]
rule Bangumi script-path=https://raw.githubusercontent.com/onewayticket255/Surge-Script/master/surge%20bilibili%20autoarea.js,script-update-interval=-1
*/
let url = $request.url
let seasonurl = "api.bilibili.com/pgc/view/app/season"
let episodeurl = "api.bilibili.com/pgc/player/api/playurl"
if (url && (url.indexOf(seasonurl) != -1 || url.indexOf(episodeurl) != -1)) {
if (url.indexOf(seasonurl) != -1) {
let regex = /season_id=(.*?)&/
let season = regex.exec(url)
let sid = season[1]
let api = `https://bangumi.bilibili.com/anime/${sid}`
$httpClient.get(url, (error, response, data) => {
if (error) $done({ matched: false })
else {
console.log(response)
console.log(data)
if (data.match(`"code":-404`) || data.match("僅")) $done({ matched: true })
else $done({ matched: false })
}
})
}
if (url.indexOf(episodeurl) != -1) {
let regex = /ep_id=(.*?)&/
let episode = regex.exec(url)
let epid = episode[1]
let api = `https://www.bilibili.com/bangumi/play/ep${epid}`
$httpClient.get(url, (error, response, data) => {
if (error) $done({ matched: false })
else {
if (data.match(`"code":-10403`) || data.match("僅")) $done({ matched: true })
else $done({ matched: false })
}
})
}
}
else {
$done({ matched: false })
}