cytrus
v1.0.6
Published
Cytrus implementation in Node.js
Readme
Cytrus
Cytrus allows you to watch available games and assets updates on the Ankama Launcher. It also allows to download them.
Cytrus is available through a CLI and Class usable in your own code
Table of contents
Installation
You can install the cytrus package with npm
npm i --save cytrusIf you want to use the cli everywhere you can add the -g option
CLI
You can follow the instruction of the help command of the cli
cytrus --help
cytrus [command] --helpCytrus
Watch a cytrus.json file
Kind: global class
Emits: assets:update, release:update
new Cytrus(saveFolder)
Constructor of the Cytrus class
| Param | Type | Description | | --- | --- | --- | | saveFolder | String | folder of where to save the last data of the remote cytrus.json file to not trigger at each cycle |
cytrus.watch(interval)
Watch remote cytrus.json file
Kind: instance method of Cytrus
| Param | Type | Description | | --- | --- | --- | | interval | Number | interval in ms |
cytrus.unwatch()
Remove the watcher of the remote cytrus.json file
Kind: instance method of Cytrus
"assets:update"
Assets update event
Kind: event emitted by Cytrus
Properties
| Name | Type | Description | | --- | --- | --- | | game | String | Game name | | releaseName | String | Release name of the asset updated (ex: main/beta ...) | | hash | String | undefined | New hash of the asset (undefined if deleted) |
"release:update"
Release update event
Kind: event emitted by Cytrus
Properties
| Name | Type | Description | | --- | --- | --- | | game | String | Game name | | platform | String | Platform of the release (ex: windows, darwin, linux ...) | | releaseName | String | Release name of the release updated (ex: main/beta ...) | | version | String | undefined | New hash of the release (undefined if deleted) |
Exemple
const { Cytrus } = require('cytrus');
const cytrus = new Cytrus();
cytrus.on('assets:update', ({ game, releaseName, hash }) => {
// an update of assets is available
});
cytrus.on('release:update', ({ game, releaseName, platform, version }) => {
// an update of game is available
});
cytrus.watch(60000); // 60 000 = 60 secReleaseDownloader
Download a release
Kind: global class
Emits: start, progress
Properties
| Name | Type | Description | | --- | --- | --- | | nbFilesDownloaded | Number | Number of files already downloaded | | nbFilesToDownload | Number | Number of files to update | | filesToUpdate | Array.<File> | List of file needed to be updated | | filesInDl | Array.<String> | List of filenames downloading |
- ReleaseDownloader
- new ReleaseDownloader(game, platform, releaseName, version, dest, options)
- .run() ⇒ Promise.<Array.<String>>
- "start"
- "progress"
- Exemple
new ReleaseDownloader(game, platform, releaseName, version, dest, options)
| Param | Type | Description | | --- | --- | --- | | game | String | Name of the game (ex: dofus) | | platform | String | Platform of the game (ex: windows/linux/darwin) | | releaseName | String | Release of the game (ex: main/beta/...) | | version | String | Version number (ex: 5.0_2.64.9.16) | | dest | String | Destination folder | | options | Object | Options of the Downloader (see each fields default) | | options.ignoredFragments | Array.<String> | Fragments ignored (ex: ['win32'] for dofus) | | options.maxConcurrentDl | Number | Maximum concurrent download (default: 10) |
releaseDownloader.run() ⇒ Promise.<Array.<String>>
Run the update (download files...) The update is finished after it resolve
Kind: instance method of ReleaseDownloader
Returns: Promise.<Array.<String>> - List of filenames being download
"start"
Starting download event
Kind: event emitted by ReleaseDownloader
Properties
| Name | Type | Description | | --- | --- | --- | | total | Number | Total number of files to dl |
"progress"
Progress download event
Kind: event emitted by ReleaseDownloader
Properties
| Name | Type | Description | | --- | --- | --- | | nbFilesDownloaded | Number | How many files are already downloaded | | filesDownloading | Array.<String> | List of filenames downloading |
Exemple
const { ReleaseDownloader } = require('cytrus');
const update = new ReleaseDownloader(game, platform, release, version, dest);
update.on('start', ({ total }) => {
// total {Number} = total number of files needed to be dl
});
update.on('progress', ({ nbFilesDownloaded, filesDownloading }) => {
// nbFilesDownloaded {Number} = number of files being downloaded
// filesDownloading {Array<string>} = filenames of file being downloaded
});
await update.run();
// update is finished hereAssetsDownloader
Download Launcher Assets of a game
Kind: global class
- AssetsDownloader
- new AssetsDownloader(game, hash, dest)
- .run() ⇒ Promise.<Array.<String>>
- Exemple
new AssetsDownloader(game, hash, dest)
Constructor of AssetsDownloader
| Param | Type | Description | | --- | --- | --- | | game | String | Name of the game | | hash | String | Hash id of the Launcher Assets (sha1) | | dest | String | Destination folder |
assetsDownloader.run() ⇒ Promise.<Array.<String>>
Run the download of the Launcher Assets The download is finished after it resolve
Kind: instance method of AssetsDownloader
Returns: Promise.<Array.<String>> - List of filenames being download
Exemple
const { AssetsDownloader } = require('cytrus');
const downloader = new AssetsDownloader(game, hash, dest);
await downloader.run();
// download is finished here