From e4995ecefa218469a99ffcd2d833dbaf80f8e75b Mon Sep 17 00:00:00 2001 From: Manuel <10187614+TheTipo01@users.noreply.github.com> Date: Sun, 13 Sep 2020 22:57:20 +0200 Subject: [PATCH] Fix for empty plays while searching --- utilities.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/utilities.go b/utilities.go index 44c5431..2b09b75 100644 --- a/utilities.go +++ b/utilities.go @@ -116,11 +116,14 @@ func execQuery(query string, db *sql.DB) { //Adds a song to the db, so next time we encounter it we don't need to call youtube-dl func addToDb(el Queue) { - statement, _ := db.Prepare("INSERT INTO song (link, id, title, duration) VALUES(?, ?, ?, ?)") + //We check for empty strings, just to be sure + if el.link != "" && el.id != "" && el.title != "" && el.duration != "" { + statement, _ := db.Prepare("INSERT INTO song (link, id, title, duration) VALUES(?, ?, ?, ?)") - _, err := statement.Exec(el.link, el.id, el.title, el.duration) - if err != nil { - log.Println("Error inserting into the database,", err) + _, err := statement.Exec(el.link, el.id, el.title, el.duration) + if err != nil { + log.Println("Error inserting into the database,", err) + } } }