This fixes The Issue when a song with unknown duration was played then the percentage was
calculated wrong and the slice was getting out of bound.
fix : I have added a check for the duration.
Sometimes the image is not found and for those artist/albums there is no
way for pointing the image path to default image path so some helper
functions have been added so that we can point them to default Image.
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 Functions have been added :
1. SetCacheDir : Sets the Cache Directory
2. CHANGE AddToCache the image path is now the Cache Directory +
image Path
The Following New Functions have been added
1. AddToCache Adds to the CACHE_LIST map
2. GetFromCache Retrieves path from CACHE_LIST map
3. Rename WriteToCache -> WriteCache()
4. GenerateName now replaces spaces with underscores.
Sometimes on adding a song/artist/album all songs were added to the
playlist. This was because of the wrong order in which the array
elements were stored. Hopefully this fixes it.
This is a very simple Implementation of searching like playlist view
and file view there is an boolean value that is checked in the draw
function to check if whether or not to draw the Search view
Later on I am thinking of rewriting this whole mechanism with pages
which will make this more modular.
The Boolean values are set and unset by the navigation menu and the done
functions.
BUG FIX :
1. Artist Added Notification moved out of for loop
this caused it to sustain for more than one second.
FEATURE :
Added Functionality to pass addAndPlay bool which defines if
the title is played after adding or not. Helpful for l and a
keybindings
AddToPlaylist adds the album, artist, track to the playlist.
Some Minor changes to UpdateSearchView have been done:
Added Colors.
AddAlbum Function also has been changed.
Following Functions have been added:
1. GenerateContentSlice :
This Function Generates a slice of interfaces which are mostly
string slices or strings. The Reason for this is the random
nature of the maps. and also this makes adding songs to playlist
a breeze as we only need the row number to add the
song/album/artist to the playlist.
2. UpdateSearchView :
this is the Update function for the search view which just
iterates over the interface slice and draws their content to the
expanded view
3. AddAlbum :
As the Name Suggests adds all the contents of the Album to the
Playlist
4. AddTitle :
As the Name Suggests adds the track to the Playlist
5. QueryArtistTreeForAlbums :
This Functions finds all the albums named album in the Artist
tree and returns an album map. This is because two artists can
have same album names too.
Album Map is basically a [2]string{artist, album} -> path to all the songs in the album
Following Functions Have been changed:
1. AddArtist :
It now sends notifications.
Following Functions Have been removed:
1. GetAlbumTree
2. PrintAlbumTree
Album Trees are no longer needed
The Following Utility Functions have been added:
1. AddAlbum : Adds Album to the Playlist
2. AddArtist : Adds all the Track of the Artist to Playlist
3. QueryArtistTree : Searches the Artist Tree for the track name
and returns a map of [ artist, album, track ] -> path
Artist tree is a map that maps the artist names to a map of albums
Similarly the Album tree is a map that maps album names to their
content.
Album trees are generated from artist trees.
the content of the album is a map of title to the destinationFile.
Using a Notification Server that will keep listening for notifications
and will render the notification upon receiving read notification.go for
more information
The Caching Module Caches the images that have been extracted and for
persistence writes the images to a cache file.
In the cache file the data is stored by tab separated values
`%s\t%s\t%s`
the cache is first loaded in the memory ( CACHE_LIST ) during the start of application
and then extracted images are added to the map CACHE_LIST which is
writtern to the cache file before exiting the program.
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 )
Following Changes have been made:
1. conn -> CONN
2. CONN is now a global as a lot of functions were requiring it and
passing them as a parameter didn't seem intuitive.
3. In progressBar.go now we are sending only the short path instead of
absolute path.
Following Changes have been made:
1. Using GenerateMappings() function
2. Using the KEY_MAP map to handle events which shortens the code
and adds modularity.
Following Changes Have been made:
1. Rename KMAP -> SPECIAL_KEYS
2. Added Default Mappings through KEY_MAPPINGS
so when the config is read it will change the KEY_MAPPINGS map
which will be then used by the handler function for events.
Following Changes have been made in addition to
`https://github.com/aditya-K2/goMP/pull/5/commits/1572a460b042c25c93d4d5ed27b1a75432a53464`
1. config.go :
ReadMappings Reads Array for each function
Basically we are going to define mappings like this :
```yml
Function :
- first mapping
- second mapping
- third mapping
`````
2. kMap.go :
GetAsciiValues will help us to get e.Rune() for the event for
the handler function. So basically we will have a keymappings map
generated which will help us to handle events.
for e.g
if an user has defined following mappings
````yml
togglePlayBack :
- P
- p
- B
````
then the keymappings map will look like this
[]keymappings = {
GetAsciiValues("P") : togglePlayBack(),
GetAsciiValues("p") : togglePlayBack(),
GetAsciiValues("B") : togglePlayBack(),
}
so when the handler function will get an event e
we will just pass it to this keymappings map i.e
keymappings[e] which will return the function
Following changes have been made:
1. Moving the getMusicDirectory() to config package
2. Moving the config.go to config package
3. Generating a Function Map that will be used for Generating keymappings in main.go
4. Using the config packge in main.go
5. First we are reading the user configuration values with
config.ReadConfig() and then we are reading the mappings with
config.ReadMappings() with the help of Function Map that is
generated.
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
the position is now calculated with the help of font_pixel_width and
font_pixel_height
font_pixel_width = Total X Pixels / Total Columns
font_pixel_height = Total Y Pixels / Total Rows
which is then multiplied to row and column co-ordinates of preview box to get it's
pixel position.