Use an event ID

This commit is contained in:
Gabriel Augendre 2018-11-19 18:21:56 +01:00
parent 03138d3809
commit f76e8bbf42
1 changed files with 7 additions and 3 deletions

View File

@ -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")
}