mot-ph 3.4.0
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/.cache/replit/env/latest +63 -0
- package/.cache/replit/env/latest.json +1 -0
- package/.cache/replit/modules/nodejs-20.res +1 -0
- package/.cache/replit/modules/replit-rtld-loader.res +1 -0
- package/.cache/replit/modules/replit.res +1 -0
- package/.cache/replit/modules.stamp +0 -0
- package/.cache/replit/nix/dotreplitenv.json +1 -0
- package/.cache/replit/toolchain.json +1 -0
- package/.cache/typescript/5.8/package.json +1 -0
- package/.codeclimate.yml +4 -0
- package/.config/configstore/update-notifier-ava.json +4 -0
- package/.gitattributes +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +17 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +11 -0
- package/.github/ISSUE_TEMPLATE/questions.md +12 -0
- package/.local/state/replit/agent/.agent_state_6fa31f60be98e5d6fb0c67811b64cd555a363f53.bin +0 -0
- package/.local/state/replit/agent/.agent_state_e44addd1339e914cd4e864c650d4d7069b3f5d4e.bin +0 -0
- package/.local/state/replit/agent/.agent_state_f567f1857ae17f372d3c99c01eb473389bc6019d.bin +0 -0
- package/.local/state/replit/agent/.agent_state_main.bin +0 -0
- package/.local/state/replit/agent/.latest.json +1 -0
- package/.local/state/replit/agent/repl_state.bin +0 -0
- package/.replit +29 -0
- package/.travis.yml +6 -0
- package/.xo-config.js +8 -0
- package/LICENSE +21 -0
- package/README.md +378 -0
- package/example.js +31 -0
- package/imgs/pornhub-api.jpg +0 -0
- package/package.json +51 -0
- package/replit.md +48 -0
- package/src/constants/consts_global.js +95 -0
- package/src/constants/consts_model.js +23 -0
- package/src/constants/consts_page.js +83 -0
- package/src/constants/consts_queries.js +11 -0
- package/src/constants/consts_sanitizer.js +14 -0
- package/src/constants/consts_scrap.js +10 -0
- package/src/constants/consts_search.js +22 -0
- package/src/constants/consts_search_gifs.js +15 -0
- package/src/constants/consts_search_pornstars.js +25 -0
- package/src/constants/consts_search_videos.js +29 -0
- package/src/helpers/utils_global.js +36 -0
- package/src/helpers/utils_sanitizer.js +144 -0
- package/src/helpers/utils_scrap.js +65 -0
- package/src/index.js +101 -0
- package/src/model.js +44 -0
- package/src/packages/postinstall.js +1 -0
- package/src/page.js +66 -0
- package/src/search.js +31 -0
- package/src/utils.js +197 -0
- package/tests/datas/page_model.html +6056 -0
- package/tests/datas/page_pornhub.html +7809 -0
- package/tests/datas/page_pornhub_exception.html +7699 -0
- package/tests/datas/search_pornhub_aa_actor_1.html +4446 -0
- package/tests/datas/search_pornhub_aa_page_1.html +4440 -0
- package/tests/datas/search_pornhub_aa_page_2.html +4044 -0
- package/tests/datas/search_pornhub_doggy_gifs.html +3390 -0
- package/tests/dynamic/tests_page.js +104 -0
- package/tests/dynamic/tests_search.js +14 -0
- package/tests/dynamic/tests_video.js +22 -0
- package/tests/static/tests_model.js +76 -0
- package/tests/static/tests_page.js +107 -0
- package/tests/static/tests_search.js +59 -0
- package/tests/static/tests_utils.js +134 -0
- package/tests/static/tests_video.js +13 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
const test = require('ava');
|
|
2
|
+
const m = require('../../src');
|
|
3
|
+
|
|
4
|
+
test('[PAGE] Test page model with only a title', async t => {
|
|
5
|
+
const page = await m.page('https://pornhub.com/view_video.php?viewkey=ph5cacd6fc1e731', [
|
|
6
|
+
'title'
|
|
7
|
+
]);
|
|
8
|
+
|
|
9
|
+
t.is(page.title, 'CUM4K MULTIPLE CUM FILLED Creampies Compilation');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('[PAGE] Test page model miakhalifa', async t => {
|
|
13
|
+
const model = await m.model('mia khalifa', [
|
|
14
|
+
'TITLE',
|
|
15
|
+
'DESCRIPTION',
|
|
16
|
+
'RANK_MODEL'
|
|
17
|
+
], 'pornstar');
|
|
18
|
+
|
|
19
|
+
t.is(model.title, 'Mia Khalifa');
|
|
20
|
+
t.is(model.description, 'No Data');
|
|
21
|
+
t.is(model.rank_model, 8);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('[PAGE] Test page model', async t => {
|
|
25
|
+
const page = await m.page('https://www.pornhub.com/view_video.php?viewkey=2006034279', [
|
|
26
|
+
'title',
|
|
27
|
+
'description',
|
|
28
|
+
'views',
|
|
29
|
+
'up_votes',
|
|
30
|
+
'down_votes',
|
|
31
|
+
'percent',
|
|
32
|
+
'author',
|
|
33
|
+
'author_subscriber',
|
|
34
|
+
'pornstars',
|
|
35
|
+
'categories',
|
|
36
|
+
'tags',
|
|
37
|
+
'production',
|
|
38
|
+
'duration',
|
|
39
|
+
'number_of_comment',
|
|
40
|
+
'thumbnail_url',
|
|
41
|
+
'upload_date',
|
|
42
|
+
'download_urls',
|
|
43
|
+
'comments',
|
|
44
|
+
'related_videos'
|
|
45
|
+
]);
|
|
46
|
+
|
|
47
|
+
t.is(page.title, 'Kim Kardashian Sex Tape with Ray J');
|
|
48
|
+
t.not(page.description, undefined);
|
|
49
|
+
t.not(page.views, undefined);
|
|
50
|
+
t.not(page.up_votes, undefined);
|
|
51
|
+
t.not(page.down_votes, undefined);
|
|
52
|
+
t.not(page.percent, undefined);
|
|
53
|
+
t.is(page.author, 'No Data');
|
|
54
|
+
t.not(page.author_subscriber, undefined);
|
|
55
|
+
t.not(page.author_subscriber, 0);
|
|
56
|
+
t.not(page.pornstars, undefined);
|
|
57
|
+
t.is(page.pornstars[0], 'Kim Kardashian');
|
|
58
|
+
t.not(page.categories, undefined);
|
|
59
|
+
t.is(page.categories[0], 'Amateur');
|
|
60
|
+
t.not(page.tags, undefined);
|
|
61
|
+
t.is(page.tags[0], 'big tits');
|
|
62
|
+
t.not(page.number_of_comment, undefined);
|
|
63
|
+
t.not(page.number_of_comment, 0);
|
|
64
|
+
t.is(page.production, 'professional');
|
|
65
|
+
t.is(page.duration, 300);
|
|
66
|
+
t.not(page.thumbnail_url, undefined);
|
|
67
|
+
t.not(page.upload_date, undefined);
|
|
68
|
+
t.not(page.download_urls, undefined);
|
|
69
|
+
t.not(page.download_urls['480P'], undefined);
|
|
70
|
+
t.not(page.download_urls['240P'], undefined);
|
|
71
|
+
t.not(page.comments, undefined);
|
|
72
|
+
t.not(page.comments[0].avatar, undefined);
|
|
73
|
+
t.not(page.comments[0].username, undefined);
|
|
74
|
+
t.not(page.comments[0].date, undefined);
|
|
75
|
+
t.not(page.comments[0].message, undefined);
|
|
76
|
+
t.not(page.comments[0].total_vote, undefined);
|
|
77
|
+
t.not(page.related_videos, undefined);
|
|
78
|
+
t.not(page.related_videos[0].title, undefined);
|
|
79
|
+
t.not(page.related_videos[0].views, undefined);
|
|
80
|
+
t.not(page.related_videos[0].author, undefined);
|
|
81
|
+
t.not(page.related_videos[0].duration, undefined);
|
|
82
|
+
t.not(page.related_videos[0].link, undefined);
|
|
83
|
+
t.not(page.related_videos[0].hd, undefined);
|
|
84
|
+
t.not(page.related_videos[0].premium, undefined);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('[SEARCH&PAGE] Chaining the search and page', async t => {
|
|
88
|
+
const result = await m.search('japan', ['title', 'link', 'premium', 'hd']);
|
|
89
|
+
const url = result.results[1].link;
|
|
90
|
+
const page = await m.page(url, ['title', 'pornstars', 'download_urls']);
|
|
91
|
+
|
|
92
|
+
t.not(page.title, undefined);
|
|
93
|
+
t.not(page.pornstars, undefined);
|
|
94
|
+
t.not(page.download_urls, undefined);
|
|
95
|
+
t.is(page.upload_date, undefined);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
test('[PAGE] Test a specific page', async t => {
|
|
99
|
+
const page = await m.page('https://cn.pornhub.com/view_video.php?viewkey=ph5b1169ea3eda1', ['title', 'duration', 'download_urls']);
|
|
100
|
+
|
|
101
|
+
t.not(page.title, undefined);
|
|
102
|
+
t.not(page.duration, undefined);
|
|
103
|
+
t.not(page.download_urls, undefined);
|
|
104
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const test = require('ava');
|
|
2
|
+
const m = require('../../src');
|
|
3
|
+
|
|
4
|
+
test('[PAGE] Test search', async t => {
|
|
5
|
+
const search = await m.search('Aa', ['title']);
|
|
6
|
+
|
|
7
|
+
t.not(search.results[0].title, undefined);
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
test('[PAGE] Test search max_duration', async t => {
|
|
11
|
+
const search = await m.search('Aa', ['title'], {min_duration: 10, max_duration: 20});
|
|
12
|
+
|
|
13
|
+
t.not(search.results[0].title, undefined);
|
|
14
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const test = require('ava');
|
|
2
|
+
const m = require('../../src');
|
|
3
|
+
|
|
4
|
+
test('[VIDEO] Test video without options', async t => {
|
|
5
|
+
const video = await m.video();
|
|
6
|
+
|
|
7
|
+
t.not(video.results[0].title, undefined);
|
|
8
|
+
t.assert(video.results.length <= 40);
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
test('[VIDEO] Test video with options page', async t => {
|
|
12
|
+
const video = await m.video(['title'], {page: 2});
|
|
13
|
+
|
|
14
|
+
t.not(video.results[0].title, undefined);
|
|
15
|
+
t.assert(video.results.length >= 72);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('[VIDEO] Test video with options', async t => {
|
|
19
|
+
const video = await m.video(null, {production: 'homemade', min_duration: 20, filter: 'MOST_VIEWED'});
|
|
20
|
+
|
|
21
|
+
t.not(video.results[0].title, undefined);
|
|
22
|
+
});
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
const test = require('ava');
|
|
2
|
+
const nock = require('nock');
|
|
3
|
+
const m = require('../../src');
|
|
4
|
+
|
|
5
|
+
test('[PAGE] Test page model', async t => {
|
|
6
|
+
nock('https://www.pornhub.com')
|
|
7
|
+
.get('/model/teacher-of-magic')
|
|
8
|
+
.replyWithFile(200, './tests/datas/page_model.html');
|
|
9
|
+
const model = await m.model('Teacher of Magic', [
|
|
10
|
+
'TITLE',
|
|
11
|
+
'DESCRIPTION',
|
|
12
|
+
'RANK_MODEL',
|
|
13
|
+
'RANK_WEEK_MODEL',
|
|
14
|
+
'RANK_MONTH_MODEL',
|
|
15
|
+
'RANK_LAST_MONTH_MODEL',
|
|
16
|
+
'RANK_YEAR_MODEL',
|
|
17
|
+
'VIDEO_NUMBER',
|
|
18
|
+
'RELATIONSHIP_STATUS',
|
|
19
|
+
'RELATIONSHIP_STATUS',
|
|
20
|
+
'INTERESTED_IN',
|
|
21
|
+
'GENDER',
|
|
22
|
+
'BIRTHDAY',
|
|
23
|
+
'AGE',
|
|
24
|
+
'HEIGHT',
|
|
25
|
+
'WEIGHT',
|
|
26
|
+
'ETHNICITY',
|
|
27
|
+
'VIDEO_VIEWS',
|
|
28
|
+
'PROFILE_VIEWS',
|
|
29
|
+
'VIDEOS_WATCHED',
|
|
30
|
+
'JOINED'
|
|
31
|
+
]);
|
|
32
|
+
|
|
33
|
+
t.is(model.title, 'Teacher of Magic');
|
|
34
|
+
t.not(model.description, undefined);
|
|
35
|
+
t.is(model.rank_model, 53);
|
|
36
|
+
t.is(model.rank_week_model, 41);
|
|
37
|
+
t.is(model.rank_month_model, 53);
|
|
38
|
+
t.is(model.rank_last_month_model, 52);
|
|
39
|
+
t.is(model.rank_year_model, 44);
|
|
40
|
+
t.is(model.video_number, 242);
|
|
41
|
+
t.is(model.relationship_status, 'Open');
|
|
42
|
+
t.is(model.interested_in, 'Guys and Girls');
|
|
43
|
+
t.is(model.gender, 'Female');
|
|
44
|
+
t.not(model.birthday, undefined);
|
|
45
|
+
t.is(model.age, 40);
|
|
46
|
+
t.is(model.height, '5\' 7" (170cm)');
|
|
47
|
+
t.is(model.weight, '156lbs. (71kg)');
|
|
48
|
+
t.is(model.ethnicity, 'Other');
|
|
49
|
+
t.is(model.video_views, 385264877);
|
|
50
|
+
t.is(model.profile_views, 19136136);
|
|
51
|
+
t.is(model.videos_watched, 3647);
|
|
52
|
+
t.is(model.joined, '4 years ago');
|
|
53
|
+
nock.cleanAll();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test('[PAGE] Test page model without video number', async t => {
|
|
57
|
+
nock('https://www.pornhub.com')
|
|
58
|
+
.get('/model/teacher-of-magic')
|
|
59
|
+
.replyWithFile(200, './tests/datas/page_model.html');
|
|
60
|
+
const model = await m.model('Teacher of Magic', [
|
|
61
|
+
'TITLE'
|
|
62
|
+
]);
|
|
63
|
+
|
|
64
|
+
t.not(model.video_number, 242);
|
|
65
|
+
nock.cleanAll();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('[SEARCH] Try to trigger an error', async t => {
|
|
69
|
+
nock('https://www.pornhub.com')
|
|
70
|
+
.get('/model/teacher-of-magic')
|
|
71
|
+
.reply(404);
|
|
72
|
+
const model = await m.model('Teacher of Magic', ['TITLE']);
|
|
73
|
+
|
|
74
|
+
t.is(model.error, 'An error occured');
|
|
75
|
+
nock.cleanAll();
|
|
76
|
+
});
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
const test = require('ava');
|
|
2
|
+
const nock = require('nock');
|
|
3
|
+
const m = require('../../src');
|
|
4
|
+
|
|
5
|
+
const url = 'https://www.pornhub.com/view_video.php?viewkey=ph56fc59c124c0c';
|
|
6
|
+
|
|
7
|
+
test('[PAGE] Test with no keys, by default title', async t => {
|
|
8
|
+
nock('https://www.pornhub.com')
|
|
9
|
+
.get('/view_video.php?viewkey=ph56fc59c124c0c')
|
|
10
|
+
.replyWithFile(200, './tests/datas/page_pornhub.html');
|
|
11
|
+
const page = await m.page(url);
|
|
12
|
+
|
|
13
|
+
t.is(page.title, 'Hot Kissing Scene');
|
|
14
|
+
nock.cleanAll();
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
test('[PAGE] Try only one selector on a pornhub page with a string', async t => {
|
|
18
|
+
nock('https://www.pornhub.com')
|
|
19
|
+
.get('/view_video.php?viewkey=ph56fc59c124c0c')
|
|
20
|
+
.replyWithFile(200, './tests/datas/page_pornhub.html');
|
|
21
|
+
const video = await m.page(url, 'title');
|
|
22
|
+
|
|
23
|
+
t.is(video.title, 'Hot Kissing Scene');
|
|
24
|
+
nock.cleanAll();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
test('[PAGE] Try only one selector on a pornhub page', async t => {
|
|
28
|
+
nock('https://www.pornhub.com')
|
|
29
|
+
.get('/view_video.php?viewkey=ph56fc59c124c0c')
|
|
30
|
+
.replyWithFile(200, './tests/datas/page_pornhub.html');
|
|
31
|
+
const video = await m.page(url, [
|
|
32
|
+
'title'
|
|
33
|
+
]);
|
|
34
|
+
|
|
35
|
+
t.is(video.title, 'Hot Kissing Scene');
|
|
36
|
+
nock.cleanAll();
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
test('[PAGE] Try call on a pornhub page with exception', async t => {
|
|
40
|
+
nock('https://www.pornhub.com')
|
|
41
|
+
.get('/view_video.php?viewkey=ph56fc59c124c0d')
|
|
42
|
+
.replyWithFile(200, './tests/datas/page_pornhub_exception.html');
|
|
43
|
+
const video = await m.page('https://www.pornhub.com/view_video.php?viewkey=ph56fc59c124c0d', [
|
|
44
|
+
'author',
|
|
45
|
+
'pornstars',
|
|
46
|
+
'production'
|
|
47
|
+
]);
|
|
48
|
+
|
|
49
|
+
t.is(video.author, 'No Data');
|
|
50
|
+
t.is(video.pornstars, 'No Data');
|
|
51
|
+
t.is(video.production, 'No Data');
|
|
52
|
+
nock.cleanAll();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('[PAGE] Try all selector on a pornhub page', async t => {
|
|
56
|
+
nock('https://www.pornhub.com')
|
|
57
|
+
.get('/view_video.php?viewkey=ph56fc59c124c0cdsds')
|
|
58
|
+
.replyWithFile(200, './tests/datas/page_pornhub.html');
|
|
59
|
+
const video = await m.page('https://www.pornhub.com/view_video.php?viewkey=ph56fc59c124c0cdsds', [
|
|
60
|
+
'title',
|
|
61
|
+
'description',
|
|
62
|
+
'views',
|
|
63
|
+
'up_votes',
|
|
64
|
+
'down_votes',
|
|
65
|
+
'percent',
|
|
66
|
+
'thumbnail_url',
|
|
67
|
+
'author',
|
|
68
|
+
'author_subscriber',
|
|
69
|
+
'number_of_comment',
|
|
70
|
+
'pornstars',
|
|
71
|
+
'categories',
|
|
72
|
+
'tags',
|
|
73
|
+
'upload_date',
|
|
74
|
+
'download_urls',
|
|
75
|
+
'comments',
|
|
76
|
+
'related_videos'
|
|
77
|
+
]);
|
|
78
|
+
|
|
79
|
+
t.is(video.title, 'Hot Kissing Scene');
|
|
80
|
+
t.is(video.pornstars[0], 'Rocco Reed');
|
|
81
|
+
t.is(video.pornstars[1], 'Jessie Andrews');
|
|
82
|
+
t.is(video.author, 'lovewetkissing');
|
|
83
|
+
t.is(video.percent, 69);
|
|
84
|
+
t.not(video.thumbnail_url, undefined);
|
|
85
|
+
t.assert(video.number_of_comment > 0);
|
|
86
|
+
t.is(video.tags[0], 'kissing');
|
|
87
|
+
t.is(video.tags[4], 'curvy');
|
|
88
|
+
t.is(video.categories[0], 'Babe');
|
|
89
|
+
t.is(video.categories[4], 'Pornstar');
|
|
90
|
+
t.is(video.comments[0].username, 'kingsignature');
|
|
91
|
+
t.is(video.comments[0].message, 'full video');
|
|
92
|
+
t.is(video.upload_date.getTime(), new Date('2016-03-30T22:59:58.000Z').getTime());
|
|
93
|
+
t.is(video.related_videos.length, 32);
|
|
94
|
+
nock.cleanAll();
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
test('[PAGE] Try to trigger an error', async t => {
|
|
98
|
+
nock('https://www.pornhub.com')
|
|
99
|
+
.get('/view_video.php?viewkey=ph56')
|
|
100
|
+
.reply(404);
|
|
101
|
+
const video = await m.page('https://www.pornhub.com/view_video.php?viewkey=ph56', [
|
|
102
|
+
'title'
|
|
103
|
+
]);
|
|
104
|
+
|
|
105
|
+
t.is(video.error, 'An error occured');
|
|
106
|
+
nock.cleanAll();
|
|
107
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const test = require('ava');
|
|
2
|
+
const nock = require('nock');
|
|
3
|
+
const m = require('../../src');
|
|
4
|
+
|
|
5
|
+
test('[SEARCH] Aa', async t => {
|
|
6
|
+
nock('https://www.pornhub.com')
|
|
7
|
+
.get('/video/search?search=aa&page=1')
|
|
8
|
+
.replyWithFile(200, './tests/datas/search_pornhub_aa_page_1.html')
|
|
9
|
+
.get('/video/search?search=aa&page=2')
|
|
10
|
+
.replyWithFile(200, './tests/datas/search_pornhub_aa_page_2.html');
|
|
11
|
+
const search = await m.search('Aa', ['related_search', 'RELATED_PORNSTARS'], {page: 2});
|
|
12
|
+
|
|
13
|
+
t.is(search.results[0].title, 'AA Big Fake Tits Shower');
|
|
14
|
+
t.is(search.results[0].hd, true);
|
|
15
|
+
t.is(search.results[0].author, 'branleur47');
|
|
16
|
+
t.assert(search.results[0].views >= 15400);
|
|
17
|
+
t.is(search.results[0].premium, false);
|
|
18
|
+
nock.cleanAll();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test('[SEARCH] Aa pornstars with special options', async t => {
|
|
22
|
+
nock('https://www.pornhub.com')
|
|
23
|
+
.get('/pornstars/search?search=ac&page=1&p=homemade')
|
|
24
|
+
.replyWithFile(200, './tests/datas/search_pornhub_aa_actor_1.html');
|
|
25
|
+
const search = await m.search('Ac', ['ACTOR', 'RANK', 'VIDEO_NUMBER', 'VIEW_NUMBER'], {production: 'homemade', search: 'pornstars'});
|
|
26
|
+
|
|
27
|
+
t.is(search.results[0].actor, 'Aaron Vick');
|
|
28
|
+
t.assert(search.results[0].rank > 0);
|
|
29
|
+
nock.cleanAll();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('[SEARCH] Doggy gifs with special options', async t => {
|
|
33
|
+
nock('https://www.pornhub.com')
|
|
34
|
+
.get('/gifs/search?search=doggy&page=1')
|
|
35
|
+
.replyWithFile(200, './tests/datas/search_pornhub_doggy_gifs.html');
|
|
36
|
+
const search = await m.search('doggy', ['TITLE', 'THUMBNAIL_URL', 'LINK_MP4', 'LINK_WEBM'], {search: 'gifs'});
|
|
37
|
+
|
|
38
|
+
t.is(search.results[0].title, 'morning doggy');
|
|
39
|
+
t.is(search.results[0].thumbnail_url, 'https://dl.phncdn.com/pics/gifs/004/331/571/(m=bKW1KNV)(mh=vzX1GL0377Gigrxw)4331571a.jpg');
|
|
40
|
+
t.is(search.results[0].link_mp4, 'https://dl.phncdn.com/pics/gifs/004/331/571/4331571a.mp4');
|
|
41
|
+
t.is(search.results[0].link_webm, 'https://dl.phncdn.com/pics/gifs/004/331/571/4331571a.webm');
|
|
42
|
+
t.is(search.results[1].title, 'Sophie Dee Doggy Anal');
|
|
43
|
+
t.is(search.results[1].thumbnail_url, 'https://dl.phncdn.com/pics/gifs/005/296/662/(m=bKW1KNV)(mh=RRWPmEuWI13Ee-gQ)5296662a.jpg');
|
|
44
|
+
t.is(search.results[1].link_mp4, 'https://dl.phncdn.com/pics/gifs/005/296/662/5296662a.mp4');
|
|
45
|
+
t.is(search.results[1].link_webm, 'https://dl.phncdn.com/pics/gifs/005/296/662/5296662a.webm');
|
|
46
|
+
|
|
47
|
+
t.is(search.results.length, 34);
|
|
48
|
+
nock.cleanAll();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test('[SEARCH] Try to trigger an error', async t => {
|
|
52
|
+
nock('https://www.pornhub.com')
|
|
53
|
+
.get('/video/search?search=bb&page=1')
|
|
54
|
+
.reply(404);
|
|
55
|
+
const search = await m.search('Bb', ['title']);
|
|
56
|
+
|
|
57
|
+
t.is(search.error, 'An error occured');
|
|
58
|
+
nock.cleanAll();
|
|
59
|
+
});
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
const test = require('ava');
|
|
2
|
+
const jsdom = require('jsdom');
|
|
3
|
+
const m = require('../../src/utils');
|
|
4
|
+
const utils_scrap = require('../../src/helpers/utils_scrap');
|
|
5
|
+
|
|
6
|
+
test('[UTILS] Test name_to_url', async t => {
|
|
7
|
+
const url = await m.name_to_url('teacher in macao', 'model');
|
|
8
|
+
|
|
9
|
+
t.is(url, 'https://www.pornhub.com/model/teacher-in-macao');
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
test('[UTILS] Test name_to_url with pornstar', async t => {
|
|
13
|
+
const url = await m.name_to_url('teacher in macao', 'pornstar');
|
|
14
|
+
|
|
15
|
+
t.is(url, 'https://www.pornhub.com/pornstar/teacher-in-macao');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
test('[UTILS] Test name_to_url without a name', async t => {
|
|
19
|
+
const url = await m.name_to_url(null);
|
|
20
|
+
|
|
21
|
+
t.is(url, null);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('[UTILS] Test name_to_url with an empty name', async t => {
|
|
25
|
+
const url = await m.name_to_url('');
|
|
26
|
+
|
|
27
|
+
t.is(url, null);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('[UTILS] Test name_to_url without a parameter', async t => {
|
|
31
|
+
const url = await m.name_to_url();
|
|
32
|
+
|
|
33
|
+
t.is(url, null);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test('[UTILS] Test options_to_keys without a parameter', async t => {
|
|
37
|
+
const error = await t.throws(() => {
|
|
38
|
+
m.options_to_keys([]);
|
|
39
|
+
});
|
|
40
|
+
t.is(error.message, 'A key need to be used with this call');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
test('[UTILS] Test convert_to_second with good parameter minutes and seconds', async t => {
|
|
44
|
+
const timestamp = await m.convert_to_second('3:35');
|
|
45
|
+
t.is(timestamp, 215);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test('[UTILS] Test convert_to_second with good parameter hours, minutes and seconds', async t => {
|
|
49
|
+
const timestamp = await m.convert_to_second('2:03:35');
|
|
50
|
+
t.is(timestamp, 7415);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
test('[UTILS] Test convert_to_second with good parameter seconds timer', async t => {
|
|
54
|
+
const timestamp = await m.convert_to_second('00:35');
|
|
55
|
+
t.is(timestamp, 35);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('[UTILS] Test convert_to_second with good parameter seconds', async t => {
|
|
59
|
+
const timestamp = await m.convert_to_second('22');
|
|
60
|
+
t.is(timestamp, 22);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test('[UTILS] Test convert_to_second with bad parameter empty', async t => {
|
|
64
|
+
const timestamp = await m.convert_to_second('');
|
|
65
|
+
t.is(timestamp, 'No Data');
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test('[UTILS] Test convert_to_second with good parameter null', async t => {
|
|
69
|
+
const timestamp = await m.convert_to_second(null);
|
|
70
|
+
t.is(timestamp, 'No Data');
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test('[UTILS] Test convert_to_second with good parameter none', async t => {
|
|
74
|
+
const timestamp = await m.convert_to_second();
|
|
75
|
+
t.is(timestamp, 'No Data');
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test('[UTILS] Test scrap dataContent with good parameter', async t => {
|
|
79
|
+
const dom = new jsdom.JSDOM('<html><meta content="inside">content</meta></html>');
|
|
80
|
+
const doc = dom.window.document;
|
|
81
|
+
const keys = {test: 'meta'};
|
|
82
|
+
const attributs = {test: 'dataContent'};
|
|
83
|
+
|
|
84
|
+
const scrap = await utils_scrap.scrap(doc, keys, attributs);
|
|
85
|
+
|
|
86
|
+
t.is(scrap.test, 'inside');
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
test('[UTILS] Test scrap dataContent with bad parameter - empty', async t => {
|
|
90
|
+
const dom = new jsdom.JSDOM('<html><div data-content="inside">content</div></html>');
|
|
91
|
+
const doc = dom.window.document;
|
|
92
|
+
const keys = {test: null};
|
|
93
|
+
const attributs = {test: 'dataContent'};
|
|
94
|
+
|
|
95
|
+
const scrap = await utils_scrap.scrap(doc, keys, attributs);
|
|
96
|
+
|
|
97
|
+
t.is(scrap.test, 'No Data');
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
test('[UTILS] Test http_to_https with good parameter', t => {
|
|
101
|
+
const url = m.http_to_https('http://pornhub.com/view_video.php?viewkey=ph5cacd6fc1e731');
|
|
102
|
+
|
|
103
|
+
t.is(url, 'https://pornhub.com/view_video.php?viewkey=ph5cacd6fc1e731');
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
test('[UTILS] Test create_query with good parameter', t => {
|
|
107
|
+
const query = m.create_query('p', 'test', ['test', 'notest']);
|
|
108
|
+
|
|
109
|
+
t.is(query, '&p=test');
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
test('[UTILS] Test create_query with empty parameter', t => {
|
|
113
|
+
const query = m.create_query('p', undefined, ['test', 'notest']);
|
|
114
|
+
|
|
115
|
+
t.is(query, '');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('[UTILS] Test create_query with not allowed parameter', t => {
|
|
119
|
+
const query = m.create_query('p', 'not_allowed', ['test', 'notest']);
|
|
120
|
+
|
|
121
|
+
t.is(query, '');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
test('[UTILS] Test create_queries with not allowed parameter', t => {
|
|
125
|
+
const query = m.create_queries({max_duration: 20}, 0);
|
|
126
|
+
|
|
127
|
+
t.is(query, '?max_duration=20&page=1');
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test('[UTILS] Test create_link with not allowed parameter', t => {
|
|
131
|
+
const query = m.create_link({max_duration: 20}, 0);
|
|
132
|
+
|
|
133
|
+
t.is(query, 'https://www.pornhub.com/video?max_duration=20&page=1');
|
|
134
|
+
});
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const test = require('ava');
|
|
2
|
+
const nock = require('nock');
|
|
3
|
+
const m = require('../../src');
|
|
4
|
+
|
|
5
|
+
test('[VIDEO] Try to trigger an error', async t => {
|
|
6
|
+
nock('https://www.pornhub.com')
|
|
7
|
+
.get('/video?o=ht&page=1')
|
|
8
|
+
.reply(404);
|
|
9
|
+
const video = await m.video(null, {filter: 'HOTTEST'});
|
|
10
|
+
|
|
11
|
+
t.is(video.error, 'An error occured');
|
|
12
|
+
nock.cleanAll();
|
|
13
|
+
});
|