From a5dfbdd6912ad701c4291294221333d7c2161a63 Mon Sep 17 00:00:00 2001 From: Graham Date: Fri, 23 Jun 2023 21:34:11 +0100 Subject: [PATCH] Remove PolarKeyDownloader Polar's site no longer hosts XTEA keys. Signed-off-by: Graham --- .../org/openrs2/archive/ArchiveModule.kt | 2 - .../openrs2/archive/key/PolarKeyDownloader.kt | 50 ------------------- 2 files changed, 52 deletions(-) delete mode 100644 archive/src/main/kotlin/org/openrs2/archive/key/PolarKeyDownloader.kt diff --git a/archive/src/main/kotlin/org/openrs2/archive/ArchiveModule.kt b/archive/src/main/kotlin/org/openrs2/archive/ArchiveModule.kt index a43e774314..00058882d9 100644 --- a/archive/src/main/kotlin/org/openrs2/archive/ArchiveModule.kt +++ b/archive/src/main/kotlin/org/openrs2/archive/ArchiveModule.kt @@ -7,7 +7,6 @@ import com.google.inject.Scopes import com.google.inject.multibindings.Multibinder import org.openrs2.archive.key.HdosKeyDownloader import org.openrs2.archive.key.KeyDownloader -import org.openrs2.archive.key.PolarKeyDownloader import org.openrs2.archive.key.RuneLiteKeyDownloader import org.openrs2.archive.name.NameDownloader import org.openrs2.archive.name.RuneStarNameDownloader @@ -46,7 +45,6 @@ public object ArchiveModule : AbstractModule() { val keyBinder = Multibinder.newSetBinder(binder(), KeyDownloader::class.java) keyBinder.addBinding().to(HdosKeyDownloader::class.java) - keyBinder.addBinding().to(PolarKeyDownloader::class.java) keyBinder.addBinding().to(RuneLiteKeyDownloader::class.java) val nameBinder = Multibinder.newSetBinder(binder(), NameDownloader::class.java) diff --git a/archive/src/main/kotlin/org/openrs2/archive/key/PolarKeyDownloader.kt b/archive/src/main/kotlin/org/openrs2/archive/key/PolarKeyDownloader.kt deleted file mode 100644 index 113ffcb04e..0000000000 --- a/archive/src/main/kotlin/org/openrs2/archive/key/PolarKeyDownloader.kt +++ /dev/null @@ -1,50 +0,0 @@ -package org.openrs2.archive.key - -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.future.await -import kotlinx.coroutines.withContext -import org.jsoup.Jsoup -import org.openrs2.http.charset -import org.openrs2.http.checkStatusCode -import java.net.URI -import java.net.http.HttpClient -import java.net.http.HttpRequest -import java.net.http.HttpResponse -import java.time.Duration -import javax.inject.Inject -import javax.inject.Singleton - -@Singleton -public class PolarKeyDownloader @Inject constructor( - private val client: HttpClient, - jsonKeyReader: JsonKeyReader -) : JsonKeyDownloader(KeySource.POLAR, client, jsonKeyReader) { - override suspend fun getMissingUrls(seenUrls: Set): Set { - val request = HttpRequest.newBuilder(ENDPOINT) - .GET() - .timeout(Duration.ofSeconds(30)) - .build() - - val response = client.sendAsync(request, HttpResponse.BodyHandlers.ofInputStream()).await() - response.checkStatusCode() - - val document = withContext(Dispatchers.IO) { - Jsoup.parse(response.body(), response.charset?.name(), ENDPOINT.toString()) - } - - val urls = mutableSetOf() - - for (element in document.select("a")) { - val url = element.absUrl("href") - if (url.endsWith(".json") && url !in seenUrls) { - urls += url - } - } - - return urls - } - - private companion object { - private val ENDPOINT = URI("https://archive.runestats.com/osrs/xtea/") - } -}