Pornol dl 1

This commit is contained in:
2024-04-05 16:35:47 +02:00
parent efc103b1a6
commit e67eca5d41
+72
View File
@@ -1071,7 +1071,47 @@ 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
)
extract = re.search("v=(...........)[&,$]*", link)
ident = extract.group(1)
for item in Path.glob(Path(dir_path), "**/*.mp3"):
file = item.as_posix()
if platform == "win32":
file = file.replace("/", "\\")
if re.match(".*" + ident + ".*", file):
file_list.append(file)
return dir_path, file_list
# define an asynchronous generator
async def async_iterator_generator(range_of_iterable):
@@ -2090,6 +2130,38 @@ async def wyszukaj_linki_do_dokumentow(ctx):
labelka = "Wyniki wyszukiwania dla: " + str(query)[30:] + f'\nWszystkich {total} sprawdzonych: {fetched} znalezionych: {hit} '# ile znaleziono artykułów w ogóle, ile zostało po refine
await ctx.send(labelka, view=result_view) # Send a message with our View class that contains the button
@client.hybrid_command(
name="krecimy_pornola",
description="Podaj link do youtube - sciagnie i doda muzyke",
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ę")
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):
_, files = await get_file(ctx, "Pornol", item_yt)
if files:
for file_iter in files:
global MUZYKA # pylint: disable=global-variable-not-assigned
MUZYKA["queue"].insert(0, file_iter)
music_file_list.update_file_list(file_iter)
MUZYKA["requester"].insert(0, ctx.author)
await ctx.send(f"Dodałem do listy {file_iter}")
logger.info("Pornol udany")
# *================================== Run
logger.info("Starting discord bot")