예제 #1
0
def cancel_mirror(bot, update):
    mirror_message = update.message.reply_to_message
    with download_dict_lock:
        keys = download_dict.keys()
        dl = download_dict[mirror_message.message_id]
    if mirror_message is None or mirror_message.message_id not in keys:
        if '/mirror' in mirror_message.text or '/tarmirror' in mirror_message.text:
            msg = 'Message has already been cancelled'
        else:
            msg = 'Please reply to the /mirror message which was used to start the download to cancel it!'
        sendMessage(msg, bot, update)
        return
    if dl.status() == "Uploading":
        sendMessage("Upload in Progress, Don't Cancel it.", bot, update)
        return
    elif dl.status() == "Archiving":
        sendMessage("Archival in Progress, Don't Cancel it.", bot, update)
        return
    elif dl.status() != "Queued":
        download = dl.download()
        if len(download.followed_by_ids) != 0:
            downloads = aria2.get_downloads(download.followed_by_ids)
            aria2.pause(downloads)
        aria2.pause([download])
    else:
        dl._listener.onDownloadError("Download stopped by user!")
    sleep(1)  # Wait a Second For Aria2 To free Resources.
    clean_download(f'{DOWNLOAD_DIR}{mirror_message.message_id}/')
예제 #2
0
 def cancel_download(self):
     download = aria2.get_download(self.gid)
     if download.is_waiting:
         aria2.remove([download])
         self.__listener.onDownloadError("Cancelled by 👤User")
         return
     if len(download.followed_by_ids) != 0:
         downloads = aria2.get_downloads(download.followed_by_ids)
         aria2.pause(downloads)
     aria2.pause([download])
 def cancel_download(self):
     LOGGER.info(f"Cancelling Download: {self.name()}")
     download = self.aria_download()
     if download.is_waiting:
         aria2.remove([download])
         self.__listener.onDownloadError("Cancelled by user")
         return
     if len(download.followed_by_ids) != 0:
         downloads = aria2.get_downloads(download.followed_by_ids)
         aria2.pause(downloads)
     aria2.pause([download])
예제 #4
0
def cancel_all(update, bot):
    with download_dict_lock:
        for dlDetails in list(download_dict.values()):
            if not dlDetails.status() == "Uploading" or dlDetails.status(
            ) == "Archiving":
                aria2.pause([dlDetails.download()])
                continue
            if dlDetails.status() == "Queued":
                dlDetails._listener.onDownloadError(
                    "Download Manually Cancelled By user.")
    delete_all_messages()
    sendMessage('Cancelled all downloads!', update, bot)
    sleep(0.5)  # Wait a Second For Aria2 To free Resources.
    clean_download(DOWNLOAD_DIR)
예제 #5
0
def cancel_all(update, bot):
    with download_dict_lock:
        count = 0
        for dlDetails in list(download_dict.values()):
            if not dlDetails.status() == "Uploading" or dlDetails.status(
            ) == "Archiving":
                aria2.pause([dlDetails.download()])
                count += 1
                continue
            if dlDetails.status() == "Queued":
                count += 1
                dlDetails._listener.onDownloadError(
                    "Download Manually Cancelled By user.")
    delete_all_messages()
    sendMessage(f'Cancelled {count} downloads!', update, bot)
def cancel_mirror(update: Update, context):
    mirror_message = update.message.reply_to_message
    with download_dict_lock:
        keys = download_dict.keys()
        download = download_dict[mirror_message.message_id].download()
    if mirror_message is None or mirror_message.message_id not in keys:
        if '/mirror' in mirror_message.text or '/tarmirror' in mirror_message.text:
            msg = 'Message has already been cancelled'
        else:
            msg = 'Please reply to the /mirror message which was used to start the download to cancel it!'
        return
    else:
        msg = 'Download cancelled'
    sendMessage(msg, context, update)
    if len(download.followed_by_ids) != 0:
        downloads = aria2.get_downloads(download.followed_by_ids)
        aria2.pause(downloads)
    aria2.pause([download])
    with download_dict_lock:
        upload_helper = download_dict[mirror_message.message_id].upload_helper
    if upload_helper is not None:
        upload_helper.cancel()
    sleep(1)  #Wait a Second For Aria2 To free Resources.
    clean_download(f'{DOWNLOAD_DIR}{mirror_message.message_id}/')