From 9b2ac7ad2d5fbfc661b2b5042ae5afab9eda57d8 Mon Sep 17 00:00:00 2001 From: anas Date: Tue, 17 Aug 2021 21:35:35 +0300 Subject: [PATCH] Fix -add torrents to qbit with link don't end with .torrent -fix yt-dl download status for individual downloads only Signed-off-by: anas --- .../download_utils/youtube_dl_download_helper.py | 7 +++++-- bot/modules/mirror.py | 5 +++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py b/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py index 19aa7aa..0326696 100644 --- a/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py +++ b/bot/helper/mirror_utils/download_utils/youtube_dl_download_helper.py @@ -46,7 +46,6 @@ class YoutubeDLHelper(DownloadHelper): 'usenetrc': True } self.__download_speed = 0 - self.download_speed_readable = '' self.downloaded_bytes = 0 self.size = 0 self.is_playlist = False @@ -88,8 +87,12 @@ class YoutubeDLHelper(DownloadHelper): except ZeroDivisionError: pass else: - self.download_speed_readable = d['_speed_str'] + self.size = d['total_bytes'] self.downloaded_bytes = d['downloaded_bytes'] + try: + self.progress = (self.downloaded_bytes / self.size) * 100 + except ZeroDivisionError: + pass def __onDownloadStart(self): with download_dict_lock: diff --git a/bot/modules/mirror.py b/bot/modules/mirror.py index b4a98cd..ab52469 100644 --- a/bot/modules/mirror.py +++ b/bot/modules/mirror.py @@ -30,6 +30,7 @@ import threading import re import random import string +import time ariaDlManager = AriaDownloadHelper() ariaDlManager.start_listener() @@ -241,10 +242,10 @@ def _mirror(bot, update, isTar=False, extract=False, isZip=False, isQbit=False): if link == "qbs": qbitsel = True link = message_args[2] - if bot_utils.is_url(link) and link.endswith(".torrent"): + if not bot_utils.is_magnet(link): resp = requests.get(link) if resp.status_code == 200: - file_name = link.split('/')[-1].replace(" ", "_") + file_name = str(time.time()).replace(".","") + ".torrent" with open(file_name, "wb") as f: f.write(resp.content) link = f"/usr/src/app/{file_name}"