idk what I was doing before

This commit is contained in:
2025-02-08 04:44:51 -06:00
parent 02f27034d5
commit ffd29b2ffe
14 changed files with 327 additions and 11 deletions
+17 -1
View File
@@ -1,5 +1,11 @@
package scraper
import (
"bytes"
"crypto/sha1"
"encoding/gob"
)
type Event struct {
Url string `json:"url"`
Slug string `json:"slug"`
@@ -11,6 +17,16 @@ type Event struct {
Fights []Fight `json:"fights"`
}
func (e *Event) Hash() ([]byte, error) {
var buf bytes.Buffer
hasher := sha1.New()
enc := gob.NewEncoder(&buf)
if err := enc.Encode(e); err != nil {
return nil, err
}
return hasher.Sum(buf.Bytes()), nil
}
type Fight struct {
Weight string `json:"weight"`
FighterA *Fighter `json:"fighter_a"`
@@ -42,7 +58,7 @@ func ScrapeEvents(callback EventCallback) {
for _, fight := range e.Fights {
fight.FighterA.Link = get_tapology(fight.FighterA.Name)
}
callback(e)
callback(e)
})
}
}