fb-downloads
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "fb-downloads", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Download the video and find the Facebook Uid using the profile link", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,4 @@ | ||
const request = require("request-promise"); | ||
const got = require("got"); | ||
const FormData = require('form-data'); | ||
const form = new FormData(); | ||
const cheerio = require("cheerio"); | ||
@@ -9,2 +11,5 @@ | ||
*/ | ||
// Change request-promise -> got + form-data | ||
async function getVideoUrl(url) { | ||
@@ -35,18 +40,16 @@ if (typeof url !== "string") throw new Error("URL must be string"); | ||
if (url.protocol !== "http:" && url.protocol !== "https:") throw new Error("Invalid protocol"); | ||
let options = { | ||
url: "https://fdown.net/download.php", | ||
formData: { | ||
URLz: url.toString() | ||
} | ||
}; | ||
form.append('URLz', url.toString()); | ||
let response; | ||
try { | ||
response = await request.post(options); | ||
response = (await got.post("https://fdown.net/download.php", { | ||
body: form | ||
})).body; | ||
} catch (e) { | ||
throw new Error("ERR: Error when trying to request or maybe link is invalid"); | ||
console.log(e); | ||
//throw new Error("ERR: Error when trying to request or maybe link is invalid"); | ||
} | ||
let $; | ||
@@ -57,10 +60,14 @@ | ||
} catch (e) { | ||
throw new Error("ERR: Error when trying to load response"); | ||
console.log(e); | ||
//throw new Error("ERR: Error when trying to load response"); | ||
} | ||
let obj = { | ||
sdLink: $("#sdlink").attr("href"), | ||
hdLink: $("#hdlink").attr("href") | ||
sd: $("#sdlink").attr("href"), | ||
hd: $("#hdlink").attr("href"), | ||
SD2: $('a .href').attr('#sdlink') | ||
}; | ||
$('a .href').attr('class'); | ||
//=> pear | ||
return obj; | ||
@@ -67,0 +74,0 @@ } |
5378
105