Skip to content

Commit

Permalink
Uo
Browse files Browse the repository at this point in the history
  • Loading branch information
gillzxo authored Sep 17, 2020
1 parent dff076b commit 6a39746
Showing 1 changed file with 73 additions and 7 deletions.
80 changes: 73 additions & 7 deletions tobrot/plugins/incoming_message_fn.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
from tobrot.helper_funcs.youtube_dl_extractor import extract_youtube_dl_formats
from tobrot.helper_funcs.admin_check import AdminCheck
from tobrot.helper_funcs.ytplaylist import yt_playlist_downg
from tobrot.helper_funcs.cloneHelper import CloneHelper

async def incoming_purge_message_f(client, message):
"""/purge command"""
Expand Down Expand Up @@ -101,16 +100,75 @@ async def incoming_message_f(client, message):
f"<b>API Error</b>: {cf_name}"
)
#
async def incoming_gdrive_message_f(client, message):
"""/gleech command"""
i_m_sefg = await message.reply_text("processing", quote=True)
is_zip = False
is_unzip = False
is_unrar = False
is_untar = False
if len(message.command) > 1:
if message.command[1] == "archive":
is_zip = True
elif message.command[1] == "unzip":
is_unzip = True
elif message.command[1] == "unrar":
is_unrar = True
elif message.command[1] == "untar":
is_untar = True
# get link from the incoming message
dl_url, cf_name, _, _ = await extract_link(message.reply_to_message, "GLEECH")
LOGGER.info(dl_url)
LOGGER.info(cf_name)
if dl_url is not None:
await i_m_sefg.edit_text("extracting links")
# start the aria2c daemon
aria_i_p = await aria_start()
LOGGER.info(aria_i_p)
current_user_id = message.from_user.id
# create an unique directory
new_download_location = os.path.join(
DOWNLOAD_LOCATION,
str(current_user_id),
str(time.time())
)
# create download directory, if not exist
if not os.path.isdir(new_download_location):
os.makedirs(new_download_location)
await i_m_sefg.edit_text("trying to download")
# try to download the "link"
await call_apropriate_function_g(
aria_i_p,
dl_url,
new_download_location,
i_m_sefg,
is_zip,
cf_name,
is_unzip,
is_unrar,
is_untar,
message
)
else:
await i_m_sefg.edit_text(
"**FCUK**! wat have you entered. \nPlease read /help \n"
f"<b>API Error</b>: {cf_name}"
)


async def incoming_youtube_dl_f(client, message):
""" /ytdl command """
i_m_sefg = await message.reply_text("**ProcessinG..**", quote=True)
i_m_sefg = await message.reply_text("processing", quote=True)
# LOGGER.info(message)
# extract link from message
dl_url, cf_name, yt_dl_user_name, yt_dl_pass_word = await extract_link(
message.reply_to_message, "YTDL"
)
LOGGER.info(dl_url)
#if len(message.command) > 1:
#if message.command[1] == "gdrive":
#with open('blame_my_knowledge.txt', 'w+') as gg:
#gg.write("I am noob and don't know what to do that's why I have did this")
LOGGER.info(cf_name)
if dl_url is not None:
await i_m_sefg.edit_text("extracting links")
Expand All @@ -123,14 +181,19 @@ async def incoming_youtube_dl_f(client, message):
# list the formats, and display in button markup formats
thumb_image, text_message, reply_markup = await extract_youtube_dl_formats(
dl_url,
# cf_name,
cf_name,
yt_dl_user_name,
yt_dl_pass_word,
user_working_dir
)
print(thumb_image)
req = requests.get(f"{thumb_image}")
gau_tam = f"{current_user_id}.jpg"
open(gau_tam, 'wb').write(req.content)
if thumb_image is not None:
await message.reply_photo(
photo=thumb_image,
#text_message,
photo=gau_tam,
quote=True,
caption=text_message,
reply_markup=reply_markup
Expand All @@ -146,15 +209,18 @@ async def incoming_youtube_dl_f(client, message):
"**FCUK**! wat have you entered. \nPlease read /help \n"
f"<b>API Error</b>: {cf_name}"
)

#playlist
async def g_yt_playlist(client, message):
""" /pytdl command """
#i_m_sefg = await message.reply_text("Processing...you should wait🤗", quote=True)
usr_id = message.from_user.id
G_DRIVE = False
if len(message.command) > 1:
if message.command[1] == "gdrive":
G_DRIVE = True
if 'youtube.com/playlist' in message.reply_to_message.text:
i_m_sefg = await message.reply_text("Downloading all videos from given playlist. Please wait! 🥱", quote=True)
i_m_sefg = await message.reply_text("Downloading...you should wait🤗", quote=True)
await yt_playlist_downg(message.reply_to_message, i_m_sefg, G_DRIVE)

else:
await message.reply_text("This command works for youtube playlists only!!")
await message.reply_text("Reply to youtube playlist link only 🙄")q

0 comments on commit 6a39746

Please sign in to comment.