diff --git a/Twitter/downloader.py b/Twitter/downloader.py index d720989..891716e 100644 --- a/Twitter/downloader.py +++ b/Twitter/downloader.py @@ -3,6 +3,7 @@ from typing import TYPE_CHECKING import asyncio import gc import traceback +import aiohttp from Classifier.classifyHelper import classify_all from Database.x_classes import DownloadMode @@ -82,7 +83,8 @@ async def download_post(artist: x_accounts, tweet: Tweet, botData: RuntimeBotDat image_containers = [x_posts_images(tweet.id, idx, file = url) for idx, url in enumerate(media)] try: - downloaded_media = await tweetHelper.DownloadMedia(tweet.id, tweet.author.id, tweet.author.username, media, botData.session) + async with aiohttp.ClientSession() as session: + downloaded_media = await tweetHelper.DownloadMedia(tweet.id, tweet.author.id, tweet.author.username, media, session) except DOWNLOAD_FAIL as e: x_post.error_id = e.code diff --git a/commands.py b/commands.py index b0fc3f5..2bc8fb7 100644 --- a/commands.py +++ b/commands.py @@ -1,6 +1,7 @@ from __future__ import annotations from typing import TYPE_CHECKING +import aiohttp import requests from Classifier.classifyHelper import classify_all @@ -85,7 +86,8 @@ class Commands(commands.Cog): image_containers : list[x_posts_images] = [] media = await tweetHelper.GetTweetMediaUrls(tweet) image_containers = [x_posts_images(tweet.id, idx, file = url) for idx, url in enumerate(media)] - downloaded_media = await tweetHelper.DownloadMedia(tweet.id, tweet.author.id, tweet.author.username, media, botData.session) + async with aiohttp.ClientSession() as session: + downloaded_media = await tweetHelper.DownloadMedia(tweet.id, tweet.author.id, tweet.author.username, media, session) vox_labels = [] final_filtered_tags = {} diff --git a/runtimeBotData.py b/runtimeBotData.py index 3fa499c..aab0ab4 100644 --- a/runtimeBotData.py +++ b/runtimeBotData.py @@ -18,7 +18,7 @@ class RuntimeBotData: db : DatabaseController = None vox : VoxClassifier = None classifier : WDClassifier = None - session : aiohttp.ClientSession = None + #session : aiohttp.ClientSession = None xView : XView = None yView : YView = None @@ -33,4 +33,4 @@ class RuntimeBotData: self.yView = YView(self) #connector = aiohttp.TCPConnector(limit=60) - self.session = aiohttp.ClientSession() \ No newline at end of file + #self.session = aiohttp.ClientSession() \ No newline at end of file