@@ -28,6 +28,10 @@ function getSiteUrl(skeyHash) {
2828 return url
2929}
3030
31+ function getPushApi ( ) {
32+ return getSiteUrl ( md5 ( 'push' ) ) ;
33+ }
34+
3135function updateSiteMap ( sites ) {
3236 sites . forEach ( ( site ) => {
3337 let skeyHash = md5 ( site . key ) ;
@@ -137,39 +141,55 @@ async function detail(_inReq, _outResp) {
137141 let url = getSiteUrl ( skeyHash ) ;
138142 const ids = ! Array . isArray ( _inReq . body . id ) ? [ _inReq . body . id ] : _inReq . body . id ;
139143
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+ }
140158 const query = { ac : 'detail' , ids : ids . join ( ',' ) } ;
141159 url = mergeQuery ( url , query ) ;
142160 const result = await request ( url ) ;
143161 // const data = {ac: 'detail', ids: ids.join(',')};
144162 // const result = await post(url, data);
145163 if ( result . list && Array . isArray ( result . list ) ) {
146164 const vod_play_url = result . list [ 0 ] . vod_play_url ;
165+ const vod_play_from = result . list [ 0 ] . vod_play_from ;
147166 // 手动处理push:// 调用push_agent
148167 if ( vod_play_url && vod_play_url . includes ( 'push://' ) ) {
149168 console . log ( 'vod_play_url:' , vod_play_url ) ;
150169 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 ( '$$$' ) ;
152171 let vod_play_arr = vod_play_url . split ( '$$$' ) ;
172+ console . log ( vod_play_arr ) ;
153173 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 ) ;
155176 if ( play_url . includes ( 'push://' ) ) {
156177 const tab_urls = play_url . split ( '#' ) ;
178+ console . log ( 'tab_urls:' , tab_urls ) ;
157179 let _vod_play_urls = [ ] ;
158180 for ( const tab_url of tab_urls ) {
159181 let _title = tab_url . split ( '$' ) [ 0 ] ;
160182 let vod_url = tab_url . split ( '$' ) [ 1 ] ;
161183 if ( vod_url && vod_url . startsWith ( 'push://' ) ) {
162184 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);
173193 if ( _result && Array . isArray ( _result . list ) ) {
174194 let _vod_play_url = _result . list [ 0 ] . vod_play_url ;
175195 vod_play_froms [ i ] = _result . list [ 0 ] . vod_play_from ;
@@ -213,10 +233,10 @@ async function play(_inReq, _outResp) {
213233 let url = getSiteUrl ( skeyHash ) ;
214234 let id = _inReq . body . id ;
215235 if ( id && id . startsWith ( 'push://' ) ) {
216- url = getSiteUrl ( md5 ( 'push_agent' ) ) ;
236+ url = getPushApi ( ) ;
217237 id = id . slice ( 7 ) ;
238+ console . log ( '[play] push:' , id ) ;
218239 }
219-
220240 const flag = _inReq . body . flag ;
221241 const flags = _inReq . body . flags ;
222242 const query = { play : `${ id } ` , flag : flag } ;
0 commit comments