The Algorithm now only inserts the color string over a range i.e
if 1, 2, 3 are matches then instead of adding individually at 1, 2, 3
it adds the color string at 1 and null color string at 3. Also Using
tcell Styles for highlighting the table cells.
Previously During Searching the Connection with mpd client was utilised
to get the title for the files this was slowing the search with large
number of files. Now after adding the Title field to the struct the
Field is accessed instead of querying the server this has lead to faster
searches.
[[ Please Note the Title of a Folder would be the last accessed
track from the FileMap. ]]
Searching the Global Database although is enough but I have felt a need to have a
quick and fast search option to search the current buffer.
Buffer Search is also one of the views It can be only turned on if the File Browser
has focus. ( Thinking of making it global ). The Searching is done
through the fuzzy module. FileNode now implements the Source Interface.
The Changed Function of the Search Bar checks for text changes and then
modifies the Matches Variable which is used by the Update Function to
Draw the Results. The Results have the Matching Characters Highlighted
Differently. Maximum of 15 results are displayed to avoid lag. Upon
Selecting the Result through the Search Bar navigation is possible and
selection of the item is done the same way it works for file Browser.
After Selection the Focus is returned Back to the File Browser. For The
Tracks only the title is used for searching.
Globals are no longer needed instead I am connecting each part with (
what were previously ) globals. Also Renaming SetRenderer to
ConnectRenderer which describes the name more precisely
Previously I was using the InsidePlaylist and InsideSearchView boolean
values which was a very hacky and unscalable way. Instead I am using a
focus map which can be queried to check which view has focus. Also the
Pages Implementation is kind of on hold because it has a lot of problems
for e.g resizing doesn't seem to work as I imagined. I am keeping that
Idea on hold right now.
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.
Instead of Caching by maintaining a cache file as mentioned here https://github.com/aditya-K2/goMP/issues/14#issuecomment-989141798
We can directly check if the file exists if it exists then we can just
pass the path to it else we can copy the default image to the path of
the imagePath
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.