From: Jacob Casper Date: Tue, 14 Apr 2020 04:46:57 +0000 (-0500) Subject: Make seed dogfood the api X-Git-Url: https://git.jacobcasper.com/?a=commitdiff_plain;h=b1e8f571a33175c28de00468565e3f863d12c936;p=brackets.git Make seed dogfood the api --- diff --git a/scrape/seed/seed.go b/scrape/seed/seed.go index 017c2dd..f4145df 100644 --- a/scrape/seed/seed.go +++ b/scrape/seed/seed.go @@ -2,18 +2,14 @@ package main import ( "git.jacobcasper.com/brackets/client" - "git.jacobcasper.com/brackets/db" _ "github.com/mattn/go-sqlite3" "log" + "net/http" + "net/url" ) func main() { - db, err := db.New() - if err != nil { - log.Fatal("Could not open db: ", err.Error()) - } - client, err := client.Get() if err != nil { log.Fatal("Could not get client: ", err.Error()) @@ -25,12 +21,11 @@ func main() { tracks, err := client.GetPlaylistTracks(playlist.ID) if err != nil { log.Printf("Couldn't retrieve playlist %s.", string(playlist.ID)) + continue } for _, trackPage := range tracks.Tracks { for _, artist := range trackPage.Track.Artists { - db.Mu.Lock() - db.Db.Exec("INSERT INTO ARTIST (ID, NAME) VALUES (?, ?)", artist.ID, artist.Name) - db.Mu.Unlock() + http.PostForm("http://localhost:8080/artist/add", url.Values{"artist_id": {string(artist.ID)}}) } } }