-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ddf49e
commit 80bfc95
Showing
6 changed files
with
158 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
#Pornsearch | ||
Easy way to search for porn content on the [Pornhub](http://pornhub.com/) | ||
|
||
##Simple search | ||
```js | ||
const pornsearch = require('../lib/pornsearch'); | ||
|
||
pornsearch.videos('boobs') | ||
.then((response) => { | ||
console.log(response); | ||
}); | ||
``` | ||
|
||
##Installation | ||
Via GIT: | ||
```bash | ||
$ git clone git://github.com/LucasLeandro1204/api.git node_modules/pornsearch | ||
``` | ||
Via NPM: | ||
```bash | ||
$ npm install pornsearch | ||
``` | ||
|
||
##Output | ||
If has success, the return will be an array with ~~possibly less than~~ 20 videos, structured as | ||
```js | ||
{ | ||
title: 'video title', | ||
url: 'video url', | ||
thumb: 'video thumbnail' | ||
} | ||
``` | ||
If has error, will be returned a message like | ||
```Markdown | ||
No results for search related to *relation* in page *page* and category number *number* | ||
``` | ||
|
||
##Usage | ||
First require Pornsearch | ||
```js | ||
const pornsearch = require('../lib/pornsearch'); | ||
``` | ||
Search for related only | ||
|
||
```js | ||
pornsearch.videos('boobs') | ||
.then((response) => { | ||
console.log(response); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
``` | ||
Specify the page number to search on | ||
|
||
```js | ||
pornsearch.videos('ass', 3); | ||
``` | ||
You can too search by category number (look at Pornhub and search through for it) | ||
|
||
```js | ||
pornsearch.videos('young', 5, 41); | ||
``` | ||
|
||
###To do | ||
|
||
- [ ] Search for GIF |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use strict'; | ||
|
||
const pornsearch = require('../lib/pornsearch'); | ||
|
||
pornsearch.videos('boobs') | ||
.then((response) => { | ||
console.log(response); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('./lib/pornsearch'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"name": "pornsearch", | ||
"version": "0.1.0", | ||
"description": "Easy way to search for porn content on the Pornhub", | ||
"main": "src/pornsearch.js", | ||
"scripts": { | ||
"test": "node ./example/example" | ||
}, | ||
"keywords": [ | ||
"porn", | ||
"nsfw", | ||
"pornhub", | ||
"xvideos", | ||
"boobs" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/LucasLeandro1204/api.git" | ||
}, | ||
"author": "Lucas", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": "https://github.com/LucasLeandro1204/api/issues" | ||
}, | ||
"homepage": "https://github.com/LucasLeandro1204/api#readme", | ||
"devDependencies": { | ||
"axios": "^0.15.3", | ||
"cheerio": "^0.22.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
|
||
const axios = require('axios'); | ||
const cheerio = require('cheerio'); | ||
|
||
const Pornsearch = { | ||
|
||
videos(relation, page = 1, category = 0) { | ||
let url = `http://www.pornhub.com/video/search?search=${relation}&page=${page}&filter_category=${category}`; | ||
|
||
return new Promise((resolve, reject) => { | ||
axios.get(url) | ||
.then((response) => { | ||
resolve(this.video.parse(response.data)); | ||
}) | ||
.catch((error) => { | ||
reject(`No results for search related to ${relation} in page ${page} and category number ${0}`); | ||
}); | ||
}); | ||
}, | ||
|
||
video: { | ||
parse(body) { | ||
const $ = cheerio.load(body); | ||
let videos = $('ul.videos.search-video-thumbs li'); | ||
|
||
return videos.map((i, video) => this.format($(video))).get(); | ||
}, | ||
|
||
format(video) { | ||
let data = video.find('a').eq(0); | ||
|
||
if (data.length !== 1) { | ||
return undefined; | ||
} | ||
|
||
return { | ||
title: data.attr('title'), | ||
url: data.attr('href'), | ||
thumb: data.find('img').attr('data-mediumthumb') | ||
}; | ||
} | ||
} | ||
}; | ||
|
||
module.exports = Pornsearch; |