RSSHub/lib/routes/cw/sub.ts

39 lines
1.1 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Route } from '@/types';
import { baseUrl, parsePage } from './utils';
import puppeteer from '@/utils/puppeteer';
export const route: Route = {
path: '/sub/:channel',
categories: ['traditional-media'],
example: '/cw/sub/615',
parameters: { channel: '子頻道 ID可在 URL 中找到' },
features: {
requireConfig: false,
requirePuppeteer: true,
antiCrawler: true,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '子頻道',
maintainers: ['TonyRL'],
handler,
};
async function handler(ctx) {
const browser = await puppeteer();
const { $, items } = await parsePage('sub', browser, ctx);
await browser.close();
return {
title: $('head title').text(),
description: $('meta[name=description]').attr('content'),
link: `${baseUrl}/subchannel.action?idSubChannel=${ctx.req.param('channel')}`,
image: `${baseUrl}/assets_new/img/fbshare.jpg`,
language: $('meta[property="og:locale"]').attr('content'),
item: items,
};
}