@@ -28,6 +28,10 @@ function getSiteUrl(skeyHash) {
28
28
return url
29
29
}
30
30
31
+ function getPushApi ( ) {
32
+ return getSiteUrl ( md5 ( 'push' ) ) ;
33
+ }
34
+
31
35
function updateSiteMap ( sites ) {
32
36
sites . forEach ( ( site ) => {
33
37
let skeyHash = md5 ( site . key ) ;
@@ -137,39 +141,55 @@ async function detail(_inReq, _outResp) {
137
141
let url = getSiteUrl ( skeyHash ) ;
138
142
const ids = ! Array . isArray ( _inReq . body . id ) ? [ _inReq . body . id ] : _inReq . body . id ;
139
143
144
+ // 一级或者搜索过滤的push直接拦截,可以避免走自身detail(虽然后面自身detail数据逻辑已经可用了,但是为了少走一次,加快速率,这样加很棒)
145
+ if ( ids [ 0 ] . startsWith ( 'push://' ) ) {
146
+ let _ids = ids [ 0 ] . slice ( 7 ) ;
147
+ let _url = getPushApi ( ) ;
148
+ console . log ( 'detail push _ids:' , _ids ) ;
149
+ console . log ( 'detail push _url:' , _url ) ;
150
+ let _data = { ac : 'detail' , ids : _ids } ;
151
+ let _result = await post ( _url , _data ) ;
152
+ if ( _result && Array . isArray ( _result . list ) ) {
153
+ let _vod_play_url = _result . list [ 0 ] . vod_play_url ;
154
+ _result . list [ 0 ] . vod_play_url = _vod_play_url . split ( '#' ) . map ( i => i . replace ( '$' , '$push://' ) ) . join ( '#' ) ;
155
+ }
156
+ return _result
157
+ }
140
158
const query = { ac : 'detail' , ids : ids . join ( ',' ) } ;
141
159
url = mergeQuery ( url , query ) ;
142
160
const result = await request ( url ) ;
143
161
// const data = {ac: 'detail', ids: ids.join(',')};
144
162
// const result = await post(url, data);
145
163
if ( result . list && Array . isArray ( result . list ) ) {
146
164
const vod_play_url = result . list [ 0 ] . vod_play_url ;
165
+ const vod_play_from = result . list [ 0 ] . vod_play_from ;
147
166
// 手动处理push:// 调用push_agent
148
167
if ( vod_play_url && vod_play_url . includes ( 'push://' ) ) {
149
168
console . log ( 'vod_play_url:' , vod_play_url ) ;
150
169
let vod_play_urls = [ ] ;
151
- let vod_play_froms = result . list [ 0 ] . vod_play_from . split ( '$$$' ) ;
170
+ let vod_play_froms = vod_play_from . split ( '$$$' ) ;
152
171
let vod_play_arr = vod_play_url . split ( '$$$' ) ;
172
+ console . log ( vod_play_arr ) ;
153
173
for ( let i in vod_play_arr ) {
154
- const play_url = vod_play_url [ i ] ;
174
+ const play_url = vod_play_arr [ i ] ;
175
+ console . log ( 'play_url:' , play_url ) ;
155
176
if ( play_url . includes ( 'push://' ) ) {
156
177
const tab_urls = play_url . split ( '#' ) ;
178
+ console . log ( 'tab_urls:' , tab_urls ) ;
157
179
let _vod_play_urls = [ ] ;
158
180
for ( const tab_url of tab_urls ) {
159
181
let _title = tab_url . split ( '$' ) [ 0 ] ;
160
182
let vod_url = tab_url . split ( '$' ) [ 1 ] ;
161
183
if ( vod_url && vod_url . startsWith ( 'push://' ) ) {
162
184
let _ids = vod_url . slice ( 7 ) ;
163
- let _url = getSiteUrl ( md5 ( 'push_agent' ) ) ;
164
-
165
-
166
- // let _data = {ac: 'detail', ids: _ids};
167
- // let _result = await post(_url, _data);
168
-
169
- const _query = { ac : 'detail' , ids : _ids } ;
170
- _url = mergeQuery ( _url , _query ) ;
171
- const _result = await request ( _url ) ;
172
-
185
+ let _url = getPushApi ( ) ;
186
+ console . log ( 'tab push _ids:' , _ids ) ;
187
+ console . log ( 'tab push _url:' , _url ) ;
188
+ let _data = { ac : 'detail' , ids : _ids } ;
189
+ let _result = await post ( _url , _data ) ;
190
+ // const _query = {ac: 'detail', ids: _ids};
191
+ // _url = mergeQuery(_url, _query);
192
+ // const _result = await request(_url);
173
193
if ( _result && Array . isArray ( _result . list ) ) {
174
194
let _vod_play_url = _result . list [ 0 ] . vod_play_url ;
175
195
vod_play_froms [ i ] = _result . list [ 0 ] . vod_play_from ;
@@ -213,10 +233,10 @@ async function play(_inReq, _outResp) {
213
233
let url = getSiteUrl ( skeyHash ) ;
214
234
let id = _inReq . body . id ;
215
235
if ( id && id . startsWith ( 'push://' ) ) {
216
- url = getSiteUrl ( md5 ( 'push_agent' ) ) ;
236
+ url = getPushApi ( ) ;
217
237
id = id . slice ( 7 ) ;
238
+ console . log ( '[play] push:' , id ) ;
218
239
}
219
-
220
240
const flag = _inReq . body . flag ;
221
241
const flags = _inReq . body . flags ;
222
242
const query = { play : `${ id } ` , flag : flag } ;
0 commit comments