-add torrents to qbit with link don't end with .torrent
-fix yt-dl download status for individual downloads only

Signed-off-by: anas <e.anastayyar@gmail.com>
This commit is contained in:
anas 2021-08-17 21:35:35 +03:00
parent f0d1bfea9a
commit 9b2ac7ad2d
2 changed files with 8 additions and 4 deletions

View File

@ -46,7 +46,6 @@ class YoutubeDLHelper(DownloadHelper):
'usenetrc': True 'usenetrc': True
} }
self.__download_speed = 0 self.__download_speed = 0
self.download_speed_readable = ''
self.downloaded_bytes = 0 self.downloaded_bytes = 0
self.size = 0 self.size = 0
self.is_playlist = False self.is_playlist = False
@ -88,8 +87,12 @@ class YoutubeDLHelper(DownloadHelper):
except ZeroDivisionError: except ZeroDivisionError:
pass pass
else: else:
self.download_speed_readable = d['_speed_str'] self.size = d['total_bytes']
self.downloaded_bytes = d['downloaded_bytes'] self.downloaded_bytes = d['downloaded_bytes']
try:
self.progress = (self.downloaded_bytes / self.size) * 100
except ZeroDivisionError:
pass
def __onDownloadStart(self): def __onDownloadStart(self):
with download_dict_lock: with download_dict_lock:

View File

@ -30,6 +30,7 @@ import threading
import re import re
import random import random
import string import string
import time
ariaDlManager = AriaDownloadHelper() ariaDlManager = AriaDownloadHelper()
ariaDlManager.start_listener() ariaDlManager.start_listener()
@ -241,10 +242,10 @@ def _mirror(bot, update, isTar=False, extract=False, isZip=False, isQbit=False):
if link == "qbs": if link == "qbs":
qbitsel = True qbitsel = True
link = message_args[2] 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) resp = requests.get(link)
if resp.status_code == 200: 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: with open(file_name, "wb") as f:
f.write(resp.content) f.write(resp.content)
link = f"/usr/src/app/{file_name}" link = f"/usr/src/app/{file_name}"