mirror of
https://github.com/migatu/conjurer.git
synced 2026-07-14 21:38:38 +00:00
Batch hopefully
This commit is contained in:
+79
-21
@@ -606,27 +606,85 @@ class MusicModule(commands.Cog):
|
|||||||
async def batch_download(self, ctx):
|
async def batch_download(self, ctx):
|
||||||
content_type = ctx.message.attachments[0].content_type
|
content_type = ctx.message.attachments[0].content_type
|
||||||
check = re.search ("text\/plain; *charset=(.*)", content_type, re.IGNORECASE)
|
check = re.search ("text\/plain; *charset=(.*)", content_type, re.IGNORECASE)
|
||||||
if check:
|
await ctx.reply("Kurwa. Aleś mi roboty narobił... No nic. Ku radości. Skal!")
|
||||||
file_bytes = await ctx.message.attachments[0].read()
|
with ctx.typing():
|
||||||
text = file_bytes.decode(encoding=check.group(1))
|
if check:
|
||||||
self.logger.info(text)
|
file_bytes = await ctx.message.attachments[0].read()
|
||||||
lines = text.split("\n")
|
text = file_bytes.decode(encoding=check.group(1))
|
||||||
for link in lines:
|
self.logger.info(text)
|
||||||
self.logger.info(link)
|
lines = text.split("\n")
|
||||||
pat = r"^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$"
|
for link in lines:
|
||||||
self.logger.info("Verification")
|
link = link.strip()
|
||||||
if re.match(pat, link) and (re.match(".*youtube.*", link) or re.match(".*youtu.be.*", link)):
|
self.logger.info(link)
|
||||||
self.logger.info("%s to link do jutuba", link)
|
pat = r"^https?:\/\/(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)$"
|
||||||
elif re.match(pat, link) and re.match(".*spotify.*", link):
|
self.logger.info("Verification")
|
||||||
self.logger.info("%s to link do spotify", link)
|
if re.match(pat, link) and (re.match(".*youtube.*", link) or re.match(".*youtu.be.*", link)):
|
||||||
elif re.match(pat, link):
|
self.logger.info("%s to link do jutuba", link)
|
||||||
self.logger.info("%s to link do czegos", link)
|
dir_path, files = await music_functions.get_file(
|
||||||
else:
|
ctx, "Youtube", link
|
||||||
self.logger.info("Spierdalaj")
|
)
|
||||||
ctx.message.reply("Spierdalaj")
|
if files:
|
||||||
else:
|
for file_iter in files:
|
||||||
self.logger.info("Spierdalaj")
|
global MUZYKA # pylint: disable=global-variable-not-assigned
|
||||||
ctx.message.reply("Spierdalaj")
|
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):
|
async def disconnect(self, ctx):
|
||||||
|
|||||||
Reference in New Issue
Block a user