Skip to content

Commit

Permalink
Fix for empty plays while searching
Browse files Browse the repository at this point in the history
  • Loading branch information
TheTipo01 committed Sep 13, 2020
1 parent 6236fbb commit e4995ec
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}

Expand Down

0 comments on commit e4995ec

Please sign in to comment.