Batch hopefully

This commit is contained in:
2024-11-10 20:10:44 +01:00
parent bda7c6cc2e
commit 061bab8e6d
+79 -21
View File
@@ -606,27 +606,85 @@ class MusicModule(commands.Cog):
async def batch_download(self, ctx):
content_type = ctx.message.attachments[0].content_type
check = re.search ("text\/plain; *charset=(.*)", content_type, re.IGNORECASE)
if check:
file_bytes = await ctx.message.attachments[0].read()
text = file_bytes.decode(encoding=check.group(1))
self.logger.info(text)
lines = text.split("\n")
for link in lines:
self.logger.info(link)
pat = r"^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$"
self.logger.info("Verification")
if re.match(pat, link) and (re.match(".*youtube.*", link) or re.match(".*youtu.be.*", link)):
self.logger.info("%s to link do jutuba", link)
elif re.match(pat, link) and re.match(".*spotify.*", link):
self.logger.info("%s to link do spotify", link)
elif re.match(pat, link):
self.logger.info("%s to link do czegos", link)
else:
self.logger.info("Spierdalaj")
ctx.message.reply("Spierdalaj")
else:
self.logger.info("Spierdalaj")
ctx.message.reply("Spierdalaj")
await ctx.reply("Kurwa. Aleś mi roboty narobił... No nic. Ku radości. Skal!")
with ctx.typing():
if check:
file_bytes = await ctx.message.attachments[0].read()
text = file_bytes.decode(encoding=check.group(1))
self.logger.info(text)
lines = text.split("\n")
for link in lines:
link = link.strip()
self.logger.info(link)
pat = r"^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$"
self.logger.info("Verification")
if re.match(pat, link) and (re.match(".*youtube.*", link) or re.match(".*youtu.be.*", link)):
self.logger.info("%s to link do jutuba", link)
dir_path, files = await music_functions.get_file(
ctx, "Youtube", link
)
if files:
for file_iter in files:
global MUZYKA # pylint: disable=global-variable-not-assigned
MUZYKA["queue"].insert(0, file_iter)
music_functions.MUSIC_FILE_LIST.update_file_list(file_iter)
MUZYKA["requester"].insert(0, ctx.author)
await ctx.send(f"Dodałem do listy {file_iter}")
self.logger.info("Jutub udany")
elif re.match(pat, link) and re.match(".*spotify.*", link):
self.logger.info("%s to link do spotify", link)
dir_path, files = await music_functions.get_file(
ctx, "Spotify", link
)
if platform == "win32":
separator = "\\"
else:
separator = "/"
for file in files:
file_path = (
dir_path
+ separator
+ file["artist"]
+ " - "
+ file["name"]
+ ".mp3"
)
global MUZYKA # pylint: disable=global-variable-not-assigned
MUZYKA["queue"].insert(
0,
dir_path
+ separator
+ file["artist"]
+ " - "
+ file["name"]
+ ".mp3",
)
MUZYKA["requester"].insert(0, ctx.author)
music_functions.MUSIC_FILE_LIST.update_file_list(file_path)
await ctx.send(
f"Dodałem do listy {dir_path}{file['artist']} - + {file['name']}.mp3"
)
self.logger.info("Spotifaj udany")
elif re.match(pat, link):
self.logger.info("%s to link do czegos", link)
sciezka,files = await music_functions.get_file(
ctx, "Pornol", link
)
if files:
self.logger.info("Pornol udany")
await ctx.send(
f"Jest w tajnym archiwum pod adresem{sciezka})"
)
else:
self.logger.info("Spierdalaj")
await ctx.message.reply("Spierdalaj")
else:
self.logger.info("Spierdalaj")
await ctx.message.reply("Spierdalaj")
async def disconnect(self, ctx):