mirror of
https://github.com/Tilo-K/ddragon-cdn.git
synced 2026-01-08 08:01:01 +00:00
now providing ranked emblems
This commit is contained in:
1
go.mod
1
go.mod
@@ -5,5 +5,6 @@ go 1.19
|
||||
require (
|
||||
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 // indirect
|
||||
github.com/otiai10/copy v1.9.0 // indirect
|
||||
github.com/xyproto/unzip v0.0.0-20150601123358-823950573952 // indirect
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
||||
)
|
||||
|
||||
2
go.sum
2
go.sum
@@ -8,5 +8,7 @@ github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT9
|
||||
github.com/otiai10/mint v1.4.0/go.mod h1:gifjb2MYOoULtKLqUAEILUG/9KONW6f7YsJ6vQLTlFI=
|
||||
github.com/walle/targz v0.0.0-20140417120357-57fe4206da5a h1:6cKSHLRphD9Fo1LJlISiulvgYCIafJ3QfKLimPYcAGc=
|
||||
github.com/walle/targz v0.0.0-20140417120357-57fe4206da5a/go.mod h1:nccQrXCnc5SjsThFLmL7hYbtT/mHJcuolPifzY5vJqE=
|
||||
github.com/xyproto/unzip v0.0.0-20150601123358-823950573952 h1:pCgYs8AOzRpEmdM55hrSnd+TZOr+1/m9Y9KkFIZPwiU=
|
||||
github.com/xyproto/unzip v0.0.0-20150601123358-823950573952/go.mod h1:ygEdojOpwX5uG71ECHji5sod2rpZ+9hqNeAZD50S84Q=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
|
||||
27
main.go
27
main.go
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
"github.com/alcortesm/tgz"
|
||||
"github.com/otiai10/copy"
|
||||
"github.com/xyproto/unzip"
|
||||
)
|
||||
|
||||
func getVersions() []string {
|
||||
@@ -50,6 +51,25 @@ func loadDdragon(version string) string {
|
||||
return filename
|
||||
}
|
||||
|
||||
func loadRankedEmblems() string {
|
||||
url := fmt.Sprintf("https://static.developer.riotgames.com/docs/lol/ranked-emblems.zip")
|
||||
filename := "ranked-emblems.zip"
|
||||
|
||||
if _, err := os.Stat(filename); os.IsNotExist(err) {
|
||||
res, err := http.Get(url)
|
||||
checkError(err)
|
||||
defer res.Body.Close()
|
||||
|
||||
out, err := os.Create(filename)
|
||||
checkError(err)
|
||||
defer out.Close()
|
||||
|
||||
io.Copy(out, res.Body)
|
||||
}
|
||||
|
||||
return filename
|
||||
}
|
||||
|
||||
func getCurrentVersion() string {
|
||||
_, err := os.Stat("current.txt")
|
||||
if os.IsNotExist(err) {
|
||||
@@ -95,6 +115,13 @@ func loadCurrent() {
|
||||
|
||||
err = os.Rename(src, dst)
|
||||
checkError(err)
|
||||
|
||||
emblemsFile := loadRankedEmblems()
|
||||
export, _ := filepath.Abs(filepath.Join("data", "ranked-emblems"))
|
||||
err = unzip.Extract(emblemsFile, export)
|
||||
checkError(err)
|
||||
|
||||
os.RemoveAll(emblemsFile)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user