'Refactored by Sourcery'
This commit is contained in:
parent
5239dfa96a
commit
e5ab2cec85
|
|
@ -157,14 +157,13 @@ def get_readable_message():
|
|||
msg += "\n\n"
|
||||
if STATUS_LIMIT is not None and index == STATUS_LIMIT:
|
||||
break
|
||||
if STATUS_LIMIT is not None:
|
||||
if dick_no > STATUS_LIMIT:
|
||||
msg += f"<b>Page:</b> <code>{PAGE_NO}</code>/<code>{pages}</code> | <b>Tasks:</b> <code>{dick_no}</code>\n"
|
||||
buttons = button_build.ButtonMaker()
|
||||
buttons.sbutton("Previous", "pre")
|
||||
buttons.sbutton("Next", "nex")
|
||||
button = InlineKeyboardMarkup(buttons.build_menu(2))
|
||||
return msg, button
|
||||
if STATUS_LIMIT is not None and dick_no > STATUS_LIMIT:
|
||||
msg += f"<b>Page:</b> <code>{PAGE_NO}</code>/<code>{pages}</code> | <b>Tasks:</b> <code>{dick_no}</code>\n"
|
||||
buttons = button_build.ButtonMaker()
|
||||
buttons.sbutton("Previous", "pre")
|
||||
buttons.sbutton("Next", "nex")
|
||||
button = InlineKeyboardMarkup(buttons.build_menu(2))
|
||||
return msg, button
|
||||
return msg, ""
|
||||
|
||||
def flip(update, context):
|
||||
|
|
|
|||
|
|
@ -160,23 +160,23 @@ def get_mime_type(file_path):
|
|||
return mime_type
|
||||
|
||||
def take_ss(video_file, duration):
|
||||
des_dir = f"Thumbnails"
|
||||
des_dir = 'Thumbnails'
|
||||
if not os.path.exists(des_dir):
|
||||
os.mkdir(des_dir)
|
||||
des_dir = os.path.join(des_dir, f"{round(time.time())}.jpg")
|
||||
duration = int(duration) / 2
|
||||
subprocess.run(["ffmpeg", "-hide_banner", "-loglevel", "error", "-ss", str(duration),
|
||||
"-i", video_file, "-vframes", "1", des_dir])
|
||||
if os.path.lexists(des_dir):
|
||||
Image.open(des_dir).convert("RGB").save(des_dir)
|
||||
img = Image.open(des_dir)
|
||||
w, h = img.size
|
||||
img.resize((320, h))
|
||||
img.save(des_dir, "JPEG")
|
||||
return des_dir, 320, h
|
||||
else:
|
||||
if not os.path.lexists(des_dir):
|
||||
return None, 0, 0
|
||||
|
||||
Image.open(des_dir).convert("RGB").save(des_dir)
|
||||
img = Image.open(des_dir)
|
||||
w, h = img.size
|
||||
img.resize((320, h))
|
||||
img.save(des_dir, "JPEG")
|
||||
return des_dir, 320, h
|
||||
|
||||
def split(path, size, split_size, start_time=0, i=1):
|
||||
out_dir = os.path.dirname(path)
|
||||
base_name = os.path.basename(path)
|
||||
|
|
|
|||
|
|
@ -215,20 +215,20 @@ def get_confirm(update, context):
|
|||
data = query.data
|
||||
data = data.split(" ")
|
||||
qdl = getDownloadByGid(data[1])
|
||||
if qdl is not None:
|
||||
if user_id != qdl.listener.message.from_user.id:
|
||||
query.answer(text="Don't waste your time!", show_alert=True)
|
||||
elif data[0] == "pin":
|
||||
query.answer(text=data[2], show_alert=True)
|
||||
elif data[0] == "done":
|
||||
query.answer()
|
||||
qdl.client.torrents_resume(torrent_hashes=data[2])
|
||||
sendStatusMessage(qdl.listener.update, qdl.listener.bot)
|
||||
query.message.delete()
|
||||
else:
|
||||
if qdl is None:
|
||||
query.answer(text="This task has been cancelled!", show_alert=True)
|
||||
query.message.delete()
|
||||
|
||||
elif user_id != qdl.listener.message.from_user.id:
|
||||
query.answer(text="Don't waste your time!", show_alert=True)
|
||||
elif data[0] == "pin":
|
||||
query.answer(text=data[2], show_alert=True)
|
||||
elif data[0] == "done":
|
||||
query.answer()
|
||||
qdl.client.torrents_resume(torrent_hashes=data[2])
|
||||
sendStatusMessage(qdl.listener.update, qdl.listener.bot)
|
||||
query.message.delete()
|
||||
|
||||
|
||||
def get_hash_magnet(mgt):
|
||||
if mgt.startswith('magnet:'):
|
||||
|
|
|
|||
|
|
@ -81,15 +81,11 @@ class TgUploader:
|
|||
if self.thumb is None and thumb is not None and os.path.lexists(thumb):
|
||||
os.remove(thumb)
|
||||
elif file.upper().endswith(AUDIO_SUFFIXES):
|
||||
title = None
|
||||
artist = None
|
||||
metadata = extractMetadata(createParser(up_path))
|
||||
if metadata.has("duration"):
|
||||
duration = metadata.get('duration').seconds
|
||||
if metadata.has("title"):
|
||||
title = metadata.get("title")
|
||||
if metadata.has("artist"):
|
||||
artist = metadata.get("artist")
|
||||
title = metadata.get("title") if metadata.has("title") else None
|
||||
artist = metadata.get("artist") if metadata.has("artist") else None
|
||||
self.sent_msg = self.sent_msg.reply_audio(audio=up_path,
|
||||
quote=True,
|
||||
caption=file,
|
||||
|
|
|
|||
|
|
@ -20,19 +20,16 @@ def leechSet(update, context):
|
|||
user_id = update.message.from_user.id
|
||||
path = f"Thumbnails/{user_id}.jpg"
|
||||
msg = f"Leech Type for {user_id} user is "
|
||||
if user_id in AS_DOC_USERS:
|
||||
if (
|
||||
user_id in AS_DOC_USERS
|
||||
or user_id not in AS_MEDIA_USERS
|
||||
and AS_DOCUMENT
|
||||
):
|
||||
msg += "DOCUMENT"
|
||||
elif user_id in AS_MEDIA_USERS:
|
||||
msg += "MEDIA"
|
||||
elif AS_DOCUMENT:
|
||||
msg += "DOCUMENT"
|
||||
elif not AS_DOCUMENT:
|
||||
else:
|
||||
msg += "MEDIA"
|
||||
msg += "\nCustom Thmubnail "
|
||||
if os.path.exists(path):
|
||||
msg += "exists"
|
||||
else:
|
||||
msg += "not exists"
|
||||
msg += "exists" if os.path.exists(path) else "not exists"
|
||||
buttons = button_build.ButtonMaker()
|
||||
buttons.sbutton("As Document", f"doc {user_id}")
|
||||
buttons.sbutton("As Media", f"med {user_id}")
|
||||
|
|
@ -51,15 +48,17 @@ def setLeechType(update, context):
|
|||
if user_id != int(data[1]):
|
||||
query.answer(text="Not Yours!", show_alert=True)
|
||||
elif data[0] == "doc":
|
||||
if user_id in AS_DOC_USERS:
|
||||
if (
|
||||
user_id in AS_DOC_USERS
|
||||
or user_id not in AS_MEDIA_USERS
|
||||
and AS_DOCUMENT
|
||||
):
|
||||
query.answer(text="Already As Document!", show_alert=True)
|
||||
elif user_id in AS_MEDIA_USERS:
|
||||
AS_MEDIA_USERS.remove(user_id)
|
||||
AS_DOC_USERS.add(user_id)
|
||||
query.answer(text="Done!", show_alert=True)
|
||||
elif AS_DOCUMENT:
|
||||
query.answer(text="Already As Document!", show_alert=True)
|
||||
elif not AS_DOCUMENT:
|
||||
else:
|
||||
AS_DOC_USERS.add(user_id)
|
||||
query.answer(text="Done!", show_alert=True)
|
||||
elif data[0] == "med":
|
||||
|
|
@ -67,13 +66,11 @@ def setLeechType(update, context):
|
|||
AS_DOC_USERS.remove(user_id)
|
||||
AS_MEDIA_USERS.add(user_id)
|
||||
query.answer(text="Done!", show_alert=True)
|
||||
elif user_id in AS_MEDIA_USERS:
|
||||
elif user_id in AS_MEDIA_USERS or not AS_DOCUMENT:
|
||||
query.answer(text="Already As Media!", show_alert=True)
|
||||
elif AS_DOCUMENT:
|
||||
else:
|
||||
AS_MEDIA_USERS.add(user_id)
|
||||
query.answer(text="Done!", show_alert=True)
|
||||
elif not AS_DOCUMENT:
|
||||
query.answer(text="Already As Media!", show_alert=True)
|
||||
elif data[0] == "thumb":
|
||||
path = f"Thumbnails/{user_id}.jpg"
|
||||
if os.path.lexists(path):
|
||||
|
|
|
|||
Loading…
Reference in New Issue