├── .editorconfig
├── .gitattributes
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── index.js
├── opt.js
├── package.json
└── test.js
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | indent_style = tab
5 | end_of_line = lf
6 | charset = utf-8
7 | trim_trailing_whitespace = true
8 | insert_final_newline = true
9 |
10 | [{package.json,*.yml}]
11 | indent_style = space
12 | indent_size = 2
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text=auto
2 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Logs
2 | logs
3 | *.log
4 | npm-debug.log*
5 |
6 | # Runtime data
7 | pids
8 | *.pid
9 | *.seed
10 |
11 | # Directory for instrumented libs generated by jscoverage/JSCover
12 | lib-cov
13 |
14 | # Coverage directory used by tools like istanbul
15 | coverage
16 |
17 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
18 | .grunt
19 |
20 | # node-waf configuration
21 | .lock-wscript
22 |
23 | # Compiled binary addons (http://nodejs.org/api/addons.html)
24 | build/Release
25 |
26 | # Dependency directory
27 | node_modules
28 |
29 | # Optional npm cache directory
30 | .npm
31 |
32 | # Optional REPL history
33 | .node_repl_history
34 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - '8'
4 | - '6'
5 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) Rishi Giri
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | 🅿 🅾 🆁 🅽 - 🅷 🆄 🅱
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 | ℍ𝕆ℝℕ𝕐 ℙ𝕆ℝℕ𝕐 ℂ𝕆ℝℕ𝕐
14 |
15 |
16 |
17 | ### Install
18 |
19 | ```
20 | $ npm install --save pornnhub
21 | ```
22 |
23 | ### Usage
24 |
25 | ```js
26 | const pornhub = require('pornnhub');
27 |
28 | const url = 'https://www.pornhub.com/view_video.php?viewkey=ph56fc59c124c0c';
29 |
30 | pornhub(url, 'title').then(res => {
31 | console.log(res);
32 | // => { data: 'Hot kissing scene' }
33 | });
34 |
35 | ```
36 |
37 | ```js
38 | pornhub(url, 'views').then(res => {
39 | console.log(res);
40 | // => { data: '615,031' }
41 | });
42 | ```
43 |
44 | ```js
45 | pornhub(url, 'low').then(res => {
46 | console.log(res);
47 | // => { data: 'https://cv.phncdn.com/videos/201603/30/../240P_400K_72472822.mp4?a5c..3d8' }
48 | });
49 | ```
50 |
51 | ### `API`
52 |
53 | #### __`pornhub(url, opts)`__
54 |
55 |
56 | __`typeof`__ `url` __-__ __`string`__
57 |
58 | __`tyepof`__ `opt` __-__ __`string`__
59 |
60 | | __`opts`__ | __`get`__ |
61 | |------------|----------------------------|
62 | | __`title`__ | `title of the porn` |
63 | | __`views`__ | `total views on a video` |
64 | | __`percent`__ | `popularity percentage` |
65 | | __`upvotes`__ | `total upvotes on a video` |
66 | | __`downvotes`__ | `total downvotes on a video` |
67 | | __`provider`__ | `video uploaded by` |
68 | | __`low`__ | `240px downloadable url` |
69 | | __`medium`__ | `480px downloadable url` |
70 | | __`high`__ | `720px downloadable url` |
71 |
72 | ### Related
73 |
74 | - __[`phub`](https://github.com/CodeDotJS/phub)__ `:` `PornHub Informer`
75 |
76 | ## License
77 |
78 | MIT - Copyright © [Rishi Giri](http://rishi.ml)
79 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | const got = require('got');
4 |
5 | const scape = str => {
6 | return str.replace(/\\/g, '');
7 | };
8 |
9 | const parseInputData = {
10 | title: ``,
12 | percent: ``,
13 | upvotes: ``,
14 | downvotes: ``,
15 | provider: `bolded">`,
16 | low: `quality":"240","videoUrl":"`,
17 | medium: `quality":"480","videoUrl":"`,
18 | high: `quality":"720","videoUrl":"`
19 | };
20 |
21 | const splitSource = (data, title) => {
22 | if (title === parseInputData.title || title === parseInputData.medium || title === parseInputData.low || title === parseInputData.high) {
23 | return data.split(title)[1].split('"')[0];
24 | }
25 |
26 | if (title === parseInputData.views || title === parseInputData.upvotes || title === parseInputData.downvotes || title === parseInputData.percent) {
27 | return data.split(title)[1].split('')[0];
28 | }
29 |
30 | return data.split(title)[1].split('')[0];
31 | };
32 |
33 | module.exports = (url, data) => {
34 | return got(url).then(res => {
35 | const source = res.body;
36 | const info = splitSource(source, parseInputData[data]);
37 | return {data: scape(info)};
38 | }).catch(err => {
39 | if (err) {
40 | err.message = 'the requested data is not available';
41 | }
42 | return {data: err.message};
43 | });
44 | };
45 |
--------------------------------------------------------------------------------
/opt.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | 'use strict';
4 |
5 | const porn = require('.');
6 |
7 | const url = 'https://www.pornhub.com/view_video.php?viewkey=ph56fc59c124c0c';
8 |
9 | const opt = process.argv[2];
10 |
11 | const returnPornData = (source, opts) => {
12 | return porn(source, opts).then(res => {
13 | console.log(res);
14 | });
15 | };
16 |
17 | // OPT : title, views, upvotes, downvotes, low, medium, high, provider, percent
18 |
19 | returnPornData(url, opt);
20 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "pornnhub",
3 | "version": "1.0.0",
4 | "description": "Horny Porny Corny",
5 | "license": "MIT",
6 | "repository": {
7 | "type": "git",
8 | "url": "git+https://github.com/CodeDotJS/porn-hub.git"
9 | },
10 | "author": "Rishi Giri (rishi.ml)",
11 | "engines": {
12 | "node": ">=4"
13 | },
14 | "scripts": {
15 | "test": "xo && ava"
16 | },
17 | "files": [
18 | "index.js",
19 | "opt.js"
20 | ],
21 | "keywords": [
22 | "porn",
23 | "title",
24 | "views",
25 | "upvotes",
26 | "downvotes",
27 | "fetch",
28 | "extract",
29 | "download",
30 | "url",
31 | "high definition",
32 | "api"
33 | ],
34 | "dependencies": {
35 | "got": "6.6.3"
36 | },
37 | "devDependencies": {
38 | "ava": "*",
39 | "execa": "^0.2.2",
40 | "xo": "*"
41 | },
42 | "xo": {
43 | "esnext": true
44 | },
45 | "bugs": {
46 | "url": "https://github.com/CodeDotJS/porn-hub/issues"
47 | },
48 | "homepage": "https://github.com/CodeDotJS/porn-hub#readme",
49 | "main": "index.js"
50 | }
51 |
--------------------------------------------------------------------------------
/test.js:
--------------------------------------------------------------------------------
1 | import test from 'ava';
2 | import m from '.';
3 |
4 | const url = 'https://www.pornhub.com/view_video.php?viewkey=ph56fc59c124c0c';
5 |
6 | test('title', async t => {
7 | const video = await m(url, 'title');
8 |
9 | t.is(video.data, 'Hot kissing scene');
10 | });
11 |
--------------------------------------------------------------------------------