xvideosx 1.4.3 → 1.4.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,4 +5,5 @@ module.exports = {
5
5
  fresh: require('./fresh'),
6
6
  verified: require('./verified'),
7
7
  search: require('./search'),
8
+ newFresh: require('./newfresh'),
8
9
  };
@@ -0,0 +1,2 @@
1
+ /* eslint-disable linebreak-style */
2
+ module.exports = require('./newfresh');
@@ -0,0 +1,42 @@
1
+ /* eslint-disable linebreak-style */
2
+ /* eslint-disable no-undef */
3
+ const puppeteer = require('puppeteer');
4
+
5
+ const newFresh = async ({ url, puppeteerConfig } = {}) => {
6
+ let browser;
7
+ try {
8
+ browser = await puppeteer.launch(puppeteerConfig);
9
+ const page = await browser.newPage();
10
+ await page.goto(url, { waitUntil: 'networkidle2' });
11
+
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,
31
+ });
32
+ }
33
+ return result;
34
+ });
35
+ return data;
36
+ });
37
+ } finally {
38
+ if (browser) await browser.close();
39
+ }
40
+ };
41
+
42
+ module.exports = newFresh;
File without changes
@@ -1,5 +1,3 @@
1
- /* eslint-disable padded-blocks */
2
-
3
1
  const chai = require('chai');
4
2
  const xvideos = require('.');
5
3
 
@@ -8,7 +6,6 @@ before(() => {
8
6
  });
9
7
 
10
8
  describe('xvideos', () => {
11
-
12
9
  it('should have xvideos api functions', async () => {
13
10
  xvideos.should.be.an('object');
14
11
  xvideos.videos.should.be.an('object');
@@ -17,6 +14,6 @@ describe('xvideos', () => {
17
14
  xvideos.videos.best.should.be.a('function');
18
15
  xvideos.videos.verified.should.be.a('function');
19
16
  xvideos.videos.details.should.be.a('function');
17
+ xvideos.videos.newFresh.should.be.a('function');
20
18
  }).timeout(10000);
21
-
22
19
  });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "xvideosx",
3
3
  "description": "xvideos.com api implementation.",
4
- "version": "1.4.3",
4
+ "version": "1.4.4",
5
5
  "main": "index.js",
6
6
  "license": "BSD-3-Clause",
7
7
  "repository": {