Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
thoriqazzikraa committed Aug 24, 2023
1 parent 97255ce commit c5e0c21
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@
`const scrape = require("scrape-websitee")`

# Endpoints
- uploadFile
`scrape.uploadFile(buffer)`

- enhanceImg
`scrape.enhanceImg(buffer)`

- twitterdl2
`scrape.twitterdl2(url)`

Expand Down
1 change: 1 addition & 0 deletions function/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
exports.num = require("./number")
exports.checkUrl = require("./isUrl")
9 changes: 9 additions & 0 deletions function/isUrl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function isUrl(url) {
return url.match(
new RegExp(
/https?:\/\/(www\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&/=]*)/gi
)
);
}

module.exports = { isUrl };
41 changes: 40 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,50 @@ const baseFilmApik = "https://filmapik21.live/";
const baseOtakudesu = "https://otakudesu.lol/";
const baseCerpen = "http://cerpenmu.com/100-cerpen-kiriman-terbaru";
const baseSSS = "https://instasupersave.com/";
const { fromBuffer, fileTypeStream } = require("file-type-cjs-fix");
const got = require("got");
const fs = require("fs");

const { num } = require("./function");
const { num, checkUrl } = require("./function");

const pickRandom = async (ext) => {
return ext[Math.floor(Math.random() * ext.length)];
};

async function uploadFile(buffer) {
const { ext, mime } = await fromBuffer(buffer);
const filePath = `temp/${Date.now()}.${ext}`;
fs.writeFileSync(filePath, file);
const fileData = fs.readFileSync(filePath);
const form = new URLSearchParams();
form.append("files[]", fileData, `${Date.now()}.${ext}`);
const { data } = await axios(`https://pomf2.lain.la/upload.php`, {
method: "post",
data: form,
});
return data;
}

async function enhanceImg(buffer) {
const media = await uploadFile(image);
const { data } = await axios(`https://toolsapi.spyne.ai/api/forward`, {
method: "post",
data: {
image_url: media.files[0].url,
scale: 4,
save_params: {
extension: ".png",
quality: 95,
},
},
headers: {
"content-type": "application/json",
accept: "*/*",
},
});
return data;
}

async function twitterdl2(url) {
try {
const result = { status: true, type: "", media: [] };
Expand Down Expand Up @@ -507,6 +544,8 @@ async function filmApikDl(url) {
}

module.exports = {
uploadFile,
enhanceImg,
twitterdl2,
igdl2,
threads,
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"homepage": "https://github.com/thoriqazzikraa/scrape-website#readme",
"dependencies": {
"axios": "^1.4.0",
"cheerio": "^1.0.0-rc.12"
"cheerio": "^1.0.0-rc.12",
"file-type-cjs-fix": "^1.1.1",
"got": "8.3.2"
}
}

0 comments on commit c5e0c21

Please sign in to comment.