.
This commit is contained in:
parent
57e97eb358
commit
d6de10e6da
1 changed files with 27 additions and 10 deletions
33
skullbot.py
33
skullbot.py
|
@ -217,13 +217,12 @@ ytdl_format_options = {
|
||||||
"format": "bestaudio/best",
|
"format": "bestaudio/best",
|
||||||
"cookiefile": "/app/cookies.txt",
|
"cookiefile": "/app/cookies.txt",
|
||||||
"extractor_args": {
|
"extractor_args": {
|
||||||
"youtube": {
|
"youtube": {"player_client": ["android"]}
|
||||||
"player_client": ["android", "web"],
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
"noplaylist": True,
|
"noplaylist": True,
|
||||||
"quiet": True,
|
"quiet": True,
|
||||||
}
|
}
|
||||||
|
|
||||||
ffmpeg_options = {
|
ffmpeg_options = {
|
||||||
"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5",
|
"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5",
|
||||||
"options": "-vn -ar 48000 -ac 2 -b:a 192k", # Optimized audio for Discord
|
"options": "-vn -ar 48000 -ac 2 -b:a 192k", # Optimized audio for Discord
|
||||||
|
@ -277,7 +276,6 @@ async def leave(ctx):
|
||||||
await ctx.voice_client.disconnect()
|
await ctx.voice_client.disconnect()
|
||||||
else:
|
else:
|
||||||
await ctx.send("I am not in a voice channel!")
|
await ctx.send("I am not in a voice channel!")
|
||||||
|
|
||||||
@bot.command(name="play")
|
@bot.command(name="play")
|
||||||
async def play(ctx, *, url):
|
async def play(ctx, *, url):
|
||||||
"""Streams Audio von einer YouTube URL"""
|
"""Streams Audio von einer YouTube URL"""
|
||||||
|
@ -288,15 +286,33 @@ async def play(ctx, *, url):
|
||||||
await ctx.send("Du bist in keinem Sprachkanal!")
|
await ctx.send("Du bist in keinem Sprachkanal!")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
player, error = await YTDLSource.from_url(url, loop=bot.loop, stream=True)
|
player, error = await YTDLSource.from_url(url, loop=bot.loop, stream=True)
|
||||||
if error or not player:
|
except Exception as e:
|
||||||
await ctx.send("⚠️ Konnte den Titel nicht abspielen. "
|
# Alle Fehler abfangen, z.B. DownloadError oder RuntimeError
|
||||||
"YouTube Restrictions blockieren möglicherweise den Zugriff.")
|
await ctx.send(
|
||||||
|
"⚠️ Konnte den Titel nicht abspielen. "
|
||||||
|
"YouTube Restrictions oder Format-Probleme blockieren möglicherweise den Zugriff."
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if error or not player:
|
||||||
|
await ctx.send(
|
||||||
|
"⚠️ Konnte den Titel nicht abspielen. "
|
||||||
|
"YouTube Restrictions blockieren möglicherweise den Zugriff."
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
# Stoppe ggf. laufenden Player
|
||||||
|
if ctx.voice_client.is_playing():
|
||||||
ctx.voice_client.stop()
|
ctx.voice_client.stop()
|
||||||
|
|
||||||
ctx.voice_client.play(player)
|
ctx.voice_client.play(player)
|
||||||
|
|
||||||
|
# Fallback für den Titel, falls None
|
||||||
|
title = getattr(player, "title", "Unbekanntes Lied")
|
||||||
|
|
||||||
|
# Buttons für Steuerung
|
||||||
stop_button = Button(label="Stop", style=discord.ButtonStyle.red)
|
stop_button = Button(label="Stop", style=discord.ButtonStyle.red)
|
||||||
pause_button = Button(label="Pause", style=discord.ButtonStyle.gray)
|
pause_button = Button(label="Pause", style=discord.ButtonStyle.gray)
|
||||||
resume_button = Button(label="Resume", style=discord.ButtonStyle.green)
|
resume_button = Button(label="Resume", style=discord.ButtonStyle.green)
|
||||||
|
@ -325,7 +341,8 @@ async def play(ctx, *, url):
|
||||||
view.add_item(pause_button)
|
view.add_item(pause_button)
|
||||||
view.add_item(resume_button)
|
view.add_item(resume_button)
|
||||||
|
|
||||||
await ctx.send(f"🎶 Now playing: **{player.title}**", view=view)
|
await ctx.send(f"🎶 Now playing: **{title}**", view=view)
|
||||||
|
|
||||||
|
|
||||||
@bot.command(name="stop", help="Stop the music.")
|
@bot.command(name="stop", help="Stop the music.")
|
||||||
async def stop(ctx):
|
async def stop(ctx):
|
||||||
|
|
Loading…
Add table
Reference in a new issue