0.0.1 • Published 4 years ago
@ilgazil/oyster v0.0.1
oyster
Analyse urls and retrieve actual file download url from supported hosts (listed below).
Note: This project is still in development and is not fully ready. API signature can still change!
Install
Using npm
npm i -S @ilgazil/oyster
API definition
getHost
Identify an host with a url.
import oyster from 'oyster'
console.log(oyster.getHost('http://uptobox.com/randomhash')); // uptobox
console.log(oyster.getHost('http://no-host.com/randomhash')); // Prints an empty string
use
Register a custom host. If identifier match an existing one, it is replaced.
import oyster from 'oyster'
oyster.use({
identifier: 'stub',
match(url: string): boolean {
// ...
},
info(url: string): Promise<Info> {
// ...
},
download(url: string, options: DownloadOptions): Promise<ReadStream> {
// ...
},
});
info
Get file infos from host.
import oyster from 'oyster'
oyster
.info('http://uptobox.com/randomhash')
.then((info) => console.log)
;
// {
// url: 'http://uptobox.com/randomhash',
// filename: 'My.Winter.Holidays.Video.mp4',
// size: '289.60 MB',
// cooldown: 0
// }
download
Get download stream so you can stop or pause it if you need.
import oyster from 'oyster'
oyster
.download(
'https://uptobox.com/randomhash',
{
credentials: {
user: 'login',
password: 'pass',
},
target: './download.mp4'
}
)
.then((stream) => {
stream.on('close', () => console.log('File downloaded!'));
})
;
Supported hosts
:closed_lock_with_key: Supports premium account
- uptobox :closed_lock_with_key: