An open API service indexing awesome lists of open source software.

https://github.com/shnwazdeveloper/xvideo

Cloud XVideo website and API browser
https://github.com/shnwazdeveloper/xvideo

Last synced: 19 days ago
JSON representation

Cloud XVideo website and API browser

Awesome Lists containing this project

README

          

# Lyra Pron

A website and [Node.js](https://nodejs.org) API wrapper for browsing, searching, previewing, and playing videos through the configured API.

## Installation

```bash
$ npm install xvideos.js
$ pnpm install xvideos.js
$ yarn add xvideos.js
```

## Usage

```javascript
import { XVideos } from "xvideos.js";
const xvideos = new XVideos();
//-- Inside an async function --//

// Retrieve fresh videos from the first page
const fresh = await xvideos.fresh(1);
// 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.page); // 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 detailed information about a specific video
const detail = await xvideos.details(fresh.videos[0].url);
// Log details of the specific video
console.log(detail); // Detailed video object with properties like title, duration, image, videoType, views, files
```

## HTTP API Server

This fork also exposes the wrapper as a JSON HTTP API.

```bash
npm install
npm run build
npm start
```

By default the server listens on `http://localhost:3000`. You can change it
with `PORT` and `HOST`.

### Routes

```bash
GET /health
GET /fresh?page=1
GET /search?q=keyword&page=1&sort=relevance&datef=all&durf=allduration&quality=all&premium=false
GET /verified?type=women&page=1
GET /details?url=https://www.xvideos.com/video...
GET /thumbai?format=json&url=&type=auto
```

Examples:

```bash
curl "http://localhost:3000/fresh?page=1"
curl "http://localhost:3000/search?q=example&page=1&quality=hd"
curl "http://localhost:3000/verified?type=women&page=1"
curl "http://localhost:3000/thumbai?format=json&type=auto&url="
```

All successful responses use:

```json
{
"success": true,
"data": {}
}
```

Download endpoints are available but disabled by default:

```bash
ENABLE_DOWNLOADS=true npm start
```

```bash
GET /download/high?url=https://www.xvideos.com/video...&filename=video.mp4
GET /download/low?url=https://www.xvideos.com/video...&filename=video.mp4
GET /download/image?url=https://www.xvideos.com/video...&filename=thumbnail.jpg
```

### Cloudflare Worker

This project also includes a Worker-safe API entry at `src/worker.js`. It uses
Cloudflare `fetch` and `HTMLRewriter`, so it does not need the Node HTTP server
or Puppeteer at the edge.

```bash
npm run dev:cloudflare
npm run deploy:cloudflare
```

For non-interactive deploys, set `CLOUDFLARE_API_TOKEN` before running
`npm run deploy:cloudflare`.

The Worker supports `/health`, `/fresh`, `/search`, `/premium`, `/verified`,
`/details`, `/thumbai`, and redirect-based download endpoints.

```bash
GET /fresh?page=1
GET /search?q=keyword&page=1
GET /premium?page=1
GET /verified?type=women&page=1
GET /thumbai?format=json&url=&type=auto
GET /thumbnail?format=json&url=&type=auto
GET /download?url=https://www.xvideos.com/video...&quality=high
GET /download/high?url=https://www.xvideos.com/video...
GET /download/low?url=https://www.xvideos.com/video...
GET /download/hls?url=https://www.xvideos.com/video...
```

Download routes redirect to the resolved media URL by default. Use
`format=json` to receive the media URL in JSON, or `proxy=true` to stream the
file through the Worker.

Thumbnail routes redirect to the resolved image by default. Use `format=json`
to receive all known thumbnail URLs in JSON, or `proxy=true` to stream the image
through the Worker.

## API

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

```javascript
// Retrieve fresh videos from the first page
const freshList = await xvideos.fresh(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

// 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 [Verified Videos](https://www.xvideos.com/verified/videos)

```javascript
// Retrieve verified videos from the first page
const verifiedList = await xvideos.getVerified("women", 1); // Argument 'type' can be either "women", "men", "gay", or "trans"

// 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/video.udefpih987f/mi_madrastra_perdio_apuesta_en_final_argentina_vs_colombia_y_me_lo_chupa)

```javascript
// Retrieve detailed information about a specific video using its URL
const details = await xvideos.details(
"https://www.xvideos.com/video.udefpih987f/mi_madrastra_perdio_apuesta_en_final_argentina_vs_colombia_y_me_lo_chupa",
);

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

### Download [Video Details](https://www.xvideos.com/video.udefpih987f/mi_madrastra_perdio_apuesta_en_final_argentina_vs_colombia_y_me_lo_chupa)

```javascript
// Download video thumbnail from a specific video using its URL
const image = await xvideos.downloadImage(
"https://www.xvideos.com/video.udefpih987f/mi_madrastra_perdio_apuesta_en_final_argentina_vs_colombia_y_me_lo_chupa",
);
// Download video in high quality from a specific video using its URL
const high = await xvideos.downloadHigh(
"https://www.xvideos.com/video.udefpih987f/mi_madrastra_perdio_apuesta_en_final_argentina_vs_colombia_y_me_lo_chupa",
);
// Download video in low quality from a specific video using its URL
const low = await xvideos.downloadLow(
"https://www.xvideos.com/video.udefpih987f/mi_madrastra_perdio_apuesta_en_final_argentina_vs_colombia_y_me_lo_chupa",
);

console.log(image, high, low); // path to downloaded image and videos
```

### 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.search("threesome", 5);
// 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

// 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.search("threesome", 5, {
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 |
| --------- | --------------- | -------------------------------------------------------------------------------------- |
| `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"` |
| `premium` | `false` | `true`, `false` |

---

### 🐼 @me

You can find me on twitter as 🐤 @osinthappyemo
or on instagram as 🍢 @osintxv