mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
unminify
This commit is contained in:
64
dist/world4u/posts.js
vendored
64
dist/world4u/posts.js
vendored
@@ -1 +1,63 @@
|
||||
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,i,r){return new(i||(i=Promise))(function(n,s){function o(t){try{c(r.next(t))}catch(t){s(t)}}function a(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i(function(t){t(e)})).then(o,a)}c((r=r.apply(t,e||[])).next())})};Object.defineProperty(exports,"__esModule",{value:!0}),exports.getSearchPosts=exports.getPosts=void 0;const getPosts=function(t){return __awaiter(this,arguments,void 0,function*({filter:t,page:e,signal:i,providerContext:r}){const{getBaseUrl:n,axios:s,cheerio:o}=r;return posts({url:`${(yield n("w4u"))+t}/page/${e}/`,signal:i,axios:s,cheerio:o})})};exports.getPosts=getPosts;const getSearchPosts=function(t){return __awaiter(this,arguments,void 0,function*({searchQuery:t,page:e,signal:i,providerContext:r}){const{getBaseUrl:n,axios:s,cheerio:o}=r;return posts({url:`${yield n("w4u")}/page/${e}/?s=${t}`,signal:i,axios:s,cheerio:o})})};function posts(t){return __awaiter(this,arguments,void 0,function*({url:t,signal:e,axios:i,cheerio:r}){try{const n=(yield i.get(t,{signal:e})).data,s=r.load(n),o=[];return s(".recent-posts").children().map((t,e)=>{const i=s(e).find(".post-thumb").find("a").attr("title"),r=s(e).find(".post-thumb").find("a").attr("href"),n=s(e).find(".post-thumb").find("img").attr("data-src")||s(e).find(".post-thumb").find("img").attr("src");i&&r&&n&&o.push({title:i.replace("Download","").trim(),link:r,image:n})}),o}catch(t){return[]}})}exports.getSearchPosts=getSearchPosts;
|
||||
"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());
|
||||
});
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getSearchPosts = exports.getPosts = void 0;
|
||||
const getPosts = function (_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ filter, page,
|
||||
// providerValue,
|
||||
signal, providerContext, }) {
|
||||
const { getBaseUrl, axios, cheerio } = providerContext;
|
||||
const baseUrl = yield getBaseUrl("w4u");
|
||||
const url = `${baseUrl + filter}/page/${page}/`;
|
||||
return posts({ url, signal, axios, cheerio });
|
||||
});
|
||||
};
|
||||
exports.getPosts = getPosts;
|
||||
const getSearchPosts = function (_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ searchQuery, page,
|
||||
// providerValue,
|
||||
signal, providerContext, }) {
|
||||
const { getBaseUrl, axios, cheerio } = providerContext;
|
||||
const baseUrl = yield getBaseUrl("w4u");
|
||||
const url = `${baseUrl}/page/${page}/?s=${searchQuery}`;
|
||||
return posts({ url, signal, axios, cheerio });
|
||||
});
|
||||
};
|
||||
exports.getSearchPosts = getSearchPosts;
|
||||
function posts(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ url, signal, axios, cheerio, }) {
|
||||
try {
|
||||
const res = yield axios.get(url, { signal });
|
||||
const data = res.data;
|
||||
const $ = cheerio.load(data);
|
||||
const catalog = [];
|
||||
$(".recent-posts")
|
||||
.children()
|
||||
.map((i, element) => {
|
||||
const title = $(element).find(".post-thumb").find("a").attr("title");
|
||||
const link = $(element).find(".post-thumb").find("a").attr("href");
|
||||
const image = $(element).find(".post-thumb").find("img").attr("data-src") ||
|
||||
$(element).find(".post-thumb").find("img").attr("src");
|
||||
if (title && link && image) {
|
||||
catalog.push({
|
||||
title: title.replace("Download", "").trim(),
|
||||
link: link,
|
||||
image: image,
|
||||
});
|
||||
}
|
||||
});
|
||||
return catalog;
|
||||
}
|
||||
catch (err) {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user