Comparing version 2.1.2 to 3.0.0
import * as t from './types'; | ||
declare class _ARQ { | ||
declare class ARQ { | ||
url: string; | ||
@@ -82,8 +82,2 @@ key: string; | ||
/** | ||
* Generate Telegram quote stickers. | ||
*/ | ||
quotly(payload: { | ||
[key: string]: any; | ||
}): Promise<t.QuotlyResult>; | ||
/** | ||
* Download a YouTube video. | ||
@@ -94,4 +88,4 @@ */ | ||
pypi(query: string): Promise<t.PyPiResult>; | ||
spellCheck(text: string): Promise<t.SpellCheckResult>; | ||
} | ||
export declare const ARQ: typeof _ARQ; | ||
export {}; | ||
export { ARQ }; |
"use strict"; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
}); | ||
}; | ||
var __generator = (this && this.__generator) || function (thisArg, body) { | ||
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; | ||
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; | ||
function verb(n) { return function (v) { return step([n, v]); }; } | ||
function step(op) { | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
if (y = 0, t) op = [op[0] & 2, t.value]; | ||
switch (op[0]) { | ||
case 0: case 1: t = op; break; | ||
case 4: _.label++; return { value: op[1], done: false }; | ||
case 5: _.label++; y = op[1]; op = [0]; continue; | ||
case 7: op = _.ops.pop(); _.trys.pop(); continue; | ||
default: | ||
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } | ||
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } | ||
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } | ||
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } | ||
if (t[2]) _.ops.pop(); | ||
_.trys.pop(); continue; | ||
} | ||
op = body.call(thisArg, _); | ||
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } | ||
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; | ||
} | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
@@ -43,340 +7,162 @@ return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
exports.ARQ = void 0; | ||
var querystring_1 = require("querystring"); | ||
var node_fetch_1 = __importDefault(require("node-fetch")); | ||
var _ARQ = /** @class */ (function () { | ||
function _ARQ(url, key) { | ||
const querystring_1 = require("querystring"); | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
class ARQ { | ||
constructor(url, key) { | ||
this.url = url.endsWith('/') ? url : url + '/'; | ||
this.key = key; | ||
} | ||
_ARQ.prototype.fetch = function (route, query, post) { | ||
if (query === void 0) { query = {}; } | ||
if (post === void 0) { post = false; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var response, _a, ok, result; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: | ||
if (!post) return [3 /*break*/, 2]; | ||
return [4 /*yield*/, node_fetch_1.default(this.url + route, { | ||
method: 'POST', | ||
headers: { 'x-api-key': this.key }, | ||
body: JSON.stringify(query), | ||
})]; | ||
case 1: | ||
response = _b.sent(); | ||
return [3 /*break*/, 4]; | ||
case 2: return [4 /*yield*/, node_fetch_1.default(this.url + route + '?' + querystring_1.encode(query), { | ||
method: 'GET', | ||
headers: { 'x-api-key': this.key }, | ||
})]; | ||
case 3: | ||
response = _b.sent(); | ||
_b.label = 4; | ||
case 4: | ||
if (response.status == 403 || response.status == 401) { | ||
throw new Error('Invalid API key'); | ||
} | ||
return [4 /*yield*/, response.json()]; | ||
case 5: | ||
_a = _b.sent(), ok = _a.ok, result = _a.result; | ||
if (typeof ok === 'undefined' || typeof result == 'undefined') { | ||
throw new Error('Invalid response'); | ||
} | ||
if (ok) { | ||
return [2 /*return*/, result]; | ||
} | ||
else { | ||
throw new Error(result); | ||
} | ||
return [2 /*return*/]; | ||
} | ||
async fetch(route, query = {}, post = false) { | ||
let response; | ||
if (post) { | ||
response = await node_fetch_1.default(this.url + route, { | ||
method: 'POST', | ||
headers: { 'x-api-key': this.key }, | ||
body: JSON.stringify(query), | ||
}); | ||
}); | ||
}; | ||
} | ||
else { | ||
response = await node_fetch_1.default(this.url + route + '?' + querystring_1.encode(query), { | ||
method: 'GET', | ||
headers: { 'x-api-key': this.key }, | ||
}); | ||
} | ||
if (response.status == 403 || response.status == 401) { | ||
throw new Error('Invalid API key'); | ||
} | ||
const { ok, result } = await response.json(); | ||
if (typeof ok === 'undefined' || typeof result == 'undefined') { | ||
throw new Error('Invalid response'); | ||
} | ||
if (ok) { | ||
return result; | ||
} | ||
else { | ||
throw new Error(result); | ||
} | ||
} | ||
/** | ||
* Search Deezer and get direct links to download songs. | ||
*/ | ||
_ARQ.prototype.deezer = function (query, count) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('deezer', { query: query, count: count })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async deezer(query, count) { | ||
return await this.fetch('deezer', { query, count }); | ||
} | ||
/** | ||
* Search for Torrents across various websites. | ||
*/ | ||
_ARQ.prototype.torrent = function (query) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('torrent', { query: query })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async torrent(query) { | ||
return await this.fetch('torrent', { query }); | ||
} | ||
/** | ||
* Get songs from Saavn. | ||
*/ | ||
_ARQ.prototype.saavn = function (query) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('saavn', { query: query })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async saavn(query) { | ||
return await this.fetch('saavn', { query }); | ||
} | ||
/** | ||
* Get information about a Saavn playlist. | ||
*/ | ||
_ARQ.prototype.saavnPlaylist = function (query) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('saavnPlaylist', { query: query })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async saavnPlaylist(query) { | ||
return await this.fetch('saavnPlaylist', { query }); | ||
} | ||
/** | ||
* Search for YouTube videos. | ||
*/ | ||
_ARQ.prototype.youtube = function (query) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('youtube', { query: query })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async youtube(query) { | ||
return await this.fetch('youtube', { query }); | ||
} | ||
/** | ||
* Search for wallpapares. | ||
*/ | ||
_ARQ.prototype.wall = function (query) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('wall', { query: query })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async wall(query) { | ||
return await this.fetch('wall', { query }); | ||
} | ||
/** | ||
* Search for Reddit posts. | ||
*/ | ||
_ARQ.prototype.reddit = function (query) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('reddit', { query: query })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async reddit(query) { | ||
return await this.fetch('reddit', { query }); | ||
} | ||
/** | ||
* Search the Urban dictionary. | ||
*/ | ||
_ARQ.prototype.ud = function (query) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('ud', { query: query })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async ud(query) { | ||
return await this.fetch('ud', { query }); | ||
} | ||
/** | ||
* Search for a PH video. | ||
*/ | ||
_ARQ.prototype.ph = function (query, page, thumbSize) { | ||
if (page === void 0) { page = 1; } | ||
if (thumbSize === void 0) { thumbSize = 'small'; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('ph', { query: query, page: page, thumbSize: thumbSize })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async ph(query, page = 1, thumbSize = 'small') { | ||
return await this.fetch('ph', { query, page, thumbSize }); | ||
} | ||
/** | ||
* Download a PH video. | ||
*/ | ||
_ARQ.prototype.phDownload = function (url) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('phdl', { url: url })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async phDownload(url) { | ||
return await this.fetch('phdl', { url }); | ||
} | ||
/** | ||
* Communicate with an AI chatbot. | ||
*/ | ||
_ARQ.prototype.luna = function (query, id) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('luna', { query: query, id: id })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async luna(query, id) { | ||
return await this.fetch('luna', { query, id }); | ||
} | ||
/** | ||
* Get song lyrics. | ||
*/ | ||
_ARQ.prototype.lyrics = function (query) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('lyrics', { query: query })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async lyrics(query) { | ||
return await this.fetch('lyrics', { query }); | ||
} | ||
/** | ||
* Search Wikipeida. | ||
*/ | ||
_ARQ.prototype.wiki = function (query) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('wiki', { query: query })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async wiki(query) { | ||
return await this.fetch('wiki', { query }); | ||
} | ||
/** | ||
* Scan and classify an image. | ||
*/ | ||
_ARQ.prototype.nsfwScan = function (url) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('nsfw_scan', { url: url })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async nsfwScan(url) { | ||
return await this.fetch('nsfw_scan', { url }); | ||
} | ||
/** | ||
* Recognize characters in an image. | ||
*/ | ||
_ARQ.prototype.ocr = function (url) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('ocr', { url: url })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async ocr(url) { | ||
return await this.fetch('ocr', { url }); | ||
} | ||
/** | ||
* Get stats of the ARQ API. | ||
*/ | ||
_ARQ.prototype.stats = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('stats')]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async stats() { | ||
return await this.fetch('stats'); | ||
} | ||
/** | ||
* Get a sock5 proxy. | ||
*/ | ||
_ARQ.prototype.proxy = function () { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('proxy')]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async proxy() { | ||
return await this.fetch('proxy'); | ||
} | ||
/** | ||
* Search movie database. | ||
*/ | ||
_ARQ.prototype.tmdb = function (query, tmdbID) { | ||
if (tmdbID === void 0) { tmdbID = 0; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('tmdb', { query: query, tmdbID: tmdbID })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
async tmdb(query, tmdbID = 0) { | ||
return await this.fetch('tmdb', { query, tmdbID }); | ||
} | ||
/** | ||
* Generate Telegram quote stickers. | ||
*/ | ||
_ARQ.prototype.quotly = function (payload) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('quotly', { payload: JSON.stringify(payload) }, true)]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
/** | ||
* Download a YouTube video. | ||
*/ | ||
_ARQ.prototype.youtubeDownload = function (url) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('ytdl', { url: url })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
_ARQ.prototype.translate = function (text, destLangCode) { | ||
if (destLangCode === void 0) { destLangCode = 'en'; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('translate', { text: text, destLangCode: destLangCode })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
_ARQ.prototype.pypi = function (query) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, this.fetch('pypi', { query: query })]; | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return _ARQ; | ||
}()); | ||
exports.ARQ = _ARQ; | ||
async youtubeDownload(url) { | ||
return await this.fetch('ytdl', { url }); | ||
} | ||
async translate(text, destLangCode = 'en') { | ||
return await this.fetch('translate', { text, destLangCode }); | ||
} | ||
async pypi(query) { | ||
return await this.fetch('pypi', { query }); | ||
} | ||
async spellCheck(text) { | ||
return await this.fetch('spellcheck', { text }); | ||
} | ||
} | ||
exports.ARQ = ARQ; |
@@ -28,2 +28,3 @@ export declare type LunaResult = string; | ||
artist: string; | ||
artistPictures: string[]; | ||
url: string; | ||
@@ -144,3 +145,2 @@ }[]; | ||
}[]; | ||
export declare type QuotlyResult = string; | ||
export interface TranslateResult { | ||
@@ -184,1 +184,7 @@ translatedText: string; | ||
} | ||
export interface SpellCheckResult { | ||
corrected: string; | ||
corrections: { | ||
[key: string]: string; | ||
}; | ||
} |
{ | ||
"name": "arq-js", | ||
"version": "2.1.2", | ||
"version": "3.0.0", | ||
"description": "", | ||
@@ -15,3 +15,3 @@ "main": "dist/index.js", | ||
}, | ||
"author": "Roj Serbest <rojserbest@gmail.com>", | ||
"author": "Roj Serbest <rojserbest@icloud.com>", | ||
"license": "MIT", | ||
@@ -18,0 +18,0 @@ "bugs": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
13068
7
445