Skip to content

Commit

Permalink
fetch object
Browse files Browse the repository at this point in the history
  • Loading branch information
Skyline300 committed Nov 9, 2024
1 parent c22fb79 commit a606588
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
2 changes: 0 additions & 2 deletions src/main/scala/com/skyline/warlangmod/App.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.skyline.warlangmod

import java.io.FileWriter

object App {
def run(inputFileName: String, originalFile: String, outputFileName: String): Unit = {

Expand Down
31 changes: 31 additions & 0 deletions src/main/scala/com/skyline/warlangmod/FetchService.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.skyline.warlangmod

import scala.sys.process._
import java.net.http._
import java.net.http.HttpResponse.{BodyHandler, BodyHandlers}
import java.time.Duration
import java.net.{ProxySelector, URI}
import java.io.FileWriter


object FetchService {
def fetchFile(): Unit = {
val client = HttpClient
.newBuilder()
.proxy(ProxySelector.getDefault)
.build()
val httpReq = HttpRequest.newBuilder()
.uri(new URI("https://raw.githubusercontent.com/gszabi99/War-Thunder-Datamine/1bc153b0d22ac06719f6ce1ba2c25b567285cc99/lang.vromfs.bin_u/lang/units.csv"))
.timeout(Duration.ofSeconds(20))
.GET()
.build()
val response = client.send(httpReq,BodyHandlers.ofString())
val body = response.body()

val fileWriter = new FileWriter("src/output.csv")
fileWriter.write(body)
fileWriter.close()
}


}
8 changes: 5 additions & 3 deletions src/main/scala/com/skyline/warlangmod/Main.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ object Main extends CommandApp(
name = "WarThunder Translation Updater",
header = "A tool to update the translation files for WarThunder ",
main = {
val defaultInFile = "units.csv"
val defaultOriginalFile = "unitsN.csv"
val defaultOutFile = "unitsMod.csv"
val defaultUnitsLink = "https://raw.githubusercontent.com/gszabi99/War-Thunder-Datamine/1bc153b0d22ac06719f6ce1ba2c25b567285cc99/lang.vromfs.bin_u/lang/units.csv"
val defaultWeaponryLink = "https://raw.githubusercontent.com/gszabi99/War-Thunder-Datamine/1bc153b0d22ac06719f6ce1ba2c25b567285cc99/lang.vromfs.bin_u/lang/units_weaponry.csv"
val defaultInFile = "src/units.csv"
val defaultOriginalFile = "src/unitsN.csv"
val defaultOutFile = "src/output.csv"
val originalFile = Opts.option[String](
long = "original",
short = "r",
Expand Down

0 comments on commit a606588

Please sign in to comment.