diff --git a/homegrown/email-rust/src/.main.rs.swp b/homegrown/email-rust/src/.main.rs.swp new file mode 100644 index 0000000..266d378 Binary files /dev/null and b/homegrown/email-rust/src/.main.rs.swp differ diff --git a/homegrown/yt-email/main.go b/homegrown/yt-email/main.go index 9affaf8..802098e 100644 --- a/homegrown/yt-email/main.go +++ b/homegrown/yt-email/main.go @@ -1,11 +1,13 @@ package main import ( + "bytes" "encoding/json" "fmt" "io" "net/http" "os" + "text/template" "time" "github.com/joho/godotenv" @@ -22,6 +24,14 @@ type videos struct { Name string } +type videourl struct { + Id string + Part string + Order string + Date string + Key string +} + func main() { channellist := "https://raw.githubusercontent.com/bvanroll/home/refs/heads/master/static/yters.json" err := godotenv.Load() @@ -37,7 +47,19 @@ func main() { date := time.Now().Add(-week) //bro wtf is up with go here man this is ass :D datestr := date.Format("2006-01-02T15:04:05Z") - videosstr := "https://www.googleapis.com/youtube/v3/search/?channelId={id}&part={part},id&order={order}&publishedAfter={date}&key={apikey}" + videosstr := "https://www.googleapis.com/youtube/v3/search/?channelId={{.Id}}&part={{.Part}},id&order={{.Order}}&publishedAfter={{.Date}}&key={{.Key}}" + templ, err := template.New("test").Parse(videosstr) + for i, val := range output { + temp := videourl{val.Id, "snippet", "date", datestr, apikey} + var output bytes.Buffer + templ.Execute(&output, temp) + resp, err := http.Get(output.String()) + body, err := io.ReadAll(resp.Body) + fmt.Println(string(body)) + fmt.Println(i) + fmt.Println(err) + + } fmt.Println(output) fmt.Println(apikey) }