feat(route): Add Collabo Cafe (#18530)
* feat: Add Collabo-cafe * Update lib/routes/collabo-cafe/namespace.ts Co-authored-by: Tony <TonyRL@users.noreply.github.com> * refactor: remove page parameter ---------
This commit is contained in:
parent
74c91fff59
commit
b3c79b07d3
|
|
@ -0,0 +1,37 @@
|
|||
import { Data, Route } from '@/types';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { load } from 'cheerio';
|
||||
import { Context } from 'hono';
|
||||
import { parseItems } from './parser';
|
||||
|
||||
export const handler = async (ctx: Context): Promise<Data | null> => {
|
||||
const { category } = ctx.req.param();
|
||||
const baseUrl = `https://collabo-cafe.com/events/category/${category}`;
|
||||
const res = await ofetch(baseUrl);
|
||||
const $ = load(res);
|
||||
const items = parseItems($);
|
||||
|
||||
return {
|
||||
title: '分类',
|
||||
link: baseUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
export const route: Route = {
|
||||
path: '/category/:category',
|
||||
categories: ['anime'],
|
||||
example: '/collabo-cafe/category/cafe',
|
||||
parameters: { category: 'Category, refer to the original website (ジャンル別)' },
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
name: '分类',
|
||||
maintainers: ['cokemine'],
|
||||
handler,
|
||||
};
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
import { Data, Route } from '@/types';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { load } from 'cheerio';
|
||||
import { parseItems } from './parser';
|
||||
|
||||
export const handler = async (): Promise<Data | null> => {
|
||||
const baseUrl = 'https://collabo-cafe.com/';
|
||||
const res = await ofetch(baseUrl);
|
||||
const $ = load(res);
|
||||
const items = parseItems($);
|
||||
|
||||
return {
|
||||
title: '全部文章',
|
||||
link: baseUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
export const route: Route = {
|
||||
path: '/',
|
||||
categories: ['anime'],
|
||||
example: '/collabo-cafe/',
|
||||
parameters: undefined,
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
name: '全部文章',
|
||||
maintainers: ['cokemine'],
|
||||
handler,
|
||||
};
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: 'コラボカフェ',
|
||||
url: 'collabo-cafe.com',
|
||||
description: 'コラボカフェ - アニメ・漫画・ゲームのコラボ情報一覧まとめ',
|
||||
lang: 'ja',
|
||||
categories: ['anime'],
|
||||
};
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
import { type DataItem } from '@/types';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { CheerioAPI } from 'cheerio';
|
||||
|
||||
export function parseItems($: CheerioAPI): DataItem[] {
|
||||
return $('div.top-post-list article')
|
||||
.toArray()
|
||||
.map((el) => {
|
||||
const $el = $(el);
|
||||
const a = $el.find('a').first();
|
||||
const title = a.attr('title')!;
|
||||
const link = a.attr('href');
|
||||
const pubDate = parseDate($el.find('span.date.gf.updated').text());
|
||||
const author = $el.find('span.author span.fn').text();
|
||||
const category = [$el.find('span.cat-name').text()];
|
||||
const description = $el.find('div.description p').text();
|
||||
const image = $el.find('img').attr('data-src');
|
||||
return {
|
||||
title,
|
||||
link,
|
||||
pubDate,
|
||||
author,
|
||||
category,
|
||||
description,
|
||||
image,
|
||||
banner: image,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
import { Data, Route } from '@/types';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import { load } from 'cheerio';
|
||||
import { Context } from 'hono';
|
||||
import { parseItems } from './parser';
|
||||
|
||||
export const handler = async (ctx: Context): Promise<Data | null> => {
|
||||
const { tag } = ctx.req.param();
|
||||
const baseUrl = `https://collabo-cafe.com/events/tag/${tag}`;
|
||||
const res = await ofetch(baseUrl);
|
||||
const $ = load(res);
|
||||
const items = parseItems($);
|
||||
|
||||
return {
|
||||
title: '标签',
|
||||
link: baseUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
export const route: Route = {
|
||||
path: '/tag/:tag',
|
||||
categories: ['anime'],
|
||||
example: '/collabo-cafe/tag/ikebukuro',
|
||||
parameters: { tag: 'Tag, refer to the original website (開催地域別)' },
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
name: '标签',
|
||||
maintainers: ['cokemine'],
|
||||
handler,
|
||||
};
|
||||
Loading…
Reference in New Issue