From b8730f7f07bd0618dcd4614ba338e7972c7c9a69 Mon Sep 17 00:00:00 2001 From: lzzy12 Date: Mon, 6 Apr 2020 22:54:18 +0530 Subject: [PATCH] [Hotfix] Fix bug where the link have 302 request are treated as torrents Download.is_torrent introduced in aria2p v0.9.0 https://github.com/pawamoy/aria2p/issues/53 Signed-off-by: lzzy12 --- bot/helper/mirror_utils/download_utils/aria2_download.py | 8 +++++--- requirements.txt | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/bot/helper/mirror_utils/download_utils/aria2_download.py b/bot/helper/mirror_utils/download_utils/aria2_download.py index 2817ba9e3..ea449b778 100644 --- a/bot/helper/mirror_utils/download_utils/aria2_download.py +++ b/bot/helper/mirror_utils/download_utils/aria2_download.py @@ -24,11 +24,13 @@ def __onDownloadStarted(self, api, gid): def __onDownloadComplete(self, api: API, gid): with self._resource_lock: if self.gid == gid: - if api.get_download(gid).followed_by_ids: - self.gid = api.get_download(gid).followed_by_ids[0] + download = api.get_download(gid) + if download.followed_by_ids: + self.gid = download.followed_by_ids[0] with download_dict_lock: download_dict[self._listener.uid] = AriaDownloadStatus(self.gid, self._listener) - download_dict[self._listener.uid].is_torrent =True + if download.is_torrent: + download_dict[self._listener.uid].is_torrent = True update_all_messages() LOGGER.info(f'Changed gid from {gid} to {self.gid}') else: diff --git a/requirements.txt b/requirements.txt index 0a00afa29..6f9a64303 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,7 +2,7 @@ python-telegram-bot==12.2.0 google-api-python-client>=1.7.11,<1.7.20 google-auth-httplib2>=0.0.3,<0.1.0 google-auth-oauthlib>=0.4.1,<0.10.0 -aria2p>=0.3.0,<0.10.0 +aria2p>=0.9.0,<0.15.0 python-dotenv>=0.10 tenacity>=6.0.0 python-magic