https://github.com/alttiri/meganz-api
Unfinished Mega.nz API library. Only some of methods are implemented.
https://github.com/alttiri/meganz-api
javascript
Last synced: 2 months ago
JSON representation
Unfinished Mega.nz API library. Only some of methods are implemented.
- Host: GitHub
- URL: https://github.com/alttiri/meganz-api
- Owner: AlttiRi
- License: mit
- Created: 2020-03-10T04:47:45.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-10-18T22:10:15.000Z (over 3 years ago)
- Last Synced: 2025-06-21T06:06:03.683Z (about 1 year ago)
- Topics: javascript
- Language: JavaScript
- Homepage:
- Size: 357 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# meganz-api
**Uncomplited, demo Mega.nz JS library.**
It works, but supports only some features:
- listing,
- thumbnails/previews downloading.
---
- `npm ci`
- `npm run build`
To open a web demo run a http server in the root folder, then open a html file from `_examples-browser` directory.
Or try to use a Node.js demo from `_examples-node` directory. (Note: remove `import * as URLS from "./test-urls-private.js";` first and use your own Mega URL.)
---
### The example usage
Downloading of thumbnails:
https://github.com/AlttiRi/meganz-api/blob/master/_examples-node/ex-3.3-ok.js:
```js
import {saveFile} from "./util-node.js";
import {Nodes} from "../src/mega.js";
const nodeArray = await Nodes.nodes("https://mega.nz/..."); // Use your own URL
const promises = [];
let i = 0;
for (const node of nodeArray) {
if (Nodes.isMediaNode(node)) {
const index = (++i).toString().padStart(3, "0");
console.log(`${index} ${node.name}`);
const filename = `thumbnail-${index}-${node.id}.jpg`;
const downloaded = node.getThumbnail()
.then(thumb => {
void saveFile(thumb, filename, node.mtime);
});
promises.push(downloaded);
}
}
await Promise.all(promises);
```
- Multiple API requests are grouped within one API request when it's possible.
- Multiple thumbnails data are downloaded within one download request when it's possible.
- All similar HTTP connections are performed concurrently, but not more that 16 at one moment. See `Semaphore` class.
- Also it uses custom (much faster (up to x9 times)) convertation from `ArrayBuffer` to `WordArray` of CryptoJS library. See `/src/crypto.js`.
---
- 2022.02.20: This private repo was turned into public one.