xvideosx 1.5.3 → 1.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -57,7 +57,14 @@ const detail = await xvideos.videos.details(fresh.videos[0]); /**
57
57
  thumb69,
58
58
  thumbSlide,
59
59
  thumbSlideBig
60
- }
60
+ },
61
+ videos:{
62
+ title,
63
+ duration,
64
+ channel,
65
+ thumbNail,
66
+ url,
67
+ }//related videos
61
68
  } **/
62
69
  ```
63
70
 
@@ -18,6 +18,27 @@ const details = async ({ url, puppeteerConfig } = {}) => {
18
18
  const videoWidth = $('meta[property="og:video:width"]').attr('content');
19
19
  const videoHeight = $('meta[property="og:video:height"]').attr('content');
20
20
  const views = $('#nb-views-number').text();
21
+ const relatedContentItems = $('div[class=mozaique]').html();
22
+ const newData = cheerio.load(relatedContentItems);
23
+ const varios = newData('.thumb-block');
24
+ const videos = varios.map((index, element) => {
25
+ const $element = newData(element);
26
+
27
+ const title = $element.find('.title a').text();
28
+ const duration = $element.find('.duration').text();
29
+ const channel = $element.find('.metadata .name').text();
30
+ const url = 'https://www.xvideos.com' + $element.find('.title a').attr('href');
31
+ const thumbNail = $element.find('.thumb img').attr('src');
32
+ return {
33
+ title,
34
+ duration,
35
+ channel,
36
+ thumbNail,
37
+ url,
38
+ },
39
+ }).get()
40
+
41
+
21
42
  const videoScript = $('#video-player-bg > script:nth-child(6)').html();
22
43
  const files = {
23
44
  low: (videoScript.match('html5player.setVideoUrlLow\\(\'(.*?)\'\\);') || [])[1],
@@ -39,6 +60,7 @@ const details = async ({ url, puppeteerConfig } = {}) => {
39
60
  videoWidth,
40
61
  videoHeight,
41
62
  files,
63
+ videos
42
64
  };
43
65
  } finally {
44
66
  if (browser) await browser.close();
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable linebreak-style */
2
2
  /* eslint-disable no-undef */
3
3
  const puppeteer = require('puppeteer');
4
+ const cheerio = require('cheerio');
4
5
 
5
6
  const newFresh = async ({ url, puppeteerConfig } = {}) => {
6
7
  let browser;
@@ -8,33 +9,29 @@ const newFresh = async ({ url, puppeteerConfig } = {}) => {
8
9
  browser = await puppeteer.launch(puppeteerConfig);
9
10
  const page = await browser.newPage();
10
11
  await page.goto(url, { waitUntil: 'networkidle2' });
12
+ const html = await page.content();
13
+ const $ = cheerio.load(html);
14
+ const data = $('div[class=mozaique]').html()
15
+ const $getVideos = cheerio.load(data);
16
+ const mozaique = $getVideos('.thumb-block');
17
+ const videos = mozaique.map((index, element) => {
18
+ const $element = $getVideos(element);
19
+ const title = $element.find('.title a').attr('title');
20
+ const url = "https://www.xvideos.com" + $element.find('.title a').attr('href');
21
+ const thumbNail = $element.find('.thumb img').attr('src');
22
+ const duration = $element.find('.duration').text();
23
+ const name = $element.find('.metadata .name').text();
11
24
 
12
- const result = await page.evaluate(() => {
13
- const thumbs = document.querySelectorAll('.thumb');
14
- const titles = document.querySelectorAll('.title');
15
- const data = [];
16
- thumbs.forEach((thumb, index) => {
17
- const anchor = thumb.querySelector('a');
18
- const img = thumb.querySelector('img');
19
- const text = titles[index];
20
- const url = anchor ? anchor.href : null;
21
- let title;
22
- if (text) {
23
- title = text.textContent;
24
- }
25
- if (img) {
26
- const thumb = img.src;
27
- data.push({
28
- thumb,
29
- title,
30
- url,
25
+ return {
31
26
 
32
- });
33
- }
34
- });
35
- return data;
36
- });
37
- return result;
27
+ title,
28
+ url,
29
+ thumbNail,
30
+ duration,
31
+ name,
32
+ },
33
+ }).get();
34
+ return videos;
38
35
  } finally {
39
36
  if (browser) await browser.close();
40
37
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "xvideosx",
3
3
  "description": "xvideos.com api implementation.",
4
- "version": "1.5.3",
4
+ "version": "1.5.5",
5
5
  "main": "index.js",
6
6
  "license": "BSD-3-Clause",
7
7
  "repository": {