Just-Some-Bots / MusicBot

:musical_note: The original MusicBot for Discord (formerly SexualRhinoceros/MusicBot)
https://just-some-bots.github.io/MusicBot/
MIT License
3.12k stars 2.35k forks source link

Cache autoplay retention option & cache folder option. #2365

Closed itsTheFae closed 9 months ago

itsTheFae commented 10 months ago

Description

Yet another cache-related PR, and easily the biggest. This PR primarily focuses on adding the StorageRetainAutoPlay option to allow autoplaylist cache to be retained regardless of the other cache settings. The retention depends on SaveVideos being enabled still.
The option can only retain autoplaylist entries that have been stored in the cachemap. Cachemap entries are stored only when they are played. Rational for this design is taken from the fact that the autoplaylist.txt file can be an arbitrarily large size, and extracting information on each entry would be too time consuming to do at start-up.

Currently the "cachemap" is a JSON file associating filenames without extensions to their respective URL in the autoplaylist file. The cachmap is named using the filename stem of the autoplaylist file, and saved in the same folder with the original list file.

This PR resulted in a sizable refactor of the cache related code and some of the code related to autoplaylist management.
Much of it has been tested, but some edge cases like ContentTooShortError processing will likely need testing in the wild and future adjustment.

Related issues

1854

1549

173

This also checks a box in planned features issue # 1 ;)