26 lines
647 B
JavaScript
26 lines
647 B
JavaScript
const mega = require("megajs");
|
|
const lib = require("../lib");
|
|
|
|
module.exports = {
|
|
get: get,
|
|
hostnames: ["mega.nz", "mega.io", "mega.co.nz"],
|
|
tests: []
|
|
}
|
|
|
|
async function get(url, options) {
|
|
lib.log(`mega`, `Fetching file metadata...`, [], true, options);
|
|
let file = mega.File.fromURL(url);
|
|
await file.loadAttributes();
|
|
lib.log(`mega`, `Got metadata:`, [file])
|
|
if (file.type == 1) throw new Error("Cannot support files at the moment.");
|
|
lib.log(`mega`, `Fetching file download...`);
|
|
let stream = await file.download();
|
|
|
|
return {
|
|
stream: stream,
|
|
metadata: {
|
|
fileName: file.name,
|
|
size: file.size
|
|
}
|
|
};
|
|
} |