parent
16d91e36c4
commit
1373d5da05
|
|
@ -80,7 +80,7 @@ def getDownloadByGid(gid):
|
||||||
|
|
||||||
def getAllDownload():
|
def getAllDownload():
|
||||||
with download_dict_lock:
|
with download_dict_lock:
|
||||||
for dlDetails in list(download_dict.values()):
|
for dlDetails in download_dict.values():
|
||||||
if dlDetails.status() == MirrorStatus.STATUS_DOWNLOADING or dlDetails.status() == MirrorStatus.STATUS_WAITING:
|
if dlDetails.status() == MirrorStatus.STATUS_DOWNLOADING or dlDetails.status() == MirrorStatus.STATUS_WAITING:
|
||||||
if dlDetails:
|
if dlDetails:
|
||||||
return dlDetails
|
return dlDetails
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ from telegram.ext import CallbackQueryHandler
|
||||||
from bot import download_dict, download_dict_lock, BASE_URL, dispatcher, get_client
|
from bot import download_dict, download_dict_lock, BASE_URL, dispatcher, get_client
|
||||||
from bot.helper.mirror_utils.status_utils.qbit_download_status import QbDownloadStatus
|
from bot.helper.mirror_utils.status_utils.qbit_download_status import QbDownloadStatus
|
||||||
from bot.helper.telegram_helper.message_utils import *
|
from bot.helper.telegram_helper.message_utils import *
|
||||||
from bot.helper.ext_utils.bot_utils import setInterval, new_thread, MirrorStatus
|
from bot.helper.ext_utils.bot_utils import setInterval, new_thread, MirrorStatus, getDownloadByGid
|
||||||
from bot.helper.telegram_helper import button_build
|
from bot.helper.telegram_helper import button_build
|
||||||
|
|
||||||
LOGGER = logging.getLogger(__name__)
|
LOGGER = logging.getLogger(__name__)
|
||||||
|
|
@ -147,29 +147,24 @@ def get_confirm(update, context):
|
||||||
user_id = query.from_user.id
|
user_id = query.from_user.id
|
||||||
data = query.data
|
data = query.data
|
||||||
data = data.split(" ")
|
data = data.split(" ")
|
||||||
qdl = None
|
qdl = getDownloadByGid(data[1])
|
||||||
with download_dict_lock:
|
|
||||||
for dl in download_dict.values():
|
|
||||||
if dl.status() == MirrorStatus.STATUS_PAUSE:
|
|
||||||
if dl.gid() == data[1]:
|
|
||||||
qdl = dl
|
|
||||||
break
|
|
||||||
if qdl is not None:
|
if qdl is not None:
|
||||||
if user_id != qdl.listen().message.from_user.id:
|
if user_id != qdl.listener.message.from_user.id:
|
||||||
query.answer(text="Don't waste your time!", show_alert=True)
|
query.answer(text="Don't waste your time!", show_alert=True)
|
||||||
return
|
return
|
||||||
if data[0] == "pin":
|
if data[0] == "pin":
|
||||||
query.answer(text=data[2], show_alert=True)
|
query.answer(text=data[2], show_alert=True)
|
||||||
elif data[0] == "done":
|
elif data[0] == "done":
|
||||||
query.answer()
|
query.answer()
|
||||||
qdl.qbclient().torrents_resume(torrent_hashes=data[2])
|
qdl.client.torrents_resume(torrent_hashes=data[2])
|
||||||
sendStatusMessage(qdl.listen().update, qdl.listen().bot)
|
sendStatusMessage(qdl.listener.update, qdl.listener.bot)
|
||||||
deleteMessage(context.bot, qdl.mark())
|
deleteMessage(context.bot, qdl.markup)
|
||||||
else:
|
else:
|
||||||
query.answer(text="This task has been cancelled!", show_alert=True)
|
query.answer(text="This task has been cancelled!", show_alert=True)
|
||||||
query.delete_message()
|
query.delete_message()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_hash_magnet(mgt):
|
def get_hash_magnet(mgt):
|
||||||
if mgt.startswith('magnet:'):
|
if mgt.startswith('magnet:'):
|
||||||
_, _, _, _, query, _ = urlparse(mgt)
|
_, _, _, _, query, _ = urlparse(mgt)
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,10 @@ class QbDownloadStatus(Status):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.__gid = gid
|
self.__gid = gid
|
||||||
self.__hash = qbhash
|
self.__hash = qbhash
|
||||||
self.__client = client
|
self.client = client
|
||||||
self.markup = None
|
self.markup = None
|
||||||
self.__uid = listener.uid
|
self.__uid = listener.uid
|
||||||
self.__listener = listener
|
self.listener = listener
|
||||||
self.message = listener.message
|
self.message = listener.message
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -65,11 +65,7 @@ class QbDownloadStatus(Status):
|
||||||
return status
|
return status
|
||||||
|
|
||||||
def torrent_info(self):
|
def torrent_info(self):
|
||||||
tor_info = self.__client.torrents_info(torrent_hashes=self.__hash)
|
return self.client.torrents_info(torrent_hashes=self.__hash)[0]
|
||||||
if len(tor_info) == 0:
|
|
||||||
return None
|
|
||||||
else:
|
|
||||||
return tor_info[0]
|
|
||||||
|
|
||||||
def download(self):
|
def download(self):
|
||||||
return self
|
return self
|
||||||
|
|
@ -80,16 +76,7 @@ class QbDownloadStatus(Status):
|
||||||
def gid(self):
|
def gid(self):
|
||||||
return self.__gid
|
return self.__gid
|
||||||
|
|
||||||
def listen(self):
|
|
||||||
return self.__listener
|
|
||||||
|
|
||||||
def qbclient(self):
|
|
||||||
return self.__client
|
|
||||||
|
|
||||||
def mark(self):
|
|
||||||
return self.markup
|
|
||||||
|
|
||||||
def cancel_download(self):
|
def cancel_download(self):
|
||||||
LOGGER.info(f"Cancelling Download: {self.name()}")
|
LOGGER.info(f"Cancelling Download: {self.name()}")
|
||||||
self.__listener.onDownloadError('Download stopped by user!')
|
self.listener.onDownloadError('Download stopped by user!')
|
||||||
self.__client.torrents_delete(torrent_hashes=self.__hash)
|
self.client.torrents_delete(torrent_hashes=self.__hash)
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ class MirrorListener(listeners.MirrorListeners):
|
||||||
path = f'{DOWNLOAD_DIR}{self.uid}/{name}'
|
path = f'{DOWNLOAD_DIR}{self.uid}/{name}'
|
||||||
up_name = pathlib.PurePath(path).name
|
up_name = pathlib.PurePath(path).name
|
||||||
up_path = f'{DOWNLOAD_DIR}{self.uid}/{up_name}'
|
up_path = f'{DOWNLOAD_DIR}{self.uid}/{up_name}'
|
||||||
LOGGER.info(f"Upload Name: {name}")
|
LOGGER.info(f"Upload Name: {up_name}")
|
||||||
drive = gdriveTools.GoogleDriveHelper(up_name, self)
|
drive = gdriveTools.GoogleDriveHelper(up_name, self)
|
||||||
size = fs_utils.get_path_size(up_path)
|
size = fs_utils.get_path_size(up_path)
|
||||||
upload_status = UploadStatus(drive, size, gid, self)
|
upload_status = UploadStatus(drive, size, gid, self)
|
||||||
|
|
|
||||||
|
|
@ -40,12 +40,8 @@ def _watch(bot: Bot, update, isTar=False):
|
||||||
except IndexError:
|
except IndexError:
|
||||||
name = ""
|
name = ""
|
||||||
reply_to = update.message.reply_to_message
|
reply_to = update.message.reply_to_message
|
||||||
if reply_to is not None:
|
|
||||||
tag = reply_to.from_user.username
|
|
||||||
else:
|
|
||||||
tag = None
|
|
||||||
pswd = ""
|
pswd = ""
|
||||||
listener = MirrorListener(bot, update, pswd, isTar, tag)
|
listener = MirrorListener(bot, update, pswd, isTar)
|
||||||
ydl = YoutubeDLHelper(listener)
|
ydl = YoutubeDLHelper(listener)
|
||||||
threading.Thread(target=ydl.add_download,args=(link, f'{DOWNLOAD_DIR}{listener.uid}', qual, name)).start()
|
threading.Thread(target=ydl.add_download,args=(link, f'{DOWNLOAD_DIR}{listener.uid}', qual, name)).start()
|
||||||
sendStatusMessage(update, bot)
|
sendStatusMessage(update, bot)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue