Skip to content

Commit

Permalink
Merge pull request #32 from OSintt/osintt
Browse files Browse the repository at this point in the history
improving search method
  • Loading branch information
rodrigogs authored Jul 20, 2024
2 parents a8255d8 + af3b1a3 commit f4d41b6
Show file tree
Hide file tree
Showing 5 changed files with 3,712 additions and 190 deletions.
340 changes: 178 additions & 162 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,185 +4,201 @@
[![Code Climate](https://codeclimate.com/github/rodrigogs/xvideos/badges/gpa.svg)](https://codeclimate.com/github/rodrigogs/xvideos)
[![Test Coverage](https://codeclimate.com/github/rodrigogs/xvideos/badges/coverage.svg)](https://codeclimate.com/github/rodrigogs/xvideos/coverage)

A a [Node.js](https://nodejs.org) [xvideos.com](xvideos.com) API library.
A [Node.js](https://nodejs.org) library for the [xvideos.com](https://www.xvideos.com) API.

## Installation

### Install
```bash
$ npm install @rodrigogs/xvideos
```

### Usage
## Usage

```javascript
const xvideos = require('@rodrigogs/xvideos');

//-- Inside an async function --//

// Retrieve fresh videos
// Retrieve fresh videos from the first page
const fresh = await xvideos.videos.fresh({ page: 1 });
console.log(fresh.videos); // { url, path, title, duration, profile: { name, url }, views, }
console.log(fresh.pagination.current); // 1
console.log(fresh.pagination.pages); // [1, 2, 3, 4, 5...]
console.log(fresh.hasNext()); // true
console.log(fresh.hasPrevious()); // false
// Log details of the retrieved videos
console.log(fresh.videos); // Array of video objects with properties like url, path, title, duration, profile, views
console.log(fresh.pagination.current); // Current page number
console.log(fresh.pagination.pages); // Array of available page numbers
console.log(fresh.hasNext()); // Check if there is a next page
console.log(fresh.hasPrevious()); // Check if there is a previous page

// Retrieve the next page of fresh videos
const nextPage = await fresh.next();
console.log(nextPage.pagination.current); // 2
console.log(nextPage.hasNext()); // true
console.log(nextPage.hasPrevious()); // true
// Log details of the next page
console.log(nextPage.pagination.current); // Updated current page number
console.log(nextPage.hasNext()); // Check if the next page exists
console.log(nextPage.hasPrevious()); // Check if the previous page exists

// Retrieve the previous page of fresh videos
const previousPage = await fresh.previous();
console.log(previousPage.pagination.current); // 1
console.log(previousPage.hasNext()); // true
console.log(previousPage.hasPrevious()); // tfalse

const detail = await xvideos.videos.details(fresh.videos[0]); /**
{
title,
duration,
image,
videoType,
videoWidth,
videoHeigth,
views,
files: {
low,
high,
HLS,
thumb,
thumb69,
thumbSlide,
thumbSlideBig
}
} **/
// Log details of the previous page
console.log(previousPage.pagination.current); // Updated current page number
console.log(previousPage.hasNext()); // Check if the next page exists
console.log(previousPage.hasPrevious()); // Check if the previous page exists

// Retrieve detailed information about a specific video
const detail = await xvideos.videos.details(fresh.videos[0]);
// Log details of the specific video
console.log(detail); // Detailed video object with properties like title, duration, image, videoType, views, files
```

## API

### Retrieve [Dashboard Videos](https://www.xvideos.com)

```javascript
// Retrieve dashboard videos from the first page
const dashboardList = await xvideos.videos.dashboard({ page: 1 });

// Check if there is a next page of results
console.log(dashboardList.hasNext()); // Outputs: true or false

// Check if there is a previous page of results
console.log(dashboardList.hasPrevious()); // Outputs: true or false

// Refresh the current page of results to get updated data
const refreshedVideos = await dashboardList.refresh();

// Retrieve the next page of dashboard videos if available
const nextVideos = await dashboardList.next();

// Retrieve the previous page of dashboard videos if available
const previousVideos = await dashboardList.previous();
```

### Retrieve [Fresh Videos](https://www.xvideos.com/new/1)

```javascript
// Retrieve fresh videos from the first page
const freshList = await xvideos.videos.fresh({ page: 1 });

// Check if there is a next page of results
console.log(freshList.hasNext()); // Outputs: true or false

// Check if there is a previous page of results
console.log(freshList.hasPrevious()); // Outputs: true or false

// Refresh the current page of results to get updated data
const refreshedVideos = await freshList.refresh();

// Retrieve the next page of fresh videos if available
const nextVideos = await freshList.next();

// Retrieve the previous page of fresh videos if available
const previousVideos = await freshList.previous();
```

### Retrieve [Best Videos](https://www.xvideos.com/best)

```javascript
// Retrieve best videos for a specific year and month, starting from the first page
const bestList = await xvideos.videos.best({ year: '2018', month: '02', page: 1 });

// Check if there is a next page of results
console.log(bestList.hasNext()); // Outputs: true or false

// Check if there is a previous page of results
console.log(bestList.hasPrevious()); // Outputs: true or false

// Refresh the current page of results to get updated data
const refreshedVideos = await bestList.refresh();

// Retrieve the next page of best videos if available
const nextVideos = await bestList.next();

// Retrieve the previous page of best videos if available
const previousVideos = await bestList.previous();
```

### Retrieve [Verified Videos](https://www.xvideos.com/verified/videos)

```javascript
// Retrieve verified videos from the first page
const verifiedList = await xvideos.videos.verified({ page: 1 });

// Check if there is a next page of results
console.log(verifiedList.hasNext()); // Outputs: true or false

// Check if there is a previous page of results
console.log(verifiedList.hasPrevious()); // Outputs: true or false

// Refresh the current page of results to get updated data
const refreshedVideos = await verifiedList.refresh();

// Retrieve the next page of verified videos if available
const nextVideos = await verifiedList.next();

// Retrieve the previous page of verified videos if available
const previousVideos = await verifiedList.previous();
```

### Retrieve [Video Details](https://www.xvideos.com/video36638661/chaturbate_lulacum69_30-05-2018)

```javascript
// Retrieve detailed information about a specific video using its URL
const details = await xvideos.videos.details({ url: 'https://www.xvideos.com/video36638661/chaturbate_lulacum69_30-05-2018' });

// Log detailed information about the video
console.log(details); // Detailed video object with properties like title, duration, image, videoType, views, files
```

### API
* Retrieve [dashboard videos](https://www.xvideos.com)
```javascript
const dashboardList = await xvideos.videos.dashboard({ page: 1 });
```
* Is there a next page?
```javascript
console.log(deshboardList.hasNext()); // true or false
```
* Is there a previous page?
```javascript
console.log(deshboardList.hasPrevious()); // true or false
```
* Refresh page videos
```javascript
const refreshedVideos = await deshboardList.refresh();
```
* Retrieve next deshboard page videos
```javascript
const nextVideos = await deshboardList.next();
```
* Retrieve previous deshboard page videos
```javascript
const previousVideos = await deshboardList.previous();
```
* Retrieve [fresh videos](https://www.xvideos.com/new/1)
```javascript
const freshList = await xvideos.videos.fresh({ page: 1 });
```
* Is there a next page?
```javascript
console.log(freshList.hasNext()); // true or false
```
* Is there a previous page?
```javascript
console.log(freshList.hasPrevious()); // true or false
```
* Refresh page videos
```javascript
const refreshedVideos = await freshList.refresh();
```
* Retrieve next fresh page videos
```javascript
const nextVideos = await freshList.next();
```
* Retrieve previous fresh page videos
```javascript
const previousVideos = await freshList.previous();
```
* Retrieve [best videos](https://www.xvideos.com/best)
```javascript
const bestList = await xvideos.videos.best({ year: '2018', month: '02', page: 1 });
```
* Is there a next page?
```javascript
console.log(bestList.hasNext()); // true or false
```
* Is there a previous page?
```javascript
console.log(bestList.hasPrevious()); // true or false
```
* Refresh page videos
```javascript
const refreshedVideos = await bestList.refresh();
```
* Retrieve next best page videos
```javascript
const nextVideos = await bestList.next();
```
* Retrieve previous best page videos
```javascript
const previousVideos = await bestList.previous();
```
* Retrieve [verified videos](https://www.xvideos.com/verified/videos)
```javascript
const verifiedList = await xvideos.videos.verified({ page: 1 });
```
* Is there a next page?
```javascript
console.log(verifiedList.hasNext()); // true or false
```
* Is there a previous page?
```javascript
console.log(verifiedList.hasPrevious()); // true or false
```
* Refresh page videos
```javascript
const refreshedVideos = await verifiedList.refresh();
```
* Retrieve next verified page videos
```javascript
const nextVideos = await verifiedList.next();
```
* Retrieve previous verified page videos
```javascript
const previousVideos = await verifiedList.previous();
```
* Retrieve [video details](https://www.xvideos.com/video36638661/chaturbate_lulacum69_30-05-2018)
```javascript
const details = await xvideos.videos.details({ url: 'https://www.xvideos.com/video36638661/chaturbate_lulacum69_30-05-2018' });
```

* Filter [videos](https://www.xvideos.com/?k=threesome)
```javascript
const videos = await xvideos.videos.search({ k: 'threesome' });
const videos = await xvideos.videos.search({ k: 'public', page: 5 });
```
* Is there a next page?
```javascript
console.log(videos.hasNext()); // true or false
```
* Is there a previous page?
```javascript
console.log(videos.hasPrevious()); // true or false
```
* Refresh page videos
```javascript
const refreshedVideos = await videos.refresh();
```
* Retrieve next verified page videos
```javascript
const nextVideos = await videos.next();
```
* Retrieve previous verified page videos
```javascript
const previousVideos = await videos.previous();
```
### Filter [Videos](https://www.xvideos.com/?k=threesome)

```javascript
// Search for videos using a keyword, and optionally specify a page number
const videos = await xvideos.videos.search({ k: 'threesome' });
// Example with a specific page number
// const videos = await xvideos.videos.search({ k: 'public', page: 5 });

// Check if there is a next page of results
console.log(videos.hasNext()); // Outputs: true or false

// Check if there is a previous page of results
console.log(videos.hasPrevious()); // Outputs: true or false

// Refresh the current page of results to get updated data
const refreshedVideos = await videos.refresh();

// Retrieve the next page of videos if available
const nextVideos = await videos.next();

// Retrieve the previous page of videos if available
const previousVideos = await videos.previous();

// Search for videos with specific parameters
const videos = await xvideos.videos.search({
page: 2,
k: 'threesome',
sort: 'rating',
datef: 'week',
durf: '3-10min',
quality: 'hd'
});

// Log the search results
console.log(videos); // Array of video objects with properties based on the search parameters
```

#### Params explanation

| Parameter | Default | Options |
|-----------|----------------|------------------------------------------------------------------------------------------|
| `page` | `1` | (any positive integer) |
| `k` | `""` | (any search keyword) |
| `sort` | `"relevance"` | `"uploaddate"`, `"rating"`, `"length"`, `"views"`, `"random"` |
| `datef` | `"all"` | `"today"`, `"week"`, `"month"`, `"3month"`, `"6month"`, `"all"` |
| `durf` | `"allduration"`| `"1-3min"`, `"3-10min"`, `"10min_more"`, `"10-20min"`, `"20min_more"`, `"allduration"` |
| `quality` | `"all"` | `"hd"`, `"1080P"`, `"all"` |



---

### License
[Licence](https://github.com/rodrigogs/xvideos/blob/master/LICENSE) © Rodrigo Gomes da Silva
Loading

0 comments on commit f4d41b6

Please sign in to comment.