This commit is contained in:
himanshu8443
2025-07-11 19:45:14 +05:30
parent 13f71510d5
commit 35f1e57a0b
139 changed files with 10578 additions and 139 deletions

61
dist/drive/posts.js vendored
View File

@@ -1 +1,60 @@
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))(function(i,o){function s(t){try{c(n.next(t))}catch(t){o(t)}}function a(t){try{c(n.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(s,a)}c((n=n.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:n}){const{getBaseUrl:i}=n;return posts({url:`${(yield i("drive"))+t}/page/${e}/`,signal:r,providerContext:n})})};exports.getPosts=getPosts;const getSearchPosts=function(t){return __awaiter(this,arguments,void 0,function*({searchQuery:t,page:e,signal:r,providerContext:n}){const{getBaseUrl:i}=n;return posts({url:`${yield i("drive")}page/${e}/?s=${t}`,signal:r,providerContext:n})})};function posts(t){return __awaiter(this,arguments,void 0,function*({url:t,signal:e,providerContext:r}){try{const{cheerio:n}=r,i=yield fetch(t,{signal:e}),o=yield i.text(),s=n.load(o),a=[];return s(".recent-movies").children().map((t,e)=>{const r=s(e).find("figure").find("img").attr("alt"),n=s(e).find("a").attr("href"),i=s(e).find("figure").find("img").attr("src");r&&n&&i&&a.push({title:r.replace("Download","").trim(),link:n,image:i})}),a}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, signal, providerContext, }) {
const { getBaseUrl } = providerContext;
const baseUrl = yield getBaseUrl("drive");
const url = `${baseUrl + filter}/page/${page}/`;
return posts({ url, signal, providerContext });
});
};
exports.getPosts = getPosts;
const getSearchPosts = function (_a) {
return __awaiter(this, arguments, void 0, function* ({ searchQuery, page, signal, providerContext, }) {
const { getBaseUrl } = providerContext;
const baseUrl = yield getBaseUrl("drive");
const url = `${baseUrl}page/${page}/?s=${searchQuery}`;
return posts({ url, signal, providerContext });
});
};
exports.getSearchPosts = getSearchPosts;
function posts(_a) {
return __awaiter(this, arguments, void 0, function* ({ url, signal, providerContext, }) {
try {
const { cheerio } = providerContext;
const res = yield fetch(url, { signal });
const data = yield res.text();
const $ = cheerio.load(data);
const catalog = [];
$(".recent-movies")
.children()
.map((i, element) => {
const title = $(element).find("figure").find("img").attr("alt");
const link = $(element).find("a").attr("href");
const image = $(element).find("figure").find("img").attr("src");
if (title && link && image) {
catalog.push({
title: title.replace("Download", "").trim(),
link: link,
image: image,
});
}
});
return catalog;
}
catch (err) {
console.error("drive error ", err);
return [];
}
});
}