package steam import ( "fmt" "net/http" "strconv" ) // ExtractHTTP is a wrapper around Extract that handles an HTTP endpoint. // this spawns an "extractHTTP" on the library. Status will be updated there // as this goes along. Non fatal and fatal errors will be populated there func (l *Library) ExtractHTTP(url string) (*Game, error) { g := &Game{} j := newJob("extractHTTP", g) defer j.done() l.status.addJob(j) resp, err := http.Get(url) if err != nil { j.addError(err) return g, err } estSize, err := strconv.ParseInt(resp.Header.Get("Estimated-size"), 10, 64) if err != nil { j.addError(err) return g, fmt.Errorf("Failed to convert estimated size header: %w", err) } j.setSize(estSize) return l.extractUpdate(j, g, resp.Body) }