import { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load, type CheerioAPI, type Element } from 'cheerio';
import { art } from '@/utils/render';
import path from 'node:path';
import { config } from '@/config';
import { getCurrentPath } from '@/utils/helpers';
const __dirname = getCurrentPath(import.meta.url);
const appUrl = 'https://app.theinitium.com/';
const userAgent = 'PugpigBolt v4.1.8 (iPhone, iOS 18.2.1) on phone (model iPhone15,2)';
export const route: Route = {
path: '/app/:category?',
categories: ['new-media', 'popular'],
example: '/theinitium/app',
parameters: {
category: 'Category, see below, latest_sc by default',
},
features: {
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: 'App',
maintainers: ['quiniapiezoelectricity'],
radar: [
{
source: ['app.theinitium.com/t/latest/:category'],
target: '/app/:category',
},
],
handler,
description: `抓取[The Initium App](https://app.theinitium.com/)的文章列表
::: warning
此路由暂不支持登陆认证
:::
Category 栏目:
| ----- | 简体中文 | 繁體中文 |
| ----- | ----------------- | ---------------- |
| 最新 | latest_sc | latest_tc |
| 日报 | daily_brief_sc | daily_brief_tc |
| 速递 | whats_new_sc | whats_new_tc |
| 专题 | report_sc | report_tc |
| 评论 | opinion_sc | opinion_tc |
| 国际 | international_sc | international_tc |
| 大陆 | mainland_sc | mainland_tc |
| 香港 | hongkong_sc | hongkong_tc |
| 台湾 | taiwan_sc | taiwan_tc |
| 播客 | article_audio_sc | article_audio_tc |`,
};
const resolveRelativeLink = ($: CheerioAPI, elem: Element, attr: string, appUrl?: string) => {
// code from @/middleware/paratmeter.ts
const $elem = $(elem);
if (appUrl) {
try {
const oldAttr = $elem.attr(attr);
if (oldAttr) {
// e.g. should leave