diff --git a/src/scraper/pornhub/pornhubGetController.ts b/src/scraper/pornhub/pornhubGetController.ts new file mode 100644 index 0000000..14d5248 --- /dev/null +++ b/src/scraper/pornhub/pornhubGetController.ts @@ -0,0 +1,78 @@ +import { load } from "cheerio"; +import LustPress from "../../LustPress"; +import { IVideoData } from "../../interfaces"; + +const lust = new LustPress(); + +export async function scrapeContent(url: string) { + try { + const resolve = await lust.fetchBody(url); + const $ = load(resolve); + + class PornHub { + link: string; + id: string; + title: string; + image: string; + duration: string; + views: string; + rating: string; + videoInfo: string; + upVote: string; + downVote: string; + video: string; + tags: string[]; + models: string[]; + constructor() { + this.link = $("link[rel='canonical']").attr("href") || "None"; + this.id = this.link.split("=")[1] || "None"; + this.title = $("meta[property='og:title']").attr("content") || "None"; + this.image = $("meta[property='og:image']").attr("content") || "None"; + //get span.count").text() || "None"; + this.rating = $("div.ratingPercent > span.percent").text() || "None"; + this.videoInfo = $("div.videoInfo").text() || "None"; + this.upVote = $("span.votesUp").attr("data-rating") || "None"; + this.downVote = $("span.votesDown").attr("data-rating") || "None"; + this.video = $("meta[property='og:video:url']").attr("content") || "None"; + this.tags = $("div.video-info-row") + .find("a") + .map((i, el) => { + return $(el).text(); + }).get(); + this.tags.shift(); + this.tags = this.tags.map((el) => lust.removeHtmlTagWithoutSpace(el)); + this.models = $("div.pornstarsWrapper.js-pornstarsWrapper") + .find("a") + .map((i, el) => { + return $(el).attr("data-mxptext"); + }).get(); + } + } + + const ph = new PornHub(); + const data: IVideoData = { + success: true, + data: { + title: lust.removeHtmlTagWithoutSpace(ph.title), + id: ph.id, + image: ph.image, + duration: lust.secondToMinute(Number(ph.duration)), + views: ph.views, + rating: ph.rating, + uploaded: ph.videoInfo, + upvoted: ph.upVote, + downvoted: ph.downVote, + models: ph.models, + tags: ph.tags.filter((el) => el !== "Suggest" && el !== " Suggest") + }, + source: ph.link, + assets: [ph.video, ph.image] + }; + return data; + } catch (err) { + const e = err as Error; + throw Error(e.message); + } +} \ No newline at end of file diff --git a/src/scraper/pornhub/pornhubSearchController.ts b/src/scraper/pornhub/pornhubSearchController.ts new file mode 100644 index 0000000..a95a045 --- /dev/null +++ b/src/scraper/pornhub/pornhubSearchController.ts @@ -0,0 +1,59 @@ +import { load } from "cheerio"; +import LustPress from "../../LustPress"; +import c from "../../utils/options"; +import { ISearchVideoData } from "../../interfaces"; + +const lust = new LustPress(); + +export async function scrapeContent(url: string) { + try { + const res = await lust.fetchBody(url); + const $ = load(res); + + class PornhubSearch { + search: object[]; + data: object; + constructor() { + this.search = $("div.wrap") + .map((i, el) => { + const link = $(el).find("a").attr("href"); + const id = link?.split("=")[1]; + const title = $(el).find("a").attr("title"); + const image = $(el).find("img").attr("src"); + const duration = $(el).find("var.duration").text(); + const views = $(el).find("div.videoDetailsBlock").find("span.views").text(); + return { + link: `${c.PORNHUB}${link}`, + id: id, + title: title, + image: image, + duration: duration, + views: views, + video: `${c.PORNHUB}/embed/${id}`, + }; + }).get(); + + this.data = this.search.filter((el: any) => { + return el.link.includes("javascript:void(0)") === false && el.image?.startsWith("data:image") === false; + }); + } + + } + + const ph = new PornhubSearch(); + if (ph.search.length === 0) throw Error("No result found"); + const data = ph.data as string[]; + const result: ISearchVideoData = { + success: true, + data: data, + source: url, + }; + return result; + + + + } catch (err) { + const e = err as Error; + throw Error(e.message); + } +} \ No newline at end of file diff --git a/src/scraper/redtube/redtubeGetController.ts b/src/scraper/redtube/redtubeGetController.ts new file mode 100644 index 0000000..0a2cbcb --- /dev/null +++ b/src/scraper/redtube/redtubeGetController.ts @@ -0,0 +1,79 @@ +import { load } from "cheerio"; +import LustPress from "../../LustPress"; +import { IVideoData } from "../../interfaces"; + +const lust = new LustPress(); + +export async function scrapeContent(url: string) { + try { + const resolve = await lust.fetchBody(url); + const $ = load(resolve); + + class RedTube { + link: string; + id: string; + title: string; + image: string; + duration: string; + views: string; + rating: string; + publish: string; + upVote: string; + downVote: null; + video: string; + tags: string[]; + models: string[]; + constructor() { + this.link = $("link[rel='canonical']").attr("href") || "None"; + this.id = this.link.split("/")[3] || "None"; + this.title = $("meta[property='og:title']").attr("content") || "None"; + this.image = $("meta[property='og:image']").attr("content") || "None"; + this.duration = $("meta[property='og:video:duration']").attr("content") || "0"; + this.views = $("span.video_view_count").text() || "None"; + this.rating = $("div.rating_percent.js_rating_percent").attr("data-percent") + "%" || "None"; + this.publish = $("span.video-infobox-date-added").text().replace("Published on ", "") || "None"; + this.upVote = this.rating; + this.downVote = null; + this.video = $("meta[name='twitter:player']").attr("content") || "None"; + this.tags = $("a.item.video_carousel_item.video_carousel_category, a.item.video_carousel_item.video_carousel_tag") + .map((i, el) => { + return $(el).text(); + }).get(); + this.tags = this.tags.map((el) => lust.removeHtmlTagWithoutSpace(el)); + this.models = $("div.pornstar-name.pornstarPopupWrapper") + .find("a") + .map((i, el) => { + return $(el).text(); + } + ).get(); + this.models = this.models.map((el) => lust.removeHtmlTagWithoutSpace(el)); + this.models = this.models.filter((el) => !el.includes("Subscribe") && !el.includes("Rank")) + .filter((el, i, arr) => arr.indexOf(el) === i); + } + } + + const red = new RedTube(); + const data: IVideoData = { + success: true, + data: { + title: lust.removeHtmlTagWithoutSpace(red.title), + id: red.id, + image: red.image, + duration: lust.secondToMinute(Number(red.duration)), + views: red.views, + rating: red.rating, + uploaded: red.publish, + upvoted: red.upVote, + downvoted: red.downVote, + models: red.models, + tags: red.tags + }, + source: red.link, + assets: [red.video, red.image] + }; + return data; + } catch (err) { + const e = err as Error; + throw Error(e.message); + } +} \ No newline at end of file diff --git a/src/scraper/redtube/redtubeSearchController.ts b/src/scraper/redtube/redtubeSearchController.ts new file mode 100644 index 0000000..f05c677 --- /dev/null +++ b/src/scraper/redtube/redtubeSearchController.ts @@ -0,0 +1,72 @@ +import { load } from "cheerio"; +import LustPress from "../../LustPress"; +import c from "../../utils/options"; +import { ISearchVideoData } from "../../interfaces"; + +const lust = new LustPress(); + +export async function scrapeContent(url: string) { + try { + const res = await lust.fetchBody(url); + const $ = load(res); + + class RedTubeSearch { + views: string[]; + search: object[]; + data: object; + constructor() { + this.views = $("span.video_count") + .map((i, el) => { + const views = $(el).text(); + return views; + }).get(); + this.search = $("a.video_link") + .map((i, el) => { + const link = $(el).attr("href"); + const id = link?.split("/")[1]; + const title = $(el).find("img").attr("alt"); + const image = $(el).find("img").attr("data-src"); + const duration = $(el).find("span.duration").text().split(" ").map((el: string) => { + return el.replace(/[^0-9:]/g, ""); + }).filter((el: string) => { + return el.includes(":"); + }).join(" "); + + return { + link: `${c.REDTUBE}${link}`, + id: id, + title: title, + image: image, + duration: duration, + views: this.views[i], + video: `https://embed.redtube.com/?id=${id}`, + + }; + }).get(); + + + + + this.data = this.search.filter((el: any) => { + return el.link.includes("javascript:void(0)") === false && el.image?.startsWith("data:image") === false; + }); + } + + } + + const red = new RedTubeSearch(); + + if (red.search.length === 0) throw Error("No result found"); + const data = red.data as string[]; + const result: ISearchVideoData = { + success: true, + data: data, + source: url, + }; + return result; + + } catch (err) { + const e = err as Error; + throw Error(e.message); + } +} \ No newline at end of file diff --git a/src/scraper/xhamster/xhamsterGetController.ts b/src/scraper/xhamster/xhamsterGetController.ts new file mode 100644 index 0000000..7e73ac5 --- /dev/null +++ b/src/scraper/xhamster/xhamsterGetController.ts @@ -0,0 +1,83 @@ +import { load } from "cheerio"; +import LustPress from "../../LustPress"; +import { IVideoData } from "../../interfaces"; + +const lust = new LustPress(); + +export async function scrapeContent(url: string) { + try { + const resolve = await lust.fetchBody(url); + const $ = load(resolve); + + class Xhamster { + link: string; + id: string; + title: string; + image: string; + duration: any; + views: string; + rating: string; + publish: string; + upVote: string; + downVote: string; + video: string; + tags: string[]; + models: string[]; + constructor() { + this.link = $("link[rel='canonical']").attr("href") || "None"; + this.id = this.link.split("/")[3] + "/" + this.link.split("/")[4] || "None"; + this.title = $("meta[property='og:title']").attr("content") || "None"; + this.image = $("meta[property='og:image']").attr("content") || "None"; + this.duration = $("script#initials-script").html() || "None"; + //remove window.initials={ and }; + this.duration = this.duration.replace("window.initials=", ""); + this.duration = this.duration.replace(/;/g, ""); + this.duration = JSON.parse(this.duration); + this.duration = this.duration.videoModel.duration || "None"; + this.views = $("div.header-icons").find("span").first().text() || "None"; + this.rating = $("div.header-icons").find("span").eq(1).text() || "None"; + this.publish = $("div.entity-info-container__date").attr("data-tooltip") || "None"; + this.upVote = $("div.rb-new__info").text().split("/")[0].trim() || "None"; + this.downVote = $("div.rb-new__info").text().split("/")[1].trim() || "None"; + this.video = "https://xheve2.com/embed/" + this.link.split("-").pop() || "None"; + this.tags = $("a.video-tag") + .map((i, el) => { + return $(el).text(); + }).get(); + this.tags = this.tags.map((el) => lust.removeHtmlTagWithoutSpace(el)); + this.models = $("a.video-tag") + .map((i, el) => { + return $(el).attr("href"); + } + ).get(); + this.models = this.models.filter((el) => el.startsWith("https://xheve2.com/pornstars/")); + this.models = this.models.map((el) => el.replace("https://xheve2.com/pornstars/", "")); + } + } + + const xh = new Xhamster(); + const data: IVideoData = { + success: true, + data: { + title: lust.removeHtmlTagWithoutSpace(xh.title), + id: xh.id, + image: xh.image, + duration: lust.secondToMinute(Number(xh.duration)), + views: xh.views, + rating: xh.rating, + uploaded: xh.publish, + upvoted: xh.upVote, + downvoted: xh.downVote, + models: xh.models, + tags: xh.tags + }, + source: xh.link, + assets: [xh.video, xh.image] + }; + return data; + + } catch (err) { + const e = err as Error; + throw Error(e.message); + } +} \ No newline at end of file diff --git a/src/scraper/xhamster/xhamsterSearchController.ts b/src/scraper/xhamster/xhamsterSearchController.ts new file mode 100644 index 0000000..7bb7eeb --- /dev/null +++ b/src/scraper/xhamster/xhamsterSearchController.ts @@ -0,0 +1,56 @@ +import { load } from "cheerio"; +import LustPress from "../../LustPress"; +import { ISearchVideoData } from "../../interfaces"; + +const lust = new LustPress(); + +export async function scrapeContent(url: string) { + try { + const res = await lust.fetchBody(url); + const $ = load(res); + + class XhamsterSearch { + search: any; + constructor() { + const views = $("div.video-thumb-views") + .map((i, el) => { + const views = $(el).text(); + return views; + }).get(); + const duration = $("span[data-role='video-duration']") + .map((i, el) => { + const duration = $(el).text(); + return duration; + }).get(); + this.search = $("a.video-thumb__image-container") + .map((i, el) => { + const link = $(el).attr("href"); + + return { + link: `${link}`, + id: link?.split("/")[3] + "/" + link?.split("/")[4], + title: $(el).find("img").attr("alt"), + image: $(el).find("img").attr("src"), + duration: duration[i], + views: views[i], + video: $(el).attr("data-previewvideo"), + }; + }).get(); + } + } + + const xh = new XhamsterSearch(); + if (xh.search.length === 0) throw Error("No result found"); + const data = xh.search as unknown as string[]; + const result: ISearchVideoData = { + success: true, + data: data, + source: url, + }; + return result; + + } catch (err) { + const e = err as Error; + throw Error(e.message); + } +} \ No newline at end of file diff --git a/src/scraper/xnxx/xnxxGetController.ts b/src/scraper/xnxx/xnxxGetController.ts new file mode 100644 index 0000000..3683047 --- /dev/null +++ b/src/scraper/xnxx/xnxxGetController.ts @@ -0,0 +1,102 @@ +import { load } from "cheerio"; +import LustPress from "../../LustPress"; +import { IVideoData } from "../../interfaces"; + +const lust = new LustPress(); + +export async function scrapeContent(url: string) { + try { + console.log(url); + const resolve = await lust.fetchBody(url); + const $ = load(resolve); + + class Xnxx { + link: string; + id: string; + title: string; + image: string; + duration: string; + views: string; + uploaded: string; + action: string[]; + upVote: string; + downVote: string; + favVote: string; + tags: string[]; + models: string[]; + thumbnail: string; + bigimg: string; + video: string; + constructor() { + const thumb = $("script") + .map((i, el) => { + return $(el).text(); + }).get() + .filter((el) => el.includes("html5player.setThumbSlideBig"))[0] || "None"; + + this.thumbnail = thumb.match(/html5player.setThumbSlideBig\((.*?)\)/)?.[1] || "None"; + this.bigimg = thumb.match(/html5player.setThumbUrl169\((.*?)\)/)?.[1] || "None"; + this.video = thumb.match(/html5player.setVideoUrlHigh\((.*?)\)/)?.[1] || "None"; + this.link = $("meta[property='og:url']").attr("content") || "None"; + this.id = this.link.split(".com/")[1] || "None"; + this.title = $("meta[property='og:title']").attr("content") || "None"; + this.image = $("meta[property='og:image']").attr("content") || "None"; + this.duration = $("meta[property='og:duration']").attr("content") || "None"; + this.views = $("span.metadata").text() || "None"; + this.views = this.views.split("-")[2] || "None"; + this.uploaded = $("script[type='application/ld+json']").text() || "None"; + this.uploaded = this.uploaded + .split("uploadDate")[1] + .split("}")[0] + .split(":")[1] + .replace(/"/g, "") + .replace(/,/g, "") || "None"; + this.action = $("span.vote-actions") + .find("span.value") + .map((i, el) => { + return $(el).text(); + }).get(); + + this.upVote = this.action[0] || "None"; + this.downVote = this.action[1] || "None"; + this.favVote = $("span.rating-box.value").text() || "None"; + this.models = $("a.is-pornstar") + .map((i, el) => { + return $(el).text(); + }).get(); + this.tags = $("div.metadata-row.video-tags") + .find("a") + .map((i, el) => { + return $(el).text(); + }).get(); + + } + } + + const x = new Xnxx(); + + const data: IVideoData = { + success: true, + data: { + title: lust.removeHtmlTagWithoutSpace(x.title), + id: x.id, + image: x.image, + duration: lust.secondToMinute(Number(x.duration)), + views: lust.removeHtmlTag(x.views), + rating: x.favVote, + uploaded: x.uploaded.trim(), + upvoted: x.upVote, + downvoted: x.downVote, + models: x.models, + tags: x.tags.filter((el) => el !== "Edit tags and models") + }, + source: x.link, + assets: lust.removeAllSingleQuoteOnArray([x.thumbnail, x.bigimg, x.video]) + }; + return data; + + } catch (err) { + const e = err as Error; + throw Error(e.message); + } +} \ No newline at end of file diff --git a/src/scraper/xnxx/xnxxGetRelatedController.ts b/src/scraper/xnxx/xnxxGetRelatedController.ts new file mode 100644 index 0000000..8ffec25 --- /dev/null +++ b/src/scraper/xnxx/xnxxGetRelatedController.ts @@ -0,0 +1,55 @@ +import { load } from "cheerio"; +import LustPress from "../../LustPress"; +import c from "../../utils/options"; +import { ISearchVideoData } from "../../interfaces"; + +const lust = new LustPress(); + +export async function scrapeContent(url: string) { + try { + const res = await lust.fetchBody(url); + const $ = load(res); + + class PornhubSearch { + search: object[]; + data: object; + constructor() { + // in