mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Pornol dl 1
This commit is contained in:
@@ -750,7 +750,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):
|
||||
@@ -1652,6 +1692,38 @@ 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="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
|
||||
# trunk-ignore(mypy/arg-type)
|
||||
|
||||
Reference in New Issue
Block a user