mirror of
https://github.com/vega-org/vega-providers.git
synced 2026-04-17 23:51:44 +00:00
minify
This commit is contained in:
61
dist/multi/posts.js
vendored
61
dist/multi/posts.js
vendored
@@ -1,60 +1 @@
|
||||
"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, signal, providerContext, }) {
|
||||
const { getBaseUrl, cheerio } = providerContext;
|
||||
const baseUrl = yield getBaseUrl("multi");
|
||||
const url = `${baseUrl + filter}page/${page}/`;
|
||||
return posts({ url, signal, cheerio });
|
||||
});
|
||||
};
|
||||
exports.getPosts = getPosts;
|
||||
const getSearchPosts = function (_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ searchQuery, signal, providerContext, }) {
|
||||
const { getBaseUrl, cheerio } = providerContext;
|
||||
const baseUrl = yield getBaseUrl("multi");
|
||||
const url = `${baseUrl}/?s=${searchQuery}`;
|
||||
return posts({ url, signal, cheerio });
|
||||
});
|
||||
};
|
||||
exports.getSearchPosts = getSearchPosts;
|
||||
function posts(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ url, signal, cheerio, }) {
|
||||
try {
|
||||
const res = yield fetch(url, { signal });
|
||||
const data = yield res.text();
|
||||
const $ = cheerio.load(data);
|
||||
const catalog = [];
|
||||
$(".items.full")
|
||||
.children()
|
||||
.map((i, element) => {
|
||||
const title = $(element).find(".poster").find("img").attr("alt");
|
||||
const link = $(element).find(".poster").find("a").attr("href");
|
||||
const image = $(element).find(".poster").find("img").attr("data-src") ||
|
||||
$(element).find(".poster").find("img").attr("src");
|
||||
if (title && link && image) {
|
||||
catalog.push({
|
||||
title: title,
|
||||
link: link,
|
||||
image: image,
|
||||
});
|
||||
}
|
||||
});
|
||||
return catalog;
|
||||
}
|
||||
catch (err) {
|
||||
console.error("multiGetPosts error ", err);
|
||||
return [];
|
||||
}
|
||||
});
|
||||
}
|
||||
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))(function(n,s){function o(t){try{c(i.next(t))}catch(t){s(t)}}function a(t){try{c(i.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?n(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(o,a)}c((i=i.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:r,providerContext:i}){const{getBaseUrl:n,cheerio:s}=i;return posts({url:`${(yield n("multi"))+t}page/${e}/`,signal:r,cheerio:s})})};exports.getPosts=getPosts;const getSearchPosts=function(t){return __awaiter(this,arguments,void 0,function*({searchQuery:t,signal:e,providerContext:r}){const{getBaseUrl:i,cheerio:n}=r;return posts({url:`${yield i("multi")}/?s=${t}`,signal:e,cheerio:n})})};function posts(t){return __awaiter(this,arguments,void 0,function*({url:t,signal:e,cheerio:r}){try{const i=yield fetch(t,{signal:e}),n=yield i.text(),s=r.load(n),o=[];return s(".items.full").children().map((t,e)=>{const r=s(e).find(".poster").find("img").attr("alt"),i=s(e).find(".poster").find("a").attr("href"),n=s(e).find(".poster").find("img").attr("data-src")||s(e).find(".poster").find("img").attr("src");r&&i&&n&&o.push({title:r,link:i,image:n})}),o}catch(t){return[]}})}exports.getSearchPosts=getSearchPosts;
|
||||
Reference in New Issue
Block a user