113 lines
3.6 KiB
Kotlin
113 lines
3.6 KiB
Kotlin
package net.bluemangoo.indpjsk.data
|
|
|
|
import net.bluemangoo.indpjsk.upload.Uploader
|
|
|
|
object PredefinedProfiles {
|
|
private const val SUITE_PATH = "/api/suite/user/(\\d+)(\\?isLogin=true)?$"
|
|
private const val MYSEKAI_PATH =
|
|
"/api/user/(\\d+)/mysekai\\?isForceAllReloadOnlyMysekai=True"
|
|
|
|
private fun suiteStep(hosts: List<String>) = CaptureProfileStep(
|
|
id = "suite",
|
|
name = "Suite",
|
|
hosts = hosts,
|
|
path = SUITE_PATH,
|
|
fileName = "suite",
|
|
postAction = { result ->
|
|
Uploader.tryUpload(result)
|
|
}
|
|
)
|
|
|
|
private fun mysekaiStep(hosts: List<String>) = CaptureProfileStep(
|
|
id = "mysekai",
|
|
name = "烤森",
|
|
hosts = hosts,
|
|
path = MYSEKAI_PATH,
|
|
fileName = "mysekai",
|
|
postAction = { result ->
|
|
Uploader.tryUpload(result)
|
|
}
|
|
)
|
|
|
|
private fun mysekaiBirthday(hosts: List<String>) = CaptureProfileStep(
|
|
id = "mysekai_birthday",
|
|
name = "烤森生日双叶",
|
|
hosts = hosts,
|
|
path = "/api/user/(\\d+)/mysekai/birthday-party/(\\d+)/delivery",
|
|
fileName = "mysekai_birthday",
|
|
postAction = { result ->
|
|
Uploader.tryUpload(result)
|
|
}
|
|
)
|
|
|
|
private val CN_HOSTS = listOf(
|
|
"mkcn-prod-public-60001-1.dailygn.com",
|
|
"mkcn-prod-public-60001-2.dailygn.com"
|
|
)
|
|
private val JP_HOSTS = listOf("production-game-api.sekai.colorfulpalette.org")
|
|
private val EN_HOSTS = listOf("n-production-game-api.sekai-en.com")
|
|
private val TW_HOSTS = listOf(
|
|
"mk-zian-obt-cdn.bytedgame.com",
|
|
"mk-zian-obt-https.bytedgame.com"
|
|
)
|
|
private val KR_HOSTS = listOf(
|
|
"mkkorea-obt-prod01-cdn.bytedgame.com",
|
|
"mkkorea-obt-prod01-https.bytedgame.com"
|
|
)
|
|
|
|
fun rewriteTwUrl(result: CaptureResult): CaptureResult {
|
|
val originalUrl = result.url
|
|
val rewrittenUrl = originalUrl.replace(
|
|
"mk-zian-obt-https.bytedgame.com",
|
|
"mk-zian-obt-cdn.bytedgame.com"
|
|
)
|
|
return result.copy(url = rewrittenUrl)
|
|
}
|
|
|
|
val all: List<CaptureProfile> = listOf(
|
|
// 国服不支持烤森
|
|
CaptureProfile(
|
|
id = "cn",
|
|
name = "国服",
|
|
steps = listOf(suiteStep(CN_HOSTS))
|
|
),
|
|
CaptureProfile(
|
|
id = "jp",
|
|
name = "日服",
|
|
steps = listOf(suiteStep(JP_HOSTS), mysekaiStep(JP_HOSTS), mysekaiBirthday(JP_HOSTS))
|
|
),
|
|
CaptureProfile(
|
|
id = "en",
|
|
name = "国际服",
|
|
steps = listOf(suiteStep(EN_HOSTS), mysekaiStep(EN_HOSTS), mysekaiBirthday(EN_HOSTS))
|
|
),
|
|
CaptureProfile(
|
|
id = "tw",
|
|
name = "台服",
|
|
steps = listOf(suiteStep(TW_HOSTS).apply {
|
|
postAction = { result ->
|
|
val rewrittenResult = rewriteTwUrl(result)
|
|
Uploader.tryUpload(rewrittenResult)
|
|
}
|
|
}, mysekaiStep(TW_HOSTS).apply {
|
|
postAction = { result ->
|
|
val rewrittenResult = rewriteTwUrl(result)
|
|
Uploader.tryUpload(rewrittenResult)
|
|
}
|
|
}, mysekaiBirthday(TW_HOSTS).apply {
|
|
postAction = { result ->
|
|
val rewrittenResult = rewriteTwUrl(result)
|
|
Uploader.tryUpload(rewrittenResult)
|
|
}
|
|
})
|
|
),
|
|
CaptureProfile(
|
|
id = "kr",
|
|
name = "韩服",
|
|
steps = listOf(suiteStep(KR_HOSTS), mysekaiStep(KR_HOSTS), mysekaiBirthday(KR_HOSTS))
|
|
),
|
|
)
|
|
|
|
fun byId(id: String): CaptureProfile? = all.firstOrNull { it.id == id }
|
|
}
|