From ee7cc71879b823c19eec7f76f2090e3ea0e7bf8e Mon Sep 17 00:00:00 2001 From: aditya-K2 Date: Sat, 13 Nov 2021 11:44:49 +0530 Subject: [PATCH] Update to Rendering Routine. Following changes have been made: 1. The OpenImage() function now checks if the image returned by the mp3 and flac parsers is the default image if it is true then it will query the lastfm api for cover image if no error is received then the path to that downloaded image is passed else the path is unchanged ( that is it will be the default image ) --- render.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/render.go b/render.go index c384bc0..8df442e 100644 --- a/render.go +++ b/render.go @@ -43,7 +43,18 @@ func openImage(path string, c chan string) { fw, fh := getFontWidth() var im *ueberzug.Image if path != "stop" { - img2, _ := getImg(extractImageFromFile(path)) + absPath := viper.GetString("MUSIC_DIRECTORY") + path + extractedImage := extractImageFromFile(absPath) + if extractedImage == viper.GetString("DEFAULT_IMAGE_PATH") && viper.GetString("GET_COVER_ART_FROM_LAST_FM") == "TRUE" { + a, err := CONN.ListInfo(path) + if err == nil && len(a) != 0 { + downloadedImage, err := getImageFromLastFM(a[0]["artist"], a[0]["album"]) + if err == nil { + extractedImage = downloadedImage + } + } + } + img2, _ := getImg(extractedImage) im, _ = ueberzug.NewImage(img2, int(float32(IMG_X)*fw)+viper.GetInt("ADDITIONAL_PADDING_X"), int(float32(IMG_Y)*fh)+viper.GetInt("ADDITIONAL_PADDING_Y")) } d := <-c