mirror of
https://github.com/tiennm99/loldle.git
synced 2026-10-15 04:18:43 +00:00
feat: rewrite LoLdleData in Go
4-stage pipeline: fetch ddragon champions, enrich with release dates (wiki scrape), regions (Universe API), and lanes (wiki scrape). Concurrent gender detection via goroutines with semaphore.
This commit is contained in:
1 parent
361e09910b
commit
cfa664f217
11 files changed
+556
No files matched your search
@@ -0,0 +1,51 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/tiennm99/loldle-data/parser"
|
||||
)
|
||||
|
||||
func main() {
|
||||
champions, err := parser.ParseChampions(championsVersion)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to parse champions: %v", err)
|
||||
}
|
||||
|
||||
champions, err = parser.EnrichReleaseDates(champions)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to enrich release dates: %v", err)
|
||||
}
|
||||
|
||||
champions, err = parser.EnrichRegions(champions)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to enrich regions: %v", err)
|
||||
}
|
||||
|
||||
champions, err = parser.EnrichLanes(champions)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to enrich lanes: %v", err)
|
||||
}
|
||||
|
||||
outputPath := "champions.json"
|
||||
if err := saveJSON(outputPath, champions); err != nil {
|
||||
log.Fatalf("Failed to save JSON: %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Champion data has been saved to %s\n", outputPath)
|
||||
}
|
||||
|
||||
func saveJSON(path string, data []parser.ChampionResult) error {
|
||||
file, err := os.Create(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
encoder := json.NewEncoder(file)
|
||||
encoder.SetIndent("", " ")
|
||||
return encoder.Encode(data)
|
||||
}
|
||||
Reference in new issue
Block a user