bunny-dl v1.0.5
bunny-dl
A submission downloader for Inkbunny using bunny-wrapper
Installation
npm i bunny-dlor
yarn add bunny-dlPrerequisites
Enable “Enable API Access” in the in your Inkbunny Account Settings https://inkbunny.net/account.php
You also need to get a SID for API access via bunny-wrapper. See https://github.com/nodefox/bunny-wrapper#auth on how to do this.
Archiving Inkbunny Search Result Files
- Create
bunnyDl.Archiveobject via the methodbunnyDl.loadArchive- This method takes 1 argument and it is the directory that will be used for the archive. Make sure the directory exists!
- It returns a promise that always resolves to a
bunnyDl.Archiveobject.
const bunnyDl = require('bunny-dl');
bunnyDl.archiver.loadArchive('./archives')
.then(archive=>{
// do stuff with the archive
})Use the
bunnyDl.Archive.downloadmethod to download the files returned by a search.- The method accepts 4 arguments
dir- the name of the directory in the archive to save the files to. For example if the archive directory is./archivesand the dir argument isresthen the files is saved to./archives/resparams- the search params passed to the Inkbunny API. Read more at https://wiki.inkbunny.net/wiki/API#Parameters_4recursive- if true all files of the submission is downloaded and not just the main file.hooks- functions that are called on download progress. See Download Hooks
- The method accepts 4 arguments
Save the archive lock file using
bunnyDl.Archive.saveToFile()which will save the info regarding the files in the archive to the filearchived.ymlin the archive directory. This is used when updating the search results.
Example:
const bunnyDl = require('./index');
bunnyDl.archiver.loadArchive('./archives')
.then(archive=>{
archive.download('res', { pool_id: 'xxxx' }, true, {
file_complete: e=>console.log('File Complete', e.uri),
download_complete: ()=>{
archive.saveToFile();
}
})
})
.catch(console.error)Updating the Archive
Used to download previously untracked submissions while not downloading all the submissions already archived previously.
It only takes one argument and that being the download hooks.
Example
const bunnyDl = require('./index');
bunnyDl.archiver.loadArchive('./archives')
.then(archive=>{
archive.update({
file_complete: e=>console.log('File Complete', e.uri),
download_complete: ()=>{
archive.saveToFile();
}
});
})
.catch(console.error)Download Hooks
The module uses two download hooks, passed in a object to the download and update methods of the bunnyDl.Archive object.
file_complete hook
Gets triggered when a file is downloaded and is called with the following object as argument
{file: file, uri: e}file is the file data returned by the Inkbunny API and uri is the path to the file downloaded.
download_complete hook
Called when all the downloads are completed
It is recommended to save the archive in this hook using bunnyDl.Archive.saveToFile()