Skip to content

Commit

Permalink
Added peers and seeders count for bittorent downloads
Browse files Browse the repository at this point in the history
Signed-off-by: lzzy12 <[email protected]>
  • Loading branch information
JaskaranSM authored and lzzy12 committed Feb 5, 2020
1 parent 96e623e commit 8cbe2c2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 5 additions & 1 deletion bot/helper/ext_utils/bot_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,11 @@ def get_readable_message():
if download.status() != MirrorStatus.STATUS_ARCHIVING:
msg += f"\n<code>{get_progress_bar_string(download)} {download.progress()}</code> of " \
f"{download.size()}" \
f" at {download.speed()}, ETA: {download.eta()}"
f" at {download.speed()}, ETA: {download.eta()} "
if download.status() == MirrorStatus.STATUS_DOWNLOADING:
if hasattr(download, 'is_torrent'):
msg += f"| P: {download.download().connections} " \
f"| S: {download.download().num_seeders}"
msg += "\n\n"
return msg

Expand Down
6 changes: 4 additions & 2 deletions bot/helper/mirror_utils/download_utils/aria2_download.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from bot import aria2
from bot import aria2,download_dict,download_dict_lock
from bot.helper.ext_utils.bot_utils import *
from .download_helper import DownloadHelper
from bot.helper.mirror_utils.status_utils.aria_download_status import AriaDownloadStatus
Expand Down Expand Up @@ -26,7 +26,9 @@ def __onDownloadComplete(self, api: API, gid):
if self.gid == gid:
if api.get_download(gid).followed_by_ids:
self.gid = api.get_download(gid).followed_by_ids[0]
download_dict[self._listener.uid] = AriaDownloadStatus(self.gid, self._listener)
with download_dict_lock:
download_dict[self._listener.uid] = AriaDownloadStatus(self.gid, self._listener)
download_dict[self._listener.uid].is_torrent =True
update_all_messages()
LOGGER.info(f'Changed gid from {gid} to {self.gid}')
else:
Expand Down

0 comments on commit 8cbe2c2

Please sign in to comment.