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.
Now before rendering the image the image is checked in the cache if it
exists then the image is rendered else it is added to the cache and then
rendered.
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 )
Image is now resized according to the font size and also a new
globals.go files is added which contains all the globals.
the Image width can also be changed according to use by adding or
substracting pixels to it by changing the globals
IMAGE_WIDTH_EXTRA_X, IMAGE_WIDTH_EXTRA_Y
Also, now there is no need to specify where the music directory is
the mpd.conf file in `~/.config/mpd/` is automatically parsed for music
directory
As specified in #2 the image gets out of the preview box, the previous
commit solves the problem but the image placement in the box differs
from terminal to terminal it might need some extra padding so user can
define some extra padding in the render.go
render.go : This File Contains the implementation for the Renderer which
is a channel that will receive strings to the path of decoded images)
the path is sent with the help of Send() method. The Start() method
starts the go routine OpenImage() this function blocks the image as it
keeps listening over the channel. which helps in not drawing the image
again and again.
imageUtils.go: This file contains the helper function for decoding
images.