diff --git a/downloader/instagram.py b/downloader/instagram.py index ff701ea..604ae12 100644 --- a/downloader/instagram.py +++ b/downloader/instagram.py @@ -1,7 +1,6 @@ import io from urllib.parse import urlparse -import aiohttp import instaloader from downloader import base @@ -18,13 +17,12 @@ def __init__(self, url: str): async def download(self) -> io.BytesIO: post = instaloader.Post.from_shortcode(self.client.context, self.id) - async with aiohttp.ClientSession() as session: - async with session.get(post.video_url) as resp: - return ( - self.MESSAGE.format( - url=self.url, - description=post.title or post.caption, - likes=post.likes, - ), - io.BytesIO(await resp.read()), - ) + with self.client.context._session.get(post.video_url) as resp: + return ( + self.MESSAGE.format( + url=self.url, + description=post.title or post.caption, + likes=post.likes, + ), + io.BytesIO(resp.content), + ) diff --git a/main.py b/main.py index b7d19c5..c4aff4c 100644 --- a/main.py +++ b/main.py @@ -35,7 +35,7 @@ async def on_message(self, message: discord.Message): text, video = await client.download() except Exception as e: logging.error(f'Failed downloading {url}: {str(e)}') - new_message.edit(f'Failed downloading {url}. {message.author.mention}') + await new_message.edit(content=f'Failed downloading {url}. {message.author.mention}') return await message.channel.send(