Update in the Rendering Routine

With the updates in the caching mechanism we check if the file exists in
cache if yes then extractedImagePath now points to that path else
we generate the name for the image and pass the image to extractImage
and it passes the default value if no embedded image was found and
checks in the lastfm api and the rest works the same.
This commit is contained in:
aditya-K2 2021-12-09 02:32:02 +05:30
parent 10566d87a1
commit 13b07bf7f7

View File

@ -75,10 +75,10 @@ func getImagePath(path string) string {
a, err := CONN.ListInfo(path) a, err := CONN.ListInfo(path)
var extractedImage string var extractedImage string
if err == nil && len(a) != 0 { if err == nil && len(a) != 0 {
if val, err := cache.GetFromCache(a[0]["artist"], a[0]["album"]); err == nil { if cache.Exists(a[0]["artist"], a[0]["album"]) {
extractedImage = val extractedImage = cache.GenerateName(a[0]["artist"], a[0]["album"])
} else { } else {
imagePath := cache.AddToCache(a[0]["artist"], a[0]["album"]) imagePath := cache.GenerateName(a[0]["artist"], a[0]["album"])
absPath := viper.GetString("MUSIC_DIRECTORY") + path absPath := viper.GetString("MUSIC_DIRECTORY") + path
extractedImage = extractImageFromFile(absPath, imagePath) extractedImage = extractImageFromFile(absPath, imagePath)
if extractedImage == viper.GetString("DEFAULT_IMAGE_PATH") && viper.GetString("GET_COVER_ART_FROM_LAST_FM") == "TRUE" { if extractedImage == viper.GetString("DEFAULT_IMAGE_PATH") && viper.GetString("GET_COVER_ART_FROM_LAST_FM") == "TRUE" {
@ -88,7 +88,6 @@ func getImagePath(path string) string {
extractedImage = downloadedImage extractedImage = downloadedImage
} else { } else {
NOTIFICATION_SERVER.Send("Falling Back to Default Image.") NOTIFICATION_SERVER.Send("Falling Back to Default Image.")
cache.PointToDefault(a[0]["artist"], a[0]["album"])
} }
} else { } else {
NOTIFICATION_SERVER.Send("Extracted Image Successfully") NOTIFICATION_SERVER.Send("Extracted Image Successfully")