From b1e8f571a33175c28de00468565e3f863d12c936 Mon Sep 17 00:00:00 2001 From: Jacob Casper Date: Mon, 13 Apr 2020 23:46:57 -0500 Subject: [PATCH] Make seed dogfood the api --- scrape/seed/seed.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) 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)}}) } } } -- 2.20.1