-
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.
Merge pull request #5 from LucasLeandro1204/2.0
2.0
- Loading branch information
Showing
15 changed files
with
389 additions
and
335 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
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 |
---|---|---|
@@ -1,12 +1,11 @@ | ||
'use strict'; | ||
|
||
const pornsearch = require('../'); | ||
const pornhub = pornsearch.load('pornhub'); | ||
const Pornsearch = require('../').search(); | ||
|
||
pornhub.videos('boobs') | ||
.then((response) => { | ||
console.log(response); | ||
Pornsearch.driver('sex').gifs() | ||
.then((gifs) => { | ||
console.log(gifs); | ||
|
||
return Pornsearch.videos(); | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
}); | ||
.then(videos => console.log(videos)); |
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
'use strict'; | ||
|
||
module.exports = require('./src/pornsearch'); | ||
module.exports = require('./src/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
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,41 @@ | ||
'use strict'; | ||
|
||
class AbstractModule { | ||
constructor () { | ||
this.query = ''; | ||
} | ||
|
||
get name () { | ||
throw new Error('This function must be overwrite'); | ||
} | ||
|
||
get firstpage () { | ||
throw new Error('This function must be overwrite'); | ||
} | ||
|
||
videoUrl () { | ||
throw new Error(`${this.name} doesn't support video search`); | ||
} | ||
|
||
gifUrl () { | ||
throw new Error(`${this.name} doesn't support gif search`); | ||
} | ||
|
||
videoParser () { | ||
throw new Error('This function must be overwrite'); | ||
} | ||
|
||
gifParser () { | ||
throw new Error('This function must be overwrite'); | ||
} | ||
|
||
static extendsToMe (module) { | ||
if (! (module instanceof this)) { | ||
throw new Error(`Module should be an instance of Abstract module`); | ||
} | ||
|
||
return module; | ||
} | ||
}; | ||
|
||
module.exports = AbstractModule; |
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,58 @@ | ||
'use strict'; | ||
|
||
const AbstractModule = require('../Core/AbstractModule'); | ||
|
||
class Pornhub extends AbstractModule { | ||
get name () { | ||
return 'Pornhub'; | ||
} | ||
|
||
get firstpage () { | ||
return 1; | ||
} | ||
|
||
videoUrl (page) { | ||
return `http://www.pornhub.com/video/search?search=${this.query}&page=${page || this.firstpage}`; | ||
} | ||
|
||
gifUrl (page) { | ||
return `http://www.pornhub.com/gifs/search?search=${this.query}&page=${page || this.firstpage}`; | ||
} | ||
|
||
videoParser ($) { | ||
let videos = $('ul.videos.search-video-thumbs li'); | ||
|
||
return videos.map((i, video) => { | ||
video = $(video); | ||
|
||
let data = video.find('a').eq(0); | ||
|
||
return data.length | ||
? { | ||
title: data.find('img').attr('title'), | ||
url: 'http://pornhub.com/' + data.attr('href'), | ||
duration: data.find('.duration').text(), | ||
thumb: data.find('img').attr('data-mediumthumb').replace('(m=ecuK8daaaa)', '') | ||
} | ||
: undefined; | ||
}).get(); | ||
} | ||
|
||
gifParser ($) { | ||
let gifs = $('ul.gifs.gifLink li'); | ||
|
||
return gifs.map((i, gif) => { | ||
gif = $(gif); | ||
|
||
let data = gif.find('a'); | ||
|
||
return { | ||
title: data.find('span').text(), | ||
url: 'http://dl.phncdn.com#id#.gif'.replace('#id#', data.attr('href')), | ||
webm: data.find('video').attr('data-webm') | ||
}; | ||
}).get(); | ||
} | ||
}; | ||
|
||
module.exports = Pornhub; |
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 @@ | ||
'use strict'; | ||
|
||
const AbstractModule = require('../Core/AbstractModule'); | ||
|
||
class Redtube extends AbstractModule { | ||
get name () { | ||
return 'Redtube'; | ||
} | ||
|
||
get firstpage () { | ||
return 1; | ||
} | ||
|
||
videoUrl (page) { | ||
return `https://api.redtube.com/?data=redtube.Videos.searchVideos&output=json&search=${this.query}&thumbsize=big&page=${page || this.firstpage}`; | ||
} | ||
|
||
videoParser ($, { videos }) { | ||
return videos.map(({ video }) => { | ||
return { | ||
title: video.title, | ||
url: video.url, | ||
duration: video.duration, | ||
thumb: video.default_thumb, | ||
}; | ||
}); | ||
} | ||
}; | ||
|
||
module.exports = Redtube; |
Oops, something went wrong.