func SendNotification(result []string) { var notify *notificator.Notificator notify = notificator.New(notificator.Options{ DefaultIcon: Icon, AppName: "Zabbix", }) for _, val := range result { notify.Push("Server Alert", val, Icon, notificator.UR_CRITICAL) } }
func main() { var database DataBase var notify *notificator.Notificator notify = notificator.New(notificator.Options{ DefaultIcon: "icon/default.png", AppName: "Youtube", }) database.session, _ = mgo.Dial("localhost:27017") defer database.session.Close() fmt.Println("session connected to mongodb") c := database.session.DB("youtube").C("toDownload") var R *Result //fmt.Println(*R) iter := c.Find(nil).Sort("$natural").Tail(time.Second * 5) for { for iter.Next(&R) { Res := R fmt.Println("Added result : " + Res.Url) notify.Push("Youtube Video", Res.Url, "", notificator.UR_NORMAL) mack.Notify(Res.Url, "Youtube") if !R.isDownloaded(&database) { go func(Res *Result) { err := R.download() if err == nil { Res.updateDB(&database) fmt.Println("waiting for : " + Res.Url) if err != nil { fmt.Println("Error while downloading video : " + Res.Url) fmt.Println(err) } } }(Res) } else { log.Printf("Video is already downloaded ", R.Url) } } } }
// Notify pushes a notification on the desktop of the user. func (s *Song) Notify(nt *notificator.Notificator) { title := strings.Title(strings.ToLower(s.Titre)) artist := strings.Title(strings.ToLower(s.Interpretemorceau)) album := strings.Title(strings.ToLower(s.Titrealbum)) nt.Push(title, fmt.Sprintf("%s (%s)", artist, album), "") }
func (s *songAPIType) push(nt *notificator.Notificator) { title := strings.Title(strings.ToLower(s.Titre)) artist := strings.Title(strings.ToLower(s.Interpretemorceau)) album := strings.Title(strings.ToLower(s.Titrealbum)) nt.Push(title, artist+" ("+album+")", "") }