@@ -87,7 +87,10 @@ class Request {
8787        ysp =  YSP (context)
8888    }
8989
90+     var  call:  Call <LiveInfo >?  =  null 
91+ 
9092    fun  fetchVideo (tvModel :  TVViewModel , cookie :  String ) {
93+         call?.cancel()
9194        if  (::myRunnable.isInitialized) {
9295            handler.removeCallbacks(myRunnable)
9396        }
@@ -97,71 +100,71 @@ class Request {
97100        tvModel.seq =  0 
98101        val  data =  ysp?.switch(tvModel)
99102        val  request =  data?.let  { LiveInfoRequest (it) }
103+         call =  request?.let  { yspApiService.getLiveInfo(" guid=${ysp?.getGuid()} ; $cookie " 
100104
101-         request?.let  { yspApiService.getLiveInfo(cookie, it) }
102-             ?.enqueue(object  :  Callback <LiveInfo > {
103-                 override  fun  onResponse (call :  Call <LiveInfo >, response :  Response <LiveInfo >) {
104-                     if  (response.isSuccessful) {
105-                         val  liveInfo =  response.body()
106-                         if  (liveInfo?.data?.playurl !=  null ) {
107-                             val  chanll =  liveInfo.data.chanll
108-                             val  decodedBytes =  Base64 .decode(
109-                                 chanll.substring(9 , chanll.length -  3 ),
110-                                 Base64 .DEFAULT 
111-                             )
112-                             val  decodedString =  String (decodedBytes)
113-                             val  regex =  Regex (""" des_key = "([^"]+).+var des_iv = "([^"]+)""" 
114-                             val  matchResult =  regex.find(decodedString)
115-                             if  (matchResult !=  null ) {
116-                                 val  (key, iv) =  matchResult.destructured
117-                                 val  keyBytes =  Base64 .decode(key, Base64 .DEFAULT )
118-                                 val  ivBytes =  Base64 .decode(iv, Base64 .DEFAULT )
119-                                 val  url =  liveInfo.data.playurl +  " &revoi=" +  encryptTripleDES(
120-                                     keyBytes +  byteArrayOf(0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ),
121-                                     ivBytes
122-                                 ).uppercase()
123-                                 Log .i(TAG , " $title  url $url " 
124-                                 tvModel.addVideoUrl(url)
125-                                 tvModel.allReady()
126-                                 tvModel.retryTimes =  0 
127-                                 myRunnable =  MyRunnable (tvModel)
128-                                 handler.post(myRunnable)
129-                             } else  {
130-                                 Log .e(TAG , " $title  key error" 
131-                                 if  (tvModel.retryTimes <  tvModel.retryMaxTimes) {
132-                                     tvModel.retryTimes++ 
133-                                     fetchVideo(tvModel, cookie)
134-                                 }
135-                             }
105+         call?.enqueue(object  :  Callback <LiveInfo > {
106+             override  fun  onResponse (call :  Call <LiveInfo >, response :  Response <LiveInfo >) {
107+                 if  (response.isSuccessful) {
108+                     val  liveInfo =  response.body()
109+                     if  (liveInfo?.data?.playurl !=  null ) {
110+                         val  chanll =  liveInfo.data.chanll
111+                         val  decodedBytes =  Base64 .decode(
112+                             chanll.substring(9 , chanll.length -  3 ),
113+                             Base64 .DEFAULT 
114+                         )
115+                         val  decodedString =  String (decodedBytes)
116+                         val  regex =  Regex (""" des_key = "([^"]+).+var des_iv = "([^"]+)""" 
117+                         val  matchResult =  regex.find(decodedString)
118+                         if  (matchResult !=  null ) {
119+                             val  (key, iv) =  matchResult.destructured
120+                             val  keyBytes =  Base64 .decode(key, Base64 .DEFAULT )
121+                             val  ivBytes =  Base64 .decode(iv, Base64 .DEFAULT )
122+                             val  url =  liveInfo.data.playurl +  " &revoi=" +  encryptTripleDES(
123+                                 keyBytes +  byteArrayOf(0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ),
124+                                 ivBytes
125+                             ).uppercase()
126+                             Log .i(TAG , " $title  url $url " 
127+                             tvModel.addVideoUrl(url)
128+                             tvModel.allReady()
129+                             tvModel.retryTimes =  0 
130+                             myRunnable =  MyRunnable (tvModel)
131+                             handler.post(myRunnable)
136132                        } else  {
137-                             if  (liveInfo?.data?.errinfo !=  null  &&  liveInfo.data.errinfo ==  " 应版权方要求,暂停提供直播信号,请点击观看其他精彩节目" 
138-                                 Log .e(TAG , " $title  error ${liveInfo.data.errinfo} " 
139-                                 tvModel.setErrInfo(liveInfo.data.errinfo)
140-                             } else  {
141-                                 Log .e(TAG , " $title  url error $request  $liveInfo " 
142-                                 if  (tvModel.retryTimes <  tvModel.retryMaxTimes) {
143-                                     tvModel.retryTimes++ 
144-                                     fetchVideo(tvModel, cookie)
145-                                 }
133+                             Log .e(TAG , " $title  key error" 
134+                             if  (tvModel.retryTimes <  tvModel.retryMaxTimes) {
135+                                 tvModel.retryTimes++ 
136+                                 fetchVideo(tvModel, cookie)
146137                            }
147138                        }
148139                    } else  {
149-                         Log .e(TAG , " $title  status error" 
150-                         if  (tvModel.retryTimes <  tvModel.retryMaxTimes) {
151-                             tvModel.retryTimes++ 
152-                             fetchVideo(tvModel, cookie)
140+                         if  (liveInfo?.data?.errinfo !=  null  &&  liveInfo.data.errinfo ==  " 应版权方要求,暂停提供直播信号,请点击观看其他精彩节目" 
141+                             Log .e(TAG , " $title  error ${liveInfo.data.errinfo} " 
142+                             tvModel.setErrInfo(liveInfo.data.errinfo)
143+                         } else  {
144+                             Log .e(TAG , " $title  url error $request  $liveInfo " 
145+                             if  (tvModel.retryTimes <  tvModel.retryMaxTimes) {
146+                                 tvModel.retryTimes++ 
147+                                 fetchVideo(tvModel, cookie)
148+                             }
153149                        }
154150                    }
155-                 }
156- 
157-                 override  fun  onFailure (call :  Call <LiveInfo >, t :  Throwable ) {
158-                     Log .e(TAG , " $title  request error" 
151+                 } else  {
152+                     Log .e(TAG , " $title  status error" 
159153                    if  (tvModel.retryTimes <  tvModel.retryMaxTimes) {
160154                        tvModel.retryTimes++ 
161155                        fetchVideo(tvModel, cookie)
162156                    }
163157                }
164-             })
158+             }
159+ 
160+             override  fun  onFailure (call :  Call <LiveInfo >, t :  Throwable ) {
161+                 Log .e(TAG , " $title  request error" 
162+                 if  (tvModel.retryTimes <  tvModel.retryMaxTimes) {
163+                     tvModel.retryTimes++ 
164+                     fetchVideo(tvModel, cookie)
165+                 }
166+             }
167+         })
165168    }
166169
167170    fun  fetchVideo (tvModel :  TVViewModel ) {
@@ -172,7 +175,7 @@ class Request {
172175                        val  token =  response.body()?.data?.token
173176                        Log .i(TAG , " info success $token " 
174177                        val  cookie = 
175-                             " guid=1;  vplatform=109; yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token " 
178+                             " vplatform=109; yspopenid=vu0-8lgGV2LW9QjDeuBFsX8yMnzs37Q3_HZF6XyVDpGR_I; vusession=$token " 
176179                        fetchVideo(tvModel, cookie)
177180                    } else  {
178181                        Log .e(TAG , " info status error" 
@@ -197,7 +200,7 @@ class Request {
197200        if  (tvModel.needToken) {
198201            fetchVideo(tvModel)
199202        } else  {
200-             val  cookie =  " guid=1;  vplatform=109" 
203+             val  cookie =  " vplatform=109" 
201204            fetchVideo(tvModel, cookie)
202205        }
203206    }
0 commit comments