Esempio n. 1
0
 def add_download(self, link: str, path, listener, filename):
     if is_magnet(link):
         download = aria2.add_magnet(link, {'dir': path, 'out': filename})
     else:
         download = aria2.add_uris([link], {'dir': path, 'out': filename})
     if download.error_message:  # no need to proceed further at this point
         listener.onDownloadError(download.error_message)
         return
     with download_dict_lock:
         download_dict[listener.uid] = AriaDownloadStatus(download.gid, listener)
         LOGGER.info(f"Started: {download.gid} DIR:{download.dir} ")
Esempio n. 2
0
 def add_download(self, link: str):
     if is_magnet(link):
         download = aria2.add_magnet(link, {'dir': DOWNLOAD_DIR + str(self.__listener.uid)})
         self.__is_torrent = True
     else:
         if link.endswith('.torrent'):
             self.__is_torrent = True
         download = aria2.add_uris([link], {'dir': DOWNLOAD_DIR + str(self.__listener.uid)})
     with download_dict_lock:
         download_dict[self.__listener.message.message_id] = DownloadStatus(download.gid,
                                                                            self.__listener.uid)
     self.__listener.onDownloadStarted(link)
     self.__update_download_status()
Esempio n. 3
0
def add_aria2c_download(link: str, path, listener, filename):
    if is_magnet(link):
        download = aria2.add_magnet(link, {'dir': path, 'out': filename})
    else:
        download = aria2.add_uris([link], {'dir': path, 'out': filename})
    if download.error_message:
        error = str(download.error_message).replace('<', ' ').replace('>', ' ')
        LOGGER.info(f"Download Error: {error}")
        return sendMessage(error, listener.bot, listener.update)
    with download_dict_lock:
        download_dict[listener.uid] = AriaDownloadStatus(
            download.gid, listener)
        LOGGER.info(f"Started: {download.gid} DIR: {download.dir} ")
    sendStatusMessage(listener.update, listener.bot)
 def add_download(self, link: str, path):
     if is_magnet(link):
         download = aria2.add_magnet(link, {'dir': path})
     else:
         download = aria2.add_uris([link], {'dir': path})
     self.gid = download.gid
     with download_dict_lock:
         download_dict[self.__listener.uid] = AriaDownloadStatus(self, self.__listener)
     if download.error_message:
         self.__listener.onDownloadError(download.error_message)
         return
     LOGGER.info(f"Started: {self.gid} DIR:{download.dir} ")
     aria2.listen_to_notifications(threaded=True, on_download_start=self.__onDownloadStarted,
                                   on_download_error=self.__onDownloadError,
                                   on_download_pause=self.__onDownloadPause,
                                   on_download_stop=self.__onDownloadStopped,
                                   on_download_complete=self.__onDownloadComplete)