@uwu-codes/furaffinity-api
Version:
FurAffinity wrapper for Node.js
164 lines (163 loc) • 5.92 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
};
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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MyWatchingList = exports.WatchingList = exports.Scraps = exports.Gallery = exports.Author = exports.User = exports.Submission = exports.Submissions = exports.Browse = exports.Search = void 0;
const Request_1 = require("./Request");
const Parser_1 = require("./Parser");
__exportStar(require("./Enums"), exports);
__exportStar(require("./interfaces"), exports);
__exportStar(require("./Parser"), exports);
__exportStar(require("./Request"), exports);
var Request_2 = require("./Request");
Object.defineProperty(exports, "Login", { enumerable: true, get: function () { return Request_2.Login; } });
Object.defineProperty(exports, "SetProxy", { enumerable: true, get: function () { return Request_2.SetProxy; } });
/**
* Get results from search page
* @param query search query
* @param options search options
*/
function Search(query, options) {
return __awaiter(this, void 0, void 0, function* () {
const body = yield Request_1.FetchSearch(query, options);
const results = Parser_1.ParseFigures(body);
return Parser_1.ParseSearchPaging(body, results, query, options);
});
}
exports.Search = Search;
/**
* Get results from browse page
* @param options browse options
*/
function Browse(options) {
return __awaiter(this, void 0, void 0, function* () {
const body = yield Request_1.FetchBrowse(options);
const results = Parser_1.ParseFigures(body);
return Parser_1.ParseBrowsePaging(body, results, options);
});
}
exports.Browse = Browse;
/**
* Get results from submissions timeline page
* @param options submissions options
*/
function Submissions(options) {
return __awaiter(this, void 0, void 0, function* () {
const body = yield Request_1.FetchSubmissions(options);
const results = Parser_1.ParseFigures(body);
return Parser_1.ParseSubmissionsPaging(body, results);
});
}
exports.Submissions = Submissions;
/**
* Get submission's info by pass submission id
* @param id submission id
*/
function Submission(id) {
return __awaiter(this, void 0, void 0, function* () {
return Parser_1.ParseSubmission(yield Request_1.FetchSubmission(id), id);
});
}
exports.Submission = Submission;
/**
* Get the current logged in user
*/
function User() {
return __awaiter(this, void 0, void 0, function* () {
return Parser_1.ParseAuthor(yield Request_1.FetchHome());
});
}
exports.User = User;
/**
* Get author's info by pass author id
* @param id author id
*/
function Author(id) {
return __awaiter(this, void 0, void 0, function* () {
return Parser_1.ParseAuthor(yield Request_1.FetchAuthor(id));
});
}
exports.Author = Author;
/**
* Get results of a gallery page
* @param id author id
* @param page page number
*/
function Gallery(id, page, perpage = 72) {
return __awaiter(this, void 0, void 0, function* () {
const body = yield Request_1.FetchGallery(id, page, perpage);
const results = Parser_1.ParseFigures(body);
return Parser_1.ParseGalleryPaging(body, results, perpage);
});
}
exports.Gallery = Gallery;
/**
* Get results of a scraps page
* @param id author id
* @param page page number
*/
function Scraps(id, page, perpage = 72) {
return __awaiter(this, void 0, void 0, function* () {
const body = yield Request_1.FetchScraps(id, page, perpage);
const results = Parser_1.ParseFigures(body);
return Parser_1.ParseScrapsPaging(body, results, perpage);
});
}
exports.Scraps = Scraps;
/**
* Get an author's watching list
* result don't has avatar
* @param id author id
*/
function WatchingList(id) {
return __awaiter(this, void 0, void 0, function* () {
let result = [];
let page = 1;
while (true) {
const users = Parser_1.ParseWatchingList(yield Request_1.FetchWatchingList(id, page++));
result = [...result, ...users];
if (users.length === 0 || users.length < 200) {
break;
}
}
return result;
});
}
exports.WatchingList = WatchingList;
/**
* Get current login user's watching list
* this can only use after login
* result has avatar
*/
function MyWatchingList() {
return __awaiter(this, void 0, void 0, function* () {
let result = [];
let page = 1;
while (true) {
const users = Parser_1.ParseMyWatchingList(yield Request_1.FetchMyWatchingList(page++));
result = [...result, ...users];
if (users.length === 0 || users.length < 64) {
break;
}
}
return result;
});
}
exports.MyWatchingList = MyWatchingList;