Skip to content

Commit

Permalink
[add] now groups by game type
Browse files Browse the repository at this point in the history
- game types: EFT, ETS, ARENA
  • Loading branch information
king committed Jan 1, 2024
1 parent c06f62f commit 5a8e63d
Showing 1 changed file with 59 additions and 29 deletions.
88 changes: 59 additions & 29 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,17 @@ import (
const cdn string = "http://cdn-11.eft-store.com"

type eftDLV struct {
Version string
GUID string
Size string
URL string
GameType string
Version string
GUID string
Size string
URL string
}

var categories = map[string][]eftDLV{
"EFT": make([]eftDLV, 0),
"ETS": make([]eftDLV, 0),
"ARENA": make([]eftDLV, 0),
}

func main() {
Expand Down Expand Up @@ -66,38 +73,58 @@ func main() {
}
}

sort.Slice(output, func(i, j int) bool {
return output[i].Version < output[j].Version
})

for _, dlv := range output {
if dlv.Version != "" && dlv.GUID != "" && dlv.URL != "" {
fmt.Println("Version:", dlv.Version, "GUID:", dlv.GUID, "FileSize:", dlv.Size)
fmt.Println("Download Link:", dlv.URL)
fmt.Println()
for name, category := range categories {
sort.SliceStable(category, func(i, j int) bool {
return category[i].Version < category[j].Version
})
fmt.Println("[", name, "]")
for _, dlv := range category {
if dlv.Version != "" && dlv.GUID != "" && dlv.URL != "" {
fmt.Println("Version:", dlv.Version, "GUID:", dlv.GUID, "FileSize:", dlv.Size)
fmt.Println("Download Link:", dlv.URL)
fmt.Println()
}
}
}

//for name, category := range categories {
// fmt.Println("[", name, "]")
// for _, dlv := range category {
// if dlv.Version != "" && dlv.GUID != "" && dlv.URL != "" {
// fmt.Println("Version:", dlv.Version, "GUID:", dlv.GUID, "FileSize:", dlv.Size)
// fmt.Println("Download Link:", dlv.URL)
// fmt.Println()
// }
// }
//}

fmt.Println("Press Enter to exit...")
_, err = fmt.Scanln()
if err != nil {
return
}
}

var output = make([]eftDLV, 0)
// var output = make([]eftDLV, 0)
var duplicates = make(map[string]struct{})

func extractInfo(line string) {
var isUpdate bool
var clientInfo string
var gameType string

var filepathSplit = "/client"
var guidSplit []string

if strings.Contains(line, "/arena/client") {
gameType = "ARENA"
filepathSplit = "/arena"
} else if strings.Contains(line, "/eft/client") {
if strings.Contains(line, "ets") {
gameType = "ETS"
} else {
gameType = "EFT"
}
filepathSplit = "/eft"
}

Expand Down Expand Up @@ -126,11 +153,12 @@ func extractInfo(line string) {
return
}

output = append(output, eftDLV{
Version: guidSplit[0],
GUID: guidSplit[1],
URL: updateURL,
Size: line[strings.Index(line, "size of")+8:],
categories[gameType] = append(categories[gameType], eftDLV{
GameType: gameType,
Version: guidSplit[0],
GUID: guidSplit[1],
URL: updateURL,
Size: line[strings.Index(line, "size of")+8:],
})
duplicates[guidSplit[0]] = struct{}{}

Expand All @@ -141,11 +169,12 @@ func extractInfo(line string) {
}

zipURL := cdn + "/" + splitClientInfo[1] + "/" + splitClientInfo[2] + "/distribs/" + versionSplit + "_" + guidSplit[1] + "/Client." + versionSplit + ".zip"
output = append(output, eftDLV{
Version: versionSplit,
GUID: guidSplit[1],
URL: zipURL,
Size: "Unknown",
categories[gameType] = append(categories[gameType], eftDLV{
GameType: gameType,
Version: versionSplit,
GUID: guidSplit[1],
URL: zipURL,
Size: "Unknown",
})
duplicates[versionSplit] = struct{}{}
}
Expand All @@ -154,11 +183,12 @@ func extractInfo(line string) {
return
}

output = append(output, eftDLV{
Version: guidSplit[0],
GUID: guidSplit[1],
URL: cdn + clientInfo + ".zip",
Size: line[strings.Index(line, "size of")+8:],
categories[gameType] = append(categories[gameType], eftDLV{
GameType: gameType,
Version: guidSplit[0],
GUID: guidSplit[1],
URL: cdn + clientInfo + ".zip",
Size: line[strings.Index(line, "size of")+8:],
})
duplicates[guidSplit[0]] = struct{}{}
}
Expand Down

0 comments on commit 5a8e63d

Please sign in to comment.