Intermediate commits (oldest → newest):
- Coroutine fix
- Pornol dl 1
- Pornol dl2
This commit is contained in:
2025-10-30 16:58:57 +01:00
parent d914711559
commit 50986860e9
+72 -4
View File
@@ -663,7 +663,7 @@ async def get_file(ctx, source, link):
url_dict["songs"] = file_list
url_data["urls"].append(url_dict.copy())
file_name_f = youtube_download.default_filename
youtube_download.download_songs(
coro = asyncio.to_thread(youtube_download.download_songs,
songs=url_data,
output_dir=MUSIC_FOLDER,
format_str="bestaudio/best",
@@ -676,6 +676,7 @@ async def get_file(ctx, source, link):
multi_core=0,
proxy="",
)
_ = await coro
dir_path = (url_dict["save_path"].resolve()).as_posix()
if platform == "win32":
dir_path = dir_path.replace("/", "\\")
@@ -728,7 +729,8 @@ async def get_file(ctx, source, link):
ydl_opts["postprocessors"].append(mp3_postprocess_opts.copy())
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
try:
ydl.download([query])
coro = asyncio.to_thread(ydl.download, [query])
_ = await coro
except Exception as exce: # pylint: disable=broad-exception-caught
logger.error(exce)
logger.info(
@@ -748,7 +750,40 @@ async def get_file(ctx, source, link):
)
logger.error("Wrong link provided youtube: %s", link)
return "", None
elif source == "Pornol":
dir_path = ""
file_list = []
query = link
sponsorblock_postprocessor = [
{
"key": "SponsorBlock",
"categories": ["skip_non_music_sections"],
},
{
"key": "ModifyChapters",
"remove_sponsor_segments": ["music_offtopic"],
"force_keyframes": True,
},
]
# TODO: Make sponsorblock work
sponsorblock_postprocessor = []
dir_path = "/home/pi/RetroPie/movies/porn"
ydl_opts = {
"postprocessors": sponsorblock_postprocessor,
"paths": {"home": dir_path},
}
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
try:
coro = asyncio.to_thread(ydl.download, [query])
_ = await coro
except Exception as exce: # pylint: disable=broad-exception-caught
logger.error(exce)
logger.info(
"Failed to download %s, make sure yt_dlp is up to date", link
)
file_list.append("wiadomo co wiadomo gdzie")
return dir_path, file_list
# define an asynchronous generator
async def async_iterator_generator(range_of_iterable):
@@ -1300,8 +1335,7 @@ async def zagraj_mi_kawalek(ctx):
async with ctx.typing():
search_time_glob = datetime.now()
logger.info("Zaczynam szukać timestamp %s", datetime.now())
coro = asyncio.to_thread(wyszukaj,ctx=ctx)
file = await coro
file = await wyszukaj(ctx=ctx)
logger.info(
"Koniec szukania(timestamp %s zajęło %s",
datetime.now(),
@@ -1651,6 +1685,40 @@ async def parametry_muzyki_mego_ludu(ctx, ile_historii=1500, ile_slow_kluczowych
global MUZYKA_MOJEGO_LUDU_PLAJLISTA # pylint: disable=global-statement
MUZYKA_MOJEGO_LUDU_PLAJLISTA = jak_dluga_plejlista
@client.hybrid_command(
name="krecimy_pornola",
description="Wiadomo co, dla kogo i po co",
guild=discord.Object(id=664789470779932693),
)
async def krecimy_pornola(ctx):
"""
Download a music number from youtube.
:param ctx: ctx stands for "context" and is a parameter commonly used in Discord.py commands. It
represents the context in which the command was invoked, including information such as the message,
the channel, the server, and the user who invoked the command. It allows the command to interact
with the Discord API and
"""
await ctx.send("Dej mnie chwilkę")
allowed = False
for role in ctx.author.roles:
if role.name == "Bartender":
allowed = True
if allowed:
logger.info("Pornol")
async with ctx.typing():
# wyciagnij linka z kontekstu
content = ctx.message.content.split()
for item_yt in content:
if re.match("http.*", item_yt):
sciezka, files = await get_file(ctx, "Pornol", item_yt)
if files:
logger.info("Pornol udany")
ctx.reply(f"Jest w tajnym archiwum pod adresem{sciezka})")
else:
ctx.reply("Jak ładnie szefa poprosisz.")
# *================================== Run
# trunk-ignore(mypy/arg-type)