[Audio] Added [p]cache stats command (#861)

This commit is contained in:
Eric Hanko 2017-08-01 06:58:56 -07:00 committed by Twentysix
parent 493a729c30
commit 23db0208d0

View File

@ -44,7 +44,6 @@ youtube_dl_options = {
'format': 'bestaudio/best',
'extractaudio': True,
'audioformat': "mp3",
'outtmpl': '%(id)s',
'nocheckcertificate': True,
'ignoreerrors': True,
'quiet': True,
@ -195,7 +194,6 @@ class Playlist:
is_admin,
is_mod))
# def __del__() ?
def append_song(self, author, url):
@ -1192,18 +1190,20 @@ class Audio:
dumped = self._dump_cache()
await self.bot.say("Dumped {:.3f} MB of audio files.".format(dumped))
@cache.command(name="minimum")
async def cache_minimum(self):
"""Current minimum cache size, based on server count."""
await self.bot.say("The cache will be at least {:.3f} MB".format(
@cache.command(name='stats')
async def cache_stats(self):
"""Reports info about the cache.
- Current size of the cache.
- Maximum cache size. User setting or minimum, whichever is higher.
- Minimum cache size. Automatically determined by number of servers Red is running on.
"""
await self.bot.say("Cache stats:\n"
"Current size: {:.2f} MB\n"
"Maximum: {:.1f} MB\n"
"Minimum: {:.1f} MB".format(self._cache_size(),
self._cache_max(),
self._cache_min()))
@cache.command(name="size")
async def cache_size(self):
"""Current size of the cache."""
await self.bot.say("Cache is currently at {:.3f} MB.".format(
self._cache_size()))
@commands.group(pass_context=True, hidden=True, no_pm=True)
@checks.is_owner()
async def disconnect(self, ctx):
@ -1564,7 +1564,6 @@ class Audio:
self._delete_playlist(server, name)
await self.bot.say("Playlist deleted.")
@playlist.command(pass_context=True, no_pm=True, name="start")
async def playlist_start(self, ctx, name):
"""Plays a playlist."""
@ -1832,7 +1831,6 @@ class Audio:
is_admin = discord.utils.get(member.roles, name=admin_role) is not None
is_mod = discord.utils.get(member.roles, name=mod_role) is not None
nonbots = sum(not m.bot for m in member.voice_channel.voice_members)
alone = nonbots <= 1
@ -2199,6 +2197,7 @@ def check_files():
"Adding " + str(key) + " field to audio settings.json")
dataIO.save_json(settings_path, current)
def verify_ffmpeg_avconv():
try:
subprocess.call(["ffmpeg", "-version"], stdout=subprocess.DEVNULL)
@ -2214,6 +2213,7 @@ def verify_ffmpeg_avconv():
else:
return "avconv"
def setup(bot):
check_folders()
check_files()