2024-04-29 16:29:54 -07:00
|
|
|
package cron
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/domain"
|
|
|
|
"git.jamestombleson.com/jtom38/newsbot-api/internal/services/input"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (c *Cron) CheckYoutube() {
|
|
|
|
// Add call to the db to request youtube sources.
|
|
|
|
sources, err := c.repo.Sources.ListBySource(*c.ctx, 0, 100, domain.SourceCollectorYoutube)
|
|
|
|
if err != nil {
|
|
|
|
log.Printf("[Youtube] No sources found to query - %v\r", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
for _, source := range sources {
|
|
|
|
if !source.Enabled {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("[YouTube] Checking '%v'...", source.DisplayName)
|
|
|
|
|
|
|
|
yc := input.NewYoutubeClient(source)
|
|
|
|
raw, err := yc.GetContent()
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
}
|
|
|
|
c.SaveNewArticles(raw, domain.SourceCollectorYoutube)
|
|
|
|
}
|
|
|
|
log.Print("[YouTube] Done!")
|
|
|
|
}
|
2024-04-29 16:49:52 -07:00
|
|
|
|
|
|
|
|