xvideosx 1.6.3 → 1.6.4
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/AUTHORS +2 -2
- package/README.md +3 -2
- package/index.js +1 -1
- package/lib/api/base.js +14 -14
- package/lib/api/index.js +5 -5
- package/lib/api/videos/best/best.js +19 -19
- package/lib/api/videos/best/best.spec.js +138 -138
- package/lib/api/videos/best/createHasNextFunction.js +10 -10
- package/lib/api/videos/best/createHasPreviousFunction.js +10 -10
- package/lib/api/videos/best/createNextFunction.js +12 -12
- package/lib/api/videos/best/createPreviousFunction.js +12 -12
- package/lib/api/videos/best/createRefreshFunction.js +11 -11
- package/lib/api/videos/best/index.js +1 -1
- package/lib/api/videos/best/parseResponse.js +45 -45
- package/lib/api/videos/best/parseVideo.js +27 -27
- package/lib/api/videos/dashboard/createHasNextFunction.js +10 -10
- package/lib/api/videos/dashboard/createHasPreviousFunction.js +10 -10
- package/lib/api/videos/dashboard/createNextFunction.js +12 -12
- package/lib/api/videos/dashboard/createPreviousFunction.js +12 -12
- package/lib/api/videos/dashboard/createRefreshFunction.js +11 -11
- package/lib/api/videos/dashboard/dashboard.js +14 -14
- package/lib/api/videos/dashboard/dashboard.spec.js +138 -138
- package/lib/api/videos/dashboard/index.js +1 -1
- package/lib/api/videos/dashboard/parseResponse.js +45 -45
- package/lib/api/videos/dashboard/parseVideo.js +27 -27
- package/lib/api/videos/details/details.js +14 -14
- package/lib/api/videos/details/details.spec.js +49 -49
- package/lib/api/videos/details/index.js +1 -1
- package/lib/api/videos/details/parseCategory.js +9 -9
- package/lib/api/videos/details/parseModels.js +21 -21
- package/lib/api/videos/details/parseRelated.js +24 -24
- package/lib/api/videos/details/parseResponse.js +43 -43
- package/lib/api/videos/details/parseVideo.js +30 -30
- package/lib/api/videos/fresh/createHasNextFunction.js +10 -10
- package/lib/api/videos/fresh/createHasPreviousFunction.js +10 -10
- package/lib/api/videos/fresh/createNextFunction.js +12 -12
- package/lib/api/videos/fresh/createPreviousFunction.js +12 -12
- package/lib/api/videos/fresh/createRefreshFunction.js +11 -11
- package/lib/api/videos/fresh/fresh.js +14 -14
- package/lib/api/videos/fresh/fresh.spec.js +138 -138
- package/lib/api/videos/fresh/index.js +1 -1
- package/lib/api/videos/fresh/parseResponse.js +45 -45
- package/lib/api/videos/fresh/parseVideo.js +27 -27
- package/lib/api/videos/index.js +9 -9
- package/lib/api/videos/newfresh/createHasNextFunction.js +10 -10
- package/lib/api/videos/newfresh/createHasPreviousFunction.js +10 -10
- package/lib/api/videos/newfresh/createNextFunction.js +12 -12
- package/lib/api/videos/newfresh/createPreviousFunction.js +12 -12
- package/lib/api/videos/newfresh/createRefreshFunction.js +11 -11
- package/lib/api/videos/newfresh/newfresh.js +20 -20
- package/lib/api/videos/newfresh/parseResponse.js +47 -47
- package/lib/api/videos/newfresh/parseVideo.js +45 -45
- package/lib/api/videos/search/createHasNextFunction.js +10 -10
- package/lib/api/videos/search/createHasPreviousFunction.js +10 -10
- package/lib/api/videos/search/createNextFunction.js +12 -12
- package/lib/api/videos/search/createPreviousFunction.js +12 -12
- package/lib/api/videos/search/createRefreshFunction.js +11 -11
- package/lib/api/videos/search/index.js +1 -1
- package/lib/api/videos/search/parseResponse.js +45 -45
- package/lib/api/videos/search/parseVideo.js +27 -27
- package/lib/api/videos/search/search.js +23 -23
- package/lib/api/videos/search/search.spec.js +138 -138
- package/lib/api/videos/verified/createHasNextFunction.js +10 -10
- package/lib/api/videos/verified/createHasPreviousFunction.js +10 -10
- package/lib/api/videos/verified/createNextFunction.js +12 -12
- package/lib/api/videos/verified/createPreviousFunction.js +12 -12
- package/lib/api/videos/verified/createRefreshFunction.js +11 -11
- package/lib/api/videos/verified/index.js +1 -1
- package/lib/api/videos/verified/parseResponse.js +45 -45
- package/lib/api/videos/verified/parseVideo.js +27 -27
- package/lib/api/videos/verified/verified.js +14 -14
- package/lib/api/videos/verified/verified.spec.js +138 -138
- package/lib/index.js +1 -1
- package/lib/xvideos.js +1 -1
- package/lib/xvideos.spec.js +19 -19
- package/package.json +1 -1
@@ -1,138 +1,138 @@
|
|
1
|
-
/* eslint-disable padded-blocks */
|
2
|
-
|
3
|
-
const chai = require('chai');
|
4
|
-
const search = require('./search');
|
5
|
-
|
6
|
-
before(() => {
|
7
|
-
chai.should();
|
8
|
-
});
|
9
|
-
|
10
|
-
describe('api/videos/search', () => {
|
11
|
-
|
12
|
-
it('should list videos based on search param', async () => {
|
13
|
-
const list = await search({ page: 2, k: 'threesome' });
|
14
|
-
|
15
|
-
list.should.be.an('object');
|
16
|
-
list.pagination.should.be.an('object');
|
17
|
-
list.pagination.page.should.be.equals(2);
|
18
|
-
list.pagination.pages.should.be.an('array');
|
19
|
-
list.pagination.pages[0].should.be.a('number');
|
20
|
-
list.hasNext.should.be.a('function');
|
21
|
-
list.hasNext().should.be.equals(true);
|
22
|
-
list.hasPrevious.should.be.a('function');
|
23
|
-
list.hasPrevious().should.be.equals(true);
|
24
|
-
list.next.should.be.a('function');
|
25
|
-
list.previous.should.be.a('function');
|
26
|
-
list.videos.should.be.an('array');
|
27
|
-
list.videos.forEach((video) => {
|
28
|
-
video.should.be.an('object');
|
29
|
-
video.should.have.ownPropertyDescriptor('duration');
|
30
|
-
video.duration.should.be.a('string');
|
31
|
-
video.should.have.ownPropertyDescriptor('path');
|
32
|
-
video.path.should.be.a('string');
|
33
|
-
video.should.have.ownPropertyDescriptor('profile');
|
34
|
-
video.profile.should.be.an('object');
|
35
|
-
video.profile.should.have.ownPropertyDescriptor('name');
|
36
|
-
video.profile.name.should.be.an('string');
|
37
|
-
video.profile.should.have.ownPropertyDescriptor('url');
|
38
|
-
video.profile.url.should.be.an('string');
|
39
|
-
video.should.have.ownPropertyDescriptor('title');
|
40
|
-
video.title.should.be.a('string');
|
41
|
-
video.should.have.ownPropertyDescriptor('url');
|
42
|
-
video.url.should.be.a('string');
|
43
|
-
video.should.have.ownPropertyDescriptor('views');
|
44
|
-
video.views.should.be.a('string');
|
45
|
-
});
|
46
|
-
|
47
|
-
const previous = await list.previous();
|
48
|
-
previous.should.be.an('object');
|
49
|
-
previous.pagination.should.be.an('object');
|
50
|
-
previous.pagination.page.should.be.equals(1);
|
51
|
-
previous.pagination.pages.should.be.an('array');
|
52
|
-
previous.pagination.pages[0].should.be.a('number');
|
53
|
-
previous.hasNext.should.be.a('function');
|
54
|
-
previous.hasNext().should.be.equals(true);
|
55
|
-
previous.hasPrevious.should.be.a('function');
|
56
|
-
previous.hasPrevious().should.be.equals(false);
|
57
|
-
previous.next.should.be.a('function');
|
58
|
-
previous.previous.should.be.a('function');
|
59
|
-
previous.videos.should.be.an('array');
|
60
|
-
previous.videos.forEach((video) => {
|
61
|
-
video.should.be.an('object');
|
62
|
-
video.should.have.ownPropertyDescriptor('duration');
|
63
|
-
video.duration.should.be.a('string');
|
64
|
-
video.should.have.ownPropertyDescriptor('path');
|
65
|
-
video.path.should.be.a('string');
|
66
|
-
video.should.have.ownPropertyDescriptor('profile');
|
67
|
-
video.profile.should.be.an('object');
|
68
|
-
video.profile.should.have.ownPropertyDescriptor('name');
|
69
|
-
video.profile.name.should.be.an('string');
|
70
|
-
video.profile.should.have.ownPropertyDescriptor('url');
|
71
|
-
video.profile.url.should.be.an('string');
|
72
|
-
video.should.have.ownPropertyDescriptor('title');
|
73
|
-
video.title.should.be.a('string');
|
74
|
-
video.should.have.ownPropertyDescriptor('url');
|
75
|
-
video.url.should.be.a('string');
|
76
|
-
video.should.have.ownPropertyDescriptor('views');
|
77
|
-
video.views.should.be.a('string');
|
78
|
-
});
|
79
|
-
|
80
|
-
const next = await list.next();
|
81
|
-
next.should.be.an('object');
|
82
|
-
next.pagination.should.be.an('object');
|
83
|
-
next.pagination.page.should.be.equals(3);
|
84
|
-
next.pagination.pages.should.be.an('array');
|
85
|
-
next.pagination.pages[0].should.be.a('number');
|
86
|
-
next.hasNext.should.be.a('function');
|
87
|
-
next.hasNext().should.be.equals(true);
|
88
|
-
next.hasPrevious.should.be.a('function');
|
89
|
-
next.hasPrevious().should.be.equals(true);
|
90
|
-
next.next.should.be.a('function');
|
91
|
-
next.previous.should.be.a('function');
|
92
|
-
next.videos.should.be.an('array');
|
93
|
-
next.videos.forEach((video) => {
|
94
|
-
video.should.be.an('object');
|
95
|
-
video.should.have.ownPropertyDescriptor('duration');
|
96
|
-
video.duration.should.be.a('string');
|
97
|
-
video.should.have.ownPropertyDescriptor('path');
|
98
|
-
video.path.should.be.a('string');
|
99
|
-
video.should.have.ownPropertyDescriptor('profile');
|
100
|
-
video.profile.should.be.an('object');
|
101
|
-
video.profile.should.have.ownPropertyDescriptor('name');
|
102
|
-
video.profile.name.should.be.an('string');
|
103
|
-
video.profile.should.have.ownPropertyDescriptor('url');
|
104
|
-
video.profile.url.should.be.an('string');
|
105
|
-
video.should.have.ownPropertyDescriptor('title');
|
106
|
-
video.title.should.be.a('string');
|
107
|
-
video.should.have.ownPropertyDescriptor('url');
|
108
|
-
video.url.should.be.a('string');
|
109
|
-
video.should.have.ownPropertyDescriptor('views');
|
110
|
-
video.views.should.be.a('string');
|
111
|
-
});
|
112
|
-
|
113
|
-
await list.refresh();
|
114
|
-
}).timeout(10000);
|
115
|
-
|
116
|
-
it('should fail when page parameter is beyond limit', async () => {
|
117
|
-
let err;
|
118
|
-
try {
|
119
|
-
await search({ page: Number.MAX_SAFE_INTEGER + 1 });
|
120
|
-
} catch (error) {
|
121
|
-
err = error;
|
122
|
-
} finally {
|
123
|
-
err.should.be.an('error');
|
124
|
-
}
|
125
|
-
}).timeout(10000);
|
126
|
-
|
127
|
-
it('should fail when page parameter is less than 0', async () => {
|
128
|
-
let err;
|
129
|
-
try {
|
130
|
-
await search({ page: -1 });
|
131
|
-
} catch (error) {
|
132
|
-
err = error;
|
133
|
-
} finally {
|
134
|
-
err.should.be.an('error');
|
135
|
-
}
|
136
|
-
}).timeout(10000);
|
137
|
-
|
138
|
-
});
|
1
|
+
/* eslint-disable padded-blocks */
|
2
|
+
|
3
|
+
const chai = require('chai');
|
4
|
+
const search = require('./search');
|
5
|
+
|
6
|
+
before(() => {
|
7
|
+
chai.should();
|
8
|
+
});
|
9
|
+
|
10
|
+
describe('api/videos/search', () => {
|
11
|
+
|
12
|
+
it('should list videos based on search param', async () => {
|
13
|
+
const list = await search({ page: 2, k: 'threesome' });
|
14
|
+
|
15
|
+
list.should.be.an('object');
|
16
|
+
list.pagination.should.be.an('object');
|
17
|
+
list.pagination.page.should.be.equals(2);
|
18
|
+
list.pagination.pages.should.be.an('array');
|
19
|
+
list.pagination.pages[0].should.be.a('number');
|
20
|
+
list.hasNext.should.be.a('function');
|
21
|
+
list.hasNext().should.be.equals(true);
|
22
|
+
list.hasPrevious.should.be.a('function');
|
23
|
+
list.hasPrevious().should.be.equals(true);
|
24
|
+
list.next.should.be.a('function');
|
25
|
+
list.previous.should.be.a('function');
|
26
|
+
list.videos.should.be.an('array');
|
27
|
+
list.videos.forEach((video) => {
|
28
|
+
video.should.be.an('object');
|
29
|
+
video.should.have.ownPropertyDescriptor('duration');
|
30
|
+
video.duration.should.be.a('string');
|
31
|
+
video.should.have.ownPropertyDescriptor('path');
|
32
|
+
video.path.should.be.a('string');
|
33
|
+
video.should.have.ownPropertyDescriptor('profile');
|
34
|
+
video.profile.should.be.an('object');
|
35
|
+
video.profile.should.have.ownPropertyDescriptor('name');
|
36
|
+
video.profile.name.should.be.an('string');
|
37
|
+
video.profile.should.have.ownPropertyDescriptor('url');
|
38
|
+
video.profile.url.should.be.an('string');
|
39
|
+
video.should.have.ownPropertyDescriptor('title');
|
40
|
+
video.title.should.be.a('string');
|
41
|
+
video.should.have.ownPropertyDescriptor('url');
|
42
|
+
video.url.should.be.a('string');
|
43
|
+
video.should.have.ownPropertyDescriptor('views');
|
44
|
+
video.views.should.be.a('string');
|
45
|
+
});
|
46
|
+
|
47
|
+
const previous = await list.previous();
|
48
|
+
previous.should.be.an('object');
|
49
|
+
previous.pagination.should.be.an('object');
|
50
|
+
previous.pagination.page.should.be.equals(1);
|
51
|
+
previous.pagination.pages.should.be.an('array');
|
52
|
+
previous.pagination.pages[0].should.be.a('number');
|
53
|
+
previous.hasNext.should.be.a('function');
|
54
|
+
previous.hasNext().should.be.equals(true);
|
55
|
+
previous.hasPrevious.should.be.a('function');
|
56
|
+
previous.hasPrevious().should.be.equals(false);
|
57
|
+
previous.next.should.be.a('function');
|
58
|
+
previous.previous.should.be.a('function');
|
59
|
+
previous.videos.should.be.an('array');
|
60
|
+
previous.videos.forEach((video) => {
|
61
|
+
video.should.be.an('object');
|
62
|
+
video.should.have.ownPropertyDescriptor('duration');
|
63
|
+
video.duration.should.be.a('string');
|
64
|
+
video.should.have.ownPropertyDescriptor('path');
|
65
|
+
video.path.should.be.a('string');
|
66
|
+
video.should.have.ownPropertyDescriptor('profile');
|
67
|
+
video.profile.should.be.an('object');
|
68
|
+
video.profile.should.have.ownPropertyDescriptor('name');
|
69
|
+
video.profile.name.should.be.an('string');
|
70
|
+
video.profile.should.have.ownPropertyDescriptor('url');
|
71
|
+
video.profile.url.should.be.an('string');
|
72
|
+
video.should.have.ownPropertyDescriptor('title');
|
73
|
+
video.title.should.be.a('string');
|
74
|
+
video.should.have.ownPropertyDescriptor('url');
|
75
|
+
video.url.should.be.a('string');
|
76
|
+
video.should.have.ownPropertyDescriptor('views');
|
77
|
+
video.views.should.be.a('string');
|
78
|
+
});
|
79
|
+
|
80
|
+
const next = await list.next();
|
81
|
+
next.should.be.an('object');
|
82
|
+
next.pagination.should.be.an('object');
|
83
|
+
next.pagination.page.should.be.equals(3);
|
84
|
+
next.pagination.pages.should.be.an('array');
|
85
|
+
next.pagination.pages[0].should.be.a('number');
|
86
|
+
next.hasNext.should.be.a('function');
|
87
|
+
next.hasNext().should.be.equals(true);
|
88
|
+
next.hasPrevious.should.be.a('function');
|
89
|
+
next.hasPrevious().should.be.equals(true);
|
90
|
+
next.next.should.be.a('function');
|
91
|
+
next.previous.should.be.a('function');
|
92
|
+
next.videos.should.be.an('array');
|
93
|
+
next.videos.forEach((video) => {
|
94
|
+
video.should.be.an('object');
|
95
|
+
video.should.have.ownPropertyDescriptor('duration');
|
96
|
+
video.duration.should.be.a('string');
|
97
|
+
video.should.have.ownPropertyDescriptor('path');
|
98
|
+
video.path.should.be.a('string');
|
99
|
+
video.should.have.ownPropertyDescriptor('profile');
|
100
|
+
video.profile.should.be.an('object');
|
101
|
+
video.profile.should.have.ownPropertyDescriptor('name');
|
102
|
+
video.profile.name.should.be.an('string');
|
103
|
+
video.profile.should.have.ownPropertyDescriptor('url');
|
104
|
+
video.profile.url.should.be.an('string');
|
105
|
+
video.should.have.ownPropertyDescriptor('title');
|
106
|
+
video.title.should.be.a('string');
|
107
|
+
video.should.have.ownPropertyDescriptor('url');
|
108
|
+
video.url.should.be.a('string');
|
109
|
+
video.should.have.ownPropertyDescriptor('views');
|
110
|
+
video.views.should.be.a('string');
|
111
|
+
});
|
112
|
+
|
113
|
+
await list.refresh();
|
114
|
+
}).timeout(10000);
|
115
|
+
|
116
|
+
it('should fail when page parameter is beyond limit', async () => {
|
117
|
+
let err;
|
118
|
+
try {
|
119
|
+
await search({ page: Number.MAX_SAFE_INTEGER + 1 });
|
120
|
+
} catch (error) {
|
121
|
+
err = error;
|
122
|
+
} finally {
|
123
|
+
err.should.be.an('error');
|
124
|
+
}
|
125
|
+
}).timeout(10000);
|
126
|
+
|
127
|
+
it('should fail when page parameter is less than 0', async () => {
|
128
|
+
let err;
|
129
|
+
try {
|
130
|
+
await search({ page: -1 });
|
131
|
+
} catch (error) {
|
132
|
+
err = error;
|
133
|
+
} finally {
|
134
|
+
err.should.be.an('error');
|
135
|
+
}
|
136
|
+
}).timeout(10000);
|
137
|
+
|
138
|
+
});
|
@@ -1,10 +1,10 @@
|
|
1
|
-
const hasNextFunction = (currentPage, pages) => () => {
|
2
|
-
return currentPage < Math.max(...pages);
|
3
|
-
};
|
4
|
-
|
5
|
-
const createHasNextFunction = (pagination) => {
|
6
|
-
const { page, pages } = pagination;
|
7
|
-
return hasNextFunction(page, pages);
|
8
|
-
};
|
9
|
-
|
10
|
-
module.exports = createHasNextFunction;
|
1
|
+
const hasNextFunction = (currentPage, pages) => () => {
|
2
|
+
return currentPage < Math.max(...pages);
|
3
|
+
};
|
4
|
+
|
5
|
+
const createHasNextFunction = (pagination) => {
|
6
|
+
const { page, pages } = pagination;
|
7
|
+
return hasNextFunction(page, pages);
|
8
|
+
};
|
9
|
+
|
10
|
+
module.exports = createHasNextFunction;
|
@@ -1,10 +1,10 @@
|
|
1
|
-
const hasPreviousFunction = (currentPage, pages) => () => {
|
2
|
-
return currentPage > Math.min(...pages);
|
3
|
-
};
|
4
|
-
|
5
|
-
const createHasPreviousFunction = (pagination) => {
|
6
|
-
const { page, pages } = pagination;
|
7
|
-
return hasPreviousFunction(page, pages);
|
8
|
-
};
|
9
|
-
|
10
|
-
module.exports = createHasPreviousFunction;
|
1
|
+
const hasPreviousFunction = (currentPage, pages) => () => {
|
2
|
+
return currentPage > Math.min(...pages);
|
3
|
+
};
|
4
|
+
|
5
|
+
const createHasPreviousFunction = (pagination) => {
|
6
|
+
const { page, pages } = pagination;
|
7
|
+
return hasPreviousFunction(page, pages);
|
8
|
+
};
|
9
|
+
|
10
|
+
module.exports = createHasPreviousFunction;
|
@@ -1,12 +1,12 @@
|
|
1
|
-
const nextFunction = (currentPage) => () => {
|
2
|
-
const verified = require('./verified');
|
3
|
-
const next = currentPage + 1;
|
4
|
-
return verified({ page: next });
|
5
|
-
};
|
6
|
-
|
7
|
-
const createNextFunction = (pagination) => {
|
8
|
-
const { page } = pagination;
|
9
|
-
return nextFunction(page);
|
10
|
-
};
|
11
|
-
|
12
|
-
module.exports = createNextFunction;
|
1
|
+
const nextFunction = (currentPage) => () => {
|
2
|
+
const verified = require('./verified');
|
3
|
+
const next = currentPage + 1;
|
4
|
+
return verified({ page: next });
|
5
|
+
};
|
6
|
+
|
7
|
+
const createNextFunction = (pagination) => {
|
8
|
+
const { page } = pagination;
|
9
|
+
return nextFunction(page);
|
10
|
+
};
|
11
|
+
|
12
|
+
module.exports = createNextFunction;
|
@@ -1,12 +1,12 @@
|
|
1
|
-
const previousFunction = (currentPage) => () => {
|
2
|
-
const verified = require('./verified');
|
3
|
-
const previous = currentPage - 1;
|
4
|
-
return verified({ page: previous });
|
5
|
-
};
|
6
|
-
|
7
|
-
const createPreviousFunction = (pagination) => {
|
8
|
-
const { page } = pagination;
|
9
|
-
return previousFunction(page);
|
10
|
-
};
|
11
|
-
|
12
|
-
module.exports = createPreviousFunction;
|
1
|
+
const previousFunction = (currentPage) => () => {
|
2
|
+
const verified = require('./verified');
|
3
|
+
const previous = currentPage - 1;
|
4
|
+
return verified({ page: previous });
|
5
|
+
};
|
6
|
+
|
7
|
+
const createPreviousFunction = (pagination) => {
|
8
|
+
const { page } = pagination;
|
9
|
+
return previousFunction(page);
|
10
|
+
};
|
11
|
+
|
12
|
+
module.exports = createPreviousFunction;
|
@@ -1,11 +1,11 @@
|
|
1
|
-
const refreshFunction = (currentPage) => () => {
|
2
|
-
const verified = require('./verified');
|
3
|
-
return verified({ page: currentPage });
|
4
|
-
};
|
5
|
-
|
6
|
-
const createRefreshFunction = (pagination) => {
|
7
|
-
const { page } = pagination;
|
8
|
-
return refreshFunction(page);
|
9
|
-
};
|
10
|
-
|
11
|
-
module.exports = createRefreshFunction;
|
1
|
+
const refreshFunction = (currentPage) => () => {
|
2
|
+
const verified = require('./verified');
|
3
|
+
return verified({ page: currentPage });
|
4
|
+
};
|
5
|
+
|
6
|
+
const createRefreshFunction = (pagination) => {
|
7
|
+
const { page } = pagination;
|
8
|
+
return refreshFunction(page);
|
9
|
+
};
|
10
|
+
|
11
|
+
module.exports = createRefreshFunction;
|
@@ -1 +1 @@
|
|
1
|
-
module.exports = require('./verified');
|
1
|
+
module.exports = require('./verified');
|
@@ -1,45 +1,45 @@
|
|
1
|
-
const cheerio = require('cheerio');
|
2
|
-
const parseVideo = require('./parseVideo');
|
3
|
-
const createRefreshFunction = require('./createRefreshFunction');
|
4
|
-
const createHasNextFunction = require('./createHasNextFunction');
|
5
|
-
const createNextFunction = require('./createNextFunction');
|
6
|
-
const createHasPreviousFunction = require('./createHasPreviousFunction');
|
7
|
-
const createPreviousFunction = require('./createPreviousFunction');
|
8
|
-
|
9
|
-
const getVideos = ($) => {
|
10
|
-
return $('#content > .mozaique > .thumb-block')
|
11
|
-
.map((i, video) => parseVideo($, video))
|
12
|
-
.get();
|
13
|
-
};
|
14
|
-
|
15
|
-
const getPages = ($) => {
|
16
|
-
return $('.pagination > ul > li > a')
|
17
|
-
.map((i, page) => $(page)
|
18
|
-
.text())
|
19
|
-
.filter((i, page) => !isNaN(page))
|
20
|
-
.map((i, page) => Number(page))
|
21
|
-
.get();
|
22
|
-
};
|
23
|
-
|
24
|
-
const parseResponse = (page, { data }) => {
|
25
|
-
const $ = cheerio.load(data);
|
26
|
-
|
27
|
-
const videos = getVideos($);
|
28
|
-
|
29
|
-
const pagination = {
|
30
|
-
page,
|
31
|
-
pages: getPages($),
|
32
|
-
};
|
33
|
-
|
34
|
-
return {
|
35
|
-
videos,
|
36
|
-
pagination,
|
37
|
-
refresh: createRefreshFunction(pagination),
|
38
|
-
hasNext: createHasNextFunction(pagination),
|
39
|
-
next: createNextFunction(pagination),
|
40
|
-
hasPrevious: createHasPreviousFunction(pagination),
|
41
|
-
previous: createPreviousFunction(pagination),
|
42
|
-
};
|
43
|
-
};
|
44
|
-
|
45
|
-
module.exports = parseResponse;
|
1
|
+
const cheerio = require('cheerio');
|
2
|
+
const parseVideo = require('./parseVideo');
|
3
|
+
const createRefreshFunction = require('./createRefreshFunction');
|
4
|
+
const createHasNextFunction = require('./createHasNextFunction');
|
5
|
+
const createNextFunction = require('./createNextFunction');
|
6
|
+
const createHasPreviousFunction = require('./createHasPreviousFunction');
|
7
|
+
const createPreviousFunction = require('./createPreviousFunction');
|
8
|
+
|
9
|
+
const getVideos = ($) => {
|
10
|
+
return $('#content > .mozaique > .thumb-block')
|
11
|
+
.map((i, video) => parseVideo($, video))
|
12
|
+
.get();
|
13
|
+
};
|
14
|
+
|
15
|
+
const getPages = ($) => {
|
16
|
+
return $('.pagination > ul > li > a')
|
17
|
+
.map((i, page) => $(page)
|
18
|
+
.text())
|
19
|
+
.filter((i, page) => !isNaN(page))
|
20
|
+
.map((i, page) => Number(page))
|
21
|
+
.get();
|
22
|
+
};
|
23
|
+
|
24
|
+
const parseResponse = (page, { data }) => {
|
25
|
+
const $ = cheerio.load(data);
|
26
|
+
|
27
|
+
const videos = getVideos($);
|
28
|
+
|
29
|
+
const pagination = {
|
30
|
+
page,
|
31
|
+
pages: getPages($),
|
32
|
+
};
|
33
|
+
|
34
|
+
return {
|
35
|
+
videos,
|
36
|
+
pagination,
|
37
|
+
refresh: createRefreshFunction(pagination),
|
38
|
+
hasNext: createHasNextFunction(pagination),
|
39
|
+
next: createNextFunction(pagination),
|
40
|
+
hasPrevious: createHasPreviousFunction(pagination),
|
41
|
+
previous: createPreviousFunction(pagination),
|
42
|
+
};
|
43
|
+
};
|
44
|
+
|
45
|
+
module.exports = parseResponse;
|
@@ -1,27 +1,27 @@
|
|
1
|
-
const base = require('../../base');
|
2
|
-
|
3
|
-
const parseVideo = ($, video) => {
|
4
|
-
const $video = $(video);
|
5
|
-
|
6
|
-
const title = $video.find('p:not(.metadata) a').attr('title');
|
7
|
-
const path = $video.find('.thumb > a').attr('href');
|
8
|
-
const url = `${base.BASE_URL}${path}`;
|
9
|
-
const views = $video.find('p.metadata > span > span:not(.duration)').text();
|
10
|
-
const duration = $video.find('p.metadata > span.bg > span.duration').text();
|
11
|
-
const profileElement = $video.find('p.metadata > span > a');
|
12
|
-
const profile = {
|
13
|
-
name: profileElement.text(),
|
14
|
-
url: `${base.BASE_URL}${profileElement.attr('href')}`,
|
15
|
-
};
|
16
|
-
|
17
|
-
return {
|
18
|
-
url,
|
19
|
-
path,
|
20
|
-
title,
|
21
|
-
duration,
|
22
|
-
profile,
|
23
|
-
views,
|
24
|
-
};
|
25
|
-
};
|
26
|
-
|
27
|
-
module.exports = parseVideo;
|
1
|
+
const base = require('../../base');
|
2
|
+
|
3
|
+
const parseVideo = ($, video) => {
|
4
|
+
const $video = $(video);
|
5
|
+
|
6
|
+
const title = $video.find('p:not(.metadata) a').attr('title');
|
7
|
+
const path = $video.find('.thumb > a').attr('href');
|
8
|
+
const url = `${base.BASE_URL}${path}`;
|
9
|
+
const views = $video.find('p.metadata > span > span:not(.duration)').text();
|
10
|
+
const duration = $video.find('p.metadata > span.bg > span.duration').text();
|
11
|
+
const profileElement = $video.find('p.metadata > span > a');
|
12
|
+
const profile = {
|
13
|
+
name: profileElement.text(),
|
14
|
+
url: `${base.BASE_URL}${profileElement.attr('href')}`,
|
15
|
+
};
|
16
|
+
|
17
|
+
return {
|
18
|
+
url,
|
19
|
+
path,
|
20
|
+
title,
|
21
|
+
duration,
|
22
|
+
profile,
|
23
|
+
views,
|
24
|
+
};
|
25
|
+
};
|
26
|
+
|
27
|
+
module.exports = parseVideo;
|
@@ -1,14 +1,14 @@
|
|
1
|
-
const base = require('../../base');
|
2
|
-
const parseResponse = require('./parseResponse');
|
3
|
-
|
4
|
-
const PATH = '/verified/videos';
|
5
|
-
|
6
|
-
const verified = async ({ page = 1 } = {}) => {
|
7
|
-
if (page < 1 || page > Number.MAX_SAFE_INTEGER) {
|
8
|
-
throw new Error(`Invalid page: ${page}`);
|
9
|
-
}
|
10
|
-
const request = base.createRequest();
|
11
|
-
return parseResponse(page, await request.get(`${PATH}/${page === 0 ? '' : page}`));
|
12
|
-
};
|
13
|
-
|
14
|
-
module.exports = verified;
|
1
|
+
const base = require('../../base');
|
2
|
+
const parseResponse = require('./parseResponse');
|
3
|
+
|
4
|
+
const PATH = '/verified/videos';
|
5
|
+
|
6
|
+
const verified = async ({ page = 1 } = {}) => {
|
7
|
+
if (page < 1 || page > Number.MAX_SAFE_INTEGER) {
|
8
|
+
throw new Error(`Invalid page: ${page}`);
|
9
|
+
}
|
10
|
+
const request = base.createRequest();
|
11
|
+
return parseResponse(page, await request.get(`${PATH}/${page === 0 ? '' : page}`));
|
12
|
+
};
|
13
|
+
|
14
|
+
module.exports = verified;
|