Skip to content

Commit

Permalink
feat: remove checking for Sunday
Browse files Browse the repository at this point in the history
  • Loading branch information
Samarium150 committed Apr 23, 2023
1 parent 1ad4e64 commit b0040b0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ plugins {
}

group = "io.github.samarium150"
version = "1.8.2"
version = "1.8.3"

repositories {
mavenCentral()
}

dependencies {
implementation("cn.hutool:hutool-cron:5.8.15")
implementation("cn.hutool:hutool-cron:5.8.18")
implementation("com.twelvemonkeys.imageio:imageio-webp:3.9.4")
implementation(platform("io.ktor:ktor-bom:2.2.3"))
implementation(platform("io.ktor:ktor-bom:2.3.0"))
implementation("io.ktor:ktor-client-okhttp-jvm")
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/config/PluginConfig.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Samarium
* Copyright (c) 2023 Samarium
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
Expand All @@ -25,7 +25,7 @@ object PluginConfig : AutoSavePluginConfig("PluginConfig") {
val save: Boolean by value(true)

@ValueDescription("Cron表达式")
val cron: String by value("0 0 12 ? * MON-SAT *")
val cron: String by value("0 0 12 * * ?")

@ValueDescription("执行Cron表达式的时区")
val timezone: String by value("GMT+08:00")
Expand Down
14 changes: 3 additions & 11 deletions src/main/kotlin/util/General.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 Samarium
* Copyright (c) 2023 Samarium
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
Expand Down Expand Up @@ -62,13 +62,6 @@ internal fun sanitizeDate(date: String?): String {
return date
}

internal fun isSunday(date: String): Boolean {
Calendar.getInstance().apply {
time = SimpleDateFormat("yyyyMMdd").parse(date)
return get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY
}
}

internal suspend fun convertWebPToPNG(webpData: ByteArray): ByteArray {
return runInterruptible {
val output = ByteArrayOutputStream()
Expand All @@ -84,7 +77,7 @@ internal suspend fun downloadLoafersCalender(date: String? = null): InputStream
if (file.exists()) return file.inputStream()
val response: HttpResponse = httpClient.get("https://api.j4u.ink/proxy/redirect/moyu/calendar/$target.png")
var body: ByteArray = response.body()
if (!isSunday(target) && response.etag() == "\"6251bbbb-d2781\"")
if (response.etag() == "\"6251bbbb-d2781\"")
throw NotUpdatedYetException("API is not updated yet")
if (response.headers["Content-Type"] == "image/webp")
body = convertWebPToPNG(body)
Expand Down Expand Up @@ -120,7 +113,6 @@ internal fun cleanCalendarCache(date: String?) = runCatching {
val file = cacheFolder.resolve("${sanitizeDate(date)}.png")
if (file.isFile)
file.delete()
else
return@runCatching
return@runCatching
}
}

0 comments on commit b0040b0

Please sign in to comment.