feat(route): add coolidge (#19984)

* feat: add coolidge film guide

* feat: add coolidge news route

* refactor: use kebab case

* fix: change category
This commit is contained in:
Tsung-Han Yu
2025-09-05 23:40:45 +00:00
committed by GitHub
parent f44a68847a
commit 4e08741300
4 changed files with 138 additions and 0 deletions
+62
View File
@@ -0,0 +1,62 @@
import { type Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import { art } from '@/utils/render';
import path from 'node:path';
const handler = async () => {
const link = 'https://coolidge.org/film-guide';
const html = await ofetch(link);
const $ = load(html);
const container = $('#block-coolidge-content > article > div.node__content > div').first();
const cover = container.find('p').eq(0).find('img').first().attr('src');
const title = container.find('p').eq(1).text().trim();
const description = container.find('p').eq(2).text().trim();
const linkEl = container.find('a').first();
const itemLink = linkEl.attr('href');
const absoluteCover = cover ? new URL(cover, link).href : undefined;
const absoluteItemLink = itemLink ? new URL(itemLink, link).href : undefined;
const rendered = art(path.join(__dirname, 'templates/description.art'), {
image: absoluteCover,
intro: description,
});
return {
title: 'Coolidge Corner Theatre - Film Guide',
link,
description: 'Film Guide',
item: [
{
title,
description: rendered,
link: absoluteItemLink ?? link,
guid: absoluteItemLink ?? absoluteCover ?? link,
},
],
};
};
export const route: Route = {
path: '/film-guide',
name: 'Film Guide',
url: 'coolidge.org/film-guide',
maintainers: ['johan456789'],
example: '/coolidge/film-guide',
categories: ['blog'],
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
handler,
};
+7
View File
@@ -0,0 +1,7 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'Coolidge Corner Theatre',
url: 'coolidge.org',
lang: 'en',
};
+65
View File
@@ -0,0 +1,65 @@
import { type Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import { art } from '@/utils/render';
import path from 'node:path';
const handler = async () => {
const link = 'https://coolidge.org/about-us/news-media';
const html = await ofetch(link);
const $ = load(html);
const container = $('#block-coolidge-content > div > div > div.view-content').first();
const elements = container.find('div.news-item').toArray();
const items = elements.map((el) => {
const element = $(el);
const titleEl = element.find('h2.news-item__title > a').first();
const title = titleEl.text().trim();
const href = titleEl.attr('href');
const descriptionText = element.find('div.news-item__content > p').first().text().trim();
const imageSrc = element.find('div.news-item__image img').first().attr('src');
const absoluteLink = href ? new URL(href, link).href : undefined;
const absoluteImage = imageSrc ? new URL(imageSrc, link).href : undefined;
const rendered = art(path.join(__dirname, 'templates/description.art'), {
image: absoluteImage,
intro: descriptionText,
});
return {
title,
description: rendered,
link: absoluteLink ?? link,
guid: absoluteLink ?? absoluteImage ?? title,
};
});
return {
title: 'Coolidge Corner Theatre - News',
link,
description: 'News',
item: items,
};
};
export const route: Route = {
path: '/news',
name: 'News',
url: 'coolidge.org/about-us/news-media',
maintainers: ['johan456789'],
example: '/coolidge/news',
categories: ['blog'],
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
handler,
};
@@ -0,0 +1,4 @@
{{if image}}
<p><img src="{{ image }}"></p>
{{/if}}
<p>{{ intro }}</p>