Skip to content

Commit

Permalink
CI // Fix WallpaperAssetCollector.
Browse files Browse the repository at this point in the history
  • Loading branch information
ShikiSuen committed Nov 18, 2024
1 parent 90159a4 commit 51ff08c
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions Script/WallpaperAssetCollector.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,18 @@ public enum GenshinLang: String, CaseIterable, Sendable, Identifiable {
https://raw.githubusercontent.com/DimbreathBot/AnimeGameData/master/TextMap/\(filename)
""")
}

// MARK: Internal

var filenamesForChunks -> [String] {
switch self {
case .langTH: [
rawValue.replacingOccurrences(of: "lang", with: "TextMap").appending("_1.json"),
rawValue.replacingOccurrences(of: "lang", with: "TextMap").appending("_2.json"),
]
default: [filename]
}
}
}

// MARK: - WallpaperAsset
Expand Down Expand Up @@ -422,11 +434,18 @@ func makeLanguageMeta() async throws {
) { taskGroup in
GenshinLang.allCases.forEach { locale in
taskGroup.addTask {
let (data, _) = try await URLSession.shared.data(from: locale.url)
var dict = try JSONDecoder().decode([String: String].self, from: data)
let keysToRemove = await Set<String>(dict.keys).subtracting(allNameTextMapHashesNeeded)
keysToRemove.forEach { dict.removeValue(forKey: $0) }
return (subDict: dict, lang: locale)
let urls = getLangDataURLs(for: locale)
var finalDict = [String: String]()
for url in urls {
let (data, _) = try await URLSession.shared.data(from: locale.url)
var dict = try JSONDecoder().decode([String: String].self, from: data)
dict.forEach { key, value in
finalDict[key] = value
}
}
let keysToRemove = await Set<String>(finalDict.keys).subtracting(allNameTextMapHashesNeeded)
keysToRemove.forEach { finalDict.removeValue(forKey: $0) }
return (subDict: finalDict, lang: locale)
}
}
var results = [String: [String: String]]()
Expand Down

0 comments on commit 51ff08c

Please sign in to comment.