Browse Source

Use an event ID

master
Gabriel Augendre 3 years ago
parent
commit
f76e8bbf42
  1. 10
      beater/youtubebeat.go

10
beater/youtubebeat.go

@ -35,10 +35,10 @@ func New(b *beat.Beat, cfg *common.Config) (beat.Beater, error) {
return bt, nil
}
func scrapeVideos(startId string, fieldsToSend chan common.MapStr, done chan bool) {
const BaseUrl = "https://www.youtube.com"
const BaseSuffix = "/watch?v="
const BaseUrl = "https://www.youtube.com"
const BaseSuffix = "/watch?v="
func scrapeVideos(startId string, fieldsToSend chan common.MapStr, done chan bool) {
videoCollector := colly.NewCollector(
colly.AllowedDomains("youtube.com", "www.youtube.com"),
colly.Async(true),
@ -117,6 +117,10 @@ func (bt *Youtubebeat) Run(b *beat.Beat) error {
Timestamp: time.Now(),
Fields: fields,
}
id := strings.Replace(fields["url"].(string), BaseUrl+BaseSuffix, "", -1)
event.SetID(id)
bt.client.Publish(event)
logp.Info("Event sent")
}

Loading…
Cancel
Save