@@ -4,13 +4,12 @@ import { Converters, uposMap } from '../../util/converters';
4
4
import { _ } from '../../util/react'
5
5
import { Async , Promise } from '../../util/async' ;
6
6
import { r , _t } from '../../feature/r'
7
- import { util_error , util_info , util_log , util_warn , util_debug , logHub } from '../../util/log'
7
+ import { util_error , util_warn , log } from '../../util/log'
8
8
import { cookieStorage } from '../../util/cookie'
9
9
import { balh_config , isClosed } from '../../feature/config'
10
- import { Func } from '../../util/utils' ;
11
10
import { util_page } from '../../feature/page'
12
11
import { access_key_param_if_exist , platform_android_param_if_app_only } from '../../api/bilibili-utils'
13
- import { BiliPlusApi , generateMobiPlayUrlParams , getMobiPlayUrl , fixMobiPlayUrlJson , fixThailandPlayUrlJson } from '../../api/biliplus'
12
+ import { generateMobiPlayUrlParams , getMobiPlayUrl , fixMobiPlayUrlJson , fixThailandPlayUrlJson } from '../../api/biliplus'
14
13
import { ui } from '../../util/ui'
15
14
import { Strings } from '../../util/strings'
16
15
import { util_init } from '../../util/initiator'
@@ -43,23 +42,23 @@ export const area_limit_xhr = (() => {
43
42
/// {@endtemplate }
44
43
transformResponse : ( { url, response, xhr, container } ) => {
45
44
if ( url . match ( RegExps . url ( 'api.bilibili.com/pgc/view/web/season?' ) ) ) {
46
- log ( '/pgc/view/web/season:' , xhr . responseText )
47
45
let json = JSON . parse ( xhr . responseText )
48
46
if ( json . code === 0 && json . result ) {
49
47
// processSeasonInfo(json.result)
50
48
json . result . episodes . forEach ( removeEpAreaLimit )
51
- json . result . rights . area_limit = false
49
+ json . result . rights . area_limit = 0
50
+ json . result . rights . ban_area_show = 0
52
51
return json
53
52
}
54
53
} else if ( url . match ( RegExps . url ( 'bangumi.bilibili.com/view/web_api/season/user/status' ) )
55
54
|| url . match ( RegExps . url ( 'api.bilibili.com/pgc/view/web/season/user/status' ) ) ) {
56
- log ( '/season/user/status:' , xhr . responseText )
57
55
let json = JSON . parse ( xhr . responseText )
58
56
let rewriteResult = false
59
57
if ( json . code === 0 && json . result ) {
60
58
areaLimit ( json . result . area_limit !== 0 )
61
59
if ( json . result . area_limit !== 0 ) {
62
60
json . result . area_limit = 0 // 取消区域限制
61
+ json . result . ban_area_show = 0
63
62
rewriteResult = true
64
63
}
65
64
if ( balh_config . blocked_vip ) {
@@ -211,24 +210,26 @@ export const area_limit_xhr = (() => {
211
210
log ( '/x/player/playurl' , 'origin' , `block: ${ container . __block_response } ` , xhr . response )
212
211
// todo : 当前只实现了r.const.mode.REPLACE, 需要支持其他模式
213
212
// 2018-10-14: 等B站全面启用新版再说(;¬_¬)
214
- } else if ( url . match ( RegExps . url ( 'api.bilibili.com/pgc/player/web/playurl' ) )
213
+ } else if ( url . match ( RegExps . url ( 'api.bilibili.com/pgc/player/web/playurl' ) ) || url . match ( RegExps . url ( 'api.bilibili.com/pgc/player/web/v2/playurl' ) )
215
214
&& ! Strings . getSearchParam ( url , 'balh_ajax' ) ) {
216
- log ( '/pgc/player/web/playurl' , 'origin' , `block: ${ container . __block_response } ` , xhr . response )
217
- if ( ! container . __redirect ) { // 请求没有被重定向, 则需要检测结果是否有区域限制
218
- let json = typeof xhr . response === 'object' ? xhr . response : JSON . parse ( xhr . responseText )
215
+ const reqUrl = new URL ( url , document . location . href )
216
+ const isV1 = reqUrl . pathname === '/pgc/player/web/playurl'
217
+ let json = typeof xhr . response === 'object' ? xhr . response : JSON . parse ( xhr . responseText )
218
+ if ( ! container . __redirect || ( ! isV1 && isAreaLimitForPlayUrl ( json . result ) ) ) { // 请求没有被重定向, 则需要检测结果是否有区域限制
219
219
if ( balh_config . blocked_vip || json . code || isAreaLimitForPlayUrl ( json . result ) ) {
220
220
areaLimit ( true )
221
221
// 2022-09-17 ipcjs: 为什么这里用的是请求url, 而不是响应url?...
222
- let requestUrl = container . __url
222
+ let requestUrl = isV1 ? container . __url : `//api.bilibili.com/pgc/player/web/playurl ${ reqUrl . search } `
223
223
if ( isBangumiPage ( ) ) {
224
224
requestUrl += `&module=bangumi`
225
225
}
226
226
return bilibiliApis . _playurl . asyncAjax ( requestUrl )
227
227
. then ( data => {
228
228
if ( ! data . code ) {
229
- data = { code : 0 , result : data , message : "0" }
229
+ data = isV1
230
+ ? { code : 0 , result : data , message : "0" }
231
+ : { code : 0 , message : "success" , result : { video_info : data } }
230
232
}
231
- log ( '/pgc/player/web/playurl' , 'proxy' , data )
232
233
return data
233
234
} )
234
235
} else {
@@ -288,7 +289,6 @@ export const area_limit_xhr = (() => {
288
289
} else if ( url . match ( RegExps . url ( 'api.bilibili.com/pgc/player/web/playurl' ) )
289
290
&& ! Strings . getSearchParam ( url , 'balh_ajax' )
290
291
&& needRedirect ( ) ) {
291
- log ( '/pgc/player/web/playurl' )
292
292
// debugger
293
293
container . __redirect = true // 标记该请求被重定向
294
294
if ( isBangumiPage ( ) ) {
@@ -297,13 +297,8 @@ export const area_limit_xhr = (() => {
297
297
return bilibiliApis . _playurl . asyncAjax ( url )
298
298
. then ( data => {
299
299
if ( ! data . code ) {
300
- data = {
301
- code : 0 ,
302
- result : data ,
303
- message : "0" ,
304
- }
300
+ data = { code : 0 , result : data , message : "0" }
305
301
}
306
- log ( '/pgc/player/web/playurl' , 'proxy(redirect)' , data )
307
302
return data
308
303
} )
309
304
}
@@ -337,7 +332,6 @@ export const area_limit_xhr = (() => {
337
332
let oriResultTransformer
338
333
let oriResultTransformerWhenProxyError
339
334
let one_api ;
340
- // log(param)
341
335
if ( param . url . match ( RegExps . urlPath ( '/web_api/get_source' ) ) ) {
342
336
one_api = bilibiliApis . _get_source ;
343
337
oriResultTransformer = p => p
@@ -372,7 +366,6 @@ export const area_limit_xhr = (() => {
372
366
param . data = undefined
373
367
}
374
368
if ( isBangumiPage ( ) ) {
375
- log ( `playurl add 'module=bangumi' param` )
376
369
param . url += `&module=bangumi`
377
370
}
378
371
// 加上这个参数, 防止重复拦截这个url
@@ -385,7 +378,6 @@ export const area_limit_xhr = (() => {
385
378
}
386
379
oriResultTransformer = p => p
387
380
. then ( json => {
388
- log ( json )
389
381
if ( isNewPlayurl && ! json . code ) {
390
382
json = json . result
391
383
}
@@ -536,7 +528,7 @@ export const area_limit_xhr = (() => {
536
528
}
537
529
538
530
function isBangumiPage ( ) {
539
- const mediaInfo = window . __INITIAL_STATE__ ?. mediaInfo
531
+ const mediaInfo = window . __INITIAL_STATE__ ?. mediaInfo || window . __NEXT_DATA__ ?. props . pageProps . dehydratedState ?. queries [ 0 ] ?. state . data . seasonInfo ?. mediaInfo
540
532
return isBangumi ( mediaInfo ?. season_type || mediaInfo ?. ssType )
541
533
}
542
534
@@ -606,7 +598,7 @@ export const area_limit_xhr = (() => {
606
598
}
607
599
608
600
function isAreaLimitForPlayUrl ( json ) {
609
- return ( json . errorcid && json . errorcid == '8986943' ) || ( json . durl && json . durl . length === 1 && json . durl [ 0 ] . length === 15126 && json . durl [ 0 ] . size === 124627 ) ;
601
+ return ( json . errorcid && json . errorcid == '8986943' ) || ( json . durl && json . durl . length === 1 && json . durl [ 0 ] . length === 15126 && json . durl [ 0 ] . size === 124627 ) || ! json . video_info ;
610
602
}
611
603
612
604
var bilibiliApis = ( function ( ) {
0 commit comments