File tree Expand file tree Collapse file tree
src/main/java/com/muedsa/tvbox Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,10 +20,15 @@ jobs:
2020 java-version : ' 17'
2121 distribution : ' temurin'
2222 cache : gradle
23- - name : Load Google Service file
23+ - name : Load secret files
2424 env :
25- DATA : ${{ secrets.GOOGLE_SERVICES_JSON }}
26- run : echo $DATA | base64 -di > app/google-services.json
25+ - GOOGLE_SERVICES_JSON_DATA : ${{ secrets.GOOGLE_SERVICES_JSON }}
26+ - SIGN_KEY_DATA : ${{ secrets.SIGN_KEY }}
27+ - KEY_STORE_PROP_DATA : ${{ secrets.KEY_STORE_PROP }}
28+ run : |
29+ echo $GOOGLE_SERVICES_JSON_DATA | base64 -di > app/google-services.json
30+ echo $SIGN_KEY_DATA | base64 -di > MUEDSA.jks
31+ echo $KEY_STORE_PROP_DATA | base64 -di > keystore.properties
2732 - name : Grant execute permission for gradlew
2833 run : chmod +x gradlew
2934 - name : Build with Gradle
Original file line number Diff line number Diff line change @@ -48,6 +48,19 @@ android {
4848 }
4949 }
5050
51+ defaultConfig {
52+ buildConfigField(
53+ " String" ,
54+ " DANDANPLAY_APP_ID" ,
55+ " \" ${keystoreProperties[" muedsa.danDanPlay.appId" ]} \" "
56+ )
57+ buildConfigField(
58+ " String" ,
59+ " DANDANPLAY_APP_SECRET" ,
60+ " \" ${keystoreProperties[" muedsa.danDanPlay.appSecret" ]} \" "
61+ )
62+ }
63+
5164 buildTypes {
5265 release {
5366 isMinifyEnabled = false
@@ -70,6 +83,7 @@ android {
7083
7184 buildFeatures {
7285 compose = true
86+ buildConfig = true
7387 }
7488
7589 room {
Original file line number Diff line number Diff line change @@ -4,8 +4,10 @@ import android.content.Context
44import androidx.room.Room
55import com.muedsa.tvbox.room.AppDatabase
66import com.muedsa.tvbox.service.DanDanPlayApiService
7+ import com.muedsa.tvbox.service.DanDanPlayAuthInterceptor
78import com.muedsa.tvbox.store.DataStoreRepo
89import com.muedsa.tvbox.tool.createJsonRetrofit
10+ import com.muedsa.tvbox.tool.createOkHttpClient
911import com.muedsa.util.AppUtil
1012import dagger.Module
1113import dagger.Provides
@@ -46,6 +48,8 @@ internal object AppModule {
4648 createJsonRetrofit(
4749 baseUrl = " https://api.dandanplay.net/api/" ,
4850 service = DanDanPlayApiService ::class .java,
49- debug = AppUtil .debuggable(context)
51+ okHttpClient = createOkHttpClient(debug = AppUtil .debuggable(context)) {
52+ addInterceptor(DanDanPlayAuthInterceptor ())
53+ }
5054 )
5155}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.muedsa.tvbox.screens.detail
22
33import androidx.lifecycle.ViewModel
44import androidx.lifecycle.viewModelScope
5+ import com.muedsa.tvbox.BuildConfig
56import com.muedsa.tvbox.api.data.MediaDetail
67import com.muedsa.tvbox.api.data.MediaEpisode
78import com.muedsa.tvbox.api.data.MediaHttpSource
@@ -93,6 +94,8 @@ class MediaDetailScreenViewModel @Inject constructor(
9394 private val _danBangumiListFlow =
9495 combine(_mediaDetailFlow , _banBangumiSearchQueryFlow ) { wrapper, searchQuery ->
9596 if (wrapper.data != null
97+ && ! BuildConfig .DANDANPLAY_APP_ID .isEmpty()
98+ && ! BuildConfig .DANDANPLAY_APP_SECRET .isEmpty()
9699 && wrapper.data.second.enableDanDanPlaySearch
97100 && ! wrapper.data.third.enableCustomDanmakuList
98101 && ! wrapper.data.third.enableCustomDanmakuFlow
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package com.muedsa.tvbox.screens.playback
33import androidx.lifecycle.ViewModel
44import androidx.lifecycle.viewModelScope
55import com.kuaishou.akdanmaku.data.DanmakuItemData
6+ import com.muedsa.tvbox.BuildConfig
67import com.muedsa.tvbox.api.data.DanmakuDataFlow
78import com.muedsa.tvbox.api.data.MediaEpisode
89import com.muedsa.tvbox.model.AppSettingModel
@@ -70,7 +71,10 @@ class PlaybackScreenViewModel @Inject constructor(
7071 danmakuStyle = data.danmakuStyle
7172 )
7273 }
73- } else if (it.danEpisodeId > 0 ) {
74+ } else if (! BuildConfig .DANDANPLAY_APP_ID .isEmpty()
75+ && ! BuildConfig .DANDANPLAY_APP_SECRET .isEmpty()
76+ && it.danEpisodeId > 0
77+ ) {
7478 danDanPlayApiService.getComment(
7579 episodeId = it.danEpisodeId,
7680 from = 0 ,
Original file line number Diff line number Diff line change 1+ package com.muedsa.tvbox.service
2+
3+ import com.muedsa.tvbox.BuildConfig
4+ import com.muedsa.tvbox.tool.encodeBase64
5+ import okhttp3.Interceptor
6+ import okhttp3.Response
7+ import java.security.MessageDigest
8+
9+ class DanDanPlayAuthInterceptor : Interceptor {
10+
11+ override fun intercept (chain : Interceptor .Chain ): Response {
12+ val timestamp = System .currentTimeMillis() / 1000
13+ val path = chain.request().url.encodedPath
14+ val sign =
15+ " ${BuildConfig .DANDANPLAY_APP_ID }$timestamp$path${BuildConfig .DANDANPLAY_APP_SECRET } " .let {
16+ MessageDigest .getInstance(" SHA-256" )
17+ .digest(it.toByteArray(Charsets .UTF_8 ))
18+ .encodeBase64()
19+ }
20+ val request = chain.request().newBuilder()
21+ .header(" X-AppId" , BuildConfig .DANDANPLAY_APP_ID )
22+ .header(" X-Timestamp" , " $timestamp " )
23+ .header(" X-Signature" , sign)
24+ .build()
25+ return chain.proceed(request)
26+ }
27+ }
You can’t perform that action at this time.
0 commit comments