30 lines
723 B
JavaScript
30 lines
723 B
JavaScript
const axios = require("axios");
|
|
|
|
module.exports = {
|
|
get: get,
|
|
hostnames: ["pixeldrain.com"],
|
|
tests: []
|
|
};
|
|
|
|
async function get(url, options) {
|
|
let id = url.split("/u/")?.[1]?.split("/")?.[0]?.split("?")?.[0];
|
|
|
|
if (!id) throw new Error("Could not extract ID from URL.");
|
|
|
|
let {data} = await axios({
|
|
url: `https://pixeldrain.com/api/file/${id}/info`,
|
|
validateStatus: function() {return true}
|
|
});
|
|
|
|
if (data?.success == true) {
|
|
return {
|
|
axiosData: {
|
|
url: `https://pixeldrain.com/api/file/${id}`
|
|
},
|
|
metadata: {
|
|
fileName: data.name,
|
|
size: data.size
|
|
}
|
|
}
|
|
} else throw new Error((data.message || "Could not find file. Check if the link is alive."));
|
|
} |