Skip to content

Commit

Permalink
fix: vip play source url
Browse files Browse the repository at this point in the history
  • Loading branch information
muedsa committed Nov 3, 2023
1 parent 9db0871 commit c6d929d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
30 changes: 30 additions & 0 deletions app/src/main/kotlin/com/muedsa/agetv/service/AgePlayerService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.google.common.net.HttpHeaders
import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFactory
import com.muedsa.agetv.AgeMobileUrl
import com.muedsa.agetv.AgeMobileUrlBase64
import com.muedsa.agetv.BuildConfig
import com.muedsa.agetv.model.AgePlayInfoModel
import com.muedsa.uitl.ChromeUserAgent
import com.muedsa.uitl.LenientJson
Expand All @@ -14,6 +15,8 @@ import com.muedsa.uitl.md5
import kotlinx.serialization.encodeToString
import okhttp3.HttpUrl.Companion.toHttpUrl
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.jsoup.Jsoup
import org.jsoup.nodes.Document
import retrofit2.Retrofit
Expand Down Expand Up @@ -64,6 +67,7 @@ class AgePlayerService {
val encryptReq = LenientJson.encodeToString(req)
.encryptAES128CBCPKCS7(WASM_AES_KEY, WASM_AES_KEY)
.toHexString(HexFormat.UpperCase)
LogUtil.fb("api baseUrl: $baseUrl")
val resp = getVipApiService(baseUrl).api(
params = encryptReq,
uuid = uuid,
Expand Down Expand Up @@ -145,6 +149,19 @@ class AgePlayerService {
val retrofit = Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(LenientJson.asConverterFactory("image/vnd.microsoft.icon".toMediaType()))
.client(OkHttpClient.Builder().addInterceptor {
it.proceed(
it.request().newBuilder()
.header(HttpHeaders.USER_AGENT, ChromeUserAgent)
.header(HttpHeaders.REFERER, AgeMobileUrl).build()
)
}.also {
if (BuildConfig.DEBUG) {
val loggingInterceptor = HttpLoggingInterceptor()
loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY
it.addInterceptor(loggingInterceptor)
}
}.build())
.build()
retrofit.create(AgeVipPlayerApiService::class.java)
}
Expand All @@ -156,6 +173,19 @@ class AgePlayerService {
DEFAULT_RETROFIT = Retrofit.Builder()
.baseUrl(baseUrl)
.addConverterFactory(LenientJson.asConverterFactory("image/vnd.microsoft.icon".toMediaType()))
.client(OkHttpClient.Builder().addInterceptor {
it.proceed(
it.request().newBuilder()
.header(HttpHeaders.USER_AGENT, ChromeUserAgent)
.header(HttpHeaders.REFERER, AgeMobileUrl).build()
)
}.also {
if (BuildConfig.DEBUG) {
val loggingInterceptor = HttpLoggingInterceptor()
loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY
it.addInterceptor(loggingInterceptor)
}
}.build())
.build()
DEFAULT_VIP_API_SERVICE = DEFAULT_RETROFIT!!.create(AgeVipPlayerApiService::class.java)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import retrofit2.http.POST

interface AgeVipPlayerApiService {

@POST("vip/Api.php")
@POST("Api.php")
@FormUrlEncoded
@Headers(
"${HttpHeaders.X_REQUESTED_WITH}: XMLHttpRequest",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class AgePlayerServiceTest {
if (playInfo.vUrl.isEmpty()) {
throw AgeParseException("vurl is empty")
}
val playUrl = service.decryptPlayUrl(playInfo, "https://43.240.74.134:8443/vip")
val playUrl = service.decryptPlayUrl(playInfo, "https://43.240.74.134:8443/vip/")
println(playUrl)
}
}
Expand Down

0 comments on commit c6d929d

Please sign in to comment.