Skip to content

Commit

Permalink
Fix thumbnail
Browse files Browse the repository at this point in the history
Signed-off-by: anasty17 <e.anastayyar@gmail.com>
  • Loading branch information
anasty17 committed Nov 8, 2023
1 parent fdb2b6c commit d00f87c
Show file tree
Hide file tree
Showing 6 changed files with 518 additions and 414 deletions.
2 changes: 1 addition & 1 deletion bot/helper/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ async def beforeStart(self):
)

if is_telegram_link(self.thumb):
msg = await get_tg_link_message(self.thumb)
msg = (await get_tg_link_message(self.thumb))[0]
self.thumb = await createThumb(msg) if msg.photo or msg.document else ""

async def getTag(self, text: list):
Expand Down
8 changes: 2 additions & 6 deletions bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,8 @@ async def initiate_help_messages():
telegraph.create_page(
title="Mirror-Leech Command Usage", content=MIRROR_HELP_MESSAGE
),
telegraph.create_page(
title="YTDLP Command Usage", content=YT_HELP_MESSAGE
),
telegraph.create_page(
title="Clone Command Usage", content=CLONE_HELP_MESSAGE
),
telegraph.create_page(title="YTDLP Command Usage", content=YT_HELP_MESSAGE),
telegraph.create_page(title="Clone Command Usage", content=CLONE_HELP_MESSAGE),
)
buttons = ButtonMaker()
buttons.ubutton("Usage Guide", f"https://telegra.ph/{mirror['path']}")
Expand Down
6 changes: 4 additions & 2 deletions bot/helper/ext_utils/media_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ def getSplitSizeBytes(size):
return size


async def createThumb(msg):
async def createThumb(msg, _id=""):
if not _id:
_id = msg.id
path = "Thumbnails/"
if not await aiopath.isdir(path):
await mkdir(path)
photo_dir = await msg.download()
des_dir = f"{path}{msg.id}.jpg"
des_dir = f"{path}{_id}.jpg"
await sync_to_async(Image.open(photo_dir).convert("RGB").save, des_dir, "JPEG")
await aioremove(photo_dir)
return des_dir
Expand Down
8 changes: 6 additions & 2 deletions bot/helper/mirror_utils/rclone_utils/transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,9 @@ async def _get_gdrive_link(self, config_path, remote, rc_path, mime_type):

if code == 0:
result = loads(res)
fid = next((r["ID"] for r in result if r["Path"] == self._listener.name), "err")
fid = next(
(r["ID"] for r in result if r["Path"] == self._listener.name), "err"
)
link = (
f"https://drive.google.com/drive/folders/{fid}"
if mime_type == "Folder"
Expand Down Expand Up @@ -419,7 +421,9 @@ async def clone(self, config_path, src_remote, src_path, mime_type):
return (None, None) if self._is_cancelled else (link, destination)
else:
if mime_type != "Folder":
destination += f"/{self._listener.name}" if dst_path else self._listener.name
destination += (
f"/{self._listener.name}" if dst_path else self._listener.name
)

cmd = ["rclone", "link", "--config", config_path, destination]
res, err, code = await cmd_exec(cmd)
Expand Down
Loading

0 comments on commit d00f87c

Please sign in to comment.