auto-downloader
v0.1.6
Published
An automatic background downloader using an file as input
Downloads
2
Readme
Auto Downloader
Installation
npm
npm install auto-downloader
Yarn
yarn add auto-downloader
Configuration
You can customize the default behavior of the Auto Downloader passing options.
Here are the defaults:
{
"path": {
"errors": "data/var",
"progress": "data/var",
"canceled": "data/var",
"finished": "data/var",
"queue": "."
},
"output": "downloads",
"parallelDonwloads": 3,
"postDownload": null
}
path
: The directories used in the application.
path.errors
: The directory that the errors of the downloads will be saved. The errors.json
file have this format:
{
"url": "...",
"filename": "...",
"message": "..."
}
path.progress
: The directory that the progress of the downloads will be saved. The filename is progress.json
. The format is generated by request-progress:
{
"download-link": {
"time": {
"elapsed": 0, // The total elapsed seconds since the start (3 decimals)
"remaining": 0 // The remaining seconds to finish (3 decimals)
},
"speed": 0, // The download speed in bytes/sec
"percent": 0, // Overall percent (between 0 to 1)
"size": {
"total": 0, // The total payload size in bytes
"transferred": 0 // The transferred payload size in bytes
}
}
}
path.canceled
: The directory that the information of canceled downloads will be saved. The canceled.json
have this format:
[
{
"url": "...",
"filename": "..."
}
]
path.finished
: The directory that the information of completed downloads will be saved. The finished.json
have this format:
[
{
"url": "...",
"filename": "..."
}
]
path.queue
: The location of the file with the links to downloads. The format is here.
output
: The directory where the files will be downloaded.
parallelDownloads
: The number of downloads performed at the same time.
postDownload
: An shell command with will be executed when the downloads are
finished. The command will have access to three constants of the download:
%filename%
: The name of the file downloaded with extension.%filedir%
: The name of the directory that the file has been downloaded.%filepath%
: The absolute path to the file downloaded.
Usage
const downloader = require('auto-downloader');
downloader(options);
Download
You can paste on this file every link that you want to download.
By default, the filename of the downloads will be download-<link>
without extension. To save the file with an specific name and extension, you could the >
operator:
link > filename.extension
You can use absolute paths too:
link > /home/user/filename.extension
Cancel Downloads
In the progress.json
file, in addition to the downloads information, you will have the hash
key in each download of the array. You can copy this hash and use the !
operator to cancel that download:
!hash