Fix code style issues with Black

This commit is contained in:
Lint Action
2021-09-05 21:34:20 +00:00
parent a23dae8604
commit 7513c2138f
108 changed files with 5369 additions and 4858 deletions

View File

@@ -6,26 +6,24 @@ import youtube_dl
from discord.ext import commands
# Suppress noise about console usage from errors
youtube_dl.utils.bug_reports_message = lambda: ''
youtube_dl.utils.bug_reports_message = lambda: ""
ytdl_format_options = {
'format': 'bestaudio/best',
'outtmpl': '%(extractor)s-%(id)s-%(title)s.%(ext)s',
'restrictfilenames': True,
'noplaylist': True,
'nocheckcertificate': True,
'ignoreerrors': False,
'logtostderr': False,
'quiet': True,
'no_warnings': True,
'default_search': 'auto',
'source_address': '0.0.0.0' # bind to ipv4 since ipv6 addresses cause issues sometimes
"format": "bestaudio/best",
"outtmpl": "%(extractor)s-%(id)s-%(title)s.%(ext)s",
"restrictfilenames": True,
"noplaylist": True,
"nocheckcertificate": True,
"ignoreerrors": False,
"logtostderr": False,
"quiet": True,
"no_warnings": True,
"default_search": "auto",
"source_address": "0.0.0.0", # bind to ipv4 since ipv6 addresses cause issues sometimes
}
ffmpeg_options = {
'options': '-vn'
}
ffmpeg_options = {"options": "-vn"}
ytdl = youtube_dl.YoutubeDL(ytdl_format_options)
@@ -36,19 +34,19 @@ class YTDLSource(discord.PCMVolumeTransformer):
self.data = data
self.title = data.get('title')
self.url = data.get('url')
self.title = data.get("title")
self.url = data.get("url")
@classmethod
async def from_url(cls, url, *, loop=None, stream=False):
loop = loop or asyncio.get_event_loop()
data = await loop.run_in_executor(None, lambda: ytdl.extract_info(url, download=not stream))
if 'entries' in data:
if "entries" in data:
# take first item from a playlist
data = data['entries'][0]
data = data["entries"][0]
filename = data['url'] if stream else ytdl.prepare_filename(data)
filename = data["url"] if stream else ytdl.prepare_filename(data)
return cls(discord.FFmpegPCMAudio(filename, **ffmpeg_options), data=data)
@@ -70,9 +68,9 @@ class Music(commands.Cog):
"""Plays a file from the local filesystem"""
source = discord.PCMVolumeTransformer(discord.FFmpegPCMAudio(query))
ctx.voice_client.play(source, after=lambda e: print(f'Player error: {e}') if e else None)
ctx.voice_client.play(source, after=lambda e: print(f"Player error: {e}") if e else None)
await ctx.send(f'Now playing: {query}')
await ctx.send(f"Now playing: {query}")
@commands.command()
async def yt(self, ctx, *, url):
@@ -80,9 +78,9 @@ class Music(commands.Cog):
async with ctx.typing():
player = await YTDLSource.from_url(url, loop=self.bot.loop)
ctx.voice_client.play(player, after=lambda e: print(f'Player error: {e}') if e else None)
ctx.voice_client.play(player, after=lambda e: print(f"Player error: {e}") if e else None)
await ctx.send(f'Now playing: {player.title}')
await ctx.send(f"Now playing: {player.title}")
@commands.command()
async def stream(self, ctx, *, url):
@@ -90,9 +88,9 @@ class Music(commands.Cog):
async with ctx.typing():
player = await YTDLSource.from_url(url, loop=self.bot.loop, stream=True)
ctx.voice_client.play(player, after=lambda e: print(f'Player error: {e}') if e else None)
ctx.voice_client.play(player, after=lambda e: print(f"Player error: {e}") if e else None)
await ctx.send(f'Now playing: {player.title}')
await ctx.send(f"Now playing: {player.title}")
@commands.command()
async def volume(self, ctx, volume: int):
@@ -123,16 +121,19 @@ class Music(commands.Cog):
elif ctx.voice_client.is_playing():
ctx.voice_client.stop()
bot = commands.Bot(
command_prefix=commands.when_mentioned_or("!"),
description='Relatively simple music bot example',
intents=discord.Intents(guilds=True, guild_messages=True, voice_states=True)
description="Relatively simple music bot example",
intents=discord.Intents(guilds=True, guild_messages=True, voice_states=True),
)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user} (ID: {bot.user.id})')
print('------')
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
print("------")
bot.add_cog(Music(bot))
bot.run('token')
bot.run("token")