diff --git a/index.tmpl b/index.tmpl index ea0248c..ceca976 100644 --- a/index.tmpl +++ b/index.tmpl @@ -12,3 +12,11 @@

Inspirado en Kopimashin de brokep.

Kopimi

+
+

Algunos NFTs descargados

+ {{range .NFTs}} + + + + {{end}} +
diff --git a/main.go b/main.go index 4eafe2b..ec09343 100644 --- a/main.go +++ b/main.go @@ -7,16 +7,19 @@ import ( "io" "io/fs" "log" + "math/rand" "net/http" "os" "path" "path/filepath" "strings" + "time" ) type Status struct { NFTNum int TotalUSDValue float64 + NFTs []string } const NFTS_DIR = "./nfts" @@ -41,6 +44,10 @@ func getStatus() (Status, error) { return status, err } + // https://yourbasic.org/golang/shuffle-slice-array/ + rand.Seed(time.Now().UnixNano()) + rand.Shuffle(len(entries), func(i, j int) { entries[i], entries[j] = entries[j], entries[i] }) + for _, val := range entries { info, err := val.Info() if err != nil { @@ -50,11 +57,16 @@ func getStatus() (Status, error) { continue } - asset, err := getDownloadedOpenSeaAsset(strings.Split(info.Name(), ".")[0]) + id := strings.Split(info.Name(), ".")[0] + asset, err := getDownloadedOpenSeaAsset(id) if err != nil { return status, err } + if len(status.NFTs) <= 20 { + status.NFTs = append(status.NFTs, id) + } + status.NFTNum += 1 status.TotalUSDValue += asset.GetUSDPrice() }