From 76e3db1946d488cd94f3390d5b4e22eeb0e4172c 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 | 6 ++++-- requirements.txt | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bot/helper/mirror_utils/download_utils/aria2_download.py b/bot/helper/mirror_utils/download_utils/aria2_download.py index aaa299f..22c403c 100644 --- a/bot/helper/mirror_utils/download_utils/aria2_download.py +++ b/bot/helper/mirror_utils/download_utils/aria2_download.py @@ -25,10 +25,12 @@ class AriaDownloadHelper(DownloadHelper): 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, self.__listener) + 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}') diff --git a/requirements.txt b/requirements.txt index 307a6f1..69fbbe1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,7 +3,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