4 Commits

Author SHA1 Message Date
Indrawan I
55e88b57d1 fix: proper null type for video, assets and slice slash on fetchBody (#4)
* broken slash will broke it

* xhamster fix embed assets

* xnxx fix nullable assets

* xvideos fix nullable assets

* it should be none instead null type

* pre release
2023-04-19 21:40:53 +07:00
Indrawan I
5f641096a2 chore(release): 1.6.1-alpha, flyctl deploy
chore(release): 1.6.1-alpha, flyctl deploy
2023-04-18 14:47:19 +07:00
Indrawan I
fcf2cff58b ci: add separate testing cases for each site
ci: add separate testing cases for each site
2023-04-18 13:13:28 +07:00
Indrawan I
0f88b3ce5b ci: tdd
ci: tdd
2023-04-18 11:36:31 +07:00
11 changed files with 24 additions and 19 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "lustpress", "name": "lustpress",
"version": "1.6.1-alpha", "version": "1.6.2-alpha",
"description": "RESTful and experimental API for PornHub and other porn sites, which official is lack even isn't exist.", "description": "RESTful and experimental API for PornHub and other porn sites, which official is lack even isn't exist.",
"main": "build/src/index.js", "main": "build/src/index.js",
"scripts": { "scripts": {

View File

@@ -40,6 +40,7 @@ class LustPress {
return res.body; return res.body;
} else { } else {
console.log("Fetching from source"); console.log("Fetching from source");
url = url.replace(/\/\//g, "/");
const res = await p({ const res = await p({
url: url, url: url,
"headers": { "headers": {

View File

@@ -1,5 +1,6 @@
import { load } from "cheerio"; import { load } from "cheerio";
import LustPress from "../../LustPress"; import LustPress from "../../LustPress";
import c from "../../utils/options";
import { ISearchVideoData } from "../../interfaces"; import { ISearchVideoData } from "../../interfaces";
const lust = new LustPress(); const lust = new LustPress();
@@ -33,7 +34,7 @@ export async function scrapeContent(url: string) {
image: $(el).find("img").attr("src"), image: $(el).find("img").attr("src"),
duration: duration[i], duration: duration[i],
views: views[i], views: views[i],
video: $(el).attr("data-previewvideo"), video: `${c.XHAMSTER}/embed/${link?.split("-").pop()}`
}; };
}).get(); }).get();
} }

View File

@@ -6,7 +6,6 @@ const lust = new LustPress();
export async function scrapeContent(url: string) { export async function scrapeContent(url: string) {
try { try {
console.log(url);
const resolve = await lust.fetchBody(url); const resolve = await lust.fetchBody(url);
const $ = load(resolve); const $ = load(resolve);
@@ -27,6 +26,7 @@ export async function scrapeContent(url: string) {
thumbnail: string; thumbnail: string;
bigimg: string; bigimg: string;
video: string; video: string;
embed: string;
constructor() { constructor() {
const thumb = $("script") const thumb = $("script")
.map((i, el) => { .map((i, el) => {
@@ -69,6 +69,8 @@ export async function scrapeContent(url: string) {
.map((i, el) => { .map((i, el) => {
return $(el).text(); return $(el).text();
}).get(); }).get();
this.embed = $("input#copy-video-embed").attr("value") || "None";
this.embed = this.embed.split("iframe")[1].split(" ")[1].replace(/src=/g, "").replace(/"/g, "") || "None";
} }
} }
@@ -91,7 +93,7 @@ export async function scrapeContent(url: string) {
tags: x.tags.filter((el) => el !== "Edit tags and models") tags: x.tags.filter((el) => el !== "Edit tags and models")
}, },
source: x.link, source: x.link,
assets: lust.removeAllSingleQuoteOnArray([x.thumbnail, x.bigimg, x.video]) assets: lust.removeAllSingleQuoteOnArray([x.embed, x.thumbnail, x.bigimg, x.video])
}; };
return data; return data;

View File

@@ -22,15 +22,16 @@ export async function scrapeContent(url: string) {
//stop and replace everything after the last ]; //stop and replace everything after the last ];
const badJson = video_related?.split("];")[0] + "]"; const badJson = video_related?.split("];")[0] + "]";
const actualResult = JSON.parse(String(badJson)); const actualResult = JSON.parse(String(badJson));
//console.log(actualResult);
const result = actualResult.map((el: any) => { const result = actualResult.map((el: any) => {
return { return {
link: `${c.XNXX}${el.u}`, link: `${c.XNXX}${el.u}`,
id: el.u, id: el.u.slice(1, -1),
title: el.t, title: el.t,
image: el.i, image: el.i,
duration: el.d, duration: el.d,
views: `${el.n}, ${el.r}`, views: `${el.n}, ${el.r}`,
video: null video: `${c.XNXX}/embedframe/${el.id}`
}; };
}); });
return result; return result;

View File

@@ -17,7 +17,8 @@ export async function scrapeContent(url: string) {
.map((i, el) => { .map((i, el) => {
return { return {
link: `${c.XNXX}${$(el).find("a").attr("href")}`, link: `${c.XNXX}${$(el).find("a").attr("href")}`,
id: $(el).find("a").attr("href"), // remove first "/" and last "/"
id: $(el).find("a").attr("href")?.slice(1, -1),
title: $(el).find("div.thumb-under").text().split("\n") title: $(el).find("div.thumb-under").text().split("\n")
.map((el) => el.trim()).filter((el) => el !== "")[0], .map((el) => el.trim()).filter((el) => el !== "")[0],
image: $(el).find("img").attr("data-src"), image: $(el).find("img").attr("data-src"),
@@ -25,8 +26,7 @@ export async function scrapeContent(url: string) {
.map((el) => el.trim()).filter((el) => el !== "")[2], .map((el) => el.trim()).filter((el) => el !== "")[2],
rating: $(el).find("div.thumb-under").text().split("\n") rating: $(el).find("div.thumb-under").text().split("\n")
.map((el) => el.trim()).filter((el) => el !== "")[1], .map((el) => el.trim()).filter((el) => el !== "")[1],
video: null video: `${c.XNXX}/embedframe/${$(el).find("img").attr("data-videoid")}`
}; };
}).get(); }).get();
} }

View File

@@ -25,6 +25,7 @@ export async function scrapeContent(url: string) {
models: string[]; models: string[];
thumbnail: string; thumbnail: string;
bigimg: string; bigimg: string;
embed: string;
constructor() { constructor() {
this.link = $("meta[property='og:url']").attr("content") || "None"; this.link = $("meta[property='og:url']").attr("content") || "None";
this.id = this.link.split("/")[3] + "/" + this.link.split("/")[4] || "None"; this.id = this.link.split("/")[3] + "/" + this.link.split("/")[4] || "None";
@@ -60,7 +61,8 @@ export async function scrapeContent(url: string) {
} }
).get(); ).get();
this.models = this.models.map((el) => el.split("/")[2]); this.models = this.models.map((el) => el.split("/")[2]);
this.embed = $("input#copy-video-embed").attr("value") || "None";
this.embed = this.embed.split("iframe")[1].split(" ")[1].replace(/src=/g, "").replace(/"/g, "") || "None";
} }
} }
@@ -81,7 +83,7 @@ export async function scrapeContent(url: string) {
tags: xv.tags, tags: xv.tags,
}, },
source: xv.link, source: xv.link,
assets: lust.removeAllSingleQuoteOnArray([xv.thumbnail, xv.bigimg, xv.video]) assets: lust.removeAllSingleQuoteOnArray([xv.embed, xv.thumbnail, xv.bigimg, xv.video])
}; };
return data; return data;

View File

@@ -9,7 +9,6 @@ export async function scrapeContent(url: string) {
try { try {
const res = await lust.fetchBody(url); const res = await lust.fetchBody(url);
const $ = load(res); const $ = load(res);
console.log(url);
class XvideosSearch { class XvideosSearch {
search: object[]; search: object[];
@@ -24,12 +23,12 @@ export async function scrapeContent(url: string) {
const result = actualResult.map((el: any) => { const result = actualResult.map((el: any) => {
return { return {
link: `${c.XVIDEOS}${el.u}`, link: `${c.XVIDEOS}${el.u}`,
id: el.u, id: el.u.slice(1, -1),
title: el.t, title: el.t,
image: el.i, image: el.i,
duration: el.d, duration: el.d,
views: `${el.n}, ${el.r}`, views: `${el.n}, ${el.r}`,
video: null video: `${c.XVIDEOS}/embedframe/${el.id}`
}; };
}); });
return result; return result;

View File

@@ -7,7 +7,6 @@ const lust = new LustPress();
export async function scrapeContent(url: string) { export async function scrapeContent(url: string) {
try { try {
console.log(url);
const res = await lust.fetchBody(url); const res = await lust.fetchBody(url);
const $ = load(res); const $ = load(res);
@@ -36,7 +35,7 @@ export async function scrapeContent(url: string) {
? "" ? ""
: data[i].duration || "None", : data[i].duration || "None",
rating: null, rating: null,
video: null video: `${c.XVIDEOS}/embedframe/${$(el).find("img").attr("data-videoid")}`
}; };
}).get(); }).get();

View File

@@ -19,7 +19,7 @@ export async function scrapeContent(url: string) {
rating: string; rating: string;
publish: string; publish: string;
upVote: string; upVote: string;
downVote: null; downVote: string;
video: string; video: string;
tags: string[]; tags: string[];
models: string[]; models: string[];
@@ -33,7 +33,7 @@ export async function scrapeContent(url: string) {
this.rating = $("div.feature").find("span").text().replace(/[^0-9.,%]/g, "") || "0"; this.rating = $("div.feature").find("span").text().replace(/[^0-9.,%]/g, "") || "0";
this.publish = $("div.video-uploaded").find("span").text() || "None"; this.publish = $("div.video-uploaded").find("span").text() || "None";
this.upVote = this.views; this.upVote = this.views;
this.downVote = null; this.downVote = "None";
this.video = `https://www.youporn.com/embed/${this.id}`; this.video = `https://www.youporn.com/embed/${this.id}`;
this.tags = $("a[data-espnode='category_tag'], a[data-espnode='porntag_tag']") this.tags = $("a[data-espnode='category_tag'], a[data-espnode='porntag_tag']")
.map((i, el) => { .map((i, el) => {

View File

@@ -29,7 +29,7 @@ export async function scrapeContent(url: string) {
title: lust.removeHtmlTagWithoutSpace(title), title: lust.removeHtmlTagWithoutSpace(title),
image: image, image: image,
duration: this.dur[i], duration: this.dur[i],
views: null, views: "None",
video: `https://www.youporn.com/embed/${id}`, video: `https://www.youporn.com/embed/${id}`,
}; };
}).get(); }).get();