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

View File

@@ -1 +1,65 @@
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,r,i){return new(r||(r=Promise))(function(s,o){function n(t){try{c(i.next(t))}catch(t){o(t)}}function a(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?s(t.value):(e=t.value,e instanceof r?e:new r(function(t){t(e)})).then(n,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:s,axios:o,cheerio:n}=i,a=yield s("tokyoinsider");return posts({baseURL:a,url:`${a}/${t}&start=${e<2?0:20*(e-1)}`,signal:r,axios:o,cheerio:n})})};exports.getPosts=getPosts;const getSearchPosts=function(t){return __awaiter(this,arguments,void 0,function*({searchQuery:t,page:e,signal:r,providerContext:i}){const{getBaseUrl:s,axios:o,cheerio:n}=i,a=yield s("tokyoinsider");return posts({baseURL:a,url:`${a}/anime/search?k=${t}&start=${e<2?0:20*(e-1)}`,signal:r,axios:o,cheerio:n})})};function posts(t){return __awaiter(this,arguments,void 0,function*({baseURL:t,url:e,signal:r,axios:i,cheerio:s}){try{const o=(yield i.get(e,{signal:r})).data,n=s.load(o),a=[];return n('td.c_h2[width="40"]').map((e,r)=>{var i;const s=null===(i=n(r).find(".a_img").attr("src"))||void 0===i?void 0:i.replace("small","default"),o=n(r).find("a").attr("title"),c=t+n(r).find("a").attr("href");o&&c&&s&&a.push({title:o,link:c,image:s})}),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,
// providerValue,
signal, providerContext, }) {
const { getBaseUrl, axios, cheerio } = providerContext;
const baseURL = yield getBaseUrl("tokyoinsider");
const start = page < 2 ? 0 : (page - 1) * 20;
const url = `${baseURL}/${filter}&start=${start}`;
return posts({ baseURL, 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("tokyoinsider");
const start = page < 2 ? 0 : (page - 1) * 20;
const url = `${baseURL}/anime/search?k=${searchQuery}&start=${start}`;
return posts({ baseURL, url, signal, axios, cheerio });
});
};
exports.getSearchPosts = getSearchPosts;
function posts(_a) {
return __awaiter(this, arguments, void 0, function* ({ baseURL, url, signal, axios, cheerio, }) {
try {
const res = yield axios.get(url, { signal });
const data = res.data;
const $ = cheerio.load(data);
const catalog = [];
$('td.c_h2[width="40"]').map((i, element) => {
var _a;
const image = (_a = $(element)
.find(".a_img")
.attr("src")) === null || _a === void 0 ? void 0 : _a.replace("small", "default");
const title = $(element).find("a").attr("title");
const link = baseURL + $(element).find("a").attr("href");
if (title && link && image) {
catalog.push({
title: title,
link: link,
image: image,
});
}
});
return catalog;
}
catch (err) {
return [];
}
});
}