soundcloid now half-works
This commit is contained in:
parent
740f62cafa
commit
6d69421305
1 changed files with 9 additions and 6 deletions
15
main.py
15
main.py
|
|
@ -45,27 +45,30 @@ async def play(ctx, url: str):
|
||||||
blocked_keywords = [line.strip().lower() for line in f if line.strip()]
|
blocked_keywords = [line.strip().lower() for line in f if line.strip()]
|
||||||
|
|
||||||
ydl_opts = {
|
ydl_opts = {
|
||||||
"format": "bestaudio",
|
"format": "bestaudio/best",
|
||||||
"quiet": True,
|
"quiet": True,
|
||||||
"default_search": "ytsearch"
|
"noplaylist": True,
|
||||||
|
"default_search": "auto",
|
||||||
}
|
}
|
||||||
|
|
||||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||||
info = ydl.extract_info(url, download=False)
|
info = ydl.extract_info(url, download=False)
|
||||||
title = info["title"].lower()
|
title = info["title"].lower()
|
||||||
|
|
||||||
if any(keyword in title for keyword in blocked_keywords):
|
if any(keyword in title for keyword in blocked_keywords):
|
||||||
await ctx.send(f"na ezt a fost nem jatszom le: `{info['title']}`")
|
await ctx.send(f"na ezt a fost nem jatszom le: `{info['title']}`")
|
||||||
return
|
return
|
||||||
|
|
||||||
audio_url = info["url"]
|
audio_url = info["url"]
|
||||||
|
print("Audio URL:", audio_url)
|
||||||
|
|
||||||
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 -protocol_whitelist file,http,https,tcp,tls,crypto",
|
||||||
"options": "-vn"
|
"options": "-vn"
|
||||||
}
|
}
|
||||||
|
|
||||||
voice_client.play(FFmpegPCMAudio(audio_url, **ffmpeg_options), after=lambda e: print(f"Finished playing: {e}"))
|
voice_client.play(
|
||||||
|
FFmpegPCMAudio(audio_url, **ffmpeg_options),
|
||||||
|
after=lambda e: print(f"Finished playing: {e}")
|
||||||
|
)
|
||||||
await ctx.send(f"most ez a fos szól: {info['title']}")
|
await ctx.send(f"most ez a fos szól: {info['title']}")
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue