ayiin 1.0.21 → 1.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ayiin/base.d.ts +14 -0
- package/ayiin/base.js +77 -0
- package/ayiin/index.d.ts +16 -0
- package/ayiin/index.js +87 -0
- package/ayiin/types/provider.d.ts +1 -0
- package/ayiin/types/provider.js +2 -0
- package/ayiin/types/response.d.ts +12 -0
- package/ayiin/types/response.js +4 -0
- package/ayiin/types/video.d.ts +25 -0
- package/ayiin/types/video.js +3 -0
- package/ayiin/types/videos.d.ts +9 -0
- package/ayiin/types/videos.js +3 -0
- package/package.json +2 -2
- package/.env +0 -1
- package/tests/download.ts +0 -19
- package/tests/get.ts +0 -16
- package/tests/random.ts +0 -12
- package/tests/related.ts +0 -16
- package/tests/search.ts +0 -12
- package/tests/user.ts +0 -12
package/ayiin/base.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
import { Response, ResponseAxios } from "./types/response";
|
|
3
|
+
import { Provider } from "./types/provider";
|
|
4
|
+
type TypeField = "json" | "stream";
|
|
5
|
+
declare class Base {
|
|
6
|
+
api: AxiosInstance;
|
|
7
|
+
baseUrl: string;
|
|
8
|
+
basePath: string;
|
|
9
|
+
constructor(apiToken: string, basePath?: string);
|
|
10
|
+
post: (provider: Provider, url: string) => Promise<Response>;
|
|
11
|
+
get: (url: string, type?: TypeField) => Promise<ResponseAxios>;
|
|
12
|
+
validatePath: (autoClean?: boolean) => void;
|
|
13
|
+
}
|
|
14
|
+
export default Base;
|
package/ayiin/base.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const axios_1 = __importDefault(require("axios"));
|
|
18
|
+
class Base {
|
|
19
|
+
constructor(apiToken, basePath) {
|
|
20
|
+
this.baseUrl = "https://ayiinhub.vercel.app/api";
|
|
21
|
+
this.post = (provider, url) => __awaiter(this, void 0, void 0, function* () {
|
|
22
|
+
const res = yield this.api.post(`${provider}/${url}`);
|
|
23
|
+
const data = res.data;
|
|
24
|
+
if (data.success) {
|
|
25
|
+
return data;
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw new Error(data.message);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
this.get = (url, type) => __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
if (type && type === "stream") {
|
|
33
|
+
const res = yield this.api.get(url, {
|
|
34
|
+
responseType: "stream"
|
|
35
|
+
});
|
|
36
|
+
const response = {
|
|
37
|
+
success: true,
|
|
38
|
+
message: "success",
|
|
39
|
+
response: res
|
|
40
|
+
};
|
|
41
|
+
return response;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
const res = yield this.api.get(url);
|
|
45
|
+
const data = res.data;
|
|
46
|
+
if (data.success) {
|
|
47
|
+
return data;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
throw new Error(data.message);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
this.validatePath = (autoClean) => {
|
|
55
|
+
if (!fs_1.default.existsSync(this.basePath)) {
|
|
56
|
+
fs_1.default.mkdirSync(this.basePath);
|
|
57
|
+
}
|
|
58
|
+
;
|
|
59
|
+
if (autoClean) {
|
|
60
|
+
const files = fs_1.default.readdirSync(this.basePath);
|
|
61
|
+
files.forEach(file => {
|
|
62
|
+
fs_1.default.unlinkSync(path_1.default.join(this.basePath, file));
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
this.api = axios_1.default.create({
|
|
67
|
+
baseURL: `${this.baseUrl}`,
|
|
68
|
+
headers: {
|
|
69
|
+
"Authorization": `Bearer ${apiToken}`,
|
|
70
|
+
"Content-Type": "application/json",
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
this.basePath = basePath !== null && basePath !== void 0 ? basePath : "downloads";
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
;
|
|
77
|
+
exports.default = Base;
|
package/ayiin/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Base from "./base";
|
|
2
|
+
import { Provider } from "./types/provider";
|
|
3
|
+
import { Response } from "./types/response";
|
|
4
|
+
import { Video } from "./types/video";
|
|
5
|
+
import { Videos } from "./types/videos";
|
|
6
|
+
declare class Ayiin extends Base {
|
|
7
|
+
version: string;
|
|
8
|
+
constructor(apiToken: string);
|
|
9
|
+
download: (url: string, fileName: string) => Promise<string>;
|
|
10
|
+
getContent: (provider: Provider, id: string) => Promise<Video>;
|
|
11
|
+
randomContent: (provider: Provider) => Promise<Video>;
|
|
12
|
+
relatedContent: (provider: Provider, id: string) => Promise<Array<Videos>>;
|
|
13
|
+
searchContent: (provider: Provider, query: string, page?: number) => Promise<Array<Videos>>;
|
|
14
|
+
userInfo: () => Promise<Response>;
|
|
15
|
+
}
|
|
16
|
+
export default Ayiin;
|
package/ayiin/index.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const fs_1 = __importDefault(require("fs"));
|
|
16
|
+
const path_1 = __importDefault(require("path"));
|
|
17
|
+
const base_1 = __importDefault(require("./base"));
|
|
18
|
+
const package_json_1 = __importDefault(require("../package.json"));
|
|
19
|
+
class Ayiin extends base_1.default {
|
|
20
|
+
constructor(apiToken) {
|
|
21
|
+
super(apiToken);
|
|
22
|
+
this.version = package_json_1.default.version;
|
|
23
|
+
this.download = (url, fileName) => __awaiter(this, void 0, void 0, function* () {
|
|
24
|
+
const res = yield this.get(url, "stream");
|
|
25
|
+
const writeStream = fs_1.default.createWriteStream(path_1.default.join(`${this.basePath}/${fileName}.mp4`), res.response.data);
|
|
26
|
+
return new Promise((resolve, reject) => {
|
|
27
|
+
res.response.data.pipe(writeStream);
|
|
28
|
+
writeStream.on("error", (err) => {
|
|
29
|
+
console.log(err);
|
|
30
|
+
reject(err);
|
|
31
|
+
});
|
|
32
|
+
writeStream.on("finish", () => {
|
|
33
|
+
writeStream.close();
|
|
34
|
+
return resolve(path_1.default.join(`${this.basePath}/${fileName}.mp4`));
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
this.getContent = (provider, id) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
const res = yield this.post(provider, `detail?id=${id}`);
|
|
40
|
+
if (res.success) {
|
|
41
|
+
return res.result;
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
throw new Error(res.message);
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
this.randomContent = (provider) => __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const res = yield this.post(provider, "random");
|
|
49
|
+
if (res.success) {
|
|
50
|
+
return res.result;
|
|
51
|
+
}
|
|
52
|
+
else {
|
|
53
|
+
throw new Error(res.message);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
this.relatedContent = (provider, id) => __awaiter(this, void 0, void 0, function* () {
|
|
57
|
+
const res = yield this.post(provider, `related?id=${id}`);
|
|
58
|
+
if (res.success) {
|
|
59
|
+
return res.result.data;
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
throw new Error(res.message);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
this.searchContent = (provider, query, page) => __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
const res = yield this.post(provider, `search?key=${query}${page ? `&page=${page}` : ""}`);
|
|
67
|
+
if (res.success) {
|
|
68
|
+
return res.result.data;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
throw new Error(res.message);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
this.userInfo = () => __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
const res = yield this.get("/auth");
|
|
76
|
+
if (res.success) {
|
|
77
|
+
return res;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
throw new Error(res.message);
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
;
|
|
85
|
+
}
|
|
86
|
+
;
|
|
87
|
+
exports.default = Ayiin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type Provider = "xnxx" | "xvideos";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AxiosResponse } from "axios";
|
|
2
|
+
export interface Response {
|
|
3
|
+
success: boolean;
|
|
4
|
+
message: string;
|
|
5
|
+
result?: any;
|
|
6
|
+
}
|
|
7
|
+
export interface ResponseAxios<AR extends AxiosResponse = AxiosResponse<any, any>> {
|
|
8
|
+
response: AR;
|
|
9
|
+
success: boolean;
|
|
10
|
+
message: string;
|
|
11
|
+
result?: any;
|
|
12
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
interface Assets {
|
|
2
|
+
embed: string;
|
|
3
|
+
thumbnail: string;
|
|
4
|
+
bigimg: string;
|
|
5
|
+
video: string;
|
|
6
|
+
}
|
|
7
|
+
interface Data {
|
|
8
|
+
title: string;
|
|
9
|
+
id: string;
|
|
10
|
+
image: string;
|
|
11
|
+
duration: string;
|
|
12
|
+
views: string;
|
|
13
|
+
rating: string;
|
|
14
|
+
uploaded: string;
|
|
15
|
+
upvoted: string;
|
|
16
|
+
downvoted: string;
|
|
17
|
+
models: Array<string>;
|
|
18
|
+
tags: Array<string>;
|
|
19
|
+
}
|
|
20
|
+
export interface Video {
|
|
21
|
+
data: Data;
|
|
22
|
+
source: string;
|
|
23
|
+
assets: Assets;
|
|
24
|
+
}
|
|
25
|
+
export {};
|
package/package.json
CHANGED
package/.env
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
API_TOKEN=AxD_L8CgDfAK3xoSRGuQLcECiXfC5BNLscCs6LQpWeO5Xiank
|
package/tests/download.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { config } from "dotenv";
|
|
2
|
-
config();
|
|
3
|
-
|
|
4
|
-
import Ayiin from "../src";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const ayiin = new Ayiin(process.env.API_TOKEN!);
|
|
8
|
-
|
|
9
|
-
(async () => {
|
|
10
|
-
ayiin.validatePath(true)
|
|
11
|
-
const content = await ayiin.getContent("xvideos", "video.umoeitc6367/reality_kings_presents_hot_girls_game_-_new_site_");
|
|
12
|
-
const download = await ayiin.download(content.assets.video, "test")
|
|
13
|
-
// .then((value) => { return value });
|
|
14
|
-
if (download) {
|
|
15
|
-
console.log(download);
|
|
16
|
-
} else {
|
|
17
|
-
console.log("error in download");
|
|
18
|
-
}
|
|
19
|
-
})();
|
package/tests/get.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { config } from "dotenv";
|
|
2
|
-
config();
|
|
3
|
-
|
|
4
|
-
import Ayiin from "../src";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const ayiin = new Ayiin(process.env.API_TOKEN!);
|
|
8
|
-
|
|
9
|
-
(async () => {
|
|
10
|
-
try {
|
|
11
|
-
const info = await ayiin.getContent("xvideos", "video.umoeitc6367/reality_kings_presents_hot_girls_game_-_new_site_");
|
|
12
|
-
console.log(info);
|
|
13
|
-
} catch (error) {
|
|
14
|
-
console.log(error);
|
|
15
|
-
}
|
|
16
|
-
})();
|
package/tests/random.ts
DELETED
package/tests/related.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { config } from "dotenv";
|
|
2
|
-
config();
|
|
3
|
-
|
|
4
|
-
import Ayiin from "../src";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const ayiin = new Ayiin(process.env.API_TOKEN!);
|
|
8
|
-
|
|
9
|
-
(async () => {
|
|
10
|
-
try {
|
|
11
|
-
const info = await ayiin.relatedContent("xvideos", "video.umoeitc6367/reality_kings_presents_hot_girls_game_-_new_site_");
|
|
12
|
-
console.log(info.map((x) => x.id));
|
|
13
|
-
} catch (error) {
|
|
14
|
-
console.log(error);
|
|
15
|
-
}
|
|
16
|
-
})();
|
package/tests/search.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { config } from "dotenv";
|
|
2
|
-
config();
|
|
3
|
-
|
|
4
|
-
import Ayiin from "../src";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const ayiin = new Ayiin(process.env.API_TOKEN!);
|
|
8
|
-
|
|
9
|
-
(async () => {
|
|
10
|
-
const info = await ayiin.searchContent("xvideos", "girl hot");
|
|
11
|
-
console.log(info.map((x) => x.id));
|
|
12
|
-
})();
|
package/tests/user.ts
DELETED