Skip to content

Commit

Permalink
Support creds.json for atcoder
Browse files Browse the repository at this point in the history
  • Loading branch information
kunyavskiy committed Sep 8, 2023
1 parent 5a3a2fe commit 4401865
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ internal class ContestData(
val StandingsData: List<AtcoderTeam>
)

internal class AtcoderDataSource(val settings: AtcoderSettings) : FullReloadContestDataSource(5.seconds) {
internal class AtcoderDataSource(val settings: AtcoderSettings, creds: Map<String, String>) : FullReloadContestDataSource(5.seconds) {
val teamIds = Enumerator<String>()
val problemIds = Enumerator<String>()
private val loader = jsonLoader<ContestData>(settings.network, ClientAuth.CookieAuth("REVEL_SESSION", settings.sessionCookie)) { "https://atcoder.jp/contests/${settings.contestId}/standings/json" }
private val loader = jsonLoader<ContestData>(settings.network, ClientAuth.CookieAuth("REVEL_SESSION", settings.sessionCookie.get(creds))) { "https://atcoder.jp/contests/${settings.contestId}/standings/json" }

var submissionId: Int = 1
val runs = mutableMapOf<Pair<Int, Int>, List<RunInfo>>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,15 @@ class CodeDrillsSettings(
@Serializable
class AtcoderSettings(
val contestId: String,
val sessionCookie: String,
val sessionCookie: Credential,
@Serializable(with = HumanTimeSerializer::class)
val startTime: Instant,
@Serializable(with = DurationInSecondsSerializer::class)
@SerialName("contestLengthSeconds") val contestLength: Duration,
override val emulation: EmulationSettings? = null,
override val network: NetworkSettings? = null
) : CDSSettings() {
override fun toDataSource(creds: Map<String, String>) = AtcoderDataSource(this)
override fun toDataSource(creds: Map<String, String>) = AtcoderDataSource(this, creds)
}

@SerialName("cms")
Expand Down

0 comments on commit 4401865

Please sign in to comment.